/// <summary>
 /// 覆寫心跳的事件,在這個事件可以處理每一次心跳時,要做的事
 /// </summary>
 /// <param name="Status">電腦狀態</param>
 public override void OnHeartBeating(ComputerStatus Status)
 {
     string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(Status);
     RestClient client = new RestClient(BaseUrl);
     RestRequest req = new RestRequest("wdapi/report", Method.POST);
     req.AddParameter("data", strJson, ParameterType.GetOrPost);
     var result = client.Execute(req);
     Console.WriteLine("report done.");
 }
        /// <summary>
        /// 取得目前電腦狀態及程序狀態
        /// </summary>
        /// <returns></returns>
        public ComputerStatus GetStatus()
        {
            ComputerStatus status = new ComputerStatus();
            status.CPUIds = GetCPUs().ToList();
            status.MachineName = Environment.MachineName;
            status.CpuUsage = cpuCounter.NextValue();
            status.RamUsage = ramCounter.NextValue();
            status.ProcessId = currentProcess.Id;
            status.OSVersion = Environment.OSVersion;

            return status;
        }
Exemple #3
0
 /// <summary>
 /// 每次心跳時,需執行的工作,通常是將 Task 狀態傳回中控台
 /// </summary>
 public abstract void OnHeartBeating(ComputerStatus Status);
Exemple #4
0
 /// <summary>
 /// 每次心跳時,需執行的工作,通常是將 Task 狀態傳回中控台
 /// </summary>
 public abstract void OnHeartBeating(ComputerStatus Status);