Exemple #1
0
 public void GetRunLog(RunLogAssemble runLogAssemble)
 {
     if (this.InvokeRequired)
     {
         GetRunLogDel del = new
                            GetRunLogDel(GetRunLog);
         this.Invoke(del, runLogAssemble);
     }
     else
     {
         if (runLogAssemble == null)
         {
             myPageControl_RunLog.PageIndex        = 1;
             myPageControl_RunLog.PageRecordCount  = 1;
             myPageControl_RunLog.PageRecordNumber = 20;
             dataGridView_RunLog.DataSource        = new List <RunLog>();
             return;
         }
         myPageControl_RunLog.PageIndex        = runLogAssemble.PageNumber;
         myPageControl_RunLog.PageRecordCount  = runLogAssemble.LogCount;
         myPageControl_RunLog.PageRecordNumber = runLogAssemble.rowsPerPage;
         dataGridView_RunLog.DataSource        = runLogAssemble.RunLogList.Select(_ =>
         {
             return(new
             {
                 _.ID,
                 OperationType = Enum.Parse(typeof(OperationType), _.OperationType.ToString()).ToString(),
                 _.OperationTime,
                 _.Operator,
                 _.OperationContent
             });
         }).ToList();
     }
 }
        protected override void ProcessProtocol(object arg)
        {
            string content  = string.Empty;
            string protocol = arg as string;

            if (protocol.StartsWith(LogServerCommand.GetAlarmLogResult.ToString()))
            {
                content = protocol.Substring(LogServerCommand.GetAlarmLogResult.ToString().Length).Trim();
                try
                {
                    AlarmLogAssemble alarmLogAssemble = JsonConvert.DeserializeObject <AlarmLogAssemble>(content);
                    if (GetAlarmLog != null)
                    {
                        GetAlarmLog(alarmLogAssemble);
                    }
                }
                catch
                { }
            }
            else if (protocol.StartsWith(LogServerCommand.GetRunLogResult.ToString()))
            {
                content = protocol.Substring(LogServerCommand.GetRunLogResult.ToString().Length).Trim();
                try
                {
                    RunLogAssemble runLogAssemble = JsonConvert.DeserializeObject <RunLogAssemble>(content);
                    if (GetRunLog != null)
                    {
                        GetRunLog(runLogAssemble);
                    }
                }
                catch
                { }
            }
            else if (protocol.StartsWith(LogServerCommand.GetErrLogResult.ToString()))
            {
                content = protocol.Substring(LogServerCommand.GetErrLogResult.ToString().Length).Trim();
                try
                {
                    ErrLogAssemble errLogAssemble = JsonConvert.DeserializeObject <ErrLogAssemble>(content);
                    if (GetErrLog != null)
                    {
                        GetErrLog(errLogAssemble);
                    }
                }
                catch
                { }
            }
        }
Exemple #3
0
        public override void ExecuteCommand(LogSession session, StringRequestInfo requestInfo)
        {
            try
            {
                string[] contents   = requestInfo.Body.Split(',');
                int      pageNumber = 0;
                int.TryParse(contents[0], out pageNumber);
                int rowsPerPage = 0;
                int.TryParse(contents[1], out rowsPerPage);
                RunLogRepository repo           = new RunLogRepository();
                RunLogAssemble   runLogAssemble = new RunLogAssemble();
                runLogAssemble.PageNumber  = pageNumber;
                runLogAssemble.rowsPerPage = rowsPerPage;
                runLogAssemble.LogCount    = repo.RecordCount();
                runLogAssemble.PageCount   = (int)Math.Ceiling((double)runLogAssemble.LogCount / rowsPerPage);
                runLogAssemble.RunLogList  = repo.GetListPaged(pageNumber, rowsPerPage, null, "OperationTime desc");

                session.TrySend(LogServerCommand.GetRunLogResult.ToString() + " " + JsonConvert.SerializeObject(runLogAssemble) + "\r\n");
            }
            catch (Exception ex)
            {
                LogServerManager.AddErrLog(ErrLogType.InnerErr, ex);
            }
        }