using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_IBasicInfoService; using WIDESEAWCS_Model.Models; namespace WIDESEAWCS_BasicInfoService { public class TrackloginfoService : ServiceBase>, ITrackloginfoService { public TrackloginfoService(IRepository BaseDal) : base(BaseDal) { } public IRepository Repository => BaseDal; public WebResponseContent AddTrackLog(T entity, WebResponseContent content, string logName, string logCode, string description) { WebResponseContent content1 = new WebResponseContent(); try { if (entity == null || content == null) return content1; if (!content.Status) { //string sql = @"select top 3 tracklog_message from dt_trackloginfo ORDER BY tracklog_createtime desc"; List obj = BaseDal.QueryData().OrderByDescending(x => x.tracklog_createtime).Select(x => x.tracklog_message).Take(3).ToList(); if (null != obj) { if (obj.Contains(content.Message)) return content1; } } Dt_trackloginfo trackloginfo = new Dt_trackloginfo() { tracklog_name = logName, //tracklog_content = JsonConvert.SerializeObject(entity), tracklog_content = entity is string strEntity ? strEntity : JsonConvert.SerializeObject(entity),//如果entity是字符串类型,则直接使用,否则序列化为JSON字符串 tracklog_createtime = DateTime.Now, Creater = "system", tracklog_type = content.Status ? "成功" : "失败", tracklog_code = content.Status ? logCode : ("4" + logCode), tracklog_des = description, tracklog_message = content.Status ? "" : content.Message, tracklog_operator = "system"/*UserContext.Current.UserName*/ }; BaseDal.AddData(trackloginfo); } catch (Exception ex) { content1.Message = ex.Message; } return content1; } public override PageGridData GetPageData(PageDataOptions options) { PageGridData car = null; try { car = base.GetPageData(options); } catch (Exception ex) { } return car; } } }