Browse Source

启动默认上传一次日志文件,半个小时默认上传一次日志文件

样式分支
fyf 2 years ago
parent
commit
bf664879ae
3 changed files with 7 additions and 6 deletions
  1. +2
    -0
      BPASmartClient.IoT/DataVClient.cs
  2. +4
    -4
      BPASmartClient.IoT/Model/FileUpload.cs
  3. +1
    -2
      BPASmartClient.ViewModel/LogViewModel.cs

+ 2
- 0
BPASmartClient.IoT/DataVClient.cs View File

@@ -145,6 +145,7 @@ namespace BPASmartClient.IoT
DeviceSecret = DeviceDataV.deviceTable.devicesecret; DeviceSecret = DeviceDataV.deviceTable.devicesecret;
DeviceDataV.DataVMessageAction += DevIOTActionHandler; DeviceDataV.DataVMessageAction += DevIOTActionHandler;
MessageLog.GetInstance.Show($"客户端:【{ClientId}】,设备名称{DeviceName}阿里云连接成功"); MessageLog.GetInstance.Show($"客户端:【{ClientId}】,设备名称{DeviceName}阿里云连接成功");
UpDataFile();
} }
else else
{ {
@@ -156,6 +157,7 @@ namespace BPASmartClient.IoT
if (DeviceDataV.InitializeNo(ProductKey, DeviceName, DeviceSecret, ref message)) if (DeviceDataV.InitializeNo(ProductKey, DeviceName, DeviceSecret, ref message))
{ {
MessageLog.GetInstance.Show($"客户端:【{ClientId}】,设备名称{DeviceName}阿里云连接成功"); MessageLog.GetInstance.Show($"客户端:【{ClientId}】,设备名称{DeviceName}阿里云连接成功");
UpDataFile();
} }
else else
MessageLog.GetInstance.ShowEx(message); MessageLog.GetInstance.ShowEx(message);


+ 4
- 4
BPASmartClient.IoT/Model/FileUpload.cs View File

@@ -26,13 +26,15 @@ namespace BPASmartClient.IoT.Model
{ {
return UploadData.ContainsKey(key) ? UploadData[key] : string.Empty; return UploadData.ContainsKey(key) ? UploadData[key] : string.Empty;
} }
public static long length = 0;
public static byte[] FileBlock;
/// <summary> /// <summary>
/// 文件请求上传 /// 文件请求上传
/// </summary> /// </summary>
public static void FileRequest(DataVReport dataV) public static void FileRequest(DataVReport dataV)
{ {
long length = new FileInfo(path).Length;
byte[] FileBlock = FileContent(path);
FileBlock = FileContent(path);
length = FileBlock.Count();
FileUploadModel fileUpload = new FileUploadModel(); FileUploadModel fileUpload = new FileUploadModel();
fileUpload.@params.fileName = FileName; fileUpload.@params.fileName = FileName;
fileUpload.@params.fileSize = length; fileUpload.@params.fileSize = length;
@@ -58,7 +60,6 @@ namespace BPASmartClient.IoT.Model
/// </summary> /// </summary>
public static void FileSend(DataVReport dataV, string uploadId) public static void FileSend(DataVReport dataV, string uploadId)
{ {
long length = new FileInfo(path).Length;
FileSendModel fileSend = new FileSendModel(); FileSendModel fileSend = new FileSendModel();
fileSend.@params.uploadId = uploadId; fileSend.@params.uploadId = uploadId;
fileSend.@params.offset = 0; fileSend.@params.offset = 0;
@@ -68,7 +69,6 @@ namespace BPASmartClient.IoT.Model
byte[] Header = Encoding.UTF8.GetBytes(Tools.JsonConvertTools(fileSend)); byte[] Header = Encoding.UTF8.GetBytes(Tools.JsonConvertTools(fileSend));
byte HeaderLen_L = (byte)(Header.Length); byte HeaderLen_L = (byte)(Header.Length);
byte HeaderLen_H = (byte)(Header.Length >> 8); byte HeaderLen_H = (byte)(Header.Length >> 8);
byte[] FileBlock = FileContent(path);
byte[] CRC16 = CRC16Standard.getCRCBytes(FileBlock);//CRC.CRC16(FileBlock); byte[] CRC16 = CRC16Standard.getCRCBytes(FileBlock);//CRC.CRC16(FileBlock);
List<byte> message = new List<byte>() { HeaderLen_H, HeaderLen_L }; List<byte> message = new List<byte>() { HeaderLen_H, HeaderLen_L };
message.AddRange(Header); message.AddRange(Header);


+ 1
- 2
BPASmartClient.ViewModel/LogViewModel.cs View File

@@ -234,13 +234,12 @@ namespace BPASmartClient.ViewModel
}; };
dispatcherTimer.Interval = TimeSpan.FromSeconds(10); dispatcherTimer.Interval = TimeSpan.FromSeconds(10);
dispatcherTimer.Start(); dispatcherTimer.Start();

UpDataFileTimer = new DispatcherTimer(); UpDataFileTimer = new DispatcherTimer();
UpDataFileTimer.Tick += delegate UpDataFileTimer.Tick += delegate
{ {
DataVClient.GetInstance().UpDataFile(); DataVClient.GetInstance().UpDataFile();
}; };
UpDataFileTimer.Interval = TimeSpan.FromHours(2);
UpDataFileTimer.Interval = TimeSpan.FromHours(0.5);
UpDataFileTimer.Start(); UpDataFileTimer.Start();
} }
/// <summary> /// <summary>


Loading…
Cancel
Save