|
|
|
@ -4,6 +4,8 @@ using S3Demo.Model.Uploader;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using S3Demo.Model;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace S3Demo
|
|
|
|
|
{
|
|
|
|
@ -33,6 +35,12 @@ namespace S3Demo
|
|
|
|
|
// 开始监控
|
|
|
|
|
watch.EnableRaisingEvents = true;
|
|
|
|
|
}
|
|
|
|
|
Thread th = new Thread(HeartBeatMethord)
|
|
|
|
|
{
|
|
|
|
|
Name = "HeartBeatMethord",
|
|
|
|
|
IsBackground = true
|
|
|
|
|
};
|
|
|
|
|
th.Start();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存至数据库
|
|
|
|
@ -129,6 +137,34 @@ namespace S3Demo
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 心跳
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void HeartBeatMethord()
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
//TODO: 优化无效数据包
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ScadaRequest req = new ScadaRequest();
|
|
|
|
|
ScadaResponse resp = new ScadaResponse();
|
|
|
|
|
req.s3Flag = "heart beat";
|
|
|
|
|
req.dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");
|
|
|
|
|
resp = JsonConvert.DeserializeObject<ScadaResponse>(Helper.HttpHelper.PostUrl("http://172.17.204.30:9000/api/tri/imagesupload", JsonConvert.SerializeObject(req)));
|
|
|
|
|
Console.WriteLine(resp);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("连接异常");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建文件
|
|
|
|
|
/// </summary>
|
|
|
|
|