Accessing system settings (settings.xml)
  • Updated on 11 Dec 2013
  • 1 minute to read
  • Print
  • Dark
    Light

Accessing system settings (settings.xml)

  • Print
  • Dark
    Light

The system settings are stored in the settings.xml file which is found at C:\Program Files\Decisions\Decisions Services Manager in a default Decisions installation. Any of the values of this file can be accessed and set in code.

Create a new Visual Studio project and after settings up your project with a reference to DecisionsFramework.dll , you can access these settings via DecisionsFramework.ServiceLayer.Settings.GetSettings().[PropertyName] .

For example, if you wanted to access the DefaultAccountEmailAddress you would write DecisionsFramework.ServiceLayer.Settings.GetSettings().DefaultAccountEmailAddress .
You can also update and save settings. The following two lines show how to update the DefaultAccountEmailAddress :

 Settings.GetSettings().DefaultAccountEmailAddress = "Updated@decisions.com";
Settings.SaveSettings();

Below is an example showing how to access and update/save selected settings from this settings file in a console application.

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DecisionsFramework.ServiceLayer;
 
namespace DecisionsSampleAccessingSystemSettingsXML
{
    class AccessingSettingsXMLExample
    {
        static void Main(string[] args)
        {
 
            Console.WriteLine("LogFileMaxSize: " + Settings.GetSettings().LogFileMaxSize);
            Console.WriteLine("Bypass SMTP Server: " + Settings.GetSettings().Mail.ByPassSmtpServer);
            Console.WriteLine("Default Account Email Address: " + Settings.GetSettings().DefaultAccountEmailAddress);
            Console.WriteLine("Changing default account email address...");
            Settings.GetSettings().DefaultAccountEmailAddress = "Updated@decisions.com";
            Settings.SaveSettings();
            Console.WriteLine("Default Account Email Address: " + Settings.GetSettings().DefaultAccountEmailAddress);
 
            Console.ReadLine();
        }
    }
}

The output of this settings file would look like.

 LogFileMaxSize: 10485760
Bypass SMTP Server: True
Default Account Email Address: admin@decisions.com
Changing default account email address...
Default Account Email Address: Updated@decisions.com

To download this sample code please see the attached file below.

Was this article helpful?