public async Task <ResponseMessage> NoticeCallbackAsync(UserNoticeCallbackRequest userNoticeCallbackRequest) { ResponseMessage response = new ResponseMessage(); if (userNoticeCallbackRequest == null) { throw new ArgumentNullException(nameof(userNoticeCallbackRequest)); } //找到本地审核流程 var examineFlow = await _examineFlowStore.ExamineFlowGetAsync(a => a.Where(b => b.TaskGuid == userNoticeCallbackRequest.TaskGuid)); if (examineFlow == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未在本地找到该审核流程"; } //找到所有通知的人 var userIds = await _permissionExpansionManager.GetPermissionUserIds(userNoticeCallbackRequest.PermissionItemId); if (userIds == null || userIds?.Count == 0) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到通知的人"; } examineFlow.CurrentStepId = userNoticeCallbackRequest.CurrentStepId; await Store.NoticeCallbackAsync(userIds, examineFlow); //发送通知消息 SendMessageRequest sendMessageRequest = new SendMessageRequest(); sendMessageRequest.MessageTypeCode = "ExamineNotice"; MessageItem messageItem = new MessageItem(); messageItem.UserIds = userIds; messageItem.MessageTypeItems = new List <TypeItem> { new TypeItem { Key = "NOTICETYPE", Value = ExamineContentTypeConvert.GetContentTypeString(examineFlow.ContentType) }, new TypeItem { Key = "NAME", Value = examineFlow.ContentName }, new TypeItem { Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm") } }; sendMessageRequest.MessageList = new List <MessageItem> { messageItem }; try { MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest)); _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection()); } catch (Exception e) { MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString()); } return(response); }
/// <summary> /// 审核步骤回调 /// </summary> /// <param name="examineCallbackRequest"></param> /// <returns></returns> public async Task <ResponseMessage> StepCallback(ExamineCallbackRequest examineCallbackRequest) { ResponseMessage response = new ResponseMessage(); if (examineCallbackRequest == null) { throw new ArgumentNullException(nameof(examineCallbackRequest)); } //找到本地审核流程 var examineFlow = await Store.ExamineFlowGetAsync(a => a.Where(b => b.TaskGuid == examineCallbackRequest.TaskGuid)); if (examineFlow == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未在本地找到该审核流程"; return(response); } //找到所有能审核的人 var userIds = await _permissionExpansionManager.GetPermissionUserIds(examineCallbackRequest.PermissionItemId); if (userIds == null || userIds?.Count == 0) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到有权限审核人"; return(response); } //找到第一个符合条件的审核人 string examineUserId = ""; if (string.IsNullOrEmpty(examineCallbackRequest.OrganizationId)) { examineUserId = await FindExamineUserId(examineFlow.SubmitOrganizationId, userIds); } else { examineUserId = await FindExamineUserIdByOrganization(examineCallbackRequest.OrganizationId, userIds); } if (string.IsNullOrEmpty(examineUserId)) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到有权限并且符合组织条件的审核人"; return(response); } examineFlow.CurrentStepId = examineCallbackRequest.CurrentStepId; await Store.StepCallBackUpdateExamineFlowAsync(examineUserId, examineFlow); //发送通知消息 SendMessageRequest sendMessageRequest = new SendMessageRequest(); sendMessageRequest.MessageTypeCode = "ExamineWaiting"; MessageItem messageItem = new MessageItem(); messageItem.UserIds = new List <string> { examineUserId }; messageItem.MessageTypeItems = new List <TypeItem> { new TypeItem { Key = "NOTICETYPE", Value = ExamineContentTypeConvert.GetContentTypeString(examineFlow.ContentType) }, new TypeItem { Key = "NAME", Value = examineFlow.ContentName }, new TypeItem { Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm") } }; sendMessageRequest.MessageList = new List <MessageItem> { messageItem }; try { MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest)); _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection()); } catch (Exception e) { MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString()); } return(response); }
public async Task <ResponseMessage> ExamineReject(UserInfo user, [FromRoute] string recordId, [FromBody] string desc) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject),请求体为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); ResponseMessage response = new ResponseMessage(); if (string.IsNullOrEmpty(recordId)) { response.Code = ResponseCodeDefines.ArgumentNullError; return(response); } try { var record = await _examineFlowManager.FindExamineRecordById(recordId); if (record == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到审核流程"; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n未找到相应的审核记录{response.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } GatewayInterface.Dto.ExamineResponse examineResponse = new GatewayInterface.Dto.ExamineResponse(); examineResponse.ContentId = record.ExamineFlow.ContentId; examineResponse.ContentType = record.ExamineFlow.ContentType; examineResponse.FlowId = record.ExamineFlow.Id; examineResponse.Content = record.ExamineFlow.Content; examineResponse.Ext1 = record.ExamineFlow.Ext1; examineResponse.Ext2 = record.ExamineFlow.Ext2; examineResponse.Ext3 = record.ExamineFlow.Ext3; examineResponse.Ext4 = record.ExamineFlow.Ext4; examineResponse.Ext5 = record.ExamineFlow.Ext5; examineResponse.Ext6 = record.ExamineFlow.Ext6; examineResponse.Ext7 = record.ExamineFlow.Ext7; examineResponse.Ext8 = record.ExamineFlow.Ext8; examineResponse.SubmitDefineId = record.ExamineFlow.SubmitDefineId; examineResponse.ExamineStatus = GatewayInterface.Dto.ExamineStatus.Reject; var _shopsInterface = ApplicationContext.Current.Provider.GetRequiredService <IShopsInterface>(); var _customerInterface = ApplicationContext.Current.Provider.GetRequiredService <ICustomerInterface>(); var response3 = new GatewayInterface.Dto.ResponseMessage(); if (record.ExamineFlow.ContentType == "building") { response3 = await _shopsInterface.SubmitBuildingCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "shops") { response3 = await _shopsInterface.SubmitShopsCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "TransferCustomer") { response3 = await _customerInterface.TransferCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "BuildingsOnSite") { response3 = await _shopsInterface.BuildingsOnSiteCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "CustomerDeal") { response3 = await _customerInterface.CustomerDealCallback(examineResponse); } else { response3 = await _shopsInterface.UpdateRecordSubmitCallback(examineResponse); } //var response3 = JsonHelper.ToObject<ResponseMessage>(result); if (response3.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "回调客户端返回错误:" + response3.Message; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n回调相关应用失败{response3.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection.Add("appToken", "app:nwf"); var taskCallback = new TaskCallback { Message = "", TaskGuid = record.ExamineFlow.TaskGuid, StepID = record.ExamineFlow.CurrentStepId, CallbackProtocol = new FlowProtocol { ProtocolType = "", Protocol = "false" }, Status = TaskStatusEnum.Finished }; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})审核驳回回调nwf协议:\r\n{0}", JsonHelper.ToJson(taskCallback)); string response4 = await _restClient.Post(ApplicationContext.Current.NWFExamineCallbackUrl, taskCallback, "POST", nameValueCollection); Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})审核驳回回调nwf返回:\r\n{0}", response4); var nwfresponse = JsonHelper.ToObject <ResponseMessage>(response4); if (nwfresponse.Code != "0") { Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})像NWF发起驳回审核请求(ExaminePass)失败:NWF返回失败:\r\n{nwfresponse.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(nwfresponse); } var response2 = await _examineFlowManager.ExamineReject(user.Id, recordId, desc); if (response2.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "审核中心处理出错"; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n未找到相应的审核记录{response2.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } //发送通知消息 SendMessageRequest sendMessageRequest = new SendMessageRequest(); sendMessageRequest.MessageTypeCode = "ExamineReject"; MessageItem messageItem = new MessageItem(); messageItem.UserIds = new List <string> { record.ExamineFlow.SubmitUserId }; messageItem.MessageTypeItems = new List <TypeItem> { new TypeItem { Key = "NOTICETYPE", Value = ExamineContentTypeConvert.GetContentTypeString(record.ExamineFlow.ContentType) }, new TypeItem { Key = "NAME", Value = record.ExamineFlow.ContentName }, new TypeItem { Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm") } }; sendMessageRequest.MessageList = new List <MessageItem> { messageItem }; try { MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest)); _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection()); } catch (Exception e) { MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString()); } } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); } return(response); }