qinchulong
2025-03-29 039a4a5433e7f80adc88b491b549e5d9486e4f9a
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 WIDESEA_Core.BaseProvider;
using WIDESEA_Core.Extensions.AutofacManager;
using WIDESEA_Entity.DomainModels;
using System.Linq;
using WIDESEA_Core.Utilities;
using System.Linq.Expressions;
using WIDESEA_Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
using System;
using Newtonsoft.Json;
using WIDESEA_Core.ManageUser;
 
namespace WIDESEA_Services.Services
{
    public partial class dt_trackloginfoService
    {
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="saveModel">参数</param>
        /// <param name="content">返回结果</param>
        /// <param name="logName">日志名称</param>
        /// <param name="logCode">日志代码</param>
        /// <param name="description">操作说明</param>
        /// <returns></returns>
        public WebResponseContent AddTrackLog(SaveModel saveModel, WebResponseContent content, string logName, string logCode, string description)
        {
            WebResponseContent content1 = new WebResponseContent();
            try
            {
                //saveModel = null;
                if (saveModel == null || content == null)
                    return content1;
                object para;
                if (saveModel.MainData != null)
                    para = saveModel.MainData;
                else if (saveModel.DelKeys != null)
                    para = saveModel.DelKeys;
                else
                    para = saveModel.DetailData;
 
                dt_trackloginfo trackloginfo = new dt_trackloginfo { tracklog_name = logName, tracklog_content = JsonConvert.SerializeObject(para), tracklog_createtime = DateTime.Now, tracklog_type = content.Status ? "成功" : "失败", tracklog_code = content.Status ? logCode : ("4" + logCode), tracklog_des = description, tracklog_message = content.Status ? "" : content.Message, tracklog_operator = "admin"/*UserContext.Current.UserName*/ };
                repository.Add(trackloginfo, true);
                
            }
            catch (Exception ex)
            {
                content1.Message = ex.Message;
            }
            return content1;
        }
 
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity">参数</param>
        /// <param name="content">返回结果</param>
        /// <param name="logName">日志名称</param>
        /// <param name="logCode">日志代码</param>
        /// <param name="description">操作说明</param>
        /// <returns></returns>
        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;
 
                dt_trackloginfo trackloginfo = new dt_trackloginfo { tracklog_name = logName, tracklog_content = JsonConvert.SerializeObject(entity), tracklog_createtime = DateTime.Now, tracklog_type = content.Status ? "成功" : "失败", tracklog_code = content.Status ? logCode : ("4" + logCode), tracklog_des = description, tracklog_message = content.Status ? "" : content.Message, tracklog_operator = "admin"/*UserContext.Current.UserName*/  };
 
                repository.Add(trackloginfo, true);
            }
            catch (Exception ex)
            {
                content1.Message = ex.Message;
            }
            return content1;
        }
 
    }
}