将Logger都更改为使用NLogHelper
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using iNKORE.UI.WPF.Modern.Common.IconKeys;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Enums;
|
||||
using PMSWPF.Extensions;
|
||||
@@ -14,7 +13,6 @@ public class DeviceRepository
|
||||
{
|
||||
private readonly MenuRepository _menuRepository;
|
||||
private readonly VarTableRepository _varTableRepository;
|
||||
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DeviceRepository()
|
||||
{
|
||||
@@ -36,7 +34,7 @@ public class DeviceRepository
|
||||
{
|
||||
var result = await Edit(device, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑设备 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑设备 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +51,7 @@ public class DeviceRepository
|
||||
var result = await db.Updateable<DbDevice>(device.CopyTo<DbDevice>())
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑设备 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑设备 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -80,7 +78,7 @@ public class DeviceRepository
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"加载设备列表总耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"加载设备列表总耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
return devices;
|
||||
}
|
||||
@@ -100,7 +98,7 @@ public class DeviceRepository
|
||||
var result = await db.Queryable<DbDevice>()
|
||||
.FirstAsync(p => p.Id == id);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"根据ID '{id}' 获取设备耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"根据ID '{id}' 获取设备耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +121,7 @@ public class DeviceRepository
|
||||
var res = await Delete(device, menus, db);
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除设备:{device.Name},耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除设备:{device.Name},耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
await db.CommitTranAsync();
|
||||
return res;
|
||||
}
|
||||
@@ -161,7 +159,7 @@ public class DeviceRepository
|
||||
throw new NullReferenceException($"没有找到设备:{device.Name},的菜单对象。");
|
||||
await _menuRepository.DeleteMenu(menu, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除设备:{device.Name},耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除设备:{device.Name},耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -206,7 +204,7 @@ public class DeviceRepository
|
||||
finally
|
||||
{
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加设备 '{device.Name}' 及相关菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加设备 '{device.Name}' 及相关菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
using System.Diagnostics;
|
||||
using iNKORE.UI.WPF.Modern.Common.IconKeys;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Enums;
|
||||
using PMSWPF.Extensions;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
using SqlSugar;
|
||||
|
||||
using PMSWPF.Helper;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
|
||||
public class MenuRepository
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MenuRepository()
|
||||
{
|
||||
@@ -36,7 +37,7 @@ public class MenuRepository
|
||||
var result = await db.Deleteable<DbMenu>(childList)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ public class MenuRepository
|
||||
foreach (var dbMenu in dbMenuTree)
|
||||
menuTree.Add(dbMenu.CopyTo<MenuBean>());
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"获取菜单树耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"获取菜单树耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return menuTree;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +67,7 @@ public class MenuRepository
|
||||
using var db = DbContext.GetInstance();
|
||||
var result = await Add(menu, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ public class MenuRepository
|
||||
var result = await db.Insertable<DbMenu>(menu.CopyTo<DbMenu>())
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -104,7 +105,7 @@ public class MenuRepository
|
||||
var addTableRes = await db.Insertable<DbMenu>(addVarTable)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
// Logger.Info($"添加变量表菜单 '{addVarTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
// NlogHelper.Info($"添加变量表菜单 '{addVarTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return addTableRes;
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ public class MenuRepository
|
||||
var addDeviceMenuId = await db.Insertable<DbMenu>(menu.CopyTo<DbMenu>())
|
||||
.ExecuteReturnIdentityAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加设备菜单 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加设备菜单 '{device.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return addDeviceMenuId;
|
||||
}
|
||||
|
||||
@@ -154,7 +155,7 @@ public class MenuRepository
|
||||
{
|
||||
var result = await Edit(menu, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public class MenuRepository
|
||||
var result = await db.Updateable<DbMenu>(menu.CopyTo<DbMenu>())
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑菜单 '{menu.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ public class MenuRepository
|
||||
var result = await db.Queryable<DbMenu>()
|
||||
.FirstAsync(m => m.DataId == dataId && m.Type == menuType);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"根据DataId '{dataId}' 和 MenuType '{menuType}' 获取菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"根据DataId '{dataId}' 和 MenuType '{menuType}' 获取菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result?.CopyTo<MenuBean>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Models;
|
||||
using PMSWPF.Extensions;
|
||||
@@ -18,7 +17,6 @@ namespace PMSWPF.Data.Repositories;
|
||||
public class MqttRepository
|
||||
{
|
||||
private readonly MenuRepository _menuRepository;
|
||||
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MqttRepository()
|
||||
{
|
||||
@@ -40,7 +38,7 @@ public class MqttRepository
|
||||
.In(id)
|
||||
.SingleAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"根据ID '{id}' 获取Mqtt配置耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"根据ID '{id}' 获取Mqtt配置耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result.CopyTo<Mqtt>();
|
||||
}
|
||||
}
|
||||
@@ -58,7 +56,7 @@ public class MqttRepository
|
||||
var result = await _db.Queryable<DbMqtt>().Includes(m=>m.VariableDatas)
|
||||
.ToListAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"获取所有Mqtt配置耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"获取所有Mqtt配置耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result.Select(m => m.CopyTo<Mqtt>())
|
||||
.ToList();
|
||||
}
|
||||
@@ -92,13 +90,13 @@ public class MqttRepository
|
||||
await _menuRepository.Add(menu, db);
|
||||
await db.CommitTranAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增Mqtt配置 '{mqtt.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增Mqtt配置 '{mqtt.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await db.RollbackTranAsync();
|
||||
Logger.Error(ex, $"添加MQTT配置 {{mqtt.Name}} 失败");
|
||||
NlogHelper.Error( $"添加MQTT配置 {{mqtt.Name}} 失败",ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -129,13 +127,13 @@ public class MqttRepository
|
||||
|
||||
await db.CommitTranAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"更新Mqtt配置 '{mqtt.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"更新Mqtt配置 '{mqtt.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await db.RollbackTranAsync();
|
||||
Logger.Error(ex, $"更新MQTT配置 {{mqtt.Name}} 失败");
|
||||
NlogHelper.Error($"更新MQTT配置 {{mqtt.Name}} 失败", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -163,13 +161,13 @@ public class MqttRepository
|
||||
await _menuRepository.DeleteMenu(menu, db);
|
||||
await db.CommitTranAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除Mqtt配置ID '{mqtt.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除Mqtt配置ID '{mqtt.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await db.RollbackTranAsync();
|
||||
Logger.Error(ex, $"删除MQTT配置 {{mqtt.Name}} 失败");
|
||||
NlogHelper.Error( $"删除MQTT配置 {{mqtt.Name}} 失败",ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Helper;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace PMSWPF.Data.Repositories;
|
||||
/// </summary>
|
||||
public class UserRepository
|
||||
{
|
||||
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取用户
|
||||
@@ -26,7 +25,7 @@ public class UserRepository
|
||||
{
|
||||
var result = await _db.Queryable<DbUser>().In(id).SingleAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"根据ID '{id}' 获取用户耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"根据ID '{id}' 获取用户耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +42,7 @@ public class UserRepository
|
||||
{
|
||||
var result = await _db.Queryable<DbUser>().ToListAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"获取所有用户耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"获取所有用户耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +60,7 @@ public class UserRepository
|
||||
{
|
||||
var result = await _db.Insertable(user).ExecuteReturnIdentityAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增用户 '{user.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增用户 '{user.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +78,7 @@ public class UserRepository
|
||||
{
|
||||
var result = await _db.Updateable(user).ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"更新用户 '{user.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"更新用户 '{user.Id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +96,7 @@ public class UserRepository
|
||||
{
|
||||
var result = await _db.Deleteable<DbUser>().In(id).ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除用户ID '{id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除用户ID '{id}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Extensions;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
using SqlSugar;
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace PMSWPF.Data.Repositories;
|
||||
/// </summary>
|
||||
public class VarDataRepository
|
||||
{
|
||||
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取VariableData
|
||||
@@ -31,7 +30,7 @@ public class VarDataRepository
|
||||
.In(id)
|
||||
.SingleAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"根据ID '{id}' 获取VariableData耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"根据ID '{id}' 获取VariableData耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +48,7 @@ public class VarDataRepository
|
||||
var result = await _db.Queryable<DbVariableData>()
|
||||
.ToListAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"获取所有VariableData耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"获取所有VariableData耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result.Select(d => d.CopyTo<VariableData>())
|
||||
.ToList();
|
||||
}
|
||||
@@ -70,7 +69,7 @@ public class VarDataRepository
|
||||
.Select(dbVarData => dbVarData.CopyTo<VariableData>())
|
||||
.ToListAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"获取变量表的所有变量{result.Count()}个耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"获取变量表的所有变量{result.Count()}个耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +87,7 @@ public class VarDataRepository
|
||||
{
|
||||
var varData = await AddAsync(variableData, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return varData;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public class VarDataRepository
|
||||
var dbVarData = await db.Insertable(variableData.CopyTo<DbVariableData>())
|
||||
.ExecuteReturnEntityAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return dbVarData.CopyTo<VariableData>();
|
||||
}
|
||||
|
||||
@@ -123,7 +122,7 @@ public class VarDataRepository
|
||||
{
|
||||
var varData = await AddAsync(variableDatas, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增VariableData '{variableDatas.Count()}'个, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增VariableData '{variableDatas.Count()}'个, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return varData;
|
||||
}
|
||||
}
|
||||
@@ -143,13 +142,13 @@ public class VarDataRepository
|
||||
var dbList = variableDatas.Select(vb => vb.CopyTo<DbVariableData>())
|
||||
.ToList();
|
||||
stopwatch2.Stop();
|
||||
Logger.Info($"复制 VariableData'{variableDatas.Count()}'个, 耗时:{stopwatch2.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"复制 VariableData'{variableDatas.Count()}'个, 耗时:{stopwatch2.ElapsedMilliseconds}ms");
|
||||
|
||||
var res = await db.Insertable<DbVariableData>(dbList)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"新增VariableData '{variableDatas.Count()}'个, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"新增VariableData '{variableDatas.Count()}'个, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -169,7 +168,7 @@ public class VarDataRepository
|
||||
.Include(d => d.Mqtts)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"更新VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"更新VariableData '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +187,7 @@ public class VarDataRepository
|
||||
var result = await UpdateAsync(variableDatas, _db);
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"更新VariableData {variableDatas.Count()}个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"更新VariableData {variableDatas.Count()}个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -209,7 +208,7 @@ public class VarDataRepository
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"更新VariableData {variableDatas.Count()}个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"更新VariableData {variableDatas.Count()}个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -225,7 +224,7 @@ public class VarDataRepository
|
||||
using var db = DbContext.GetInstance();
|
||||
var result = await DeleteAsync(variableData, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除VariableData: '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除VariableData: '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -244,7 +243,7 @@ public class VarDataRepository
|
||||
.Where(d => d.Id == variableData.Id)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除VariableData: '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除VariableData: '{variableData.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -262,7 +261,7 @@ public class VarDataRepository
|
||||
var result = await DeleteAsync(variableDatas, db);
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除VariableData: '{variableDatas.Count()}'个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除VariableData: '{variableDatas.Count()}'个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -282,7 +281,7 @@ public class VarDataRepository
|
||||
var result = await _db.Deleteable<DbVariableData>(dbList)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除VariableData: '{variableDatas.Count()}'个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除VariableData: '{variableDatas.Count()}'个 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,15 @@ using iNKORE.UI.WPF.Modern.Common.IconKeys;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Enums;
|
||||
using PMSWPF.Extensions;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
using SqlSugar;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
|
||||
public class VarTableRepository
|
||||
{
|
||||
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 添加变量表
|
||||
@@ -27,7 +26,7 @@ public class VarTableRepository
|
||||
var addVarTable = await Add(varTable, db);
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加变量表 '{varTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加变量表 '{varTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return addVarTable;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +46,7 @@ public class VarTableRepository
|
||||
var addVarTabel = await db.Insertable<DbVariableTable>(variableTable.CopyTo<DbVariableTable>())
|
||||
.ExecuteReturnEntityAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"添加设备 '{addVarTabel.Name}' 的默认变量表耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"添加设备 '{addVarTabel.Name}' 的默认变量表耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return addVarTabel.CopyTo<VariableTable>();
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ public class VarTableRepository
|
||||
{
|
||||
var result = await Edit(variableTable, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public class VarTableRepository
|
||||
var result = await db.Updateable<DbVariableTable>(variableTable.CopyTo<DbVariableTable>())
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"编辑变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"编辑变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ public class VarTableRepository
|
||||
{
|
||||
var result = await Delete(variableTable, db);
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除变量表 '{variableTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -118,7 +117,7 @@ public class VarTableRepository
|
||||
var res= await db.Deleteable<DbVariableTable>(varTable.CopyTo<DbVariableTable>())
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
Logger.Info($"删除变量表 '{varTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
NlogHelper.Info($"删除变量表 '{varTable.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user