public IHttpActionResult IsTempClosed(string projectId) { var result = false; var projectInfo = ProjectInfo.Get(projectId, FlowCode.TempClosure); if (projectInfo != null) { if (projectInfo.Status == ProjectStatus.Completed) { result = true; } else if (projectInfo.Status == ProjectStatus.UnFinish) { var closureMemo = TempClosureMemo.FirstOrDefault(i => i.ProjectId == projectId); if (closureMemo == null) { result = false; } else { var tempClosure = TempClosureInfo.Get(projectId); if (tempClosure != null && tempClosure.ActualTempClosureDate.Date <= DateTime.Now.Date) { result = true; } } } } return(Ok(new { result = result, isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor) })); }
public IHttpActionResult GetLegalReview(string projectId, Guid?Id = null) { var tempClosure = TempClosureInfo.FirstOrDefault(tc => tc.ProjectId == projectId); var project = ProjectInfo.Get(projectId, FlowCode.TempClosure_LegalReview); var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); TempClosureLegalReview entity; if (Id != null) { entity = TempClosureLegalReview.Get(Id.Value); } else { entity = TempClosureLegalReview.Get(projectId); } entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId("TempClosurePackage", projectId)); var nextFlowStarted = ProjectInfo.Any(p => p.FlowCode == FlowCode.TempClosure_ClosurePackage && p.ProjectId == projectId && p.NodeCode != NodeCode.Start); //var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.TempClosure_LegalReview && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(entity.Id, "TempClosureLegalReview", ClientCookie.UserCode); var isLegalStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.TempClosure_LegalReview); return(Ok(new { Info = tempClosure, LegalReview = entity, ProjectComment = projectComment != null ? projectComment.Content : "", Editable = project.Status == ProjectStatus.Finished && isActor && !nextFlowStarted && !entity.IsHistory, Recallable = project.Status != ProjectStatus.Finished && isActor && !entity.IsHistory && isLegalStarted, Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_LegalReview) })); }
public IHttpActionResult Get(string projectId) { TempClosureMemo entity = null; if (projectId.ToLower().IndexOf("rebuild") != -1 || projectId.ToLower().IndexOf("reimage") != -1) { entity = TempClosureMemo.GetTempClosureMemo(projectId); } else if (projectId.ToLower().IndexOf("majorlease") != -1) { entity = TempClosureMemo.GetAttachClosureMemo(projectId, FlowCode.MajorLease); } else if (projectId.ToLower().IndexOf("renewal") != -1) { entity = TempClosureMemo.GetAttachClosureMemo(projectId, FlowCode.Renewal); } //else if (projectId.ToLower().IndexOf("reimage") != -1) //{ // entity = TempClosureMemo.GetAttachClosureMemo(projectId, FlowCode.Reimage); //} else { entity = TempClosureMemo.Get(projectId); } var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); return(Ok(new { Entity = entity, IsActor = isActor })); }
public IHttpActionResult InitReimageSummary(string projectId, string entityId = "") { var entity = ReimageSummary.GetReimageSummaryInfo(projectId, entityId); return(Ok(new { entity = entity, isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor) })); }
public IHttpActionResult Get(string projectId) { var tempClosureInfo = TempClosureInfo.Get(projectId); return(Ok(new { Entity = TempClosureReopenMemo.Get(projectId), TempClosureDate = tempClosureInfo.ActualTempClosureDate, IsActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor) })); }
public IHttpActionResult GetMaterTrackReps(string workflowId, Guid nodeId) { var tracks = MaterTrack.Search(m => m.WorkflowId == workflowId && m.NodeId == nodeId).ToList(); var reps = tracks.Where(t => t.TrackType == MaterTrackType.Rep).OrderBy(t => t.CreateTime).Select(t => { var rep = new MaterTrackRep(); rep.Id = t.Id; rep.Content = t.Content; rep.CreateTime = t.CreateTime; rep.Creator = t.Creator; rep.CreatorZHCN = t.CreatorZHCN; rep.CreatorENUS = t.CreatorENUS; rep.TrackType = (MaterTrackType)t.TrackType; if (tracks.Count(t2 => t2.TrackType == MaterTrackType.Rep && t2.CreateTime > t.CreateTime) > 0) { rep.IsFinish = true; } else { if (TaskWork.Count(t2 => t2.RefID == workflowId && t2.Status == TaskWorkStatus.UnFinish && t2.ActivityName.Contains("Start_MaterTrack")) > 0) { rep.IsFinish = false; } else { rep.IsFinish = true; } } rep.Replies = tracks.Where(f => f.ParentId == t.Id).OrderBy(f => f.CreateTime).Select(f => { var reply = new MaterTrackReply(); reply.Id = f.Id; reply.Content = f.Content; reply.CreateTime = f.CreateTime; reply.Creator = f.Creator; reply.CreatorZHCN = f.CreatorZHCN; reply.CreatorENUS = f.CreatorENUS; reply.TrackType = (MaterTrackType)f.TrackType; return(reply); }).ToList(); return(rep); }).ToList(); return(Ok(new { Reps = reps, IsLegal = ProjectUsers.IsRole(workflowId, ClientCookie.UserCode, ProjectUserRoleCode.Legal), IsAssetActor = ProjectUsers.IsRole(workflowId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor) })); }
public IHttpActionResult Get(string projectId, Guid?Id = null) { var project = ProjectInfo.Get(projectId, FlowCode.TempClosure_ClosurePackage); var tempClosure = TempClosureInfo.FirstOrDefault(tc => tc.ProjectId == projectId); var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); TempClosurePackage entity; if (Id != null) { entity = TempClosurePackage.Get(Id.Value); } else { entity = TempClosurePackage.Get(projectId); } if (entity != null) { entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId); var SavedComment = ProjectComment.GetSavedComment(entity.Id, "TempClosurePackage", ClientCookie.UserCode); var hasValidTask = TaskWork.Any(t => t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount != ClientCookie.UserCode); return(Ok(new { Info = tempClosure, ClosurePackage = entity, Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage), ProjectComment = SavedComment != null ? SavedComment.Content : "", Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.TempClosure_ClosurePackage), Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.TempClosure_ClosurePackage), Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode), Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage) })); } else { entity = TempClosurePackage.Create(projectId); return(Ok(new { Info = tempClosure, ClosurePackage = entity, Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage), ProjectComment = "", Editable = (project.Status == ProjectStatus.Finished || project.Status == ProjectStatus.Rejected) && isActor && !entity.IsHistory, Recallable = project.Status == ProjectStatus.UnFinish && isActor && project.NodeCode != NodeCode.Start, Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode), Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage) })); } }
public IHttpActionResult Get(string projectId) { var entity = ClosureMemo.Get(projectId); bool editable = false; var storeStatus = StoreBasicInfo.Search(s => s.StoreCode == entity.USCode).Select(s => s.statusName).FirstOrDefault(); if (storeStatus == "Closed") { editable = false; } else { if (TaskWork.Count(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_Memo && e.RefID == projectId) > 0) { if (entity.Id == Guid.Empty) { editable = true; } else { if (entity.ClosureDate.Value < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00") && entity.ClosureNature == ClosureNatureType.Permanent) { editable = false; } else { editable = true; } } } else { editable = true; } } var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); return(Ok(new { Entity = entity, Editable = editable, IsActor = isActor })); }
public IHttpActionResult InitPage(string projectId, string id = null) { var letter = RenewalLetter.Get(projectId, id); var project = ProjectInfo.Get(projectId, FlowCode.Renewal_Letter); var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); letter.IsProjectFreezed = letter.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId("RenewalConsInfo", projectId)); var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_ConsInfo); var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Letter && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(letter.Id, "RenewalLetter", ClientCookie.UserCode); var isStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Letter); var isFinished = ProjectInfo.IsFlowFinished(projectId, FlowCode.Renewal_Letter); return(Ok(new { Info = RenewalInfo.FirstOrDefault(info => info.ProjectId == letter.ProjectId), Letter = letter, ProjectComment = projectComment != null ? projectComment.Content : "", Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Letter), Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Letter), Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Letter) && string.IsNullOrEmpty(id) })); }
public IHttpActionResult GetNodes(string projectId, string flowCode) { var tasks = TaskWork.Search(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == 0).ToList(); var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor); var projects = ProjectInfo.Search(p => p.ProjectId == projectId); var flows = FlowInfo.Search(f => f.ParentCode == flowCode).OrderBy(f => f.LayoutSequence).ToList(); var editApproverableCodes = new string[] { FlowCode.Closure_ClosurePackage, FlowCode.TempClosure_ClosurePackage, FlowCode.MajorLease_Package, FlowCode.Reimage_Package, FlowCode.Rebuild_Package, FlowCode.Renewal_Package }; var navs = flows.Select(f => { var task = tasks.FirstOrDefault(t => t.TypeCode == f.Code); var project = projects.FirstOrDefault(p => p.FlowCode == f.Code); var node = NodeInfo.FirstOrDefault(n => n.Code == project.NodeCode); var nextFlow = flows.FirstOrDefault(nf => nf.ExecuteSequence == f.ExecuteSequence + 1); var isOriginator = ProjectInfo.IsOriginator(projectId, f.Code, ClientCookie.UserCode); var canEdit = project.Status == ProjectStatus.Finished || project.Status == ProjectStatus.Rejected; var flowStarted = node.Code != NodeCode.Start; var lastStartTask = TaskWork.Search(t => t.RefID == projectId && t.TypeCode == f.Code && (t.ActivityName == "Start" || t.ActivityName == "Originator")).OrderByDescending(t => t.CreateTime).FirstOrDefault(); var nextFlowStarted = nextFlow != null && projects.Any(p => p.FlowCode == nextFlow.Code && p.NodeCode != NodeCode.Start); var nav = new TopNavigator(); nav.Code = f.Code; nav.ParentCode = f.ParentCode; nav.NameENUS = f.NameENUS; nav.NameZHCN = f.NameZHCN; nav.ExecuteSequence = f.ExecuteSequence; nav.Percentage = f.Percentage; nav.IsFinished = project.Status == ProjectStatus.Finished; nav.Status = project.Status; nav.IsRejected = project.Status == ProjectStatus.Rejected; nav.ProgressRate = node.ProgressRate; if (task != null) { if (task.Url.IndexOf(task.RefID, StringComparison.OrdinalIgnoreCase) < 0) { if (task.Url.IndexOf("?") >= 0) { task.Url += "&"; } else { task.Url += "?"; } task.Url += "projectId=" + task.RefID; } nav.Url = task.Url; } else if (f.NoTaskEditable && isActor) { nav.Url = string.Format("/{0}/Main#/{1}?projectId={2}", flowCode, f.Code.Split('_')[1], projectId); } else { var tmpCode = f.Code.Split('_')[1]; if (flowCode == "Rebuild" && tmpCode == "Package") { tmpCode = "RebuildPackage"; } nav.Url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, tmpCode, projectId); } if (projectId.ToLower().IndexOf("renewal") != -1) { nav.Editable = f.Editable && canEdit && !nextFlowStarted && ProjectInfo.IsFlowEditable(projectId, f.Code); } else { nav.Editable = f.Editable && canEdit && ProjectInfo.IsFlowEditable(projectId, f.Code); } nav.Recallable = f.Recallable && !canEdit && isOriginator && ((lastStartTask == null && TaskWork.Any(t => t.RefID == projectId && t.TypeCode == f.Code && t.ActivityName != "Start")) || (lastStartTask != null && TaskWork.Any(t => t.CreateTime >= lastStartTask.CreateTime && t.RefID == projectId && t.TypeCode == f.Code && t.ActivityName != "Start"))) && project.NodeCode != NodeCode.Start; nav.EditApproverable = !canEdit && isOriginator && editApproverableCodes.Contains(nav.Code) && ((lastStartTask == null && TaskWork.Any(t => t.RefID == projectId && t.TypeCode == f.Code && (t.ActivityName != "Start" && t.ActivityName != "Originator"))) || (lastStartTask != null && TaskWork.Any(t => t.CreateTime >= lastStartTask.CreateTime && t.RefID == projectId && t.TypeCode == f.Code && (t.ActivityName != "Start" && t.ActivityName != "Originator")))); return(nav); }).ToList(); return(Ok(navs)); }