Ejemplo n.º 1
0
        private void menuItemProcessAdd_Click(object sender, EventArgs e)
        {
            if (this.calculateThread != null)
            {
                return;
            }
            ProcessPropertyForm processPropertyForm = new ProcessPropertyForm(this.processTemplateCollection);

            if (processPropertyForm.ShowDialog(this) == DialogResult.OK)
            {
                ControlRequestMessage controlRequestMessage = new ControlRequestMessage(SerializeWriter.ToBinary <AddProcessMessage>(new AddProcessMessage(processPropertyForm.RCProcess)).Bytes);
                bool flag = false;
                foreach (object obj in this.listViewRCClient.SelectedItems)
                {
                    RCClientControl.ClientItem clientItem = (RCClientControl.ClientItem)obj;
                    try
                    {
                        clientItem.AddProcess(processPropertyForm.RCProcess);
                        controlRequestMessage.AddClientID(clientItem.ID);
                    }
                    catch (ArgumentException)
                    {
                        flag = true;
                    }
                }
                this.messageList.Add(controlRequestMessage);
                if (flag)
                {
                    Utility.ShowErrorMessage(LocalizeText.Get(343));
                }
                this.RecalculateCommonProcess();
            }
        }
Ejemplo n.º 2
0
 public bool Cmd_ShutdownAll(string command, IList <string> args)
 {
     if (args.Count > 0)
     {
         Dictionary <string, List <int> > dictionary = new Dictionary <string, List <int> >();
         foreach (KeyValuePair <int, string> keyValuePair in HeroesCommandBridge.Client.FindAllSubProcess(args[0]))
         {
             if (!dictionary.ContainsKey(keyValuePair.Value))
             {
                 dictionary.Add(keyValuePair.Value, new List <int>());
             }
             List <int> list = dictionary[keyValuePair.Value];
             list.Add(keyValuePair.Key);
         }
         foreach (KeyValuePair <string, List <int> > keyValuePair2 in dictionary)
         {
             ControlRequestMessage controlRequestMessage = new ControlRequestMessage(SerializeWriter.ToBinary <StopProcessMessage>(new StopProcessMessage(keyValuePair2.Key)).Bytes);
             foreach (int id in keyValuePair2.Value)
             {
                 controlRequestMessage.AddClientID(id);
             }
             HeroesCommandBridge.Client.SendMessage <ControlRequestMessage>(controlRequestMessage);
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 private void menuItemProcessRemove_Click(object sender, EventArgs e)
 {
     if (this.listViewProcess.SelectedItems.Count > 0 && this.calculateThread == null)
     {
         string text = ((RCClientControl.ProcessItem) this.listViewProcess.SelectedItems[0]).Text;
         ControlRequestMessage controlRequestMessage = new ControlRequestMessage(SerializeWriter.ToBinary <RemoveProcessMessage>(new RemoveProcessMessage(text)).Bytes);
         foreach (object obj in this.listViewRCClient.SelectedItems)
         {
             RCClientControl.ClientItem clientItem = (RCClientControl.ClientItem)obj;
             clientItem.RemoveProcess(text);
             controlRequestMessage.AddClientID(clientItem.ID);
         }
         this.messageList.Add(controlRequestMessage);
         this.RecalculateCommonProcess();
     }
 }
Ejemplo n.º 4
0
 private void menuItemSelfUpdate_Click(object sender, EventArgs e)
 {
     if (Utility.InputYesNoFromWarning(LocalizeText.Get(344)))
     {
         SelfUpdateForm selfUpdateForm = new SelfUpdateForm();
         if (selfUpdateForm.ShowDialog() == DialogResult.OK)
         {
             ControlRequestMessage controlRequestMessage = new ControlRequestMessage(SerializeWriter.ToBinary <ClientSelfUpdateMessage>(new ClientSelfUpdateMessage(selfUpdateForm.Argument)).Bytes);
             foreach (object obj in this.listViewRCClient.SelectedItems)
             {
                 RCClientControl.ClientItem clientItem = (RCClientControl.ClientItem)obj;
                 controlRequestMessage.AddClientID(clientItem.ID);
                 this.RemoveClient(clientItem.Name, clientItem.IP, clientItem.ID);
             }
             this.messageList.Add(controlRequestMessage);
         }
     }
 }
Ejemplo n.º 5
0
 private void menuItemProcessProperty_Click(object sender, EventArgs e)
 {
     if (this.listViewProcess.SelectedItems.Count == 1 && this.calculateThread == null)
     {
         bool multEdit = this.listViewRCClient.SelectedItems.Count > 1;
         int  num      = 8;
         foreach (object obj in this.listViewRCClient.SelectedItems)
         {
             RCClientControl.ClientItem clientItem = (RCClientControl.ClientItem)obj;
             if (clientItem.Version < num)
             {
                 num = clientItem.Version;
             }
         }
         ProcessPropertyForm processPropertyForm = new ProcessPropertyForm(((RCClientControl.ProcessItem) this.listViewProcess.SelectedItems[0]).Process, num, true, multEdit);
         if (processPropertyForm.ShowDialog() == DialogResult.OK)
         {
             bool flag = this.listViewRCClient.SelectedItems.Count == 1;
             foreach (object obj2 in this.listViewRCClient.SelectedItems)
             {
                 RCClientControl.ClientItem clientItem2 = (RCClientControl.ClientItem)obj2;
                 ModifyProcessMessage       value;
                 if (flag)
                 {
                     value = new ModifyProcessMessage(processPropertyForm.RCProcess);
                     clientItem2.ModifyProcess(processPropertyForm.RCProcess);
                 }
                 else
                 {
                     RCProcess process = clientItem2.ModifyProcessWithoutPrimaryInfo(processPropertyForm.RCProcess);
                     value = new ModifyProcessMessage(process);
                 }
                 ControlRequestMessage controlRequestMessage = new ControlRequestMessage(SerializeWriter.ToBinary <ModifyProcessMessage>(value).Bytes);
                 controlRequestMessage.AddClientID(clientItem2.ID);
                 this.messageList.Add(controlRequestMessage);
             }
         }
         this.RecalculateCommonProcess();
     }
 }
Ejemplo n.º 6
0
        private void _ProcessMessage(object rawMessage, object tag)
        {
            User user = tag as User;

            if (user == null)
            {
                return;
            }
            try
            {
                if (!(rawMessage is RemoteControlSystem.ClientMessage.PingMessage))
                {
                    if (rawMessage is LoginMessage)
                    {
                        LoginMessage loginMessage = rawMessage as LoginMessage;
                        if (user.IsValid)
                        {
                            throw new ArgumentException("Cannot login twice - " + loginMessage.Account);
                        }
                        this.Login(user, loginMessage.Account, loginMessage.Password);
                    }
                    else if (rawMessage is NotifyMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        this.NotifyMessage(user, rawMessage as NotifyMessage);
                    }
                    else if (rawMessage is ChangeMyPasswordMessage)
                    {
                        this.CheckAuthority(user, Authority.UserMonitor);
                        ChangeMyPasswordMessage changeMyPasswordMessage = rawMessage as ChangeMyPasswordMessage;
                        this.ChangeMyPassword(user, changeMyPasswordMessage.OldPassword, changeMyPasswordMessage.NewPassword);
                    }
                    else if (rawMessage is GetUserListMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        this.GetUserList(user);
                    }
                    else if (rawMessage is AddUserMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        AddUserMessage addUserMessage = rawMessage as AddUserMessage;
                        this.AddUser(user, addUserMessage.Account, addUserMessage.Password, addUserMessage.Authority);
                    }
                    else if (rawMessage is RemoveUserMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        RemoveUserMessage removeUserMessage = rawMessage as RemoveUserMessage;
                        this.RemoveUser(user, removeUserMessage.Account);
                    }
                    else if (rawMessage is ChangePasswordMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        ChangePasswordMessage changePasswordMessage = rawMessage as ChangePasswordMessage;
                        this.ChangePassword(user, changePasswordMessage.Account, changePasswordMessage.NewPassword);
                    }
                    else if (rawMessage is ChangeAuthorityMessage)
                    {
                        this.CheckAuthority(user, Authority.Supervisor);
                        ChangeAuthorityMessage changeAuthorityMessage = rawMessage as ChangeAuthorityMessage;
                        this.ChangeAuthority(user, changeAuthorityMessage.Account, changeAuthorityMessage.Authority);
                    }
                    else if (rawMessage is GetUserAuthMesssage)
                    {
                        this.CheckAuthority(user, Authority.UserWatcher);
                        this.GetUserAuthority(user, rawMessage as GetUserAuthMesssage);
                    }
                    else if (rawMessage is ControlEnterMessage)
                    {
                        this.CheckAuthority(user, Authority.ChiefGM);
                        this.ControlEnter(user);
                    }
                    else if (rawMessage is ControlFinishMessage)
                    {
                        this.CheckMutex(user);
                        this.ControlFinish(user);
                    }
                    else if (rawMessage is ControlRequestMessage)
                    {
                        this.CheckAuthority(user, Authority.UserKicker);
                        ControlRequestMessage controlRequestMessage = rawMessage as ControlRequestMessage;
                        this.SendControlProtocol(user, controlRequestMessage.Packet, controlRequestMessage.IDs);
                    }
                    else if (rawMessage is WorkGroupChangeMessage)
                    {
                        this.CheckMutex(user);
                        WorkGroupChangeMessage workGroupChangeMessage = rawMessage as WorkGroupChangeMessage;
                        this.WorkGroupChange(user, workGroupChangeMessage.WorkGroup);
                    }
                    else if (rawMessage is ServerGroupChangeMessage)
                    {
                        this.CheckMutex(user);
                        ServerGroupChangeMessage serverGroupChangeMessage = rawMessage as ServerGroupChangeMessage;
                        this.ServerGroupChange(user, serverGroupChangeMessage.ServerGroup);
                    }
                    else if (rawMessage is TemplateChangeMessage)
                    {
                        this.CheckMutex(user);
                        TemplateChangeMessage templateChangeMessage = rawMessage as TemplateChangeMessage;
                        this.TemplateChange(user, templateChangeMessage.Template);
                    }
                    else if (rawMessage is ChildProcessLogRequestMessage)
                    {
                        ChildProcessLogRequestMessage childProcessLogRequestMessage = rawMessage as ChildProcessLogRequestMessage;
                        this.SendFunctionProtocol(user, SerializeWriter.ToBinary <ChildProcessLogRequestMessage>(childProcessLogRequestMessage).Bytes, childProcessLogRequestMessage.ClientID);
                    }
                    else if (rawMessage is ChildProcessLogListRequestMessage)
                    {
                        ChildProcessLogListRequestMessage childProcessLogListRequestMessage = rawMessage as ChildProcessLogListRequestMessage;
                        this.SendFunctionProtocol(user, SerializeWriter.ToBinary <ChildProcessLogListRequestMessage>(childProcessLogListRequestMessage).Bytes, childProcessLogListRequestMessage.ClientID);
                    }
                    else if (rawMessage is ChildProcessLogConnectMessage)
                    {
                        ChildProcessLogConnectMessage childProcessLogConnectMessage = rawMessage as ChildProcessLogConnectMessage;
                        this.logManager.AddListener(user, childProcessLogConnectMessage.ClientID, childProcessLogConnectMessage.ProcessName, childProcessLogConnectMessage.ProcessID);
                    }
                    else if (rawMessage is ChildProcessLogDisconnectMessage)
                    {
                        ChildProcessLogDisconnectMessage childProcessLogDisconnectMessage = rawMessage as ChildProcessLogDisconnectMessage;
                        this.logManager.RemoveListener(user, childProcessLogDisconnectMessage.ClientID, childProcessLogDisconnectMessage.ProcessName, childProcessLogDisconnectMessage.ProcessID);
                    }
                    else
                    {
                        if (!(rawMessage is ExeInfoRequestMessage))
                        {
                            throw new RCServerException("Invalid packet! try to update latest version");
                        }
                        ExeInfoRequestMessage exeInfoRequestMessage = rawMessage as ExeInfoRequestMessage;
                        this.SendFunctionProtocol(user, SerializeWriter.ToBinary <ExeInfoRequestMessage>(exeInfoRequestMessage).Bytes, exeInfoRequestMessage.ClientID);
                    }
                }
            }
            catch (RCServerException ex)
            {
                this.NotifyMessage(user, MessageType.Error, ex.Message, new object[0]);
            }
            catch (Exception ex2)
            {
                if (rawMessage == null)
                {
                    this.NotifyMessage(MessageType.Message, ex2.ToString(), new object[0]);
                }
                else
                {
                    IPAddress address = user.Connection.RemoteEndPoint.Address;
                    this.NotifyMessage(MessageType.Message, "[{0}/{1}] - {2}", new object[]
                    {
                        user.ClientId,
                        address.ToString(),
                        ex2.ToString()
                    });
                    user.Connection.Disconnect();
                }
            }
        }
Ejemplo n.º 7
0
 public ControlRequest(IRouter pRouter, ControlRequestMessage pRequest, Action <T> pAction)
 {
     Router   = pRouter;
     Request  = pRequest;
     Callback = pAction;
 }