public void AddClientRequest(RCClient client, bool forceRun)
        {
            if (!forceRun && this.listViewRCClient.InvokeRequired)
            {
                RCClientControl.Callback_AddClient method = new RCClientControl.Callback_AddClient(this.AddClientRequest);
                base.Invoke(method, new object[]
                {
                    client,
                    true
                });
                return;
            }
            int i   = 0;
            int num = this.listViewRCClient.Items.Count;

            while (i < num)
            {
                int num2 = (i + num) / 2;
                int num3 = ((RCClientControl.ClientItem) this.listViewRCClient.Items[num2]).CompareTo(client.Name, client.ClientIP, client.ID);
                if (num3 < 0)
                {
                    i = num2 + 1;
                }
                else
                {
                    if (num3 <= 0)
                    {
                        return;
                    }
                    num = num2;
                }
            }
            this.listViewRCClient.Items.Insert(i, new RCClientControl.ClientItem(client));
        }
Example #2
0
 public void Start(int port)
 {
     Base.ClientServer.OnChildProcessLogAdded += this.logManager.ChildProcessLogAdded;
     this.logManager.OnAddLIstenGroup         += delegate(object s, ListenerGroupEventArgs e)
     {
         Base.ClientServer.SendMessage <ChildProcessLogConnectMessage>(e.ClientID, new ChildProcessLogConnectMessage(e.ClientID, e.ProcessName, e.PID));
     };
     this.logManager.OnDeleteLIstenGroup += delegate(object s, ListenerGroupEventArgs e)
     {
         Base.ClientServer.SendMessage <ChildProcessLogDisconnectMessage>(e.ClientID, new ChildProcessLogDisconnectMessage(e.ClientID, e.ProcessName, e.PID));
     };
     this.logManager.OnChildProcessLogAdded += delegate(object s, ChildProcessLogEventArgs e)
     {
         RCClient rcclient = s as RCClient;
         e.Message.ClientID = rcclient.ID;
         foreach (int userID in e.Clients)
         {
             Base.ControlServer.SendToUser <ChildProcessLogMessage>(userID, e.Message);
         }
     };
     this.jobProcessor.Start();
     this.tcpServer.Start(this.jobProcessor, port);
     FileWatcher.Start();
     FileDistributor.Start();
 }
Example #3
0
 public ChildProcessListForm(RCClient client, RCProcess process)
 {
     this.Client  = client;
     this.Process = process;
     this.InitializeComponent();
     this.Text = string.Format("{0} {1} {2}", this.Client.Name, this.Process.Name, this.Text);
 }
Example #4
0
 private static void ProcessMessage(object rawMessage, object tag)
 {
     if (rawMessage is FunctionReplyMessage)
     {
         FunctionReplyMessage functionReplyMessage = rawMessage as FunctionReplyMessage;
         Base.ControlServer.SendToUser(functionReplyMessage.ClientID, new Packet(functionReplyMessage.Packet));
         return;
     }
     if (rawMessage is ChildProcessLogReplyMessage)
     {
         return;
     }
     if (rawMessage is ChildProcessLogMessage)
     {
         if (Base.ClientServer.OnChildProcessLogAdded != null)
         {
             RCClient sender = tag as RCClient;
             Base.ClientServer.OnChildProcessLogAdded(sender, new EventArgs <ChildProcessLogMessage>(rawMessage as ChildProcessLogMessage));
             return;
         }
     }
     else if (rawMessage is CheckPatchProcessResultMessage)
     {
         CheckPatchProcessResultMessage checkPatchProcessResultMessage = rawMessage as CheckPatchProcessResultMessage;
         foreach (string message in checkPatchProcessResultMessage.CheckPatchLog)
         {
             Base.ControlServer.NotifyMessage(MessageType.Message, message, new object[0]);
         }
     }
 }
Example #5
0
 internal Commands(HeroesAdminManager _manager)
 {
     this.manager     = _manager;
     this.commandDict = new Dictionary <string, Commands.CommandHandler>();
     MethodInfo[] methods = base.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     foreach (MethodInfo methodInfo in methods)
     {
         object[] customAttributes = methodInfo.GetCustomAttributes(typeof(CommandHandlerAttribute), false);
         if (customAttributes.Length > 0)
         {
             Delegate @delegate = Delegate.CreateDelegate(typeof(Commands.CommandHandler), this, methodInfo, false);
             if (@delegate != null)
             {
                 foreach (CommandHandlerAttribute commandHandlerAttribute in customAttributes)
                 {
                     if (!this.commandDict.ContainsKey(commandHandlerAttribute.Command))
                     {
                         this.commandDict.Add(commandHandlerAttribute.Command, @delegate as Commands.CommandHandler);
                         RCClient.Console_AddCustomCommand(RCProcess.CustomCommandParser.ToRawString(commandHandlerAttribute.Name, commandHandlerAttribute.Command, commandHandlerAttribute.Argument));
                     }
                 }
             }
         }
     }
 }
 private void CheckAndAddHeroesAdmin(RCClient client)
 {
     foreach (RCProcess process in client.ProcessList)
     {
         this.CheckAndAddHeroesAdmin(client.ID, client.ClientIP, process);
     }
 }
Example #7
0
 public void AddClient(RCClient client)
 {
     foreach (RCProcess rcprocess in client.ProcessList)
     {
         this.IncreaseConditionCountItem(new WorkGroupCondition(client.Name, rcprocess.Name));
     }
 }
Example #8
0
 public void AddToWorkGroup(RCClient client)
 {
     foreach (RCProcess process in client.ProcessList)
     {
         this.AddToWorkGroup(client, process);
     }
 }
Example #9
0
 public void RemoveFromWorkGroup(RCClient client)
 {
     foreach (RCProcess process in client.ProcessList)
     {
         this.RemoveFromWorkGroup(client, process);
     }
 }
Example #10
0
 private void RCUserHandler_ProcessLog(RCClient sender, RCClient.ProcessLogEventArgs args)
 {
     if (this.userCounts.ContainsKey(args.Process) && args.Process.PerformanceString.Length > 0 && RCProcess.IsStandardOutputLog(args.Message) && args.Process.IsPerformanceLog(args.Message) && this.UserCountLogged != null)
     {
         this.UserCountLogged(args.Process, new EventArgs <string>(args.Process.GetPerformanceLog(args.Message)));
     }
 }
Example #11
0
 private void Client_ProcessLog(RCClient sender, RCClient.ProcessLogEventArgs args)
 {
     if (RCProcess.IsNotifyLog(args.Message))
     {
         Base.ControlServer.NotifyMessage(MessageType.Message, RCProcess.GetOriginalLog(args.Message), new object[0]);
     }
     this.SendControlReplyMessageToUser <LogProcessMessage>(sender.ID, new LogProcessMessage(args.Process.Name, args.Message));
 }
Example #12
0
 public void OpenChildProcessLog(RCClient client, RCProcess process, int pid)
 {
     if (this.childProcessLogs.MakeGenerator(client, process, pid))
     {
         ChildProcessLogRequestMessage message = new ChildProcessLogRequestMessage(client.ID, process.Name, pid);
         this._rcUser.SendMessage <ChildProcessLogRequestMessage>(message);
     }
 }
Example #13
0
 public void AddClients(ICollection clientList)
 {
     foreach (object obj in clientList)
     {
         RCClient client = (RCClient)obj;
         this.AddClient(client);
     }
 }
 private void ProcessCrashed(RCClient s, RCProcess e)
 {
     if (this.OnAlarm != null)
     {
         string message = string.Format("{0} - {1} {2}", s.Name, e.Description, (e.State == RCProcess.ProcessState.Freezing) ? "Freezing" : "Crash");
         this.OnAlarm(s, new MainForm.AlarmEventArgs(message));
     }
 }
Example #15
0
        private void ProcessClientMessage(Packet packet, RCClient client)
        {
            Type type = this.MF.GetType(packet);

            if (type == typeof(AddProcessMessage))
            {
                AddProcessMessage addProcessMessage;
                SerializeReader.FromBinary <AddProcessMessage>(packet, out addProcessMessage);
                client.ProcessMessage(addProcessMessage);
                this.CheckAndAddHeroesAdmin(client.ID, client.ClientIP, addProcessMessage.Process);
                return;
            }
            if (type == typeof(ModifyProcessMessage))
            {
                ModifyProcessMessage modifyProcessMessage;
                SerializeReader.FromBinary <ModifyProcessMessage>(packet, out modifyProcessMessage);
                client.ProcessMessage(modifyProcessMessage);
                this.CheckAndAddHeroesAdmin(client.ID, client.ClientIP, modifyProcessMessage.Process);
                return;
            }
            if (type == typeof(RemoveProcessMessage))
            {
                RemoveProcessMessage removeProcessMessage;
                SerializeReader.FromBinary <RemoveProcessMessage>(packet, out removeProcessMessage);
                client.ProcessMessage(removeProcessMessage);
                this.CheckAndRemoveHeroesAdmin(client.ID, removeProcessMessage.Name);
                return;
            }
            if (type == typeof(StateChangeProcessMessage))
            {
                StateChangeProcessMessage stateChangeProcessMessage;
                SerializeReader.FromBinary <StateChangeProcessMessage>(packet, out stateChangeProcessMessage);
                if (this.serverGroups.ContainsKey(client.ID) && stateChangeProcessMessage.State == RCProcess.ProcessState.On)
                {
                    string processKey = this.GetProcessKey(client.ID, stateChangeProcessMessage.Name);
                    if (this.serverGroups[client.ID].ContainsKey(processKey))
                    {
                        string value = this.serverGroups[client.ID][processKey];
                        if (this.ServerGroupActivated != null)
                        {
                            this.ServerGroupActivated(this, new EventArgs <string>(value));
                            return;
                        }
                    }
                }
            }
            else if (type == typeof(LogProcessMessage))
            {
                LogProcessMessage logProcessMessage;
                SerializeReader.FromBinary <LogProcessMessage>(packet, out logProcessMessage);
                RCProcess rcprocess = client[logProcessMessage.Name];
                if ((rcprocess.PerformanceString.Length == 0 || !RCProcess.IsStandardOutputLog(logProcessMessage.Message) || !RCProcess.GetOriginalLog(logProcessMessage.Message).StartsWith(rcprocess.PerformanceString)) && this.ProcessLogged != null)
                {
                    this.ProcessLogged(new KeyValuePair <RCClient, RCProcess>(client, rcprocess), new EventArgs <string>(RCProcess.GetOriginalLog(logProcessMessage.Message)));
                }
            }
        }
Example #16
0
 private void RCUserHandler_ProcessRemove(RCClient sender, RCProcess process)
 {
     if (this.commandBridges.ContainsKey(process))
     {
         this.commandBridgeModified = true;
         this.commandBridges.Remove(process);
     }
     this.CheckAndRemoveProcessLog(sender, process);
 }
Example #17
0
        public void UpdateProcessState(RCClient client, RCProcess process)
        {
            string            conditionKey      = this.GetConditionKey(client, process);
            WorkGroupTreeNode workGroupTreeNode = this[conditionKey];

            if (workGroupTreeNode != null)
            {
                workGroupTreeNode.RecalculateTreeColor();
            }
        }
Example #18
0
 private void ClientInitialized(RCClient sender, object args)
 {
     Base.ControlServer.SendToUser <ClientAddedMessage>(new ClientAddedMessage(sender.ID, sender));
     sender.ServerInfoChange   += this.Client_ServerInfoChange;
     sender.ProcessAdd         += this.Client_ProcessAdd;
     sender.ProcessModify      += this.Client_ProcessModify;
     sender.ProcessRemove      += this.Client_ProcessRemove;
     sender.ProcessStateChange += this.Client_ProcessStateChange;
     sender.ProcessLog         += this.Client_ProcessLog;
 }
Example #19
0
        public void ChildProcessLogAdded(object sender, EventArgs <ChildProcessLogMessage> args)
        {
            RCClient rcclient = sender as RCClient;

            LogManager.Key key = LogManager.MakeKey(rcclient.ID, args.Value.ProcessName, args.Value.ProcessID);
            if (this.dict.ContainsKey(key) && this.OnChildProcessLogAdded != null)
            {
                this.OnChildProcessLogAdded(rcclient, new ChildProcessLogEventArgs(this.dict[key], args.Value));
            }
        }
Example #20
0
        public static ClientProcessItem GetShowItem(RCClient client, RCProcess process)
        {
            ClientProcessItem key = new ClientProcessItem(client, process);

            if (ClientProcessItem.ShowItem.ContainsKey(key))
            {
                return(ClientProcessItem.ShowItem[key]);
            }
            return(null);
        }
Example #21
0
 public ClientEventHandler(RCClient client)
 {
     client.ServerInfoChange   += this.Client_ServerInfoChange;
     client.ProcessAdd         += this.Client_ProcessAdd;
     client.ProcessModify      += this.Client_ProcessModify;
     client.ProcessRemove      += this.Client_ProcessRemove;
     client.ProcessStateChange += this.Client_ProcessStateChange;
     client.ProcessLog         += this.Client_ProcessLog;
     client.FileDistributed    += this.Client_FileDistributed;
 }
Example #22
0
        private void RC_ClientRemove(object sender, EventArgs <RCClient> args)
        {
            RCClient rcclient = this.clientList[args.Value.ID] as RCClient;

            if (rcclient == null)
            {
                return;
            }
            this.clientList.Remove(args.Value.ID);
            this.rcClientControl.RemoveClient(rcclient);
        }
Example #23
0
 private void AddClient(RCClient client)
 {
     if (!this.clientList.ContainsKey(client.ID))
     {
         this.clientList.Add(client.ID, client);
     }
     if (!this.clientNames.ContainsKey(client.Name))
     {
         this.clientNames.Add(client.Name, client);
     }
 }
Example #24
0
        public bool PreProcess(RCClient client, Packet packet)
        {
            Type packetType = this.GetPacketType(packet);

            if (packetType == typeof(PerformanceUpdateMessage))
            {
                Base.ControlServer.SendToUser <ControlReplyMessage>(new ControlReplyMessage(client.ID, packet.Bytes));
                return(false);
            }
            return(false);
        }
Example #25
0
 private void RCUserHandler_ProcessAdd(RCClient sender, RCProcess process)
 {
     if (process.Properties.ContainsKey("commandbridge"))
     {
         this.commandBridges.Add(process, sender);
         this.commandBridgeModified = true;
     }
     if (process.Properties.ContainsKey("UserCount"))
     {
         this.CheckAndAddProcessLog(sender, process);
     }
 }
Example #26
0
 public void ProcessRCClientMessage(RCClient rcClient, ArraySegment <byte> value)
 {
     try
     {
         this.MF.Handle(new Packet(value), rcClient);
     }
     catch (Exception ex)
     {
         Utility.ShowErrorMessage(LocalizeText.Get(221) + ex.ToString());
         this.Stop();
     }
 }
Example #27
0
 private bool CheckAndAddProcessLog(RCClient client, RCProcess process)
 {
     if (!this.userCounts.ContainsKey(process))
     {
         if (!this.userCounts.ContainsValue(client))
         {
             client.ProcessLog += this.RCUserHandler_ProcessLog;
         }
         this.userCounts.Add(process, client);
         return(true);
     }
     return(false);
 }
 public ClientItem(RCClient client) : base(new string[]
 {
     client.Name,
     client.ClientIP,
     client.Version.ToString()
 })
 {
     this.Name               = client.Name;
     this.IP                 = client.ClientIP;
     this.ID                 = client.ID;
     this.Version            = client.Version;
     this._processCollection = client.ProcessClone();
 }
Example #29
0
 private bool CheckAndRemoveProcessLog(RCClient client, RCProcess process)
 {
     if (this.userCounts.ContainsKey(process))
     {
         this.userCounts.Remove(process);
         if (!this.userCounts.ContainsValue(client))
         {
             client.ProcessLog -= this.RCUserHandler_ProcessLog;
             return(true);
         }
     }
     return(false);
 }
        public void LogGenerated(RCClient client, RCProcess process, string message)
        {
            string key = ProcessLogGeneratorCollection.MakeKey(client, process);

            if (this.dict.ContainsKey(key))
            {
                this.dict[key].LogGenerated(process, message);
            }
            if (this.allProcessLogActive > 0)
            {
                this.AllProcessLog.LogGenerated(process, message);
            }
        }