分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-01-31 50fd5cc9cfad08714c4daa6d481c5293ff2ae6b1
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Entity.DomainModels;
using WIDESEA_System.IRepositories;
using WIDESEA_System.Repositories;
 
namespace WIDESEA_Comm.LogInfo
{
    public class WritePCSLog
    {
        /// <summary>
        /// 接口数据记录
        /// </summary>
        /// <param name="id">任务ID</param>
        /// <param name="code">成功/失败</param>
        /// <param name="provide">接受者</param>
        /// <param name="call">请求者</param>
        /// <param name="paradata">请求数据</param>
        /// <param name="returndata">返回数据</param>
        /// <param name="remark">备注/描述</param>
        /// <param name="name">操作名称(方法名)</param>
        /// <param name="message">错误信息</param>
        public static void LogAdd(string id, string code, string provide, string call, string paradata, string returndata, string remark, string name, string message)
        {
            VOLContext context = new VOLContext();
            Idt_Interfacerecord_pcsRepository interfacerecord_PcsRepository = new dt_Interfacerecord_pcsRepository(context);
            dt_Interfacerecord_pcs interfacerecord = new dt_Interfacerecord_pcs()
            {
                interface_id = Guid.NewGuid(),
                interface_type = code,
                interface_provide = provide,
                interface_call = call,
                interface_paradata = paradata,
                interface_returndata = returndata,
                interface_createtime = DateTime.Now,
                interface_remark = remark,
                interface_operator = "admin",//UserContext.Current.UserName == null ? "admin" : UserContext.Current.UserName,
                interface_name = name,
                interface_message = message,
            };
            dt_Interfacerecord_pcs data = null;
            if (interfacerecord.interface_message != "")
                data = interfacerecord_PcsRepository.FindFirst(x => x.interface_message == interfacerecord.interface_message && x.interface_remark == interfacerecord.interface_remark && (interfacerecord.interface_createtime.Ticks - x.interface_createtime.Ticks >= 5) && x.interface_paradata.Contains(id));//超过5秒记录
            //data = interfacerecord_PcsRepository.FindFirst(x => x.interface_message == interfacerecord.interface_message && x.interface_remark == interfacerecord.interface_remark && x.interface_createtime.Day == DateTime.Now.Day && x.interface_paradata.Contains(id));
            if (data == null)
                interfacerecord_PcsRepository.Add(interfacerecord, true);
        }
    }
}