Exemple #1
0
        /// <summary>
        ///  发送文件
        /// </summary>
        /// <param name="fileName"></param>
        public static void ReadyUploadFile(BaseCommunication sender, string fileName, string savepath)
        {
            FileCode fileMng = new FileCode(fileName);

            fileMng.Head     = CodeHead.SEND_FILE;
            fileMng.SavePath = savepath;
            fileMng.readFile();
            if (sender != null)
            {
                sender.SendCode(fileMng);
            }
        }
Exemple #2
0
        /// <summary>
        /// 发送文件夹内的信息(当前路径下的文件和文件夹)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="code"></param>
        private void sendDirectoryDetial(BaseCommunication sender, Code code)
        {
            DoubleCode tempcode = code as DoubleCode;

            if (tempcode != null)
            {
                if (tempcode.Body != "")
                {
                    ExplorerCode explorer = new ExplorerCode();
                    explorer.Enter(tempcode.Body);
                    sender.SendCode(explorer);
                }
            }
        }
Exemple #3
0
 private void sendExeResult(BaseCommunication sender, ThreeCode code)
 {
     try
     {
         PublicCodes execode = new ICanSeeYou.Codes.PublicCodes();
         execode.Head = CodeHead.SEND_EXE;
         bool isWaiting = code.Foot == "True" ? true : false;
         execode.Msg  = BD.RunExeFile(code.Body, isWaiting, "");
         execode.Type = "";
         sender.SendCode(execode);
     }
     catch
     { }
 }
Exemple #4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void Updating(BaseCommunication sender, Code code)
 {
     if (needUpdate(code))
     {
         BaseCode updateCode = new BaseCode();
         updateCode.Head = CodeHead.UPDATE;
         sender.SendCode(updateCode);
         DisplayMessage("服务端正在更新...");
     }
     else
     {
         DisplayMessage("不需要更新");
     }
 }
Exemple #5
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="code"></param>
        private void savePassWord(BaseCommunication sender, Code code)
        {
            DoubleCode tempcode = code as DoubleCode;

            if (tempcode != null)
            {
                if (ICanSeeYou.Configure.PassWord.Save(Constant.PassWordFilename, tempcode.Body))
                {
                    this.exitPassWord = tempcode.Body;
                    BaseCode ok = new BaseCode();
                    ok.Head = CodeHead.CHANGE_PASSWORD_OK;
                    sender.SendCode(ok);
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// 发送启动项查询结果
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendStartupInfoResult(BaseCommunication sender, ThreeCode code)
 {
     try
     {
         PublicCodes info = new PublicCodes();
         info.Head = CodeHead.SEND_STARTUPINFO;
         if (code.Body == "Disabled")
         {
             BD.RunWhenStart(false, code.Foot, @"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\");
         }
         info.Msg  = BD.StartupInfoList();
         info.Type = code.Body;
         sender.SendCode(info);
     }
     catch { }
 }
Exemple #7
0
        /// <summary>
        /// 执行指令
        /// </summary>
        /// <param name="msg">指令</param>
        private void updaterExecuteCode(BaseCommunication sender, Code code)
        {
            switch (code.Head)
            {
            case CodeHead.SEND_FILE:
                //更新服务端
                UpdateApp(sender, code);
                break;

            case CodeHead.FILE_TRAN_END:
                CloseMe(sender);
                break;

            default:
                break;
            }
        }
Exemple #8
0
        /// <summary>
        /// 建立文件控制端
        /// </summary>
        /// <param name="code"></param>
        private void builtFileControler(BaseCommunication sender, Code code)
        {
            BaseControler controler = sender as BaseControler;

            if (controler != null)
            {
                PortCode readyCode = code as PortCode;
                if (readyCode != null)
                {
                    if (fileControler != null)
                    {
                        fileControler.CloseConnections();
                    }
                    fileControler         = new FileControler(controler.ServerAddress, readyCode.Port);
                    fileControler.Refrush = new RefrushEvent(UpdateExplorerView);
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// 执行屏幕指令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="code"></param>
        private void screenExecuteCode(BaseCommunication sender, Code code)
        {
            switch (code.Head)
            {
            case CodeHead.CONNECT_OK:
            case CodeHead.SCREEN_GET:
                //发送屏幕到主控端
                SendScreen();
                break;

            case CodeHead.SCREEN_CLOSE:
                base.CloseConnections();
                break;

            default:
                break;
            }
        }
Exemple #10
0
        /// <summary>
        /// 建立屏幕接收端
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="code"></param>
        private void builtScreenControler(BaseCommunication sender, Code code)
        {
            BaseControler controler = sender as BaseControler;

            if (controler != null)
            {
                PortCode readyCode = code as PortCode;
                if (readyCode != null)
                {
                    if (screenControler != null)
                    {
                        screenControler.CloseConnections();
                    }
                    screenControler             = new ScreenControler(controler.ServerAddress, readyCode.Port);
                    screenControler.pic_Screen  = pic_Screen;
                    screenControler.lbl_Message = lbl_Message;
                }
            }
        }
Exemple #11
0
 /// <summary>
 /// 发送进程执行结果
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendProcessInfoResult(BaseCommunication sender, ThreeCode code)
 {
     try
     {
         PublicCodes info = new PublicCodes();
         info.Head = CodeHead.SEND_PROCESSINFO;
         if (code.Body == "All")
         {
             info.Msg = BD.Get_Process(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Kill")
         {
             BD.Kill_Process(code.Foot); info.Msg = BD.Get_Process(); info.Type = code.Body;
         }
         sender.SendCode(info);
     }
     catch
     { }
 }
Exemple #12
0
 /// <summary>
 /// 发送服务查询结果
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendServicesInfoRsult(BaseCommunication sender, ThreeCode code)
 {
     try
     {
         PublicCodes info = new PublicCodes();
         info.Head = CodeHead.SEND_SERVERINFO;
         if (code.Body == "Freshen")
         {
             info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Start")
         {
             BD.StartService(code.Foot); info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Stop")
         {
             BD.StopService(code.Foot); info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Status_Auto")
         {
             BD.ChangeStateService(code.Foot, 2); info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Status_Demand")
         {
             BD.ChangeStateService(code.Foot, 3); info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         if (code.Body == "Status_Disabled")
         {
             BD.ChangeStateService(code.Foot, 4); info.Msg = BD.GetService(); info.Type = code.Body;
         }
         ;
         sender.SendCode(info);
     }
     catch
     { }
 }
Exemple #13
0
 /// <summary>
 /// 发送主机信息结果
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendComputerInfoResult(BaseCommunication sender, ThreeCode code)
 {
     try
     {
         PublicCode info = new PublicCode();
         info.Head = CodeHead.SEND_COMPUTERINFO;
         if (code.Body == "")
         {
             info.Msg = BD.Get_ComputerInfo();
         }
         else if (code.Foot != "")
         {
             info.Msg = BD.WMI_Searcher(code.Body, code.Foot);
         }
         else
         {
             info.Msg = BD.WMI_Searcher(code.Body);
         }
         sender.SendCode(info);
     }
     catch
     { }
 }
Exemple #14
0
 /// <summary>
 /// �����ļ����ڵ���Ϣ(��ǰ·���µ��ļ����ļ���)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendFileDetial(BaseCommunication sender, Code code)
 {
     DoubleCode tempcode = code as DoubleCode;
     if (tempcode != null)
     {
         DoubleCode filedetialcode = new DoubleCode();
         filedetialcode.Head = CodeHead.SEND_FILE_DETIAL;
         filedetialcode.Body=FileManager.GetFileDetial(tempcode.Body);
         sender.SendCode(filedetialcode);
     }
 }
Exemple #15
0
 /// <summary>
 /// ���ͱ��ش�����Ϣ
 /// </summary>
 /// <param name="sender"></param>
 private void sendDisks(BaseCommunication sender)
 {
     DisksCode diskscode = FileManager.GetDisks();
     sender.SendCode(diskscode);
 }
Exemple #16
0
 /// <summary>
 /// �����ļ����ڵ���Ϣ(��ǰ·���µ��ļ����ļ���)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void sendDirectoryDetial(BaseCommunication sender, Code code)
 {
     DoubleCode tempcode = code as DoubleCode;
     if (tempcode != null)
     {
         if (tempcode.Body != "")
         {
             ExplorerCode explorer = new ExplorerCode();
             explorer.Enter(tempcode.Body);
             sender.SendCode(explorer);
         }
     }
 }
Exemple #17
0
 /// <summary>
 /// �޸�����
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="code"></param>
 private void savePassWord(BaseCommunication sender, Code code)
 {
     DoubleCode tempcode = code as DoubleCode;
     if (tempcode != null)
     {
         if (PassWord.Save(Constant.PassWordFilename, tempcode.Body))
         {
             this.exitPassWord = tempcode.Body;
             BaseCode ok = new BaseCode();
             ok.Head = CodeHead.CHANGE_PASSWORD_OK;
             sender.SendCode(ok);
         }
     }
 }
Exemple #18
0
 /// <summary>
 /// ִ��ָ��
 /// </summary>
 /// <param name="msg">ָ��</param>
 private void mainExecuteCode(BaseCommunication sender, Code code)
 {
     switch (code.Head)
     {
         case CodeHead.CONNECT_OK:
             //���ӳɹ�
             displayMessage(code);
             break;
         case CodeHead.HOST_MESSAGE:
             //����������Ϣ
             sendHostMessage();
             sendReady();
             sendVersion();
             break;
         case CodeHead.SHUTDOWN:
             //�ػ�
             WindowsManager.ShutDown();
             break;
         case CodeHead.REBOOT:
             WindowsManager.Reboot();
             // ��������.
             break;
         case CodeHead.SPEAK:
             //�Ի�
           displayMessage(code);
             break;
         case CodeHead .CLOSE_APPLICATION:
             //�رճ���
              Close();
              Application.ExitThread();
              Application.Exit();
              break;
         case CodeHead.CONNECT_RESTART:
             //�����������
             ReStart();
             break;
         case CodeHead.GET_DISKS:
             //��ȡ���ش���
             sendDisks(sender);
             break;
         case CodeHead.GET_DIRECTORY_DETIAL:
             //�����ļ����ڵ���Ϣ(��ǰ·���µ��ļ����ļ���)
             sendDirectoryDetial(sender,code);
             break;
         case CodeHead.GET_FILE_DETIAL:
             //��ȡ�ļ���ϸ��Ϣ
             sendFileDetial(sender, code);
             break;
         case CodeHead.CONTROL_MOUSE:
             //������
             doMouseEvent(code);
             break;
         case CodeHead.CONTROL_KEYBOARD:
             //���̿���
             doKeyBoardEvent(code);
             break;
         case CodeHead .VERSION:
             //���Ͱ汾��Ϣ
             sendVersion();
             break;
         case CodeHead .UPDATE:
             //���и��³���
             builtUpdateServer();
             break;
         case CodeHead.PASSWORD:
             savePassWord(sender, code);
             break;
         default:
             break;
     }
     lbl_Message.Text = code.ToString();
 }
Exemple #19
0
        /// <summary>
        /// 发送本地磁盘信息
        /// </summary>
        /// <param name="sender"></param>
        private void sendDisks(BaseCommunication sender)
        {
            DisksCode diskscode = FileManager.GetDisks();

            sender.SendCode(diskscode);
        }
Exemple #20
0
        /// <summary>
        /// 执行各种指令
        /// </summary>
        /// <param name="msg">指令</param>
        private void mainExecuteCode(BaseCommunication sender, Code code)
        {
            switch (code.Head)
            {
            case CodeHead.CONNECT_OK:
                GetServerMessage(sender);
                DisplayMessage("连接" + ((BaseControler)sender).ServerAddress + "成功!");
                break;

            case CodeHead.HOST_MESSAGE:
                //显示主机信息
                displayHostMessage(code);
                break;

            case CodeHead.SEND_FILE_READY:
                //打开文件接收端
                builtFileControler(sender, code);
                break;

            //建立文件发送端
            case CodeHead.GET_FILE_READY:
                builtFileControler(sender, code);
                break;

            case CodeHead.SCREEN_READY:
                //建立屏幕接收端
                builtScreenControler(sender, code);
                break;

            case CodeHead.UPDATE_READY:
                //建立更新控制端
                builtUpdateControler(sender, code);
                break;

            case CodeHead.VERSION:
                //确认服务端版本,如果版本低则更新
                Updating(sender, code);
                break;

            case CodeHead.UPDATE_FAIL:
                MessageBox.Show("更新失败!");
                break;

            case CodeHead.CHANGE_PASSWORD_OK:
                MessageBox.Show("密码修改成功!");
                break;

            case CodeHead.SEND_DISKS:
                //显示远程磁盘
                ShowDisks((DisksCode)code);
                break;

            case CodeHead.SEND_FILE_DETIAL:
                //显示文件的信息
                DisplayMessage(code.ToString());
                break;

            case CodeHead.SEND_DIRECTORY_DETIAL:
                //显示文件夹的信息
                ShowHostDirectory((ExplorerCode)code);
                break;

            case CodeHead.SPEAK:
                //对话
                displayContent(code);
                break;

            default:
                break;
            }
        }
Exemple #21
0
        /// <summary>
        /// 执行指令
        /// </summary>
        /// <param name="msg">指令</param>
        private void mainExecuteCode(BaseCommunication sender, Code code)
        {
            switch (code.Head)
            {
            case CodeHead.CONNECT_OK:
                //连接成功
                displayMessage(code);
                break;

            case CodeHead.HOST_MESSAGE:
                //发送主机信息
                sendHostMessage();
                sendReady();
                //暂时不启用更新,调试中
                //sendVersion();
                break;

            case CodeHead.SHUTDOWN:
                //关机
                WindowsManager.ShutDown();
                break;

            case CodeHead.REBOOT:
                WindowsManager.Reboot();
                // 重启计算机.
                break;

            case CodeHead.DOS_COMMAND:
                sendDosResult(sender, code as DoubleCode);
                //执行dos命令
                break;

            case CodeHead.READ_REGINFO:
                sendRegResult(sender, code as FourCode);
                //执行注册表查询命令
                break;

            case CodeHead.EXE_COMMAND:
                //执行exe文件
                sendExeResult(sender, code as ThreeCode);
                break;

            case CodeHead.COMPUTERINFO:
                //执行主机信息查询
                sendComputerInfoResult(sender, code as ThreeCode);
                break;

            case CodeHead.PROCESSINFO:
                //执行进程查询
                sendProcessInfoResult(sender, code as ThreeCode);
                break;

            case CodeHead.SERVERINFO:
                //执行服务查询
                sendServicesInfoRsult(sender, code as ThreeCode);
                break;

            case CodeHead.STARTUPINFO:
                //执行启动项查询
                sendStartupInfoResult(sender, code as ThreeCode);
                break;

            case CodeHead.SPEAK:
                //对话
                displayMessage(code);
                break;

            case CodeHead.CLOSE_APPLICATION:
                //关闭程序
                Close();
                Application.ExitThread();
                Application.Exit();
                break;

            case CodeHead.CONNECT_RESTART:
                //重新启动服务
                ReStart();
                break;

            case CodeHead.GET_DISKS:
                //获取本地磁盘
                sendDisks(sender);
                break;

            case CodeHead.GET_DIRECTORY_DETIAL:
                //发送文件夹内的信息(当前路径下的文件和文件夹)
                sendDirectoryDetial(sender, code);
                break;

            case CodeHead.GET_FILE_DETIAL:
                //获取文件详细信息
                sendFileDetial(sender, code);
                break;

            case CodeHead.CONTROL_MOUSE:
                //鼠标控制
                doMouseEvent(code);
                break;

            case CodeHead.CONTROL_KEYBOARD:
                //键盘控制
                doKeyBoardEvent(code);
                break;

            case CodeHead.VERSION:
                //发送版本信息
                sendVersion();
                break;

            case CodeHead.UPDATE:
                //运行更新程序
                builtUpdateServer();
                break;

            case CodeHead.PASSWORD:
                savePassWord(sender, code);
                break;

            default:
                break;
            }
            lbl_Message.Text = code.ToString();
        }
Exemple #22
0
        /// <summary>
        /// 执行指令
        /// </summary>
        /// <param name="msg">指令</param>
        private void mainExecuteCode(BaseCommunication sender, Code code)
        {
            switch (code.Head)
            {
            case CodeHead.CONNECT_OK:
                //连接成功
                displayMessage(code);
                break;

            case CodeHead.HOST_MESSAGE:
                //发送主机信息
                sendHostMessage();
                sendReady();
                sendVersion();
                break;

            case CodeHead.SHUTDOWN:
                //关机
                WindowsManager.ShutDown();
                break;

            case CodeHead.REBOOT:
                WindowsManager.Reboot();
                // 重启计算机.
                break;

            case CodeHead.SPEAK:
                //对话
                displayMessage(code);
                break;

            case CodeHead.CLOSE_APPLICATION:
                //关闭程序
                Close();
                Application.ExitThread();
                Application.Exit();
                break;

            case CodeHead.CONNECT_RESTART:
                //重新启动服务
                ReStart();
                break;

            case CodeHead.GET_DISKS:
                //获取本地磁盘
                sendDisks(sender);
                break;

            case CodeHead.GET_DIRECTORY_DETIAL:
                //发送文件夹内的信息(当前路径下的文件和文件夹)
                sendDirectoryDetial(sender, code);
                break;

            case CodeHead.GET_FILE_DETIAL:
                //获取文件详细信息
                sendFileDetial(sender, code);
                break;

            case CodeHead.CONTROL_MOUSE:
                //鼠标控制
                doMouseEvent(code);
                break;

            case CodeHead.CONTROL_KEYBOARD:
                //键盘控制
                doKeyBoardEvent(code);
                break;

            case CodeHead.VERSION:
                //发送版本信息
                sendVersion();
                break;

            case CodeHead.UPDATE:
                //运行更新程序
                builtUpdateServer();
                break;

            case CodeHead.PASSWORD:
                savePassWord(sender, code);
                break;

            default:
                break;
            }
            lbl_Message.Text = code.ToString();
        }