private void OnExit(object sender, EventArgs e) { if (CMD_TYPE.SVN_ADD == this.executeCmdType) { this.svnAddFilePaths.Clear(); } if (CMD_TYPE.SVN_COMMIT == this.executeCmdType) { this.svnCommitFilePaths.Clear(); } if (this.orderQueue.Count > 0) { this.DoExecute(this.orderQueue.Dequeue()); return; } this.executeCmdType = CMD_TYPE.NONE; this.CloseProcess(); Writer.Instance.DelRsa(ConfigIni.GetRsaKeySavePath()); this.PrintLog("执行完成", Color.Blue); if (this.conflictList.Count > 0) { if (DialogResult.OK == MessageBox.Show("发现冲突文件,点确定后进行SVN还原。注意:还原将删除你本地修改的冲突文件", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)) { foreach (string path in this.conflictList) { this.Execute(string.Format("svn revert {0} & exit", path), CMD_TYPE.SVN_CLEANUP); } this.conflictList.Clear(); } } }
public void Identify() { if (CMD_TYPE.NONE != this.executeCmdType) { this.PrintLog("正在执行命令,别心急...", Color.Red); return; } this.PrintLog("开始验证,请稍等...", Color.Blue); string rsakey_save_path = ConfigIni.GetRsaKeySavePath(); Writer.Instance.WriteRsa(rsakey_save_path); try { string connect = string.Format("ssh 192.168.9.60 -p 18888 -i {0} -l root -o StrictHostKeyChecking=no", ConfigIni.GetRsaKeySavePath()); string cmd = string.Format("cd /data/game/{0}/htdocs/workbench/xls2xml", ConfigIni.ProjectName) + string.Format("&&su - www -c 'svn up /data/game/{0}/htdocs/workbench/xls2xml/server/'", ConfigIni.ProjectName) + string.Format("&&cp -f /{0}/workspace/publish_debug/EXEgameworld_debug ./check/", ConfigIni.ProjectName) + "&&cd ./check" + "&&./EXEgameworld_debug serverconfig.xml -checkres"; string full_cmd = string.Format("{0} \"{1}\" & exit", connect, cmd); this.Execute(full_cmd, CMD_TYPE.IDENTIFY); } catch (Exception) { this.PrintLog("验证失败", Color.Red); } }
private void OnErrorDataReceived(object sendingProcess, DataReceivedEventArgs outLine) { if (null == outLine.Data) { return; } if (CMD_TYPE.IDENTIFY == this.executeCmdType || CMD_TYPE.HOTUPDTEA == this.executeCmdType) { return; } this.CloseProcess(); Writer.Instance.DelRsa(ConfigIni.GetRsaKeySavePath()); Console.WriteLine(outLine.Data); this.dataReceiveds(outLine.Data, Color.Red); this.executeCmdType = CMD_TYPE.NONE; this.PrintLog("执行失败,中断操作", Color.Red); if (0 == outLine.Data.IndexOf("svn: E160028")) { if (DialogResult.OK == MessageBox.Show("本地文件过期,点确定进行SVN更新操作", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)) { this.SvnUp(); } } else if (0 == outLine.Data.IndexOf("svn: E155037")) { if (DialogResult.OK == MessageBox.Show("SVN被锁定,点确定后进行SVN清理操作", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)) { this.SvnClearup(); } } else if (0 == outLine.Data.IndexOf("svn: E155009")) { if (DialogResult.OK == MessageBox.Show("当前打开excel文件冲突,关闭文件后,再点击确定进行清理操作", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)) { this.SvnClearup(); } } else if (0 == outLine.Data.IndexOf("svn: E")) { MessageBox.Show("SVN出现未知错误,请在本地手动解决", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void HotUpdate(int index, string type_str) { if (CMD_TYPE.NONE != this.executeCmdType) { this.PrintLog("正在执行命令,别心急...", Color.Red); return; } { try { string rsakey_save_path = ConfigIni.GetRsaKeySavePath(); Writer.Instance.WriteRsa(rsakey_save_path); this.PrintLog("连接服务器开始热更,请稍等..." + type_str, Color.Blue); string connect = string.Format("ssh 192.168.9.60 -p 18888 -i {0} -l root -o StrictHostKeyChecking=no", rsakey_save_path); string cmd = string.Format("svn up /{0}/workspace/config/gameworld/", ConfigIni.ProjectName); string full_cmd = string.Format("{0} \"{1}\" & exit", connect, cmd); this.Execute(full_cmd, CMD_TYPE.HOTUPDTEA); } catch (Exception) { this.PrintLog("连接服务器失败", Color.Red); } } { string connect_str = ConfigIni.Database; MySqlConnection mysqlcon = new MySqlConnection(connect_str); try { mysqlcon.Open(); } catch (Exception) { this.PrintLog("连接数据库失败" + connect_str, Color.Red); } try { string cmd_str = string.Format("insert into command(creator,createtime,type,cmd,confirmtime)" + "values(\"test\", {0}, 2, \"Cmd Reload {1} 0 0\", 0);", 1, index + 1); MySqlCommand cmd = new MySqlCommand(cmd_str, mysqlcon); int num = cmd.ExecuteNonQuery(); if (num > 0) { this.PrintLog("热更成功 " + type_str, Color.Green); } else { this.PrintLog("热更失败 " + type_str, Color.Red); } } catch (Exception) { this.PrintLog("热更失败 " + type_str, Color.Red); } mysqlcon.Close(); } }