public void WriteRsa(string path) { StreamWriter sw = new StreamWriter(path, false); using (sw) { sw.Write(ConfigIni.GetRsaKey()); sw.Flush(); sw.Close(); } }
static void Main() { if (!ConfigIni.ReadIniConifg()) { return; } // Command.Execute("mkdir 5"); // Command.Execute("svn commit * -m"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new BuildWin()); }
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(); } }