Accessing and Updating System Settings via Settings.xml

The following example will demonstrate how to access and update the DefaultAccountEmailAddress setting via code. 

1 In a new C# project in any desired IDE, add a reference to DecisionsFramework.dll and add using DecisionsFramework.ServiceLayer;

2 To access the DefaultAcocuntEmailAddress setting, add Settings.GetSettings().DefaultAccountEmailAddress. Add the following lines to update and save the changes to the setting.

C#

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

Below is a complete code example on how to access and update/save various settings from in the settings file in a console application.

C#

 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 the above code will be the following:

C#

 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

from: https://documentation.decisions.com/v9/docs/accessing-system-settings-settings-xml

Sign In or Register to comment.