/// <summary> /// 停止服务回调 /// </summary> public void OnStopServer() { try { SysConOut.WriteLine("开始检测是否刷新情侣竞技数据到数据库..."); lock (Mutex) { this.CheckRebuildRank(TimeUtil.NowDateTime()); this.CheckFlushRank2Db(); } SysConOut.WriteLine("结束检测是否刷新情侣竞技数据到数据库..."); } catch (Exception ex) { LogManager.WriteException(ex.Message); } }
public void OnStopServer() { try { SysConOut.WriteLine("开始检测是否刷新情侣排行榜到数据库..."); lock (this.Mutex) { this.CheckSortRank(); this.CheckSaveRank(); } SysConOut.WriteLine("结束检测是否刷新情侣排行榜到数据库..."); } catch (Exception ex) { LogManager.WriteException(ex.Message); } }
public static void ShowServerTCPInfo(object obj) { try { string[] cmd = obj as string[]; bool clear = cmd.Contains("/c"); bool detail = cmd.Contains("/d"); DateTime now = TimeUtil.NowDateTime(); SysConOut.WriteLine(string.Format("当前时间:{0},统计时长:{1}", now.ToString("yyyy-MM-dd HH:mm:ss"), (now - CmdMonitor.StartTime).ToString())); if (clear) { detail = true; CmdMonitor.StartTime = now; } SysConOut.WriteLine(string.Format("总处理指令个数 {0}", CmdMonitor.TotalHandledCmdsNum)); SysConOut.WriteLine(string.Format("指令处理耗时详情", new object[0])); try { if (detail) { if (Console.WindowWidth < 160) { Console.WindowWidth = 160; } } else if (Console.WindowWidth >= 88) { Console.WindowWidth = 88; } } catch { } int count = 0; lock (CmdMonitor.mutex) { foreach (PorcessCmdMoniter i in CmdMonitor.cmdMoniter) { if (i.processNum != 0) { Console.ForegroundColor = count % 5 + ConsoleColor.Green; if (detail) { if (count++ == 0) { SysConOut.WriteLine(string.Format("{0, -48}{1, 6}{2, 7}{3, 7} {4, 7} {5, 4} {6, 4} {7, 5}", new object[] { "消息", "已处理次数", "平均处理时长", "总计消耗时长", "总计字节数", "发送次数", "发送字节数", "失败/成功/数据" })); } string info = string.Format("{0, -50}{1, 11}{2, 13:0.##}{3, 13:0.##} {4, 13:0.##} {5, 8} {6, 12} {7, 4}/{8}/{9}", new object[] { CmdMonitor.GetCmdName(i), i.processNum, TimeUtil.TimeMS(i.avgProcessTime(), 2), TimeUtil.TimeMS(i.processTotalTime, 2), i.GetTotalBytes(), i.SendNum, i.OutPutBytes, i.Num_Faild, i.Num_OK, i.Num_WithData }); SysConOut.WriteLine(info); } else { if (count++ == 0) { SysConOut.WriteLine(string.Format("{0, -48}{1, 6}{2, 7}{3, 7}", new object[] { "消息", "已处理次数", "平均处理时长", "总计消耗时长" })); } string info = string.Format("{0, -50}{1, 11}{2, 13:0.##}{3, 13:0.##}", new object[] { CmdMonitor.GetCmdName(i), i.processNum, TimeUtil.TimeMS(i.avgProcessTime(), 2), TimeUtil.TimeMS(i.processTotalTime, 2) }); SysConOut.WriteLine(info); } if (clear) { i.Reset(); } } } Console.ForegroundColor = ConsoleColor.White; } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } }