Skip to content

Server Code Configuration old

DeclanBuckley edited this page May 28, 2024 · 1 revision

Home / Configuration / Server Code

How to configure and customise the Server Interface.

Link to the original Server Configuration Settings: Server Code Original Configuration - .NET Framework 4.7.2.



The Server configuration is stored and managed under the **Server Tier**.

/Static.config.

The Static.config file contains the non-changing configuration items for the server application. It is expected that these items are not liable to require amendment during runtime.

A static item is retrieved in code by the following call example: `Utility.GetCustomConfig("APP_CONFIG_ITEM_NAME").

Configuration item Description
APP_DEFAULT_DATASET_FORMAT If no default format is specified when requesting a dataset, it is returned in this format
APP_DEFAULT_DATETIME_FORMAT The datetime format in which date related data is represented
APP_DEFAULT_GROUP Where a process must give a dataset a Group for validation purposes, this is the Group code used. This item is not visible to users.
APP_DEFAULT_SOURCE Where a process must give a dataset a Source for validation purposes, this is the Source name used. This item is not visible to users.
APP_PX_DEFAULT_FORMAT The name of the PX format
APP_PX_DEFAULT_AXIS_VERSION The current maximum version of PX managed by the application
APP_INTERNATIONALISATION_SYNONYM_FILE The root part of a file of synonyms for internationalisation. The remainder of the name must be the ISO language code for that language. This requires that a keyword class is written for that language
APP_INTERNATIONALISATION_MORPHOLOGY_FILE For internationalisation, the root part of a morphology file for pluralisation of a language. The remainder of the name must be the ISO language code for that language. This requires that a keyword class is written for that language, however the pluralisation method may not necessarily require a morphology file.
APP_INTERNATIONALISATION_KEYWORD_FILE The root part of a file of keywords for internationalisation. The remainder of the name must be the ISO language code for that language. This requires that a keyword class is written for that language
APP_INTERNATIONALISATION_ENGLISH The ISO code for the English language
APP_INTERNATIONALISATION_IRISH The ISO code for the Irish language
APP_INTERNATIONALISATION_POLISH The ISO code for the Polish language
APP_INTERNATIONALISATION_EXTRACTOR_CLASS_NAME The root part of a keyword extractor class. The remainder of the name must be the ISO language code for that language. An extractor class must be created for each language represented in the application
APP_GEO_MIMETYPE For a Geo tag in a JSON-stat structure, this gives the geo json default mimetype
APP_JSON_MIMETYPE The json mimetype
APP_PX_MIMETYPE The PX mimetype
APP_CSV_MIMETYPE The csv mimetype
APP_SALSA The salsa used for MD5 hashing
APP_FORMAT_DOWNLOAD_NAME The name used for the DOWNLOAD action
APP_FORMAT_UPLOAD_NAME The name used for the UPLOAD action
APP_PX_FREQUENCY_CODES The list of codes allowed for the FREQUENCY dimension
APP_CSV_DIVIDER The divider string used for csv outputs
APP_CSV_STATISTIC The heading for a Statistic in a csv output
APP_CSV_VALUE The heading for a Value in a csv output
APP_CSV_UNIT The heading for a Unit in a csv output
APP_PX_DEFAULT_CHARSET When creating a PX file, the default value for "CHARSET"
APP_PX_MULTILINE_CHAR_LIMIT For certain lines in a PX file, the maximum length before the text overflows to the next line
APP_PX_DATE_TIME_FORMAT The date/time format on a PX file
APP_PX_TRUE The PX equivalent of true
APP_PX_FALSE The PX equivalent of false
APP_PX_DEFAULT_UNITS In the PX document the default value for "UNITS" if no other value exists
APP_PX_TITLE_BY In the PX document the default separator for "TITLE" value
APP_JSON_STAT_QUERY The value of the identifier for a JSON-stat query
APP_JSON_STAT_QUERY_VERSION The version of the JSON-stat query schema
APP_REGEX_EMAIL Regex for an email address
APP_REGEX_URL Regex for a web address
APP_REGEX_ALPHA Regex for standard letters
APP_REGEX_ALPHA_NUMERIC Regex for standard letters and numbers
APP_REGEX_MASKED_IP Regex for ip address
APP_REGEX_NO_WHITESPACE Regex to flag whitespaces
APP_BUILD_REGEX_FORBIDDEN_CHARS Regex to flag named characters
APP_LANGUAGE_CULTURE Regex for ISO Culture values e.g. "fr-CH"
APP_CACHE_READ_ATTRIBUTE The custom attribute for reading the cache if it exists
APP_CACHE_FLUSH_ATTRIBUTE The custom attribute for storing the cache after reading
APP_COOKIELINK_RELEASE string value for release when calling a dataset from a url
APP_COOKIELINK_TABLE string value for table when calling a collection from a url

/Resources/Config/config.server.json.This configuration is liable to change during runtime and it is stored as a JSON object.

In order to immediately implement any configuration changes from these files, you must call the PxStat.Security.Configuration_API.Refresh API after making and saving the changes.

A config item is returned in code by the following example: Configuration_BSO.GetCustomConfig("configuration-item").

Configuration item Description Type
bulkcopy-tranche-multiplier For database loading, the number of data item sets loaded in each tranche Integer
px Px object Object
px.confidential-value The string to represent a confidential or empty data point String
px.default-units The string to represent an unknown unit String
analytic Analytic object Object
analytic.read-os-item-limit When listing Operating Systems in Analytics, show any number more than this as "Other" Integer
analytic.read-browser-item-limit When listing Browsers in Analytics, show any number more than this as "Other" Integer
analytic.read-referrer-item-limit When listing Referrers in Analytics, show any number more than this as "Other" Integer
analytic.referrer-not-applicable Abbreviation for "Not Applicable" String
search.search-word-multiplier Search weighting for search terms. A higher number will result in a higher score when a search term is found. Int
search.synonym-multiplier Search weighting for synonyms of search terms. A higher number will result in a higher score when a synonym of a search term is found. Int
subscription.query-threshold The maximum number of queries a subscriber can save(default = 1000) Integer

/web.config.

Each deployment environment has a specific Web.config file:

  • Web.config - Development environment (Debug).
  • Web.Live.config - Production environment (Live).
  • Web.Test.config - Test environment (Test).
  • Web.UATconfig - UAT environment (UAT).

\PxStat\Web.config entries listed as below:

  • IIS - Compilation & Worker limit.

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.7.2" />
    <!-- executionTimeout (Seconds), maxRequestLength (KB) = APP_PX_MAX_SIZE_BYTE + 1MB  -->
    <httpRuntime executionTimeout="3600" maxRequestLength="11264" targetFramework="4.7.2" />
  </system.web>
  ...
</configuration>
  • IIS - Request limit and handlers.

<configuration>
  ...
  <system.webServer>

  <security>
      <requestFiltering>
        <!-- maxAllowedContentLength (B) APP_PX_MAX_SIZE_BYTE + 1MB -->
        <requestLimits maxAllowedContentLength="11534336" />
      </requestFiltering>
    </security>

    <handlers>
      <!-- Add the handler to instruct IIS to serve the JSON RPC webservice requests -->
      <add verb="POST,GET" path="api.jsonrpc" name="API" type="API.JSONRPC" />
    </handlers>
  ...
  </system.webServer>
  ...
</configuration>
  • CORS - Cross-Origin Resource Sharing.

<configuration>
  ...
  <system.webServer>
  <httpProtocol>
      <customHeaders>
        <!-- Local CORS -->
        <add name="Access-Control-Allow-Origin" value="http://localhost" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
        <add name="Access-Control-Allow-Credentials" value="true" />
      </customHeaders>
    </httpProtocol>

    <rewrite>
      <outboundRules>
        <!-- Private CORS - Default -->
        <rule name="Access-Control-Allow-Origin" enabled="true" patternSyntax="Wildcard">
          <match serverVariable="RESPONSE_Access-Control-Allow-Origin" pattern="*" />
          <conditions trackAllCaptures="false"></conditions>
          <action type="Rewrite" value="{HTTP_ORIGIN}" />
        </rule>
        <!-- Private CORS - DNS filter -->
        <!--
				<rule name="WWW-Authenticate" enabled="true" patternSyntax="Wildcard">
					<match serverVariable="RESPONSE_WWW-Authenticate" pattern="*" />
					<conditions>
						<add input="{HTTP_ORIGIN}" pattern="https://domain" negate="true" />
					</conditions>
					<action type="Rewrite" value="Anonymous" />
				</rule>
				-->
        <!-- Private CORS - IP filter -->
        <!--
				<rule name="WWW-Authenticate" enabled="true" patternSyntax="Wildcard">
					<match serverVariable="RESPONSE_WWW-Authenticate" pattern="*" />
					<conditions>
						<add input="{REMOTE_ADDR}" pattern="x.y.z.j" negate="true" />
					</conditions>
					<action type="Rewrite" value="Anonymous" />
				</rule>
				-->
      </outboundRules>
    </rewrite>
  </system.webServer>
  ...
</configuration>
  • API - JSONRPC.

More details about API Library JSONRPC at API Library JSONRPC.

<configuration>
   ...
   <appSettings>
    <!-- JSONRPC - Success response (case sensitive) -->
    <add key="API_JSONRPC_SUCCESS" value="success" />
    <!-- JSONRPC - Windows Authentication [ANONYMOUS, WINDOWS, ANY] -->
    <add key="API_JSONRPC_AUTHENTICATION_TYPE" value="ANY" />

   </appSettings>
  ...
</configuration>
  • API - Active Directory.

More details about API Library Active Directory at API Library Active Directory

<configuration>
   ...
   <appSettings>
     <!-- Active Directory - Domain -->
    <add key="API_AD_DOMAIN" value="CSOCORK" />
    <!-- Active Directory - Path -->
    <add key="API_AD_PATH" value="" />
    <!-- Active Directory - Username -->
    <add key="API_AD_USERNAME" value="" />
    <!-- Active Directory - Password -->
    <add key="API_AD_PASSWORD" value="" />
   </appSettings>
  ...
</configuration>
  • API - ReCAPTCHA

More details about API Library ReCAPTCHA at API Library ReCAPTCHA

<configuration>
   ...
   <appSettings>
    <!-- ReCAPTCHA - Switch on [TRUE] or off [FALSE] the ReCaptcha -->
    <add key="API_RECAPTCHA_ENABLED" value="FALSE" />
    <!-- ReCAPTCHA - URL -->
    <add key="API_RECAPTCHA_URL" value="https://www.google.com/recaptcha/api/siteverify?secret={0}&amp;response={1}" />
    <!-- ReCAPTCHA - Private Key -->
    <add key="API_RECAPTCHA_PRIVATE_KEY" value="" />

   </appSettings>
  ...
</configuration>
  • API - eMail.

More details about API Library eMail at API Library eMail.

<configuration>
   ...
   <appSettings>
    <!-- EMAIL - MAIL - Sender (it covers From and ReplyTo as well) -->
    <add key="API_EMAIL_MAIL_SENDER" value="" />
    <!-- EMAIL - SMTP - Server IP address -->
    <add key="API_EMAIL_SMTP_SERVER" value="" />
    <!-- EMAIL - SMTP - Port number -->
    <add key="API_EMAIL_SMTP_PORT" value="" />
    <!-- EMAIL - SMTP - Switch on [TRUE] or off [FALSE] the authentication -->
    <add key="API_EMAIL_SMTP_AUTHENTICATION" value="FALSE" />
    <!-- EMAIL - SMTP - Set the Username if authentication is required -->
    <add key="API_EMAIL_SMTP_USERNAME" value="" />
    <!-- EMAIL - SMTP - Set the Password if authentication is required -->
    <add key="API_EMAIL_SMTP_PASSWORD" value="" />
    <!-- EMAIL - SMTP - Switch on [TRUE] or off [FALSE] the SSL -->
    <add key="API_EMAIL_SMTP_SSL" value="FALSE" />
    <!-- EMAIL - TEMPLATE - Title -->
    <add key="API_EMAIL_TEMPLATE_TITLE" value="PxStat" />
    <!-- EMAIL - TEMPLATE - Sub Title -->
    <add key="API_EMAIL_TEMPLATE_SUBTITLE" value="localhost/data.cso.ie" />
    <!-- EMAIL - TEMPLATE - Website Name -->
    <add key="API_EMAIL_TEMPLATE_WEBSITE_NAME" value="CSO.ie" />
    <!-- EMAIL - TEMPLATE - Website URL -->
    <add key="API_EMAIL_TEMPLATE_WEBSITE_URL" value="https://www.cso.ie" />

   </appSettings>
  ...
</configuration>
  • API - ADO.

More details about API Library ADO at API Library ADO.

<configuration>
   ...
   <appSettings>
    <!-- ADO - Default Connection Name -->
    <add key="API_ADO_DEFAULT_CONNECTION" value="defaultConnection" />
    <!-- ADO - Execution timeout in seconds -->
    <add key="API_ADO_EXECUTION_TIMEOUT" value="600" />
    <!-- ADO - Bulk Copy timeout in seconds -->
    <add key="API_ADO_BULKCOPY_TIMEOUT" value="600" />
    <!-- ADO - Bulk Copy BatchSize in number of rows (below 5000) -->
    <add key="API_ADO_BULKCOPY_BATCHSIZE" value="4999" />

   </appSettings>
  ...
</configuration>
  • API - MemCacheD.

More details about API Library MemCacheD at API Library MemCacheD.

<configuration>
   ...
   <appSettings>
    <!-- MemCacheD - Switch on [TRUE] or off [FALSE] the MemCacheD -->
    <add key="API_MEMCACHED_ENABLED" value="TRUE" />
    <!-- MemCacheD - Maximum validity in number of seconds that MemCacheD can handle (30 days = 2592000) -->
    <add key="API_MEMCACHED_MAX_VALIDITY" value="2592000" />
    <!-- MemCacheD - Salsa code to isolate the cache records form other applications or environments -->
    <add key="API_MEMCACHED_SALSA" value="subdomain.domain.extension" />


   </appSettings>
  ...
</configuration>
  • DB - Connection Strings

<configuration>
   ...
   <connectionStrings>
    <add name="defaultConnection" connectionString="Server=X.X.X.XX;Initial Catalog=pxstat.XX;User ID=XXX;Password=XXX;Persist Security Info=False;Column Encryption Setting=enabled;" />
    <add name="msdbConnection" connectionString="Server=X.X.X.XX;Initial Catalog=msdb;User ID=XXX;Password=XXX;Persist Security Info=False;Column Encryption Setting=enabled;" />
  </connectionStrings>

  ...
</configuration>
  • CACHE - MemCacheD - enyim.

More details about API Library MemCacheD at API Library MemCacheD

<configuration>
   ...  
    <enyim.com>
    <memcached protocol="Binary">
      <servers>
        <!-- N.B. Make sure you use the same ordering of nodes in every configuration you have -->
        <add address="X.X.X.XX" port="XXXXX" />
      </servers>
      <socketPool minPoolSize="10" maxPoolSize="20" connectionTimeout="00:00:10" deadTimeout="00:00:10" />
    </memcached>
  </enyim.com>
   
  ...
</configuration>
  • LOGGING - Log4Net.

More details about API Library MemCacheD at [API Library Logging]https://github.com/CSOIreland/Server-API-Library/wiki/API-Library-Log).

<configuration>
   ...  
   <log4net>
    <root>
      <!-- Set the level to ERROR for Live/UAT and ALL for TD-->
      <level value="ALL"/>

      <appender-ref ref="FileAppender"/>
      <appender-ref ref="SmtpAppender"/>
      <appender-ref ref="AdoNetAppender"/>
    </root>

    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <!-- Set threshold to ERROR for Live/UAT and ALL for TD-->
      <threshold value="ALL"/>
      <file type="log4net.Util.PatternString" value="Logs\Log4Net.[%processid].log"/>
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %class.%method:%line - %message%newline"/>
      </layout>
      <lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
    </appender>

    <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
      <!-- Set threshold to ERROR for Live/UAT and OFF for TD-->
      <threshold value="OFF" />
      <!-- List of coma separated emails for the recipients -->
      <to value="" />
      <!-- Email of the sender -->
      <from value="" />
      <!-- Email's subject -->
      <subject type="log4net.Util.PatternString" value="Domain [Environment] - Error log" />
      <!-- SMTP IP address -->
      <smtpHost value="" />
      <!-- SMTP IP port -->
      <port value="25" />
      <authentication value="Basic" />
      <bufferSize value="1" />
      <lossy value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %class.%method:%line - %message%newline"/>
      </layout>
    </appender>

    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <!-- Set threshold to ERROR for Live/UAT and ALL for TD-->
      <threshold value="ALL" />
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="Server=3.9.2.54;Initial Catalog=pxstat.td12;User ID=pxstat;Password=pxstat;Persist Security Info=False;Column Encryption Setting=enabled;" />
      <commandText value="INSERT INTO TD_LOGGING ([LGG_DATETIME],[LGG_THREAD],[LGG_LEVEL],[LGG_CLASS],[LGG_METHOD],[LGG_LINE],[LGG_MESSAGE],[LGG_EXCEPTION]) VALUES (@Datetime,@Thread,@Level,@Class,@Method,@Line,@Message,@Exception)" />
      <parameter>
        <parameterName value="@Datetime" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
        <parameterName value="@Thread" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%thread" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Level" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Class" />
        <dbType value="String" />
        <size value="256" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%class" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Method" />
        <dbType value="String" />
        <size value="256" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%method" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Line" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%line" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Message" />
        <dbType value="String" />
        <size value="-1" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%message" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Exception" />
        <dbType value="String" />
        <size value="-1" />
        <layout type="log4net.Layout.ExceptionLayout" />
      </parameter>
    </appender>
  </log4net>
   
  ...
</configuration>
Clone this wiki locally