Description and use of the generated application configuration files.
You can configure the generated application using configuration files.
Within these files is the information relevant for managing the application's runtime behavior.
You use the App.config file to configure local settings. These settings can then be used on a larger scale by using the <Project Name>.adm which enables the Global Group Policies.
To access these, open the Solution Explorer and then the SAP Service Reference folder in Visual Studio.
This section contains the keys for service details for each service selected while creating the project:
This section contains the configuration for the following listeners:
This listener directs the tracing, or debugging output to a TextWriter, or to a stream.
Provides a simple listener that directs tracing, or debugging output to an EventLog, (EventViewer).
Trace switches allow us to enable, disable, and filter tracing output.
Attribute | Description |
---|---|
name | The name of the trace listener. This can be any name. |
type | The type name of a class that derives from the TraceListener class |
initializeData | The name of the log file where entries are written. |
traceOutputOptions | A property used by trace listeners to determine which options
or elements, should be included in the trace output. Possible values are CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, and Timestamp. The default is None. |
These lines above can be commented if you do not wish to add to a custom log file.
<add name="TraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Trace.log" traceOutputOptions="DateTime" /> </add>
Attribute | Description |
---|---|
name | The name of the trace listener. This can be any name. |
type | The type name of a class that derives from the TraceListener class |
initializeData | The name of the log file where entries are written. |
<switches> <add name="TraceLevel" value="4">
Enumerated value | Integer value | Type of message displayed(written to specified output target) |
---|---|---|
Off | 0 | None (trace is disabled). |
Error | 1 | Only error messages. |
Warning | 2 | Warning messages and error messages. |
Info | 3 | Informational, warning and error messages. |
Verbose | 4 | Verbose, informational, warning and error messages |
<add name="TraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\MyLogs\MyLog.log" traceOutputOptions="DateTime" /> </add>
<add name="EventListener" type="System.Diagnostics.EventLogTraceListener" initializeData="MyNewSource"> </add>
Application configuration files contain settings specific to an application. This file contains configuration and settings that the application can read at runtime.
<appSettings> <app.key-'Country Code'value-'DE'/ > </appSettings> </configuration>
In GWM Outlook application, all calls to the SAP system are made through the generated class ApplicationName>BusinessApplication.cs for example CRM_ContactsBusinessApplication.cs that was created for the contacts application.
string countryCode = ConfigurationReaderHandler.Instance.GetConfigValue("CountryCode"); QueryOperationResponse<Outlook_CRM_Contacts.CONTACT.Contact> serviceresponse = null; // var serviceresponse = serviceContext.ContactCollection.Execute() as QueryOperationResponse<Outlook_CRM_Contacts.CONTACT.Contact>; if (string.IsNullOrEmpty(countryCode)) { serviceresponse = serviceContext.ContactCollection.Execute() as QueryOperationResponse<Outlook_CRM_Contacts.CONTACT.Contact>; } else { serviceresponse = serviceContext.ContactCollection.AddQueryOption("$filter", string.Format("CountryCode eq '{0}'", countryCode)).Execute() as QueryOperationResponse<Outlook_CRM_Contacts.CONTACT.Contact>; }