コード例 #1
0
        public static string GetUpdatedSystemProcessThreads(string ThreadLastUpdateDateStr, string EventLogLastUpdateDateStr)
        {
            try
            {
                DateTime ThreadLastUpdateDate = DateTime.UtcNow;
                if (DateTime.TryParse(ThreadLastUpdateDateStr, out ThreadLastUpdateDate))
                {
                    ThreadLastUpdateDate = ThreadLastUpdateDate.ToUniversalTime();
                }
                DateTime EventLogLastUpdateDate = DateTime.UtcNow;

                if (DateTime.TryParse(EventLogLastUpdateDateStr, out EventLogLastUpdateDate))
                {
                    EventLogLastUpdateDate = EventLogLastUpdateDate.ToUniversalTime();
                }
                // ControlPanel.Core.ICPWebClient webClient = ControlPanel.Core.IoC.Resolve<ControlPanel.Core.ICPWebClient>("CPWebClient");
                CPServiceClient webClient       = new CPServiceClient();
                var             threads         = webClient.GetSystemProcessThreadsByLastUpdateDate(ThreadLastUpdateDate);
                var             eventLogs       = webClient.GetEventLogByLastUpdateDate(EventLogLastUpdateDate);
                DateTime        maxThreadDate   = ThreadLastUpdateDate;
                DateTime        maxEventLogDate = EventLogLastUpdateDate;

                if (threads.Data == null)
                {
                    threads.Data = new List <ControlPanel.Core.Entities.SystemProcessThread>();
                }
                else if (threads.Data.Count > 0)
                {
                    maxThreadDate = threads.Data.Select(x => x.LastUpdateDate).Max().Value;
                }

                foreach (var dt in threads.Data)
                {
                    if (dt.LastSuccessfullyExecuted != null)
                    {
                        dt.LastExecutedSeconds = (DateTime.UtcNow - dt.LastSuccessfullyExecuted.Value.ToUniversalTime()).ToString(@"hh\:mm\:ss");
                    }
                }

                if (eventLogs == null)
                {
                    eventLogs = new List <ControlPanel.Core.Entities.SystemEventLog>();
                }
                else if (eventLogs.Count > 0)
                {
                    maxEventLogDate = eventLogs.Select(x => x.DateOccured).Max();
                }

                if (threads.Data != null && threads.Data.Count > 0)
                {
                    return(JSONhelper.GetString(new ControlPanelUpdateModel()
                    {
                        Threads = threads.Data, ThreadLastUpdateDate = maxThreadDate, EventLogs = eventLogs, EventLogLastUpdateDate = maxEventLogDate
                    }));
                }
                else
                {
                    return(JSONhelper.GetString(new ControlPanelUpdateModel()
                    {
                        ThreadLastUpdateDate = ThreadLastUpdateDate, EventLogLastUpdateDate = EventLogLastUpdateDate
                    }));
                }
            }
            catch (Exception exp) { return(exp.Message); }
        }
コード例 #2
0
        public static string GetUpdatedSystemProcessThreads(string ThreadLastUpdateDateStr, string EventLogLastUpdateDateStr)
        {
            try
            {
                DateTime ThreadLastUpdateDate = DateTime.UtcNow;
                if (DateTime.TryParse(ThreadLastUpdateDateStr, out ThreadLastUpdateDate))
                {
                    ThreadLastUpdateDate = ThreadLastUpdateDate.ToUniversalTime();
                }
                DateTime EventLogLastUpdateDate = DateTime.UtcNow;

                if (DateTime.TryParse(EventLogLastUpdateDateStr, out EventLogLastUpdateDate))
                {
                    EventLogLastUpdateDate = EventLogLastUpdateDate.ToUniversalTime();
                }
               // ControlPanel.Core.ICPWebClient webClient = ControlPanel.Core.IoC.Resolve<ControlPanel.Core.ICPWebClient>("CPWebClient");
                CPServiceClient webClient = new CPServiceClient();
                var threads = webClient.GetSystemProcessThreadsByLastUpdateDate(ThreadLastUpdateDate);
                var eventLogs = webClient.GetEventLogByLastUpdateDate(EventLogLastUpdateDate);
                DateTime maxThreadDate = ThreadLastUpdateDate;
                DateTime maxEventLogDate = EventLogLastUpdateDate;

                if (threads.Data == null)
                    threads.Data = new List<ControlPanel.Core.Entities.SystemProcessThread>();
                else if (threads.Data.Count > 0)
                    maxThreadDate = threads.Data.Select(x => x.LastUpdateDate).Max().Value;

                foreach (var dt in threads.Data)
                {
                    if (dt.LastSuccessfullyExecuted != null)
                        dt.LastExecutedSeconds = (DateTime.UtcNow - dt.LastSuccessfullyExecuted.Value.ToUniversalTime()).ToString(@"hh\:mm\:ss");
                }

                if (eventLogs == null) eventLogs = new List<ControlPanel.Core.Entities.SystemEventLog>();
                else if (eventLogs.Count > 0)
                    maxEventLogDate = eventLogs.Select(x => x.DateOccured).Max();

                if (threads.Data != null && threads.Data.Count > 0)

                    return JSONhelper.GetString(new ControlPanelUpdateModel() { Threads = threads.Data, ThreadLastUpdateDate = maxThreadDate, EventLogs = eventLogs, EventLogLastUpdateDate = maxEventLogDate });
                else return JSONhelper.GetString(new ControlPanelUpdateModel() { ThreadLastUpdateDate = ThreadLastUpdateDate, EventLogLastUpdateDate = EventLogLastUpdateDate });
            }
            catch (Exception exp) { return exp.Message; }
        }