private void SaveCommers(ClosureConsInvtChecking entity, string action, ProjectCommentStatus status) { if (status == ProjectCommentStatus.Save) { var list = ProjectComment.Search( c => c.CreateUserAccount == ClientCookie.UserCode && c.RefTableId == entity.Id && c.Action == action && c.RefTableName == ClosureConsInvtChecking.TableName && c.SourceCode == FlowCode.Closure).ToList(); if (list.Count > 0) { ProjectComment closureCommens = list[0]; closureCommens.Content = entity.Comments.Trim(); ProjectComment.Update(closureCommens); } else { AddProjectComment(entity, action, status); } } else { AddProjectComment(entity, action, status); } }
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)); }