Windows服务,线上的监控程序,监控指定的服务
1
高胜
2023-05-23 cf31c5a262ad9f8fe66e884c4ca82d6c060422ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
 
namespace HDLMonitorService.Entity
{
    public class ServiceInfo
    {
        public string ServiceName { get; set; }
 
        public string Address { get; set; }
 
        public string PublicAddress { get; set; }
 
        public DateTime LastHeartTime { get; set; }
 
        public DateTime LastRegisterTime { get; set; }
 
        public int ErrorCount { get; set; } = 0;
 
        public int AlarmCount { get; set; } = 0;
 
        public bool IsOnline
        {
            get
            {
                return (DateTime.Now - this.LastHeartTime).TotalSeconds < int.Parse(ConfigurationManager.AppSettings["LoopSeconds"].ToString()) * int.Parse(ConfigurationManager.AppSettings["LoopErrorCount"].ToString()) * int.Parse(ConfigurationManager.AppSettings["LoopAlarmCount"].ToString());
            }
        }
    }
}