Przeglądaj źródła

增加日志过滤器,调整审核接口-去掉任务id传输

ylchen 4 lat temu
rodzic
commit
29c22d7484

+ 11 - 25
WorkFlowApi/WorkFlowApi.Business/Scheme/WFProcessBusiness.cs

@@ -220,8 +220,8 @@ namespace WorkFlowApi.Business.Scheme
220 220
 
221 221
             // 获取下一节点信息
222 222
             List<WFLineInfo> lineList = new List<WFLineInfo>();
223
-            List<WFNodeInfo> list = nWFIEngine.GetNextTaskNode(nodeInfo, "agree", false, lineList);
224
-            string codelist = nWFIEngine.GetButonList(nodeInfo.id, lineList);
223
+            List<WFNodeInfo> list = nWFIEngine.GetNextTaskNode(nodeInfo, "agree", false, lineList, branchnodeCode);
224
+            string codelist = nWFIEngine.GetButonList(list.FirstOrDefault().id, lineList);
225 225
             // 创建任务
226 226
             List<T_WF_TaskView> taskList = _CreateTask(list, nodeInfo, nWFEngineParamConfig,codelist);
227 227
             List<T_WF_Task> taskListEntity = taskList.MapToList<T_WF_Task>();
@@ -383,12 +383,13 @@ namespace WorkFlowApi.Business.Scheme
383 383
             // 获取下一节点信息
384 384
             List<WFLineInfo> lineList = new List<WFLineInfo>();
385 385
             List<WFNodeInfo> list = nWFIEngine.GetNextTaskNode(nodeInfo, operationCode, false, lineList, branchnodeCode);
386
-            var codelist = string.Empty;
387
-            if (list != null && list.Count() > 0)
386
+           
387
+            if (list == null && list.Count() == 0)
388 388
             {
389
-               codelist = nWFIEngine.GetButonList(list.FirstOrDefault().id, lineList);
389
+                throw (new Exception("找不到对应流程任务!"));
390
+               
390 391
             }
391
-          
392
+            var codelist = nWFIEngine.GetButonList(list.FirstOrDefault().id, lineList);
392 393
 
393 394
 
394 395
             // 创建任务
@@ -759,25 +760,10 @@ namespace WorkFlowApi.Business.Scheme
759 760
 
760 761
             list.AddRange(list2);
761 762
 
762
-            //if (list.Count == 0)
763
-            //{// 未找到审核人,默认成系统管理员
764
-            //    if (nodeInfo.noPeopleGz == 3)
765
-            //    {
766
-            //        throw (new Exception("下一节点没有审核人,无法提交!"));
767
-            //    }
768
-            //    // 如果找不到审核人就默认超级管理员才能审核
769
-            //    var adminEntityList = user.GetList("F_RoleId=4", "");
770
-            //    foreach (var item in adminEntityList)
771
-            //    {
772
-            //        list.Add(new WFUserInfo()
773
-            //        {
774
-            //            Id = item.F_UserId.ToString(),
775
-            //            Account = item.F_UserCode,
776
-            //            Name = item.F_UserName,
777
-            //            noPeople = true
778
-            //        });
779
-            //    }
780
-            //}
763
+            if (list.Count == 0)
764
+            {
765
+                    throw (new Exception("下一节点没有审核人,无法提交!"));              
766
+            }
781 767
 
782 768
             return list;
783 769
         }

+ 0 - 1
WorkFlowApi/WorkFlowApi.Models/Input/AuditFlowReq.cs

@@ -12,7 +12,6 @@ namespace WorkFlowApi.ViewModels.Input
12 12
         public string OperationCode { get; set; }
13 13
         public string OperationName { get; set; }
14 14
         public string ProcessId { get; set; }
15
-        public string TaskId { get; set; }
16 15
 
17 16
         public string BranchnodeCode { get; set; }
18 17
         public string Des { get; set; }

+ 6 - 6
WorkFlowApi/WorkFlowApi.Models/View/NextTaskinfo.cs

@@ -15,32 +15,32 @@ namespace WorkFlowApi.ViewModels.View
15 15
         /// 主键 
16 16
         /// </summary> 
17 17
         /// <returns></returns> 
18
-        public string Id { get; set; }
18
+      //  public string Id { get; set; }
19 19
         /// <summary> 
20 20
         /// 流程实例主键 
21 21
         /// </summary> 
22 22
         /// <returns></returns> 
23
-        public string ProcessId { get; set; }
23
+     //   public string ProcessId { get; set; }
24 24
         /// <summary> 
25 25
         /// 流程节点ID 
26 26
         /// </summary> 
27 27
         /// <returns></returns> 
28
-        public string NodeId { get; set; }
28
+      //  public string NodeId { get; set; }
29 29
         /// <summary> 
30 30
         /// 流程节点名称 
31 31
         /// </summary> 
32 32
         /// <returns></returns> 
33
-        public string NodeName { get; set; }
33
+     //   public string NodeName { get; set; }
34 34
         /// <summary> 
35 35
         /// 任务类型1审批2传阅3加签4子流程5重新创建 
36 36
         /// </summary> 
37 37
         /// <returns></returns> 
38
-        public int? Type { get; set; }
38
+     //   public int? Type { get; set; }
39 39
         /// <summary> 
40 40
         /// 是否完成1完成2关闭0未完成 
41 41
         /// </summary> 
42 42
         /// <returns></returns> 
43
-        public int? IsFinished { get; set; }
43
+     //   public int? IsFinished { get; set; }
44 44
         public List<WFAuditor> auditors { get; set; }
45 45
 
46 46
         public string nodeType { get; set; }

+ 1 - 0
WorkFlowApi/WorkFlowApi/App_Start/WebApiConfig.cs

@@ -16,6 +16,7 @@ namespace WorkFlowApi
16 16
             config.MapHttpAttributeRoutes();
17 17
             config.Filters.Add(new AuthorizeFilter());
18 18
             config.Filters.Add(new ExceptionFilter());
19
+            config.Filters.Add(new WebApiActionLogFilter());
19 20
 
20 21
             config.Routes.MapHttpRoute(
21 22
                 name: "DefaultApi",

+ 1 - 1
WorkFlowApi/WorkFlowApi/Configs/system.config

@@ -12,7 +12,7 @@
12 12
   <!-- JWT-->
13 13
   <add key="JwtSecret" value="db3OIsj+BXE9NZDy0t8W3TcNekrF+2d/1sFnWG4HnV8TZYJHjsa7J9DfsaRabWvB1GlOgJuQZdcF2Luqm/hccMw==" />
14 14
   <!-- 是否开启全日志-->
15
-  <add key="IsLog" value="0" />
15
+  <add key="IsLog" value="1" />
16 16
   <!-- ================== 3:微信配置参数 ================== -->
17 17
   <!-- 设置微信appid -->
18 18
   <add key="WechatAppid" value="wxe03366d8c63d9b09" />

+ 15 - 22
WorkFlowApi/WorkFlowApi/Controllers/WorkFlow/WFProcessController.cs

@@ -17,12 +17,14 @@ namespace WorkFlowApi.Controllers.WorkFlow
17 17
     public class WFProcessController : BaseController
18 18
     {
19 19
         private readonly IWFProcessBusiness _wFProcess;
20
+        private readonly IWFTaskBusiness _wFTaskBusiness;
20 21
         /// <summary>
21 22
         /// 构造函数
22 23
         /// </summary>
23
-        public WFProcessController(IWFProcessBusiness wFProcess)
24
+        public WFProcessController(IWFProcessBusiness wFProcess, IWFTaskBusiness wFTaskBusiness)
24 25
         {
25 26
             _wFProcess = wFProcess;
27
+            _wFTaskBusiness = wFTaskBusiness;
26 28
         }
27 29
         /// <summary>
28 30
         /// 创建流程实例
@@ -33,9 +35,7 @@ namespace WorkFlowApi.Controllers.WorkFlow
33 35
         public IHttpActionResult Create(CreateFlowReq  createFlowReq)
34 36
         {
35 37
  
36
-            try
37
-            {
38
-                LogHelper.Info("CreateFlow-请求开始:" + createFlowReq.ToJson() + "\n");
38
+
39 39
                 List<T_WF_TaskView>   t_WF_TaskViews = new List<T_WF_TaskView>();
40 40
                 if (createFlowReq.IsNew)
41 41
                 {
@@ -47,13 +47,8 @@ namespace WorkFlowApi.Controllers.WorkFlow
47 47
                 }
48 48
                 
49 49
                 return Success("创建成功", t_WF_TaskViews.MapToList<NextTaskinfo>());
50
-            }
51
-            catch (Exception ex)
52
-            {
53
-
54
-                LogHelper.Error("CreateFlow-请求异常:" + ex.Message + "\n");
55
-                return Error("系统异常");
56
-            }
50
+            
51
+     
57 52
         }
58 53
         /// <summary>
59 54
         /// 审批流程
@@ -64,9 +59,7 @@ namespace WorkFlowApi.Controllers.WorkFlow
64 59
         public IHttpActionResult Audit(AuditFlowReq  auditFlowReq)
65 60
         {
66 61
 
67
-            try
68
-            {
69
-                LogHelper.Info("AuditFlow-请求开始:" + auditFlowReq.ToJson() + "\n");
62
+       
70 63
                 List<T_WF_TaskView> t_WF_TaskViews = new List<T_WF_TaskView>();
71 64
                 if (auditFlowReq.OperationCode == "send"  )
72 65
                 {
@@ -75,15 +68,15 @@ namespace WorkFlowApi.Controllers.WorkFlow
75 68
                         return Error("派单未指定审核人");
76 69
                     }
77 70
                 }
78
-                _wFProcess.AuditFlow(auditFlowReq.OperationCode, auditFlowReq.OperationName, auditFlowReq.ProcessId, auditFlowReq.TaskId, auditFlowReq.Des, "","", auditFlowReq.BranchnodeCode, CurrentUser,out t_WF_TaskViews, auditFlowReq.auditors);
71
+                var taskEntiy = _wFTaskBusiness.GetList($"F_ProcessId='{auditFlowReq.ProcessId}'   AND F_IsFinished=0", "").FirstOrDefault();
72
+                if (taskEntiy == null)
73
+                {
74
+                    return Error("未找到对应流程任务");
75
+                }
76
+                _wFProcess.AuditFlow(auditFlowReq.OperationCode, auditFlowReq.OperationName, auditFlowReq.ProcessId, taskEntiy.F_Id, auditFlowReq.Des, "","", auditFlowReq.BranchnodeCode, CurrentUser,out t_WF_TaskViews, auditFlowReq.auditors);
79 77
                 return Success("流程审批成功", t_WF_TaskViews.MapToList<NextTaskinfo>());
80
-            }
81
-            catch (Exception ex)
82
-            {
83
-
84
-                LogHelper.Error("AuditFlow-请求异常:" + ex.Message + "\n");
85
-                return Error("系统异常");
86
-            }
78
+            
79
+       
87 80
         }
88 81
     }
89 82
 }

+ 29 - 67
WorkFlowApi/WorkFlowApi/Controllers/WorkFlow/WFSchemeController.cs

@@ -40,8 +40,7 @@ namespace WorkFlowApi.Controllers.WorkFlow
40 40
         public IHttpActionResult GetEntityByCode(string code)
41 41
         {
42 42
 
43
-            try
44
-            {
43
+      
45 44
                 if (string.IsNullOrEmpty(code))
46 45
                 {
47 46
                     return Error("请求参数不正确");
@@ -49,12 +48,8 @@ namespace WorkFlowApi.Controllers.WorkFlow
49 48
                 var  infoEntityView = _wFSchemeInfo.GetEntityByCode(code);
50 49
                 return Success("成功", infoEntityView.MapTo<SchemeInfoAuditView>());
51 50
 
52
-            }
53
-            catch (Exception e)
54
-            {
55
-                LogHelper.Error("GetSchemeInfoPageList-请求异常:" + e.Message + "\n");
56
-                return Error("系统异常");
57
-            }
51
+            
52
+ 
58 53
 
59 54
         }
60 55
         /// <summary>
@@ -63,24 +58,19 @@ namespace WorkFlowApi.Controllers.WorkFlow
63 58
         [HttpPost]
64 59
         public IHttpActionResult GetListPage(GetSchemeInfoPageListReq  getSchemeInfoPageListReq)
65 60
         {
66
-            LogHelper.Info("GetSchemeInfoPageList-请求开始:"+getSchemeInfoPageListReq.ToJson()+"\n");
61
+         
67 62
             int total = 0;
68
-            try
69
-            {
63
+    
70 64
                 if (getSchemeInfoPageListReq == null)
71 65
                 {
72 66
                     return Error("请求参数不正确");
73 67
                 }
74 68
                 var list= _wFSchemeInfo.GetSchemeInfoPageList(getSchemeInfoPageListReq,out total);
75
-                LogHelper.Info("GetSchemeInfoPageList-请求结束:" + list.ToJson() + "\n");
69
+          
76 70
                 return Success("成功", list.MapToList<SchemeInfoView>(), total);
77 71
                
78
-            }
79
-            catch (Exception e)
80
-            {
81
-                LogHelper.Error("GetSchemeInfoPageList-请求异常:" + e.Message + "\n");
82
-                return Error("系统异常");
83
-            }
72
+            
73
+    
84 74
 
85 75
         }
86 76
         /// <summary>
@@ -91,24 +81,18 @@ namespace WorkFlowApi.Controllers.WorkFlow
91 81
         [HttpPost]
92 82
         public IHttpActionResult GetSchemePageList(GetSchemePageListReq getSchemePageListReq)
93 83
         {
94
-            LogHelper.Info("GetSchemePageList-请求开始:" + getSchemePageListReq.ToJson() + "\n");
84
+         
95 85
             int total = 0;
96
-            try
97
-            {
86
+     
98 87
                 if (getSchemePageListReq == null)
99 88
                 {
100 89
                     return Error("请求参数不正确");
101 90
                 }
102 91
                 var list = _wFSchemeInfo.GetSchemePageList(getSchemePageListReq, out total);
103
-                LogHelper.Info("GetSchemePageList-请求结束:" + list.ToJson() + "\n");
92
+            
104 93
                 return Success("成功", list, total);
105 94
 
106
-            }
107
-            catch (Exception e)
108
-            {
109
-                LogHelper.Error("GetSchemePageList-请求异常:" + e.Message + "\n");
110
-                return Error("系统异常");
111
-            }
95
+  
112 96
 
113 97
         }
114 98
         /// <summary>
@@ -119,9 +103,9 @@ namespace WorkFlowApi.Controllers.WorkFlow
119 103
         [HttpPost]
120 104
         public IHttpActionResult Save(SaveSchemeInfoReq  saveSchemeInfoReq)
121 105
         {
122
-            LogHelper.Info("SaveSchemeInfo-请求开始:" + saveSchemeInfoReq.ToJson() + "\n");
123
-            try
124
-            {
106
+         
107
+         
108
+        
125 109
                 T_WF_SchemeInfo t_WF_SchemeInfo = saveSchemeInfoReq.schemeInfo.MapTo<T_WF_SchemeInfo>();
126 110
                 // 验证流程编码是否重复
127 111
               
@@ -132,14 +116,9 @@ namespace WorkFlowApi.Controllers.WorkFlow
132 116
                 }
133 117
               
134 118
                 _wFSchemeInfo.SaveSchemeInfo(saveSchemeInfoReq, CurrentUser);
135
-                LogHelper.Info("SaveSchemeInfo-请求结束:" + "保存成功" + "\n");
119
+       
136 120
                 return Success("保存成功");
137
-            }
138
-            catch (Exception e)
139
-            {
140
-                LogHelper.Error("SaveSchemeInfo-请求异常:" + e.Message + "\n");
141
-                return Error("系统异常");
142
-            }
121
+     
143 122
         }
144 123
 
145 124
         /// <summary>
@@ -150,18 +129,12 @@ namespace WorkFlowApi.Controllers.WorkFlow
150 129
  
151 130
         public IHttpActionResult Delete(string keyValue)
152 131
         {
153
-            LogHelper.Info("DeleteSchemeInfo-请求开始:" + keyValue + "\n");
154
-            try
155
-            {
132
+         
133
+          
156 134
                 _wFSchemeInfo.DeleteSchemeInfo(keyValue, CurrentUser);
157
-                LogHelper.Info("DeleteSchemeInfo-请求结束:" + "删除成功" + "\n");
135
+           
158 136
                 return Success("删除成功");
159
-            }
160
-            catch (Exception e)
161
-            {
162
-                LogHelper.Error("DeleteSchemeInfo-请求异常:" + e.Message + "\n");
163
-                return Error("系统异常");
164
-            }
137
+       
165 138
         }
166 139
         /// <summary>
167 140
         /// 启用/停用
@@ -171,18 +144,13 @@ namespace WorkFlowApi.Controllers.WorkFlow
171 144
         /// <returns></returns>
172 145
         public IHttpActionResult UpdateState(string keyValue,int state)
173 146
         {
174
-            LogHelper.Info("UpdateState-请求开始:" + keyValue+":"+ state + "\n");
175
-            try
176
-            {
147
+         
148
+        
177 149
                 _wFSchemeInfo.UpdateState(keyValue, state, CurrentUser);
178
-                LogHelper.Info("UpdateState-请求结束:" +"操作成功" + "\n");
150
+           
179 151
                 return Success((state == 1 ? "启用" : "禁用") + "成功!");
180
-            }
181
-            catch (Exception e)
182
-            {
183
-                LogHelper.Error("UpdateState-请求异常:" +e.Message + "\n");
184
-                return Error("系统异常");
185
-            }
152
+          
153
+       
186 154
         }
187 155
         /// <summary>
188 156
         /// 更新模板版本
@@ -192,18 +160,12 @@ namespace WorkFlowApi.Controllers.WorkFlow
192 160
         /// <returns></returns>
193 161
         public IHttpActionResult UpdateScheme(string schemeInfoId, string schemeId)
194 162
         {
195
-            LogHelper.Info("UpdateScheme-请求开始:" + schemeInfoId + ";" + schemeId + "\n");
196
-            try
197
-            {
163
+         
164
+          
198 165
                 _wFSchemeInfo.UpdateScheme(schemeInfoId, schemeId, CurrentUser);
199 166
                 LogHelper.Info("UpdateScheme-请求结束:" + "操作成功" + "\n");
200 167
                 return Success("更新成功!");
201
-            }
202
-            catch (Exception e)
203
-            {
204
-                LogHelper.Error("UpdateScheme-请求异常:" + e.Message + "\n");
205
-                return Error("系统异常");
206
-            }
168
+      
207 169
         }
208 170
 
209 171
 

+ 90 - 0
WorkFlowApi/WorkFlowApi/Filter/WebApiActionLogFilter.cs

@@ -0,0 +1,90 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Web;
7
+using System.Web.Http.Controllers;
8
+using System.Web.Http.Filters;
9
+using WorkFlowApi.Utility;
10
+
11
+namespace WorkFlowApi.Filter
12
+{
13
+    public class WebApiActionLogFilter: ActionFilterAttribute
14
+    {
15
+        private string  _IsDebugLog = ConfigHelper.GetValue("IsLog").ToString();
16
+        public override void OnActionExecuting(HttpActionContext actionContext)
17
+        {
18
+            if (_IsDebugLog=="1")
19
+            {
20
+                base.OnActionExecuting(actionContext);
21
+                HttpContextBase cnt = (HttpContextBase)actionContext.Request.Properties["MS_HttpContext"];//获取传统context
22
+                HttpRequestBase request = cnt.Request;//定义传统request对象  
23
+
24
+                string param = string.Empty;
25
+                if (request.QueryString != null && request.QueryString.Count > 0)
26
+                {
27
+                    param = request.QueryString.ToJson();
28
+                }
29
+
30
+                if (request.ContentLength > 0)
31
+                {
32
+                    using (var ms = new MemoryStream())
33
+                    {
34
+                        request.InputStream.CopyTo(ms);
35
+                        param = Encoding.UTF8.GetString(ms.ToArray());
36
+                        //上传文件时截取
37
+                        if (param.IndexOf("\r\n\r\n") > 0)
38
+                        {
39
+                            param = param.Substring(0, param.IndexOf("\r\n\r\n"));
40
+                        }
41
+                    }
42
+
43
+                    request.InputStream.Position = 0;
44
+                }
45
+
46
+                string usercode = cnt.User?.Identity.Name ?? "";
47
+                LogHelper.Info(usercode + ",进入执行,请求地址:" + request.Url.ToString() + ",参数:" + param);
48
+            }
49
+          
50
+        }
51
+
52
+        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
53
+        {
54
+            if (_IsDebugLog == "1")
55
+            {
56
+                base.OnActionExecuted(actionExecutedContext);
57
+                HttpContextBase cnt = (HttpContextBase)actionExecutedContext.Request.Properties["MS_HttpContext"];//获取传统context
58
+                HttpRequestBase request = cnt.Request;//定义传统request对象  
59
+
60
+                string param = string.Empty;
61
+                if (request.QueryString != null && request.QueryString.Count > 0)
62
+                {
63
+                    param = request.QueryString.ToJson();
64
+                }
65
+
66
+                if (request.ContentLength > 0)
67
+                {
68
+                    using (var ms = new MemoryStream())
69
+                    {
70
+                        request.InputStream.CopyTo(ms);
71
+                        param = Encoding.UTF8.GetString(ms.ToArray());
72
+                        //上传文件时截取
73
+                        if (param.IndexOf("\r\n\r\n") > 0)
74
+                        {
75
+                            param = param.Substring(0, param.IndexOf("\r\n\r\n"));
76
+                        }
77
+                    }
78
+
79
+                    request.InputStream.Position = 0;
80
+                }
81
+
82
+                string usercode = cnt.User?.Identity.Name ?? "";
83
+                LogHelper.Info(usercode + ",退出执行,请求地址:" + request.Url.ToString() + ",返回结果:" + actionExecutedContext.Response.Content.ReadAsStringAsync().Result);
84
+            }
85
+               
86
+        }
87
+    }
88
+
89
+
90
+}

+ 1 - 1
WorkFlowApi/WorkFlowApi/Web.config

@@ -25,7 +25,7 @@
25 25
     <httpProtocol>
26 26
       <customHeaders>
27 27
         <add name="Access-Control-Allow-Origin" value="*" />
28
-        <add name="Access-Control-Allow-Headers" value="*" />
28
+        <add name="Access-Control-Allow-Headers" value="authorization,Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type" />
29 29
         <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
30 30
       </customHeaders>
31 31
     </httpProtocol>

+ 1 - 0
WorkFlowApi/WorkFlowApi/WorkFlowApi.csproj

@@ -122,6 +122,7 @@
122 122
     <Compile Include="Controllers\WorkFlow\WFSchemeController.cs" />
123 123
     <Compile Include="Filter\AuthorizeFilter.cs" />
124 124
     <Compile Include="Filter\ExceptionFilter.cs" />
125
+    <Compile Include="Filter\WebApiActionLogFilter.cs" />
125 126
     <Compile Include="Global.asax.cs">
126 127
       <DependentUpon>Global.asax</DependentUpon>
127 128
     </Compile>