public string Execute(string argument) { SystemEventLogService logService = new SystemEventLogService(); PerformanceStatisticRepository pStatisticRepo = new PerformanceStatisticRepository(); try { PerformanceStatistic stats = new PerformanceStatistic(); stats = GetPCPerformance(); PerformanceStatistic input = new PerformanceStatistic(); input.CopyFrom(stats); if (input != null) { pStatisticRepo.InsertPerformanceStatistic(input); } List<NetworkStatistic> Networkstats = new List<NetworkStatistic>(); Networkstats = GetSystemNetworkStatistic(); if (Networkstats.Count > 0 && Networkstats != null) { foreach (NetworkStatistic nstatistic in Networkstats) { if (nstatistic.IpAddress != null) { //nstatistic.IpAddress = Convert.ToString(0); InsertNetworkStatistic(nstatistic); } } } return "Success"; } catch (Exception exp) { logService.InsertSystemEventLog(string.Format("Error in PerformanceStatisticThread: {0}", exp.Message), exp.StackTrace, EventCodes.Error); return "Error"; } }
public string Execute(string argument) { PerformanceStatisticRepository pStatisticRepo = new PerformanceStatisticRepository(); SystemEventLogRepository sysEventLog = new SystemEventLogRepository(); FlushData arg=JSONhelper.GetObject<FlushData>(argument); try { int daysAgoPerformance = Convert.ToInt32(arg.PerformanceStatisticDays); DateTime dtPerformance = pStatisticRepo.GetMaxCreationDate(); dtPerformance = dtPerformance.AddDays(-daysAgoPerformance); pStatisticRepo.FlushPerformanceStatistic(dtPerformance); int daysAgoSystemEvent = Convert.ToInt32(arg.SystemEventLogDays); DateTime dtSystemEvt = sysEventLog.GetMaxCreationDate(); dtSystemEvt = dtSystemEvt.AddDays(-daysAgoSystemEvent); sysEventLog.FlushSystemEventLog(dtSystemEvt); return "Success"; } catch (Exception exp) { return "Error"; } }
public static string GetUpdatedSystemPerformanceStatistic(string ThreadLastUpdateDateStr) { DataTransfer<List<ControlPanel.Core.Entities.PerformanceStatistic>> dt = new DataTransfer<List<ControlPanel.Core.Entities.PerformanceStatistic>>(); try { PerformanceStatisticRepository repo = new PerformanceStatisticRepository(); DateTime date = DateTime.UtcNow; if (!DateTime.TryParse(ThreadLastUpdateDateStr, out date)) date = DateTime.UtcNow; List<ControlPanel.Core.Entities.PerformanceStatistic> stats = repo.GetPerformanceStatisticThreadByLastUpdatedDate(date.ToUniversalTime()); if (stats != null) stats = stats.OrderBy(x => x.CreationDate).ToList(); dt.Data = stats; } catch (Exception exp) { dt.IsSuccess = false; dt.Errors = new string[] { exp.Message }; } var a = JSONhelper.GetString(dt); return JSONhelper.GetString(dt); }