分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-23 cbd78ef6650440fcaa2f9eb8b47d16ad76cb4d77
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
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_Services.IRepositories;
using WIDESEA_Services.Repositories;
 
namespace WIDESEA_Comm.LogInfo
{
    public class WriteWMSLog
    {
        /// <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_InterfacerecordRepository interfacerecordRepository = new Dt_InterfacerecordRepository(context);
            Dt_Interfacerecord interfacerecord = new Dt_Interfacerecord()
            {
                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 data = null;
            //if (interfacerecord.interface_message != "")
            var data = interfacerecordRepository.Find(x => x.interface_message == interfacerecord.interface_message && x.interface_remark == interfacerecord.interface_remark && x.interface_createtime.Day == DateTime.Now.Day && x.interface_paradata == paradata && x.interface_returndata == returndata && x.interface_name == name).FirstOrDefault();
            if (data == null)
                interfacerecordRepository.Add(interfacerecord, true);
            else
            {
                data.interface_createtime = DateTime.Now;
                interfacerecordRepository.Update(data, true);
            }
        }
    }
}