StoreExeBean.cs
3.5 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StroreManager
{
public class StoreExeBean
{
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static char spiltStr = ';';
public StoreExeBean()
{
Priority = 1;
}
public int ID { get; set; }
/// <summary>
/// 进程名称,不带EXE
/// </summary>
public string ProcessName { get; set; }
/// <summary>
/// 路径+名称
/// </summary>
public string ExePath { get; set; }
/// <summary>
/// 版本号
/// </summary>
public string FileVersion { get; set; }
/// <summary>
/// 是否在运行中
/// </summary>
public bool IsRun { get; set; }
public string IsRunStr
{
get
{
if (IsRun)
{
return "正在运行中";
}
else
{
return "已停止";
}
}
set
{
}
}
public string StartButtonStr
{
get
{
if (IsRun)
{
return "查看";
}
else
{
return "启动";
}
}
set
{
}
}
/// <summary>
/// 进程号
/// </summary>
public string PID { get; set; }
/// <summary>
/// 使用的CPU百分率
/// </summary>
public string CPU { get; set; }
/// <summary>
/// 占用内存数
/// </summary>
public string UseMemory { get; set; }
/// <summary>
/// 是否自动运行
/// </summary>
public bool IsAutoRun { get; set; }
/// <summary>
/// 启动优先级(自动启动时才有优先级)
/// </summary>
public int Priority { get; set; }
public override string ToString()
{
return "ID=" + ID + ",ProcessName=" + ProcessName + ",ExePath=" + ExePath + ",IsRun=" + IsRun + ",IsAutoRun=" + IsAutoRun + ",FileVersion=" + FileVersion;
}
/// <summary>
/// exe的名称
/// </summary>
public string GetExeName()
{
return ProcessName + ".exe";
}
/// <summary>
/// 保存到文件的字符串
/// </summary>
/// <returns></returns>
public string AuToFileData()
{
return ProcessName + spiltStr + ExePath + spiltStr + Priority;
}
public static StoreExeBean ConverToBean(string str)
{
StoreExeBean bean = null;
try
{
string[] array = str.Split(StoreExeBean.spiltStr);
if (array.Length == 3)
{
bean = new StoreExeBean();
bean.ProcessName = array[0];
bean.ExePath = array[1];
bean.Priority = Int32.Parse(array[2]);
return bean;
}
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
return bean;
}
}
}