|
|
|
using Elight.Entity;
|
|
|
|
using Elight.Entity.SystemModel;
|
|
|
|
using Elight.Utility;
|
|
|
|
using Elight.Utility.Code;
|
|
|
|
using Elight.Utility.logs;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using SqlSugar;
|
|
|
|
using sun.nio.ch;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Security.Claims;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace Elight.Logic
|
|
|
|
{
|
|
|
|
public class WriteSysLog
|
|
|
|
{
|
|
|
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
|
|
|
|
Result ret = new Result();
|
|
|
|
public WriteSysLog(User user)
|
|
|
|
{
|
|
|
|
_userdata = user.Userdata();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 添加数据库日志信息
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public void WriteSysLogadd(string operationType, string content, Result result, SqlSugarClient _db = null, string opeCasDepAccCas = null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Func_Dossier_LogRecordModel model = new Func_Dossier_LogRecordModel
|
|
|
|
{
|
|
|
|
UnitCode = _userdata == null ? null: _userdata.unitCode,
|
|
|
|
OperationType = operationType,
|
|
|
|
SerialNumber = Guid.NewGuid().ToString(),
|
|
|
|
NameEntity = "",
|
|
|
|
LogContents = result.IsSucceed ? $"{content}成功" : $"{content}失败:{result.Message}",
|
|
|
|
ParColCreTimTakYeaTri = DateTime.Now.Year.ToString(),
|
|
|
|
OperationIp = "",
|
|
|
|
Operation = _userdata == null ? null : _userdata.name,
|
|
|
|
OperatingTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
OperatingManual = _userdata == null ? null : _userdata.Id,
|
|
|
|
OpeCasDepAccCas = opeCasDepAccCas ?? string.Empty
|
|
|
|
};
|
|
|
|
var sss = _db.Insertable(model).ExecuteCommand();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogService.WriteLog(ex, "添加数据库日志信息_WriteSysLog_1 发生异常");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///生成制定位数的随机码(数字)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="length"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public string GenerateRandomCode(int leng)
|
|
|
|
{
|
|
|
|
var result = new StringBuilder();
|
|
|
|
for (var i = 0; i < leng; i++)
|
|
|
|
{
|
|
|
|
var r = new Random(Guid.NewGuid().GetHashCode());
|
|
|
|
result.Append(r.Next(0, 10));
|
|
|
|
}
|
|
|
|
return result.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|