Page 1 of 1

Controller IP address change in runtime with script

Posted: Fri Apr 10, 2015 6:56 am
by ric
Hi,

I noticed that changing the Controller IP address could be done with the Change Active Controllers Action.

Is there a script module that perform this kind of feature automatically?

Re: Controller IP address change in runtime with script

Posted: Thu Dec 17, 2015 9:54 am
by lenius
using System.IO;
using System.Linq;
using System.Xml.Linq;


try
{
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

ControllerRunTimeSettingsFile = System.IO.Path.Combine(baseDirectory, "ControllerRunTimeSettings.xml");


if (!File.Exists(ControllerRunTimeSettingsFile)) return;

XDocument doc = XDocument.Load(ControllerRunTimeSettingsFile);
var xElemAgent = doc.Descendants("Controller").Single(arg => arg.Attribute("Name").Value == controller);
xElemAgent.SetAttributeValue("IsActive", active);
doc.Save(ControllerRunTimeSettingsFile);

//reload your application

}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}