zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
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
using HH.TOOLS.LOG;
using HH.WMS.BLL;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Common;
using HH.WMS.Utils;
using HH.WMS.WebApi.Areas.Common.Controllers;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
 
namespace HH.WMS.WebApi.Areas.Basic
{
    public class LogController : BaseController
    {
        [HttpPost]
        public string GetList(SearchDto searchModel)
        {
            try
            {
                return ValidateToken(searchModel.TokenId, t =>
                {
                    IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                    timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    List<string> states = new List<string>();
                    ////状态初始化多个 逗号隔开
                    OperateResult result = new OperateResult();
 
                    int total = 0;
 
                    LogHelper.CleanUp(0, 7);
 
                    var data = LogHelper.Get(searchModel, out total);
                    data.ForEach(e =>
                    {
                        //e.CN_S_LOG_CONTENT = e.CN_S_LOG_CONTENT.Replace("\"", "'");
                        e.CN_T_CREATE = e.CN_T_CREATE.AddHours(8);
                    });
                    OperateResult pagingList = OperateResult.Succeed("", new
                    {
                        rows = data,
                        total = total
                    });
                    return JsonConvert.SerializeObject(pagingList, timeFormat);
                });
            }
            catch (Exception ex)
            {
                return JsonConvert.SerializeObject(OperateResult.Error(ex.Message));
            }
        }
 
        [HttpGet]
        public OperateResult GetDtls(string mstGuid)
        {
            return ValidateToken(t =>
            {
                var dtls = LogHelper.GetDtls(mstGuid);
                dtls.ForEach(e =>
                {
                    e.CN_S_LOG_CONTENT = e.CN_S_LOG_CONTENT.Replace("\"", "'");
                    e.CN_T_CREATE = e.CN_T_CREATE.AddHours(8);
                });
                return OperateResult.Succeed(null, dtls);
            });
        }
 
        [HttpGet]
        public IHttpActionResult Add()
        {
            var logPara = new LogPara("日志测试");
            logPara.PushAndAdd(DateTime.Now.ToString() + "新增测试日志记录!");
            return Json("添加成功!");
        }
    }
}