Esempio n. 1
0
 private void WorkGroupChange(User user, string newWorkGroupString)
 {
     try
     {
         WorkGroupStructureNode.GetWorkGroup(newWorkGroupString);
         Base.WorkGroupString = newWorkGroupString;
         Base.SaveConfig();
         WorkGroupChangeMessage message = new WorkGroupChangeMessage(newWorkGroupString);
         this.SendToUser <WorkGroupChangeMessage>(message);
     }
     catch (Exception ex)
     {
         throw new RCServerException("Exception : Cannot parse workgroup string!\nSource Error Message : {0}", new object[]
         {
             ex.Message
         });
     }
 }
Esempio n. 2
0
 private void buttonOK_Click(object sender, EventArgs args)
 {
     if (this.workGroupControl.Modified)
     {
         WorkGroupChangeMessage message = new WorkGroupChangeMessage(this.workGroupControl.SerializedText);
         this.userClient.SendMessage <WorkGroupChangeMessage>(message);
     }
     if (this.serverGroupControl.Modified)
     {
         ServerGroupChangeMessage message2 = new ServerGroupChangeMessage(this.serverGroupControl.SerializedText);
         this.userClient.SendMessage <ServerGroupChangeMessage>(message2);
     }
     if (this.processTemplateControl.Modified)
     {
         TemplateChangeMessage message3 = new TemplateChangeMessage(this.processTemplateControl.ProcessTemplateCollection);
         this.userClient.SendMessage <TemplateChangeMessage>(message3);
     }
     foreach (ControlRequestMessage message4 in this.rcClientControl.MessageList)
     {
         this.userClient.SendMessage <ControlRequestMessage>(message4);
     }
     base.Close();
 }
Esempio n. 3
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();
                }
            }
        }
Esempio n. 4
0
 private void ProcessMessage(object rawMessage)
 {
     if (rawMessage is LoginReply)
     {
         this.clientList.Clear();
         LoginReply loginReply = rawMessage as LoginReply;
         if (BaseConfiguration.ServerVersion != loginReply.ServerVersion)
         {
             if (this.ConnectionResulted != null)
             {
                 this.ConnectionResulted(this, new EventArgs <RCUserHandler.ConnectionResult>(RCUserHandler.ConnectionResult.VersionMismatch));
             }
             this.Stop();
             return;
         }
         this.Authority = loginReply.Authority;
         if (this.ConnectionResulted != null)
         {
             this.ConnectionResulted(this, new EventArgs <RCUserHandler.ConnectionResult>(RCUserHandler.ConnectionResult.Success));
             return;
         }
     }
     else
     {
         if (rawMessage is EmergencyCallMessage)
         {
             EmergencyCallMessage emergencyCallMessage = rawMessage as EmergencyCallMessage;
             List <string>        value = new List <string>(emergencyCallMessage.Emergencies);
             this.EmergencyCallInfo(this, new EventArgs <List <string> >(value));
             return;
         }
         if (rawMessage is ClientInfoMessage)
         {
             ClientInfoMessage clientInfoMessage = rawMessage as ClientInfoMessage;
             if (this.WorkGroupStructureChange != null)
             {
                 this.WorkGroupStructureChange(this, new RCUserHandler.WorkGroupStructureEventArgs(WorkGroupStructureNode.GetWorkGroup(clientInfoMessage.WorkGroup)));
             }
             if (this.ServerGroupStructureChange != null)
             {
                 this.ServerGroupStructureChange(this, new RCUserHandler.WorkGroupStructureEventArgs(ServerGroupStructureNode.GetServerGroup(clientInfoMessage.ServerGroup)));
             }
             foreach (KeyValuePair <int, RCClient> keyValuePair in clientInfoMessage.Clients)
             {
                 RCClient rcclient = new RCClient(keyValuePair.Key, keyValuePair.Value.ClientIP);
                 rcclient.AssignFrom(keyValuePair.Value);
                 this.clientList.Add(keyValuePair.Key, rcclient);
                 if (this.ClientAdd != null)
                 {
                     this.ClientAdd(this, new EventArgs <RCClient>(rcclient));
                 }
             }
             foreach (NotifyMessage value2 in clientInfoMessage.Logs)
             {
                 this.Notify(this, new EventArgs <NotifyMessage>(value2));
             }
             this.firstUpdated = true;
             return;
         }
         if (rawMessage is GetUserListReply)
         {
             GetUserListReply getUserListReply = rawMessage as GetUserListReply;
             List <Member>    list             = new List <Member>();
             foreach (KeyValuePair <string, Authority> keyValuePair2 in getUserListReply.Users)
             {
                 list.Add(new Member(keyValuePair2.Key, keyValuePair2.Value));
             }
             this.ReceivedUserListReply(this, new EventArgs <IEnumerable <Member> >(list));
             return;
         }
         if (rawMessage is WorkGroupChangeMessage)
         {
             if (this.WorkGroupStructureChange != null)
             {
                 WorkGroupChangeMessage workGroupChangeMessage = rawMessage as WorkGroupChangeMessage;
                 this.WorkGroupStructureChange(this, new RCUserHandler.WorkGroupStructureEventArgs(WorkGroupStructureNode.GetWorkGroup(workGroupChangeMessage.WorkGroup)));
                 return;
             }
         }
         else if (rawMessage is ServerGroupChangeMessage)
         {
             if (this.ServerGroupStructureChange != null)
             {
                 ServerGroupChangeMessage serverGroupChangeMessage = rawMessage as ServerGroupChangeMessage;
                 this.ServerGroupStructureChange(this, new RCUserHandler.WorkGroupStructureEventArgs(ServerGroupStructureNode.GetServerGroup(serverGroupChangeMessage.ServerGroup)));
                 return;
             }
         }
         else if (rawMessage is ClientAddedMessage)
         {
             ClientAddedMessage clientAddedMessage = rawMessage as ClientAddedMessage;
             RCClient           rcclient2          = new RCClient(clientAddedMessage.ID, clientAddedMessage.Client.ClientIP);
             rcclient2.AssignFrom(clientAddedMessage.Client);
             if (this.clientList.ContainsKey(clientAddedMessage.ID))
             {
                 Utility.ShowErrorMessage(LocalizeText.Get(217) + clientAddedMessage.ID);
                 return;
             }
             this.clientList.Add(rcclient2.ID, rcclient2);
             this.ClientAdd(this, new EventArgs <RCClient>(rcclient2));
             return;
         }
         else if (rawMessage is ClientRemovedMessage)
         {
             ClientRemovedMessage clientRemovedMessage = rawMessage as ClientRemovedMessage;
             if (!this.clientList.ContainsKey(clientRemovedMessage.ID))
             {
                 return;
             }
             RCClient value3 = this.clientList[clientRemovedMessage.ID];
             this.clientList.Remove(clientRemovedMessage.ID);
             if (this.ClientRemove != null)
             {
                 this.ClientRemove(this, new EventArgs <RCClient>(value3));
                 return;
             }
         }
         else if (rawMessage is ControlEnterReply)
         {
             if (this.ControlReply != null)
             {
                 ControlEnterReply value4 = rawMessage as ControlEnterReply;
                 this.ControlReply(this, new EventArgs <ControlEnterReply>(value4));
                 return;
             }
         }
         else if (rawMessage is ControlReplyMessage)
         {
             ControlReplyMessage controlReplyMessage = rawMessage as ControlReplyMessage;
             if (this.firstUpdated)
             {
                 if (this.clientList.Count == 0 || (this.clientList.Count > 0 && !this.clientList.ContainsKey(controlReplyMessage.ID)))
                 {
                     Type type = this.MF.GetType(new Packet(controlReplyMessage.Packet));
                     Utility.ShowErrorMessage(string.Concat(new object[]
                     {
                         LocalizeText.Get(220),
                         controlReplyMessage.ID,
                         ":",
                         type.ToString()
                     }));
                     return;
                 }
                 this.ProcessRCClientMessage(this.clientList[controlReplyMessage.ID], controlReplyMessage.Packet);
                 return;
             }
         }
         else if (rawMessage is NotifyMessage)
         {
             if (this.Notify != null)
             {
                 NotifyMessage value5 = rawMessage as NotifyMessage;
                 this.Notify(this, new EventArgs <NotifyMessage>(value5));
                 return;
             }
         }
         else if (rawMessage is ChildProcessLogListReplyMessage)
         {
             if (this.ChildProcessListed != null)
             {
                 ChildProcessLogListReplyMessage childProcessLogListReplyMessage = rawMessage as ChildProcessLogListReplyMessage;
                 if (this.clientList.ContainsKey(childProcessLogListReplyMessage.ClientID))
                 {
                     RCClient sender = this.clientList[childProcessLogListReplyMessage.ClientID];
                     this.ChildProcessListed(sender, new EventArgs <ChildProcessLogListReplyMessage>(childProcessLogListReplyMessage));
                     return;
                 }
             }
         }
         else if (rawMessage is ChildProcessLogReplyMessage)
         {
             if (this.ChildProcessLogOpened != null)
             {
                 ChildProcessLogReplyMessage value6 = rawMessage as ChildProcessLogReplyMessage;
                 this.ChildProcessLogOpened(this, new EventArgs <ChildProcessLogReplyMessage>(value6));
                 return;
             }
         }
         else if (rawMessage is ChildProcessLogMessage)
         {
             if (this.ChildProcessLogged != null)
             {
                 ChildProcessLogMessage value7 = rawMessage as ChildProcessLogMessage;
                 this.ChildProcessLogged(this, new EventArgs <ChildProcessLogMessage>(value7));
                 return;
             }
         }
         else if (rawMessage is ExeInfoReplyMessage && this.ChildProcessListed != null)
         {
             ExeInfoReplyMessage exeInfoReplyMessage = rawMessage as ExeInfoReplyMessage;
             if (this.clientList.ContainsKey(exeInfoReplyMessage.ClientID))
             {
                 RCClient sender2 = this.clientList[exeInfoReplyMessage.ClientID];
                 this.ExeInfo(sender2, new EventArgs <ExeInfoReplyMessage>(exeInfoReplyMessage));
             }
         }
     }
 }