-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
89 lines (72 loc) · 2.22 KB
/
Program.cs
File metadata and controls
89 lines (72 loc) · 2.22 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
using API;
using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TencentCloudHelper
{
class Program
{
static void Main(string[] args)
{
//自己简单的把自己项目关于良心云的api封装的拿出来简单的做了一下
if (args==null&&args.Length!=0)
{
Console.WriteLine("您没有输入SecretId和SecretKey");
return;
}
for (int i = 0; i < args.Length; i=i+2)
{
TencentCloudApiCommon.l.Add(new API.Model.TencentCloudApiUser()
{
SecretId = args[i],
SecretKey = args[i+1]
});
}
Task.Factory.StartNew(()=> {
while (true)
{
Auto();
Thread.Sleep(1000*60*60*1);
}
});
while (true)
{
Thread.Sleep(10000);
}
}
public static void Auto() {
try
{
var list = TencentCloudApiCommon.GetAll();
foreach (var item in list)
{
try
{
if (item.BaiFenBi > 95)
{
if (item.InstanceState == "运行中")
{
TencentCloudApiCommon.Stop(item.Email, item.InstanceId, item.Region.Key);
}
}
else
{
if (item.InstanceState == "关机")
{
TencentCloudApiCommon.Start(item.Email, item.InstanceId, item.Region.Key);
}
}
}
catch (Exception)
{
}
}
}
catch (Exception)
{
}
}
}
}