コード例 #1
0
        public IHttpActionResult Create(TaskWork entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                if (entity.Id == new Guid())
                {
                    entity.Id         = Guid.NewGuid();
                    entity.CreateTime = DateTime.Now;
                    TaskWork.Add(entity);
                }
                else
                {
                    TaskWork.Update(entity);
                }
            }
            catch (DbUpdateException)
            {
                if (TaskWork.Any(e => e.Id == entity.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = entity.Id }, entity));
        }
コード例 #2
0
        public IHttpActionResult GetByProjectId(string projectID)
        {
            var entity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectID && e.IsHistory == false);

            if (entity == null)
            {
                entity           = new ClosureExecutiveSummary();
                entity.ProjectId = projectID;
                entity.IsHistory = false;
            }
            bool enableEdit   = false;
            bool enableRecall = false;

            var closureInfo = ClosureInfo.FirstOrDefault(e => e.ProjectId == projectID);
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectID && e.FlowCode == FlowCode.Closure_ExecutiveSummary);

            if (projectInfo != null)
            {
                if (ClientCookie.UserCode.Equals(closureInfo.AssetActorAccount))
                {
                    var isExistTask     = TaskWork.Any(e => e.RefID == projectID && e.TypeCode == FlowCode.Closure_ExecutiveSummary && e.Status == TaskWorkStatus.UnFinish && e.ReceiverAccount == ClientCookie.UserCode && e.ActivityName == "Originator");
                    var isPackgeStarted = ProjectInfo.IsFlowStarted(projectID, FlowCode.Closure_ClosurePackage);
                    var isESStarted     = ProjectInfo.IsFlowStarted(projectID, FlowCode.Closure_ExecutiveSummary);
                    enableEdit   = ProjectInfo.IsFlowEditable(projectID, FlowCode.Closure_ExecutiveSummary);
                    enableRecall = ProjectInfo.IsFlowRecallable(projectID, FlowCode.Closure_ExecutiveSummary);
                }
            }
            return(Ok(new
            {
                entity = entity,
                enableEdit = enableEdit,
                enableReCall = enableRecall
            }));
        }
コード例 #3
0
ファイル: BaseWFEntity.cs プロジェクト: XiaoYaTech/Demo
        public static bool IsFlowStarted(string projectId, string flowCode)
        {
            bool isStart = TaskWork.Any(e => e.RefID == projectId &&
                                        e.TypeCode == flowCode &&
                                        e.ActivityName != "Start" &&
                                        e.ActivityName != "Originator" &&
                                        e.Status == TaskWorkStatus.UnFinish);

            return(isStart);
        }
コード例 #4
0
        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)
                }));
            }
        }
コード例 #5
0
        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)
            }));
        }
コード例 #6
0
ファイル: BaseWFEntity.cs プロジェクト: XiaoYaTech/Demo
 public static bool FlowHaveTask(string projectId, string flowCode)
 {
     return(TaskWork.Any(e => e.RefID == projectId &&
                         e.TypeCode == flowCode));
 }
コード例 #7
0
 public IHttpActionResult IfUndo(string typeCode, string refId)
 {
     return(Ok(TaskWork.Any(t => t.TypeCode == typeCode && t.RefID == refId && t.Status == 0)));
 }
コード例 #8
0
ファイル: FlowInfoController.cs プロジェクト: XiaoYaTech/Demo
        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));
        }