public void SetProductSignUser() { IUserService service = FormulaHelper.GetService <IUserService>(); var auditStateArray = Enum.GetNames(typeof(Project.Logic.AuditState)); var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var allProducts = projectEntities.Set <S_E_Product>().Where(a => a.ProjectInfoID == this.Project).ToList(); foreach (var p in this.T_EXE_PublishApply_Products) { if (p.CanSetUser == 1) { var pdic = p.ToDic(); var product = allProducts.FirstOrDefault(a => a.ID == p.ProductID); if (product != null) { List <AuditUserInfo> list = new List <AuditUserInfo>(); foreach (var item in auditStateArray) { var value = pdic.GetValue(item); if (!string.IsNullOrEmpty(value)) { var users = value.Split(','); foreach (var user in users) { var u = service.GetUserInfoByID(user); if (u != null) { AuditUserInfo userInfo = new AuditUserInfo(item, user, u.UserName); userInfo.SignDate = DateTime.Now; list.Add(userInfo); } } } } var designers = list.Where(a => a.ActivityKey == AuditState.Design.ToString() || a.ActivityKey == AuditState.Designer.ToString()); var collactors = list.Where(a => a.ActivityKey == AuditState.Collact.ToString() || a.ActivityKey == AuditState.Collactor.ToString()); var auditors = list.Where(a => a.ActivityKey == AuditState.Audit.ToString() || a.ActivityKey == AuditState.Auditor.ToString()); var approvers = list.Where(a => a.ActivityKey == AuditState.Approve.ToString() || a.ActivityKey == AuditState.Approver.ToString()); product.AuditSignUser = JsonHelper.ToJson(list); product.Designer = string.Join(",", designers.Select(a => a.UserID)); product.DesignerName = string.Join(",", designers.Select(a => a.UserName)); product.Collactor = string.Join(",", collactors.Select(a => a.UserID)); product.CollactorName = string.Join(",", collactors.Select(a => a.UserName)); product.Auditor = string.Join(",", auditors.Select(a => a.UserID)); product.AuditorName = string.Join(",", auditors.Select(a => a.UserName)); product.Approver = string.Join(",", approvers.Select(a => a.UserID)); product.ApproverName = string.Join(",", approvers.Select(a => a.UserName)); product.UpdateVersison(); } } } }
public List <AuditUserInfo> GetAuditSignUser() { var entities = this.GetDbContext <ProjectEntities>(); IUserService service = FormulaHelper.GetService <IUserService>(); var auditStateArray = Enum.GetNames(typeof(Project.Logic.AuditState)); var activityList = entities.S_W_Activity.Where(d => d.BusniessID == this.ID).ToList(); List <AuditUserInfo> list = new List <AuditUserInfo>(); var dic = this.ToDic(); foreach (var item in auditStateArray) { if (this.AuditSignSource == "0")//从表单上取 { var value = dic.GetValue(item); if (!string.IsNullOrEmpty(value)) { var users = value.Split(','); foreach (var user in users) { var u = service.GetUserInfoByID(user); if (u != null) { AuditUserInfo userInfo = new AuditUserInfo(item, user, u.UserName); userInfo.SignDate = DateTime.Now; list.Add(userInfo); } } } } else//从流程中取 { //项目负责人需要按照策划的顺序进行签名 if (item == "ProjectManager" && !string.IsNullOrEmpty(this.ProjectManager)) { var pms = this.ProjectManager.Split(','); foreach (var pmID in pms) { var activity = activityList.FirstOrDefault(a => a.ActivityKey == item && a.OwnerUserID == pmID); if (activity != null) { AuditUserInfo userInfo = new AuditUserInfo(item, activity.OwnerUserID, activity.OwnerUserName); userInfo.SignDate = activityList.Where(d => d.ActivityKey == item).Max(d => d.CreateDate); list.Add(userInfo); } } } else { foreach (var activity in activityList.Where(d => d.ActivityKey == item).ToList()) { if (list.Any(a => a.ActivityKey == item && a.UserID == activity.OwnerUserID)) { continue; } AuditUserInfo userInfo = new AuditUserInfo(item, activity.OwnerUserID, activity.OwnerUserName); userInfo.SignDate = activityList.Where(d => d.ActivityKey == item).Max(d => d.CreateDate); list.Add(userInfo); } } } } return(list); }