//************************************************************************ // author: yuzhengyang // date: 2018.3.27 - 2018.6.3 // desc: 工具描述 // Copyright (c) yuzhengyang. All rights reserved. //************************************************************************ using Azylee.Core.DataUtils.CollectionUtils; using Azylee.Core.DataUtils.DateTimeUtils; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Azylee.Core.LogUtils.StatusLogUtils { /// /// 运行状态 /// public class StatusLogModel { /// /// 日期时间 /// public DateTime Time { get; set; } /// /// 统计时长(单位:秒) /// public int Long { get; set; } /// /// 脱机时长(单位:秒) /// public long AFK { get; set; } /// /// Cpu使用率 /// public int CpuPer { get; set; } /// /// 可用内存 /// public long RamFree { get; set; } /// /// 可用系统盘容量 /// public long SysDriveFree { get; set; } /// /// 应用程序Cpu使用率 /// public int AppCpuPer { get; set; } /// /// 应用程序占用内存 /// public long AppRamUsed { get; set; } public override string ToString() { string s = $"{DateTimeConvert.StandardString(Time)}|{Long}|{AFK}|{CpuPer}|" + $"{RamFree}|{SysDriveFree}|{AppCpuPer}|{AppRamUsed}"; return s; } public StatusLogModel FromString(string s) { StatusLogModel model = new StatusLogModel(); string[] elements = s.Split('|'); if (ListTool.HasElements(elements)) { try { if (elements.Length > 0) model.Time = DateTime.Parse(elements[0]); } catch { } try { if (elements.Length > 1) model.Long = int.Parse(elements[1]); } catch { } try { if (elements.Length > 2) model.AFK = long.Parse(elements[2]); } catch { } try { if (elements.Length > 3) model.CpuPer = int.Parse(elements[3]); } catch { } try { if (elements.Length > 5) model.RamFree = long.Parse(elements[5]); } catch { } try { if (elements.Length > 7) model.SysDriveFree = long.Parse(elements[7]); } catch { } try { if (elements.Length > 8) model.AppCpuPer = int.Parse(elements[8]); } catch { } try { if (elements.Length > 9) model.AppRamUsed = long.Parse(elements[9]); } catch { } } return model; } } }