yanjinhui
7 天以前 aeb971fe12b73d83d31a83b00f0a6e2876b24a00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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<Dt_trackloginfo, IRepository<Dt_trackloginfo>>, ITrackloginfoService
    {
        public TrackloginfoService(IRepository<Dt_trackloginfo> BaseDal) : base(BaseDal)
        {
        }
 
        public IRepository<Dt_trackloginfo> Repository => BaseDal;
 
 
        public WebResponseContent AddTrackLog<T>(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<string> 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 = JsonConvert.SerializeObject(content),
                    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<Dt_trackloginfo> GetPageData(PageDataOptions options)
        {
            PageGridData<Dt_trackloginfo> car = null;
            try
            {
                car = base.GetPageData(options);
            }
            catch (Exception ex)
            {
 
            }
            return car;
        }
 
 
    }
}