iX Talk
http://beijerinc.com/support/ix/forum/

Controller IP address change in runtime with script
http://beijerinc.com/support/ix/forum/viewtopic.php?f=5&t=1869
Page 1 of 1

Author:  ric [ Fri Apr 10, 2015 6:56 am ]
Post subject:  Controller IP address change in runtime with script

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?

Author:  lenius [ Thu Dec 17, 2015 9:54 am ]
Post subject:  Re: Controller IP address change in runtime with script

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);
}

Page 1 of 1 All times are UTC - 7 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/