|
|
@@ -1,32 +1,82 @@
|
|
1
|
|
-using System;
|
|
|
1
|
+
|
|
|
2
|
+using Newtonsoft.Json;
|
|
|
3
|
+using System;
|
|
2
|
4
|
using System.Collections.Generic;
|
|
|
5
|
+using System.IO;
|
|
3
|
6
|
using System.Linq;
|
|
4
|
7
|
using System.Net;
|
|
5
|
8
|
using System.Text;
|
|
6
|
9
|
using System.Threading;
|
|
7
|
10
|
using System.Threading.Tasks;
|
|
8
|
11
|
|
|
|
12
|
+
|
|
9
|
13
|
namespace Push
|
|
10
|
14
|
{
|
|
11
|
15
|
class Program
|
|
12
|
16
|
{
|
|
13
|
17
|
|
|
14
|
|
-
|
|
|
18
|
+ public class PushTime
|
|
|
19
|
+ {
|
|
|
20
|
+ public DateTime time;
|
|
|
21
|
+ public int morning;
|
|
|
22
|
+ public int Afternoon;
|
|
|
23
|
+ }
|
|
|
24
|
+ private PushTime time = new PushTime();
|
|
15
|
25
|
static void Main(string[] args)
|
|
16
|
26
|
{
|
|
17
|
27
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
|
18
|
28
|
Environment.SetEnvironmentVariable("needDetails", "true");
|
|
19
|
29
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
|
20
|
30
|
Environment.SetEnvironmentVariable("needDetails", "true");
|
|
21
|
|
-
|
|
|
31
|
+
|
|
|
32
|
+
|
|
22
|
33
|
System.Console.WriteLine("Hello Push!");
|
|
23
|
|
-
|
|
|
34
|
+ System.Console.WriteLine(DateTime.Now.ToString("HH"));
|
|
|
35
|
+ PushTime time = new PushTime();
|
|
|
36
|
+ time.time = DateTime.Now;
|
|
|
37
|
+ time.morning = 0;
|
|
|
38
|
+ time.Afternoon = 0;
|
|
|
39
|
+ Push(time);
|
|
24
|
40
|
Thread t = new Thread(new ThreadStart(SetCensusURL));
|
|
25
|
41
|
t.Start();
|
|
|
42
|
+
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ public static void Push(PushTime time)
|
|
|
46
|
+ {
|
|
|
47
|
+
|
|
|
48
|
+
|
|
|
49
|
+ FileStream fs = null;
|
|
|
50
|
+ try
|
|
|
51
|
+ {
|
|
|
52
|
+ if (!Directory.Exists("D:\\Push"))
|
|
|
53
|
+ {
|
|
|
54
|
+ Directory.CreateDirectory("D:\\Push");
|
|
|
55
|
+ }
|
|
|
56
|
+ if ( File.Exists("D:\\Push\\PushMessage.txt"))
|
|
|
57
|
+ {
|
|
|
58
|
+ System.Console.WriteLine(JsonConvert.SerializeObject(time));
|
|
|
59
|
+ File.WriteAllText("D:\\Push\\PushMessage.txt", JsonConvert.SerializeObject(time), Encoding.UTF8);
|
|
|
60
|
+ }
|
|
|
61
|
+ else
|
|
|
62
|
+ {
|
|
|
63
|
+ System.Console.WriteLine(JsonConvert.SerializeObject(time));
|
|
|
64
|
+ File.WriteAllText("D:\\Push\\PushMessage.txt", JsonConvert.SerializeObject(time), Encoding.UTF8);
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
|
67
|
+ finally
|
|
|
68
|
+ {
|
|
|
69
|
+ if (fs != null)
|
|
|
70
|
+ {
|
|
|
71
|
+ fs.Close();
|
|
|
72
|
+ }
|
|
|
73
|
+ }
|
|
26
|
74
|
|
|
27
|
75
|
}
|
|
|
76
|
+ //http://oa.shuanghui.net
|
|
28
|
77
|
private static void SetCensusURL()
|
|
29
|
78
|
{
|
|
|
79
|
+
|
|
30
|
80
|
int n = 0;
|
|
31
|
81
|
while (true)
|
|
32
|
82
|
{
|
|
|
@@ -34,12 +84,88 @@ namespace Push
|
|
34
|
84
|
n += 1;
|
|
35
|
85
|
WebClient web = new WebClient();
|
|
36
|
86
|
web.Encoding = Encoding.UTF8;
|
|
|
87
|
+
|
|
37
|
88
|
try
|
|
38
|
89
|
{
|
|
39
|
|
- string seturl = "http://oa.shuanghui.net:8046/PushMessage/SetCensusURL";
|
|
|
90
|
+ string seturl = "http://oa.shuanghui.net/PushMessage/SetCensusURL";
|
|
40
|
91
|
string Dataaaurl = web.DownloadString(seturl);//这一句话就能请求到数据了
|
|
41
|
|
- string url = "http://oa.shuanghui.net:8046/PushMessage/SetPush";
|
|
|
92
|
+ string url = "http://oa.shuanghui.net/PushMessage/SetPush";
|
|
42
|
93
|
string Dataaa = web.DownloadString(url);//这一句话就能请求到数据了
|
|
|
94
|
+ Program program = new Program();
|
|
|
95
|
+ if (DateTime.Now.ToString("HH") == "09")
|
|
|
96
|
+ {
|
|
|
97
|
+ string str1 = File.ReadAllText("D:\\Push\\PushMessage.txt");
|
|
|
98
|
+ if (!string.IsNullOrEmpty(str1))
|
|
|
99
|
+ {
|
|
|
100
|
+ var obj = JsonConvert.DeserializeObject<PushTime>(str1);
|
|
|
101
|
+ if (obj != null)
|
|
|
102
|
+ {
|
|
|
103
|
+ if (DateTime.Now.Day - obj.time .Day >0)
|
|
|
104
|
+ {
|
|
|
105
|
+ program.time.time = DateTime.Now;
|
|
|
106
|
+ program.time.morning = 1;
|
|
|
107
|
+ program.time.Afternoon = 0;
|
|
|
108
|
+ // System.Console.WriteLine("aavaa" + program.time.morning);
|
|
|
109
|
+ Push(program.time);
|
|
|
110
|
+ string urla = "http://oa.shuanghui.net/PushMessage/PushMessagePush";
|
|
|
111
|
+ string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
|
|
|
112
|
+ }
|
|
|
113
|
+ else
|
|
|
114
|
+ {
|
|
|
115
|
+ if (program.time.morning<=0)
|
|
|
116
|
+ {
|
|
|
117
|
+ program.time.time = DateTime.Now;
|
|
|
118
|
+ program.time.morning = 1;
|
|
|
119
|
+ program.time.Afternoon = obj.Afternoon ;
|
|
|
120
|
+ // System.Console.WriteLine("aacaa" + program.time.morning);
|
|
|
121
|
+ Push(program.time);
|
|
|
122
|
+ string urla = "http://oa.shuanghui.net/PushMessage/PushMessagePush";
|
|
|
123
|
+ string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
|
|
|
124
|
+ }
|
|
|
125
|
+ }
|
|
|
126
|
+ }
|
|
|
127
|
+ }
|
|
|
128
|
+ }
|
|
|
129
|
+ else if (DateTime.Now.ToString("HH") == "14")
|
|
|
130
|
+ {
|
|
|
131
|
+ string str1 = File.ReadAllText("D:\\Push\\PushMessage.txt");
|
|
|
132
|
+ // System.Console.WriteLine("nnvnn" + str1);
|
|
|
133
|
+ if (!string.IsNullOrEmpty(str1))
|
|
|
134
|
+ {
|
|
|
135
|
+ var obj = JsonConvert.DeserializeObject<PushTime>(str1);
|
|
|
136
|
+ if (obj != null)
|
|
|
137
|
+ {
|
|
|
138
|
+ if (DateTime.Now.Day - obj.time.Day > 0)
|
|
|
139
|
+ {
|
|
|
140
|
+ program.time.time = DateTime.Now;
|
|
|
141
|
+ program.time.morning = obj .morning ;
|
|
|
142
|
+ program.time.Afternoon = 1;
|
|
|
143
|
+ Push(program.time);
|
|
|
144
|
+ //System.Console.WriteLine("nnvnn" + program.time.Afternoon);
|
|
|
145
|
+ string urla = "http://oa.shuanghui.net/PushMessage/PushMessagePush";
|
|
|
146
|
+ string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
|
|
|
147
|
+
|
|
|
148
|
+
|
|
|
149
|
+ }
|
|
|
150
|
+ else
|
|
|
151
|
+ {
|
|
|
152
|
+ if (program.time.Afternoon <= 0)
|
|
|
153
|
+ {
|
|
|
154
|
+ program.time.time = DateTime.Now;
|
|
|
155
|
+ program.time.morning = obj.morning;
|
|
|
156
|
+ program.time.Afternoon = 1;
|
|
|
157
|
+ Push(program.time);
|
|
|
158
|
+ // System.Console.WriteLine("nncnn" + program.time.Afternoon);
|
|
|
159
|
+ string urla = "http://oa.shuanghui.net/PushMessage/PushMessagePush";
|
|
|
160
|
+ string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
|
|
|
161
|
+ }
|
|
|
162
|
+ }
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+
|
|
43
|
169
|
}
|
|
44
|
170
|
catch
|
|
45
|
171
|
{
|