| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
-
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Push
- {
- class Program
- {
- public class PushTime
- {
- public DateTime time;
- public int morning;
- public int Afternoon;
- }
- private PushTime time = new PushTime();
- static void Main(string[] args)
- {
- Console.OutputEncoding = System.Text.Encoding.UTF8;
- Environment.SetEnvironmentVariable("needDetails", "true");
- Console.OutputEncoding = System.Text.Encoding.UTF8;
- Environment.SetEnvironmentVariable("needDetails", "true");
-
-
- System.Console.WriteLine("Hello Push!");
- // System.Console.WriteLine(DateTime.Now.ToString("HH"));
- //PushTime time = new PushTime();
- //time.time = DateTime.Now;
- //time.morning = 0;
- //time.Afternoon = 0;
- //Push(time);
- Thread t = new Thread(new ThreadStart(SetCensusURL));
- t.Start();
-
- }
-
- public static void Push(PushTime time)
- {
-
-
- FileStream fs = null;
- try
- {
- if (!Directory.Exists("D:\\Push"))
- {
- Directory.CreateDirectory("D:\\Push");
- }
- if ( File.Exists("D:\\Push\\PushMessage.txt"))
- {
- // System.Console.WriteLine(JsonConvert.SerializeObject(time));
- File.WriteAllText("D:\\Push\\PushMessage.txt", JsonConvert.SerializeObject(time), Encoding.UTF8);
- }
- else
- {
- // System.Console.WriteLine(JsonConvert.SerializeObject(time));
- File.WriteAllText("D:\\Push\\PushMessage.txt", JsonConvert.SerializeObject(time), Encoding.UTF8);
- }
- }
- finally
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- }
- //http://oa.shuanghui.net:8046/
- private static void SetCensusURL()
- {
-
- int n = 0;
- while (true)
- {
- Thread.Sleep(60 * 1000);
- n += 1;
- WebClient web = new WebClient();
- web.Encoding = Encoding.UTF8;
-
- try
- {
- string seturl = "http://oa.shuanghui.net:8046/PushMessage/SetCensusURL";
- string Dataaaurl = web.DownloadString(seturl);//这一句话就能请求到数据了
- // System.Console.WriteLine("nnvnn" + Dataaaurl);
- string url = "http://oa.shuanghui.net:8046/PushMessage/SetPush";
- string Dataaa = web.DownloadString(url);//这一句话就能请求到数据了
- // System.Console.WriteLine("nnvnn" + Dataaa);
- //Program program = new Program();
- // if (DateTime.Now.ToString("HH") == "09")
- // {
- // string str1 = File.ReadAllText("D:\\Push\\PushMessage.txt");
- // if (!string.IsNullOrEmpty(str1))
- // {
- // var obj = JsonConvert.DeserializeObject<PushTime>(str1);
- // if (obj != null)
- // {
- // if (DateTime.Now.Day - obj.time .Day >0)
- // {
- // program.time.time = DateTime.Now;
- // program.time.morning = 1;
- // program.time.Afternoon = 0;
- // // System.Console.WriteLine("aavaa" + program.time.morning);
- // Push(program.time);
- // string urla = "http://192.168.8.9:1001//PushMessage/PushMessagePush";
- // string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
- // }
- // else
- // {
- // if (program.time.morning<=0)
- // {
- // program.time.time = DateTime.Now;
- // program.time.morning = 1;
- // program.time.Afternoon = obj.Afternoon ;
- // // System.Console.WriteLine("aacaa" + program.time.morning);
- // Push(program.time);
- // string urla = "http://192.168.8.9:1001//PushMessage/PushMessagePush";
- // string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
- // }
- // }
- // }
- // }
- // }
- // else if (DateTime.Now.ToString("HH") == "14")
- // {
- // string str1 = File.ReadAllText("D:\\Push\\PushMessage.txt");
- // // System.Console.WriteLine("nnvnn" + str1);
- // if (!string.IsNullOrEmpty(str1))
- // {
- // var obj = JsonConvert.DeserializeObject<PushTime>(str1);
- // if (obj != null)
- // {
- // if (DateTime.Now.Day - obj.time.Day > 0)
- // {
- // program.time.time = DateTime.Now;
- // program.time.morning = obj .morning ;
- // program.time.Afternoon = 1;
- // Push(program.time);
- // //System.Console.WriteLine("nnvnn" + program.time.Afternoon);
- // string urla = "http://oa.shuanghui.net:8046//PushMessage/PushMessagePush";
- // string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
- // }
- // else
- // {
- // if (program.time.Afternoon <= 0)
- // {
- // program.time.time = DateTime.Now;
- // program.time.morning = obj.morning;
- // program.time.Afternoon = 1;
- // Push(program.time);
- // // System.Console.WriteLine("nncnn" + program.time.Afternoon);
- // string urla = "http://oa.shuanghui.net:8046//PushMessage/PushMessagePush";
- // string Dataa = web.DownloadString(urla);//这一句话就能请求到数据了
- // }
- // }
- // }
- // }
-
- // }
-
-
- }
- catch
- {
- }
-
-
- }
- }
- }
- }
|