提交 2a761d2d 编写于 作者: 麦壳饼's avatar 麦壳饼

删除了无意义注释

上级 bc986040
using IoTSharp.Contracts;
using IoTSharp.Data;
using IoTSharp.Data.Shardings;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IoTSharp.Data.Shardings;
namespace IoTSharp.Storage
{
/// <summary>
/// 由于此模式目前无法通过EFCore.Sharding 进行Group By 获取最新遥测数据, 和Select 新对象, 所以, 最新遥测依然从DataStorage表里获取,历史从分表里获取
/// 更多内容可以参考<seealso cref="https://github.com/Coldairarrow/EFCore.Sharding/issues/52"/>
/// </summary>
public class ShardingStorage : IStorage
{
private readonly AppSettings _appSettings;
private readonly ILogger _logger;
//private readonly IServiceScope scope;
private readonly IServiceScopeFactory _scopeFactor;
public ShardingStorage(ILogger<ShardingStorage> logger, IServiceScopeFactory scopeFactor
, IOptions<AppSettings> options
......@@ -31,7 +20,6 @@ namespace IoTSharp.Storage
{
_appSettings = options.Value;
_logger = logger;
//scope = scopeFactor.CreateScope();
_scopeFactor = scopeFactor;
}
......@@ -53,7 +41,7 @@ namespace IoTSharp.Storage
}
catch (Exception ex)
{
_logger.LogError(ex, $"{ deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
_logger.LogError(ex, $"{deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
throw;
}
}
......@@ -77,13 +65,11 @@ namespace IoTSharp.Storage
}
catch (Exception ex)
{
_logger.LogError(ex, $"{ deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
_logger.LogError(ex, $"{deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
throw;
}
}
public Task<List<TelemetryDataDto>> LoadTelemetryAsync(Guid deviceId, string keys, DateTime begin, DateTime end, TimeSpan every, Aggregate aggregate)
{
return Task.Run(() =>
......@@ -112,13 +98,12 @@ namespace IoTSharp.Storage
}
catch (Exception ex)
{
_logger.LogError(ex, $"{ deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
_logger.LogError(ex, $"{deviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
throw;
}
});
}
public async Task<(bool result, List<TelemetryData> telemetries)> StoreTelemetryAsync(PlayloadData msg)
{
bool result = false;
......@@ -135,7 +120,7 @@ namespace IoTSharp.Storage
{
if (kp.Value != null)
{
var tdata = new TelemetryData() { DateTime = msg.ts, DeviceId = msg.DeviceId, KeyName = kp.Key};
var tdata = new TelemetryData() { DateTime = msg.ts, DeviceId = msg.DeviceId, KeyName = kp.Key };
tdata.FillKVToMe(kp);
lst.Add(tdata);
telemetries.Add(tdata);
......@@ -150,7 +135,6 @@ namespace IoTSharp.Storage
_logger.LogError(ex, $"{msg.DeviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
}
try
{
using (var scope = _scopeFactor.CreateScope())
......@@ -171,7 +155,7 @@ namespace IoTSharp.Storage
{
_logger.LogError(ex, $"{msg.DeviceId}数据处理失败{ex.Message} {ex.InnerException?.Message} ");
}
return (result,telemetries);
return (result, telemetries);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册