private void AddProjectComment(ClosureWOCheckList entity, string action, ProjectCommentStatus status) { ProjectComment closureCommens = new ProjectComment(); closureCommens.RefTableId = entity.Id; closureCommens.RefTableName = ClosureWOCheckList.TableName; closureCommens.TitleNameENUS = ClientCookie.TitleENUS; closureCommens.TitleNameZHCN = ClientCookie.TitleENUS; closureCommens.TitleCode = ClientCookie.TitleENUS; closureCommens.CreateTime = DateTime.Now; closureCommens.CreateUserAccount = ClientCookie.UserCode; closureCommens.UserAccount = ClientCookie.UserCode; closureCommens.UserNameENUS = ClientCookie.UserNameENUS; closureCommens.UserNameZHCN = ClientCookie.UserNameZHCN; closureCommens.CreateUserNameZHCN = entity.UserNameZHCN; closureCommens.Id = Guid.NewGuid(); if (!string.IsNullOrEmpty(entity.Comments)) { closureCommens.Content = entity.Comments.Trim(); } closureCommens.Action = action; closureCommens.Status = status; if (entity.ProcInstID > 0) { closureCommens.ProcInstID = entity.ProcInstID; } closureCommens.SourceCode = FlowCode.Closure; closureCommens.SourceNameENUS = FlowCode.Closure; closureCommens.SourceNameZHCN = "关店流程"; closureCommens.Add(); }
public IHttpActionResult AddEmailComment(WorkflowEmailComment emailComment) { try { if (emailComment == null) { Log4netHelper.WriteErrorLog("Email comments 对象为空!"); return(Ok(false)); } Log4netHelper.WriteInfo( string.Format("Email Comment InputVals:K2SN:{0};OperatorID:{1};Action:{2};EmailComments:{3}", emailComment.K2SN, emailComment.OperatorID, emailComment.Action, emailComment.EmailComments) ); if (string.IsNullOrEmpty(emailComment.K2SN) || string.IsNullOrEmpty(emailComment.OperatorID)) { Log4netHelper.WriteErrorLog("K2 SN 或操作人不能为空!"); return(Ok(false)); } string activity = string.Empty; try { activity = K2FxContext.Current.GetCurrentActivityName(emailComment.K2SN, emailComment.OperatorID); } catch { } var taskItem = TaskWork.Search(c => c.K2SN == emailComment.K2SN).FirstOrDefault(); if (taskItem == null) { Log4netHelper.WriteErrorLog("不能获取当前的任务对象!"); return(Ok(false)); } var empInfo = Employee.GetSimpleEmployeeByCode(emailComment.OperatorID); ProjectComment projectComment = new ProjectComment(); projectComment.Id = Guid.NewGuid(); projectComment.UserAccount = projectComment.CreateUserAccount = emailComment.OperatorID; if (empInfo != null) { projectComment.UserNameENUS = empInfo.NameENUS; projectComment.UserNameZHCN = empInfo.NameZHCN; projectComment.CreateUserNameENUS = empInfo.NameENUS; projectComment.CreateUserNameZHCN = empInfo.NameZHCN; projectComment.TitleCode = empInfo.TitleCode; projectComment.TitleNameENUS = empInfo.TitleENUS; projectComment.TitleNameZHCN = empInfo.TitleZHCN; } var existProjectComment = ProjectComment.Search( o => o.ProcInstID == taskItem.ProcInstID).FirstOrDefault(); if (existProjectComment != null) { projectComment.RefTableId = existProjectComment.RefTableId; projectComment.RefTableName = existProjectComment.RefTableName; } projectComment.SourceCode = taskItem.SourceCode; projectComment.SourceNameENUS = taskItem.SourceNameENUS; projectComment.SourceNameZHCN = taskItem.SourceNameZHCN; projectComment.Action = emailComment.Action; projectComment.CreateTime = DateTime.Now; projectComment.Content = emailComment.EmailComments; projectComment.Status = ProjectCommentStatus.Submit; projectComment.ProcInstID = taskItem.ProcInstID; projectComment.ActivityName = activity; if (!string.IsNullOrEmpty(emailComment.EmailComments) && !emailComment.EmailComments.Equals(Constants.EmptyComments)) { projectComment.Content = emailComment.EmailComments.Trim(); } projectComment.Add(); //using (var db = new McdAMEntities()) //{ // db.ProjectComment.Add(projectComment); // db.SaveChanges(); //} } catch (Exception ex) { Log4netHelper.WriteErrorLog(string.Format("添加Email Comments错误:{0}; Stack trace:{1}", ex.Message, ex.StackTrace)); return(Ok(false)); } return(Ok(true)); }
/// <summary> /// 添加审批邮件的Comments /// </summary> /// <param name="comments"></param> /// <param name="refTableId"></param> /// <param name="procInstID"></param> /// <param name="projectId"></param> private void AddComments(WorkflowStepInfo comments, Guid refTableId, string refTableName, int?procInstID, string projectId, string flowCode, string templateCode) { //获取操作人信息 var user = Employee.GetSimpleEmployeeByCode(comments.OperatorID); ProjectComment projectcomment = new ProjectComment(); projectcomment.RefTableId = refTableId; projectcomment.RefTableName = refTableName; projectcomment.TitleNameENUS = user.PositionENUS; projectcomment.TitleNameZHCN = user.PositionZHCN; projectcomment.TitleCode = string.Empty; projectcomment.Status = ProjectCommentStatus.Submit; projectcomment.CreateTime = DateTime.Now; projectcomment.CreateUserAccount = user.Code; projectcomment.UserAccount = user.Code; projectcomment.UserNameENUS = user.NameENUS; projectcomment.UserNameZHCN = user.NameZHCN; projectcomment.CreateUserNameZHCN = user.NameZHCN; if (procInstID > 0) { projectcomment.ProcInstID = procInstID; } projectcomment.Id = Guid.NewGuid(); if (!string.IsNullOrEmpty(comments.Comments) && !comments.Comments.Equals(Constants.EmptyComments)) { projectcomment.Content = comments.Comments.Trim(); } projectcomment.Action = "Comments"; projectcomment.Status = ProjectCommentStatus.Submit; projectcomment.SourceCode = flowCode; projectcomment.SourceNameENUS = flowCode; projectcomment.SourceNameZHCN = flowCode; projectcomment.Add(); //using (var db = new McdAMEntities()) //{ // db.ProjectComment.Add(projectcomment); // db.SaveChanges(); //} //邮件通知邮件干系人 string emails = string.Empty; EmailServiceReference.EmailMessage emailMessage = new EmailServiceReference.EmailMessage(); var notificationModule = new Mcdonalds.AM.Services.Common.MailHelper.NotificationModule(); if (comments != null && !string.IsNullOrEmpty(comments.SN) && !string.IsNullOrEmpty(comments.OperatorID)) { emailMessage = MailHelper.BuildEmailMessage(comments.SN, ActionLogType.Comments, ref notificationModule); emails = MailHelper.GetWorkflowRelationUserEmails(projectId, comments.WorkflowName, notificationModule, true); } //获取邮件的提醒人 //var relationEmails = MailHelper.GetNotifyUserEmails(projectId, comments.WorkflowName, comments.OperatorID); //if (!string.IsNullOrEmpty(relationEmails)) //{ // emails += relationEmails; //} emailMessage.To = emails; emailMessage.TemplateCode = templateCode; MailHelper.SendCommentsEmail(emailMessage); }