private static void LoadConfig(string fileName) { if (File.Exists(fileName)) { XmlTextReader xmlTextReader = null; try { try { xmlTextReader = new XmlTextReader(fileName); xmlTextReader.WhitespaceHandling = WhitespaceHandling.None; xmlTextReader.MoveToContent(); RCProcessCollection rcprocessCollection = new RCProcessCollection(); while (xmlTextReader.Read()) { string name; if (xmlTextReader.NodeType == XmlNodeType.Element && (name = xmlTextReader.Name) != null) { if (!(name == "Server")) { if (name == "Process") { rcprocessCollection.Add(new RCProcess(xmlTextReader)); } } else { Base.ReadServerInfo(xmlTextReader); } } } Base.Client = new RCClient(Base.Version, Base.ServerIPAddress, Base.ServerPort, Base.ClientName, rcprocessCollection); foreach (RCProcess rcprocess in Base.Client.ProcessList) { rcprocess.RunScheduler(); } new ClientEventHandler(Base.Client); } catch (Exception ex) { Log <RCClientService> .Logger.Error("Exception occured while loading configuration", ex); throw new ApplicationException("Cannot start service because configuration is invalid!"); } return; } finally { if (xmlTextReader != null) { xmlTextReader.Close(); } } } Log <RCClientService> .Logger.Warn("Cannot find configuration file!"); }
public RemoteControlSystemManager(RCUserHandler _userClient, ICollection <RCClient> _clientList, IWorkGroupStructureNode[] workGroupStructure, IWorkGroupStructureNode[] serverGroupStructure, IEnumerable <RCProcess> _processTemplateInfo) { this.InitializeComponent(); this.tabPageRCCControl.Text = LocalizeText.Get(345); this.tabPageWorkGroupControl.Text = LocalizeText.Get(346); this.tabPageProcessTemplate.Text = LocalizeText.Get(347); this.buttonOK.Text = LocalizeText.Get(348); this.buttonCancel.Text = LocalizeText.Get(349); this.tabPageServerGroupControl.Text = LocalizeText.Get(515); this.Text = LocalizeText.Get(350); if (_userClient.Authority < Authority.Supervisor) { this.tabPageWorkGroupControl.Enabled = false; this.tabPageProcessTemplate.Enabled = false; this.tabControl.Controls.Remove(this.tabPageWorkGroupControl); this.tabControl.Controls.Remove(this.tabPageServerGroupControl); this.tabControl.Controls.Remove(this.tabPageProcessTemplate); } this.userClient = _userClient; this.clientList = new SortedList(); this.userClient.ClientAdd += this.RC_ClientAdd; this.userClient.ClientRemove += this.RC_ClientRemove; Dictionary <int, RCClient> dictionary = new Dictionary <int, RCClient>(); foreach (RCClient rcclient in _clientList) { this.clientList.Add(rcclient.ID, rcclient); RCClient rcclient2 = rcclient.Clone(); foreach (RCProcess rcprocess in rcclient.ProcessList) { WorkGroupStructureNode workGroupStructureNode = null; if (workGroupStructure != null) { foreach (WorkGroupStructureNode workGroupStructureNode2 in workGroupStructure) { workGroupStructureNode = workGroupStructureNode2.GetParent(new WorkGroupCondition(rcclient.Name, rcprocess.Name)); if (workGroupStructureNode != null) { break; } } } if (workGroupStructureNode != null) { if (workGroupStructureNode.Authority > this.userClient.Authority) { ((RCProcessCollection)rcclient2.ProcessList).Remove(rcprocess.Name); } } else if (this.userClient.Authority < Authority.Supervisor) { ((RCProcessCollection)rcclient2.ProcessList).Remove(rcprocess.Name); } } if (rcclient.ProcessList.Count == 0 | rcclient2.ProcessList.Count > 0) { dictionary.Add(rcclient2.ID, rcclient2); } } RCProcessCollection rcprocessCollection = new RCProcessCollection(); foreach (RCProcess item in _processTemplateInfo) { rcprocessCollection.Add(item); } this.rcClientControl.AddClients(dictionary.Values); this.rcClientControl.SetTemplateList(rcprocessCollection); this.workGroupControl.AddWorkGroup(workGroupStructure); this.workGroupControl.AddClients(dictionary.Values); this.serverGroupControl.AddServerGroup(serverGroupStructure); this.serverGroupControl.AddClients(dictionary.Values); this.processTemplateControl.SetTemplateList(rcprocessCollection); }