public void AddTemplate(RCProcessCollection template)
 {
     foreach (RCProcess item in template)
     {
         this.processes.Add(item);
     }
 }
 public void SetTemplateList(RCProcessCollection _processTemplateCollection)
 {
     this.processTemplateCollection = _processTemplateCollection;
     foreach (RCProcess processTemplate in this.processTemplateCollection)
     {
         this.AddView(processTemplate);
     }
 }
Esempio n. 3
0
        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!");
        }
Esempio n. 4
0
 private void TemplateChange(User user, RCProcessCollection collection)
 {
     try
     {
         Base.ProcessTemplate = collection;
         Base.SaveConfig();
     }
     catch (Exception ex)
     {
         throw new RCServerException("Exception : Cannot parse process templates!\nSource Error Message : {0}", new object[]
         {
             ex.Message
         });
     }
 }
 public void SetTemplateList(RCProcessCollection _processTemplateCollection)
 {
     this.processTemplateCollection = _processTemplateCollection;
 }
Esempio n. 6
0
        public static void ProcessThread()
        {
            Log <RCServerService> .Logger.Info("FileDistributor >> Started...");

            while (!FileDistributor._exit)
            {
                FileDistributor._queueEvent.WaitOne();
                if (FileDistributor._exit)
                {
                    return;
                }
                FileDistributor.FileChangedInfo fileChangedInfo;
                lock (FileDistributor._queue.SyncRoot)
                {
                    if (FileDistributor._queue.Count == 0)
                    {
                        FileDistributor._queueEvent.Reset();
                        continue;
                    }
                    fileChangedInfo = (FileDistributor.FileChangedInfo)FileDistributor._queue.Dequeue();
                }
                IEnumerable <int> cliendIDList = Base.ClientServer.GetCliendIDList();
                foreach (int num in cliendIDList)
                {
                    bool                flag2  = false;
                    RCClient            client = Base.ClientServer.GetClient(num);
                    RCProcessCollection rcprocessCollection = client.ProcessList as RCProcessCollection;
                    foreach (RCProcess rcprocess in rcprocessCollection)
                    {
                        if (rcprocess.WorkingDirectory.IndexOf(fileChangedInfo.pathName) >= 0)
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (flag2)
                    {
                        try
                        {
                            byte[] array = null;
                            if (fileChangedInfo.changeType != WatcherChangeTypes.Deleted && !fileChangedInfo.isDirectory)
                            {
                                string path = string.Concat(new string[]
                                {
                                    Directory.GetCurrentDirectory(),
                                    "\\DistributeFiles\\",
                                    fileChangedInfo.pathName,
                                    "\\",
                                    fileChangedInfo.fileName
                                });
                                FileStream fileStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                                array = new byte[fileStream.Length];
                                fileStream.Read(array, 0, (int)fileStream.Length);
                                fileStream.Close();
                            }
                            FileDistributeMessage message = new FileDistributeMessage(fileChangedInfo.changeType, fileChangedInfo.pathName, fileChangedInfo.fileName, fileChangedInfo.oldFileName, fileChangedInfo.isDirectory, array);
                            Base.ClientServer.SendMessage <FileDistributeMessage>(num, message);
                            Log <RCServerService> .Logger.InfoFormat("FileDistributor >> [{0}] : {1} {2}\\{3}.", new object[]
                            {
                                fileChangedInfo.changeType,
                                fileChangedInfo.isDirectory ? "Dir " : "File ",
                                fileChangedInfo.pathName,
                                fileChangedInfo.fileName
                            });
                        }
                        catch (Exception ex)
                        {
                            Log <RCServerService> .Logger.ErrorFormat("FileDistributor >> {0}\\{1} : {2}", fileChangedInfo.pathName, fileChangedInfo.fileName, ex.Message);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public TemplateChangeMessage(RCProcessCollection template)
 {
     this.Template = template;
 }