Przeglądaj źródła

新增导出日志

zhoufan 3 lat temu
rodzic
commit
c08d9a9579

+ 39 - 0
CallCenterApi/CallCenterApi.Common/CommonHelper.cs

@@ -6,6 +6,7 @@ using CallCenter.Utility;
6 6
 using System.Text.RegularExpressions;
7 7
 using System.Net;
8 8
 using System.IO;
9
+using System.Collections.Generic;
9 10
 
10 11
 namespace CallCenterApi.Common
11 12
 {
@@ -299,5 +300,43 @@ namespace CallCenterApi.Common
299 300
             string signcode = EncryptHelper.MD5Encrypt(controller.ToLower() + "/" + action.ToLower() + "+" + EncryptHelper.SHA1Encrypt(sign + "+" + DateTime.Now.ToString("yyyyMMdd")));
300 301
             return signcode;
301 302
         }
303
+
304
+        /// <summary>
305
+        /// 写日志
306
+        /// </summary>
307
+        /// <param name="request"></param>
308
+        /// <returns></returns>
309
+        public static string RequestLog(HttpRequestBase request)
310
+        {
311
+            Dictionary<string, string> Params = new Dictionary<string, string>();
312
+            Params.Add("request_url", request.Url.ToString());
313
+
314
+            if (request.HttpMethod.ToUpper() != "GET")
315
+            {
316
+                foreach (var key in request.Params.AllKeys)
317
+                {
318
+                    if (key == "ALL_HTTP")
319
+                    {
320
+                        break;
321
+                    }
322
+                    Params.Add(key, request.Params[key]);
323
+                }
324
+            }
325
+
326
+            if (request.ContentLength > 0)
327
+            {
328
+                request.InputStream.Position = 0;
329
+                StreamReader reader = new StreamReader(request.InputStream);
330
+                string postString = reader.ReadToEnd();
331
+                //上传文件时截取
332
+                if (postString.IndexOf("\r\n\r\n") > 0)
333
+                {
334
+                    postString = postString.Substring(0, postString.IndexOf("\r\n\r\n"));
335
+                }
336
+                Params.Add("InputStream", postString);
337
+            }
338
+
339
+            return Params.ToJson();
340
+        }
302 341
     }
303 342
 }

+ 5 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/AuthorizeAttribute.cs

@@ -38,6 +38,11 @@ namespace CallCenterApi.Interface
38 38
                             {
39 39
                                 isAuth = true;
40 40
                                 context.User = new FormsPrincipal<Model.T_Sys_UserAccount>(ticket, user);//重新给context.User赋值。
41
+                                if (context.Request["isdc"] == "1")
42
+                                {
43
+                                    string json = CommonHelper.RequestLog(context.Request);
44
+                                    LogFactory.GetLogger("导出").Warn("操作账号:" + user.F_UserCode + ",请求信息:" + json);
45
+                                }
41 46
                             }
42 47
                         }
43 48
                     }

+ 3 - 23
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/ErrorAttribute.cs

@@ -1,4 +1,5 @@
1 1
 using CallCenter.Utility;
2
+using CallCenterApi.Common;
2 3
 using System.Collections.Generic;
3 4
 using System.IO;
4 5
 using System.Text;
@@ -28,32 +29,11 @@ namespace CallCenterApi.Interface
28 29
 
29 30
             var cnt = context.RequestContext.HttpContext;
30 31
             var rt = cnt.Request;
31
-            Dictionary<string, string> Params = new Dictionary<string, string>();
32
-            Params.Add("request_url", rt.Url.ToString());
33
-
34
-            if (rt.HttpMethod.ToUpper() != "GET")
35
-            {
36
-                foreach (var key in rt.Params.AllKeys)
37
-                {
38
-                    if (key == "ALL_HTTP")
39
-                    {
40
-                        break;
41
-                    }
42
-                    Params.Add(key, rt.Params[key]);
43
-                }
44
-            }
45
-
46
-            if (rt.ContentLength > 0)
47
-            {
48
-                rt.InputStream.Position = 0;
49
-                StreamReader reader = new StreamReader(rt.InputStream);
50
-                string postString = reader.ReadToEnd();
51
-                Params.Add("InputStream", postString);
52
-            }
32
+            string json = CommonHelper.RequestLog(rt);
53 33
 
54 34
             string usercode = cnt.User?.Identity.Name ?? "";
55 35
 
56
-            log.Error("系统异常,操作账号:" + usercode + ",请求信息:" + Params.ToJson(), context.Exception);
36
+            log.Error("系统异常,操作账号:" + usercode + ",请求信息:" + json, context.Exception);
57 37
         }
58 38
     }
59 39
 }

+ 0 - 8
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -355,14 +355,6 @@
355 355
   </ItemGroup>
356 356
   <ItemGroup>
357 357
     <Folder Include="App_Data\" />
358
-    <Folder Include="Views\Affairs\" />
359
-    <Folder Include="Views\CustomerNew\" />
360
-    <Folder Include="Views\Functions\" />
361
-    <Folder Include="Views\NounInterpretation\" />
362
-    <Folder Include="Views\QCResult\" />
363
-    <Folder Include="Views\VideoRecords\" />
364
-    <Folder Include="Views\YSReport\" />
365
-    <Folder Include="Views\ZhengWu\" />
366 358
   </ItemGroup>
367 359
   <ItemGroup>
368 360
     <ProjectReference Include="..\..\..\CallCenterCommon\CallCenter.QuartzService\CallCenter.QuartzService.csproj">