<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechFinCH News &#38; Notes</title>
	<atom:link href="http://www.techfinch.com/news/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.techfinch.com/news</link>
	<description>Technology in Finance Consulting Hub</description>
	<lastBuildDate>Sat, 24 Mar 2012 00:44:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Parsing Custom Parameters in Sophis Risk.config file</title>
		<link>http://www.techfinch.com/news/?p=197&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=parsing-customparameters-in-sophis-risk-config-using-ccli</link>
		<comments>http://www.techfinch.com/news/?p=197#comments</comments>
		<pubDate>Fri, 23 Mar 2012 23:33:07 +0000</pubDate>
		<dc:creator>Ram Kumar DANGETI</dc:creator>
				<category><![CDATA[Sophis Toolkit API]]></category>
		<category><![CDATA[.Net 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Sophis]]></category>
		<category><![CDATA[Toolkit]]></category>
		<category><![CDATA[Value]]></category>
		<category><![CDATA[VS2008]]></category>
		<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://www.techfinch.com/news/?p=197</guid>
		<description><![CDATA[Introduction Following our previous article, where we discussed the procedure to parse Standard Parameters in the Sophis Risk.config file, this main objective of this article is to extend the same to the Custom Parameters. Note that all the examples listed &#8230; <a href="http://www.techfinch.com/news/?p=197">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1 style="text-align: justify;">Introduction</h1>
<p style="text-align: justify;">Following our previous article, where we discussed the procedure to parse Standard Parameters in the Sophis Risk.config file, this main objective of this article is to extend the same to the Custom Parameters.</p>
<p><span id="more-197"></span></p>
<p style="text-align: justify;">Note that all the examples listed in this article are based on <span style="color: #87cefa;">Sophis Value 4.3.1 Toolkit</span> and have been tested on <span style="color: #87cefa;">VS 2008</span> and <span style="color: #87cefa;">.Net Framework version 3.5</span>.</p>
<h1>Custom Parameters in Risk.config file</h1>
<p>As the name implies, <span style="color: #87cefa;">&lt;CustomParameters/&gt;</span> are specific to the client applications and are accessible via Sophis API. Here is the sample config file:</p>
<pre class="brush: xml; gutter: true; first-line: 1">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;configuration&gt;
	&lt;configSections/&gt;
	&lt;Common/&gt;
	&lt;SophisEventConnection/&gt;
	&lt;APIConfiguration&gt;
		&lt;Toolkit&gt;
			&lt;DLLs/&gt;
			&lt;AssemblyDLLs/&gt;
			&lt;CustomParameters&gt;
				&lt;clear /&gt;
				&lt;add Section="Section1" Entry="key" Value="value" /&gt;
				&lt;add Section="Section2" Entry="key" Value="value" /&gt;
				&lt;add Section="Section2" Entry="key" Value="value" /&gt;
				&lt;add Section="Section3" Entry="key" Value="value" /&gt;
				&lt;add Section="Section3" Entry="key" Value="value" /&gt;
				&lt;add Section="Section3" Entry="key" Value="value" /&gt;
			&lt;/CustomParameters&gt;
		&lt;/Toolkit&gt;
	&lt;/APIConfiguration&gt;
&lt;/configuration&gt;</pre>
<h1>Retrieving Custom Parameters directly from the Risk.config in C++/CLI</h1>
<pre class="brush: cpp; gutter: true; first-line: 1">try
{
	ExeConfigurationFileMap^ fileMap = gcnew ExeConfigurationFileMap();
	System::String^ file = gcnew System::String("Risk.config");
	fileMap-&gt;ExeConfigFilename = file;

	System::Configuration::Configuration^ config =
		ConfigurationManager::OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel::None);
	if(config)
	{
		APIConfigurationGroup^ api =
			(APIConfigurationGroup^)config-&gt;SectionGroups-&gt;Get("APIConfiguration");
		if(api)
		{
			ToolkitSection^ toolkit = (ToolkitSection^) api-&gt;Toolkit;
			if(toolkit)
			{
				for each(ToolkitCustomParameter^ param in toolkit-&gt;CustomParameters)
				{
					std::string sSection = msclr::interop::marshal_as&lt;std::string&gt;(param-&gt;Section);
					std::string sKey = msclr::interop::marshal_as&lt;std::string&gt;(param-&gt;Entry);
					std::string sValue = msclr::interop::marshal_as&lt;std::string&gt;(param-&gt;Value);
				}
			}
		}
	}
}
catch(ConfigurationErrorsException^ e)
{
}</pre>
<h1>Retrieving Custom Parameters after Sophis API is initialized</h1>
<p style="text-align: justify;">Following is the C# method and note that unlike the previous Sophis Toolkit API versions , this method (and the remaining overloads) are limited to retrieving Custom Parameters. Please refer to the previous article for more information about retrieving Standard Parameters.</p>
<pre class="brush: csharp; gutter: true; first-line: 1">CSMConfigurationFile.getEntryValue(string section, string entry, ref string value, string defaultValue);</pre>
<p style="text-align: justify;">Checkout the <span style="color: #87cefa;">ConfigurationFileWrapper</span> class for the native C++ methods.</p>
<h1>Conclusion</h1>
<p style="text-align: justify;">With this, we conclude the quick review of various techniques involved in parsing the Sophis Risk.config file.</p>
<p style="text-align: justify;">As far as launching (or executing) the client application is concerned, we need to understand the <span style="color: #87cefa;">Bootstrap.config</span>, <span style="color: #87cefa;">Application.exe.config</span> and the role played by the <span style="color: #87cefa;">SophisAssemblyResolver.dll</span> during startup. Brief article on this topic should be available shortly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techfinch.com/news/?feed=rss2&#038;p=197</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing Standard Parameters in Sophis Risk.config file.</title>
		<link>http://www.techfinch.com/news/?p=99&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=parsing-sophis-risk-config-file-in-c</link>
		<comments>http://www.techfinch.com/news/?p=99#comments</comments>
		<pubDate>Sun, 18 Mar 2012 17:13:17 +0000</pubDate>
		<dc:creator>Ram Kumar DANGETI</dc:creator>
				<category><![CDATA[Sophis Toolkit API]]></category>
		<category><![CDATA[.Net 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Sophis]]></category>
		<category><![CDATA[Toolkit]]></category>
		<category><![CDATA[Value]]></category>
		<category><![CDATA[VS2008]]></category>
		<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://www.techfinch.com/news/?p=99</guid>
		<description><![CDATA[<p style="text-align: justify;">Sophis has moved from risk.ini to <strong>Risk.config </strong>to store the application's configuration in the latest version of Risque and Value. While this is a standard XML file and can be parsed in number of ways, the main objective of this article is to demonstrate the functionality provided by the Sophis Toolkit API to handle the configuration file.</p> <a href="http://www.techfinch.com/news/?p=99">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1 style="text-align: justify;">Introduction</h1>
<p style="text-align: justify;">Sophis has moved from risk.ini to <strong>Risk.config </strong>to store the application&#8217;s configuration in the latest version of Risque and Value. While this is a standard XML file and can be parsed in number of ways, the main objective of this article is to demonstrate the functionality provided by the Sophis Toolkit API to handle the configuration file.</p>
<p><span id="more-99"></span></p>
<p style="text-align: justify;">Note that all the examples listed in this article are based on <span style="color: #87cefa;">Sophis Value 4.3.1 Toolkit</span> and have been tested on <span style="color: #87cefa;">VS 2008</span> and <span style="color: #87cefa;">.Net Framework version 3.5</span>.</p>
<h1>Standard Parameters in Risk.config file</h1>
<p style="text-align: justify;">In this section, we will look at the sample code to retrieve the standard Sophis configuration parameters like <span style="color: #87cefa;">&lt;Log/&gt;</span> and <span style="color: #87cefa;">&lt;RisqueDatabase/&gt;</span>. Note that all the application specific parameters are stored in the <span style="color: #87cefa;">&lt;CustomParameters/&gt;</span> section and the sample code to parse these parameters will be provided in the next article.</p>
<p style="text-align: justify;">Here is the outline of the Risk.config file.</p>
<pre class="brush: xml; gutter: true; first-line: 1">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;configuration&gt;
	&lt;configSections/&gt;
	&lt;Common&gt;
		&lt;NamingService/&gt;
		&lt;Licensing/&gt;
		&lt;Log Verbosity="Debug" AppendDate="false" ClearFile="true"/&gt;         
		&lt;RisqueDatabase ConnectionTag="demo" User="demo"
			Password="EINBKNDCHKPPBHPKEPFCDBLIAIAEGCAD" Server="RISK" /&gt;
	&lt;/Common&gt;
	&lt;SophisEventConnection&gt;
		&lt;Coherency/&gt;
		&lt;ConnectionOptions/&gt;
		&lt;Quotation/&gt;
	&lt;/SophisEventConnection&gt;
	&lt;APIConfiguration&gt;
		&lt;Toolkit&gt;
			&lt;DLLs/&gt;
			&lt;AssemblyDLLs/&gt;
			&lt;CustomParameters/&gt;
		&lt;/Toolkit&gt;
		&lt;API/&gt;
	&lt;/APIConfiguration&gt;
&lt;/configuration&gt;</pre>
<h1 style="text-align: justify;">Retrieve parameters after the Sophis API is initialized</h1>
<p style="text-align: justify;">Following is the sample code that can be used to retrieve the configuration once the <span style="color: #87cefa;">Sophis API is initialized</span>. Note that the object <span style="color: #87cefa;">ProgramConfiguration.Current</span> is valid only when the Sophis API is sucessfully initialized.</p>
<h3 style="text-align: justify;">Read RisqueDatabase Parameters</h3>
<pre class="brush: csharp; gutter: true; first-line: 1">string dbUser="";
string dbPass="";
string dbServer="";
if ((ProgramConfiguration.Current != null) &amp;&amp; (ProgramConfiguration.Current.Configuration != null))
{
	CommonConfigurationGroup common = (CommonConfigurationGroup)ProgramConfiguration.Current.Configuration.SectionGroups.Get("Common");
	{
		DatabaseConnectionConfiguration dbConfig = common.RisqueDatabaseSection;
		{
			dbUser = dbConfig.User;
			dbPass = dbConfig.Password;
			dbServer = dbConfig.Server;
		}
	}
}</pre>
<h3>Read Log Parameters</h3>
<pre class="brush: csharp; gutter: true; first-line: 1">string verbosity="";
string path="";
if ((ProgramConfiguration.Current != null) &amp;&amp; (ProgramConfiguration.Current.Configuration != null))
{
	CommonConfigurationGroup common = (CommonConfigurationGroup)ProgramConfiguration.Current.Configuration.SectionGroups.Get("Common");
	{
		LogConfiguration log = (LogConfiguration)common.LogSection;
		{
			verbosity = log.Verbosity.ToString();
			path = log.Path;
		}
	}
}</pre>
<h1>Retrieve parameters directly from the config file</h1>
<p style="text-align: justify;">While the above examples assume that the Sophis API has been initialized, we could very well retrieve the configuration parameters directly from the config file. Here is an example showing the same:</p>
<h3>Read RisqueDatabase Parameters</h3>
<pre class="brush: csharp; gutter: true; first-line: 1">string dbUser="";
string dbPass="";
string dbServer="";
try
{
	ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap()
	{
		ExeConfigFilename = "Risk.config",
	};
	Configuration rootConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
	if (rootConfig)
	{
		CommonConfigurationGroup common = (CommonConfigurationGroup) rootConfig.SectionGroups.Get("Common");
		{
			DatabaseConnectionConfiguration dbConfig = common.RisqueDatabaseSection;
			{
				dbUser = dbConfig.User;
				dbPass = dbConfig.Password;
				dbServer = dbConfig.Server;
			}
		}
	}
}
catch (ConfigurationErrorsException e)
{
	Console.WriteLine(e.Message);
}</pre>
<h1>Namespace</h1>
<p style="text-align: justify;">Apart from the standard System and System.Configuration, you have to include the following entries to the namespace to use the Sophis Configuration functionality.</p>
<pre class="brush: csharp; gutter: true; first-line: 1">using sophis.configuration;
using sophis.misc;</pre>
<h1 class="brush: csharp; gutter: true; first-line: 1">Conclusion</h1>
<p style="text-align: justify;">All the latest versions of Sophis include a tool called SophisConfigurationManager.exe which can be used to manage the Risk.config file in a more intuitive way. While this functionality is not new to the Windows developers, the Sophis Configuration API certainly adds more flexibility to the toolkit developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techfinch.com/news/?feed=rss2&#038;p=99</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to TechFinCH News &amp; Notes!</title>
		<link>http://www.techfinch.com/news/?p=42&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=welcome-to-techfinch-news-2</link>
		<comments>http://www.techfinch.com/news/?p=42#comments</comments>
		<pubDate>Sat, 04 Feb 2012 15:06:33 +0000</pubDate>
		<dc:creator>Ram Kumar DANGETI</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Financial Services]]></category>
		<category><![CDATA[Sophis]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Toolkit]]></category>

		<guid isPermaLink="false">http://techfinch.com/news/?p=42</guid>
		<description><![CDATA[This section of www.techfinch.com is mainly intended to host very brief tutorials and news items associated with the Technology in the Financial Services industry. Most of the articles would be based on, but not limited to, Sophis Toolkit API.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This section of www.techfinch.com is mainly intended to host very brief tutorials and news items associated with the Technology in the Financial Services industry. Most of the articles would be based on, but not limited to, Sophis Toolkit API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techfinch.com/news/?feed=rss2&#038;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

