using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Oreo.NetMonitor.Models { /// /// 联网进程 /// public class NetProcess { public NetProcess() { Ports = new List(); } /// /// 当前进程 /// public Process CurrentProcess { get { return Process.GetProcessById(ProcessID); } } /// /// 联网端口列表 /// public List Ports { get; set; } public long UpBag { get; set; } public long DownBag { get; set; } /// /// 上传 /// public long UpLoad { get; set; } /// /// 下载 /// public long DownLoad { get; set; } public long UpLoadCount { get; set; } public long DownLoadCount { get; set; } public long FlowCount { get; set; } /// /// 应用图标 /// public Icon ProcessICon { get; set; } public int ProcessID { get; set; } public string ProcessName { get; set; } /// /// 添加流量 /// /// 当前瞬时流量 /// /// public bool AddFlow(long currentFlowCount, int port, bool isUpload) { if (Ports != null && Ports.Count > 0) { ProcessPort _pp = Ports.FirstOrDefault(x => x.Port == port); if (_pp != null) { if (isUpload) { UpLoad += currentFlowCount; } else { DownLoad += currentFlowCount; } return true; } } return false; } } }