Beispiel #1
0
 public static void SetProcessState(LogShowDevice dev, ServerRunState state)
 {
     foreach (var process in processList)
     {
         process.State = state;
     }
 }
Beispiel #2
0
        private string GetIconByDev(LogShowDevice dev)
        {
            switch (dev)
            {
            case LogShowDevice.CET: return("Cet");

            case LogShowDevice.MAY: return("May");

            case LogShowDevice.DBS: return("Db");

            case LogShowDevice.LGI: return("Lgi");

            case LogShowDevice.GAT: return("Gat");

            case LogShowDevice.ROL: return("Rol");
            }
            return(null);
        }
Beispiel #3
0
        public static void StartProcess(string pname, LogShowDevice dev, string parm = "")
        {
            Process process = new Process();

            process.StartInfo.FileName = pname;
            if (!string.IsNullOrEmpty(parm))
            {
                process.StartInfo.Arguments = parm;
            }
            process.StartInfo.UseShellExecute = false;       // 是否使用外壳程序 
            //process.StartInfo.CreateNoWindow = true; //是否在新窗口中启动该进程的值 
            process.StartInfo.RedirectStandardError  = true; // 重定向输入流 
            process.StartInfo.RedirectStandardOutput = true; // 重定向输入流 
            process.ErrorDataReceived  += (s, _e) => LogTextManager.AddLog(_e.Data);
            process.OutputDataReceived += (s, _e) => LogTextManager.AddLog(_e.Data);
            process.Start();
            process.BeginErrorReadLine();
            process.BeginOutputReadLine();
            processList.Add(new ProcessInfoData {
                Process = process, ProcessId = process.Id, Dev = dev, Rect = new Rectangle(25, 60 + 95 * processList.Count, 70, 70)
            });
        }
        public static void AddLog(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            if (text[0] != '[' || text.Contains("[print_frame]"))
            {
                return;
            }

            LogShowMode   type = LogShowMode.DEBUG;
            LogShowDevice dev  = LogShowDevice.ROL;

            var datas = text.Replace("][", "]").Split(']');

            if (datas.Length > 2)
            {
                switch (datas[2])
                {
                case "loginSrv": dev = LogShowDevice.LGI; break;

                case "dbSrv": dev = LogShowDevice.DBS; break;
                }
            }
            if (datas.Length > 6)
            {
                switch (datas[6])
                {
                case "WARNING": type = LogShowMode.WARN; break;

                case "ERROR": type = LogShowMode.ERROR; break;

                case "FATAL": type = LogShowMode.FATAL; break;

                case "CRITICAL": type = LogShowMode.FATAL; break;
                }
            }

            var newLog = new LogItem {
                Id = logIndex++, Type = type, Text = text, Device = dev
            };

            items.AddLast(newLog);
            if (LogCount >= ConfigObject.Instance.MaxLogCount)
            {
                var firstId = items.First.Value.Id;
                items.RemoveFirst();
                RemoveTextHandle(firstId);
            }

            if (newLog.Text.Contains("DGServerNode.AllServerRunning"))
            {
                ProcessHelper.SetProcessState(newLog.Device, ServerRunState.Running);
            }
            else if (newLog.Text.Contains("DGServerNode.DoShutdown"))
            {
                ProcessHelper.SetProcessState(newLog.Device, ServerRunState.Shutdown);
            }

            if (!ShowLog)
            {
                return;
            }

            //if ((type & filterMode) == 0 || (dev & filterDevice) == 0)
            //    return;
            //if (!string.IsNullOrEmpty(filterWords) && !text.Contains(filterWords))
            //    return;
            AppendTextHandle(newLog.Id, text, type);
        }
 public static void SetSevice(LogShowDevice md)
 {
     filterDevice = md;
     RefreshItems();
 }