示例#1
0
        public IHttpActionResult Get(string sourceCode, string refId)
        {
            var task = TaskWork.Search(c => c.SourceCode == sourceCode && c.RefID == refId).FirstOrDefault();

            if (task == null)
            {
                return(NotFound());
            }
            return(Ok(task));
        }
示例#2
0
        public void CompleteNotifyTask(string projectId)
        {
            var task = TaskWork.Search(e => e.RefID == projectId &&
                                       e.Status == TaskWorkStatus.UnFinish &&
                                       (e.TypeCode == WorkflowCode) && e.ActivityName == "Notify").FirstOrDefault();

            if (task != null)
            {
                task.Status = TaskWorkStatus.Finished;
                //string strTypeCode = task.TypeCode.Split('_')[1];
                //task.Url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", task.TypeCode.Split('_')[0], strTypeCode, projectId);
                TaskWork.Update(task);
            }
        }
示例#3
0
        public List <TaskWork> ChangeWorkflowApprovers(string projectId, ApproveUsers approver)
        {
            var workflowTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                e.Status == TaskWorkStatus.UnFinish &&
                                                e.K2SN != null).ToList();
            var approveDiallogUsers = ApproveDialogUser.Search(e => e.ProjectId == projectId).ToList();

            ChangeWorkflowApprovers(workflowTasks, approveDiallogUsers, approver);

            ApproveDialogUser.Update(approveDiallogUsers.ToArray());
            TaskWork.Update(workflowTasks.ToArray());

            return(workflowTasks);
        }
示例#4
0
        public void GetMyTaskWorkTest()
        {
            //var taskWork = new TaskWork();
            //var result = taskWork.GetMyTaskWork();
            //Assert.IsFalse(result.Any(e => e.RefID == "MajorLease14090202"));
            //var projectInfoRepos = new BaseEntity<ProjectInfo>();
            //var flowCodeList = new List<string>()
            //{
            //    FlowCode.MajorLease_ConsInfo,
            //    FlowCode.MajorLease_FinanceAnalysis,
            //    FlowCode.MajorLease_LegalReview
            //};

            var task = TaskWork.Search(c => c.ProcInstID == 2736).OrderByDescending(o => o.Num).FirstOrDefault();


            // 更新Task 状态
            task.Status = ConvertHelper.ToEnumType <TaskWorkStatus>(100);
            int _result = TaskWork.Update(task);
        }
示例#5
0
        public void ChangeProjectStatus(ProjectDto project)
        {
            using (var scope = new TransactionScope())
            {
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == project.ProjectId &&
                                                             e.FlowCode == project.FlowCode);

                if (projectInfo != null)
                {
                    projectInfo.Status = project.CurrStatus;
                    projectInfo.Update();


                    var tasks = TaskWork.Search(e => e.RefID == project.ProjectId &&
                                                e.Status == TaskWorkStatus.UnFinish &&
                                                e.ActivityName == NodeCode.Start).ToList();

                    tasks.ForEach(e =>
                    {
                        e.ActionName = SetTaskActionName(project.CurrStatus);
                    });

                    TaskWork.Update(tasks.ToArray());

                    var log = new ProjectStatusChangeLog
                    {
                        ProjectId  = project.ProjectId,
                        PrevStatus = project.PrevStatus,
                        CurrStatus = project.CurrStatus,
                        FlowCode   = project.FlowCode,
                        Comment    = project.Comment,
                        CreateBy   = ClientCookie.UserCode,
                        CreateTime = DateTime.Now
                    };

                    log.Add();
                }

                scope.Complete();
            }
        }
        public IHttpActionResult GetMemo(string flowCode, string projectId)
        {
            var memoList = AttachmentsMemo.GetAttachmentsMemoList(flowCode);

            if (memoList == null || memoList.Count == 0)
            {
                return(Ok());
            }
            var navs = memoList.Select(e =>
            {
                string url        = "";
                DateTime?date     = null;
                ProjectUsers user = null;
                switch (e.MemoCode)
                {
                case "GBMemo":
                    user         = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.PM);
                    var gbEntity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.GBMemo);
                    if (gbEntity != null)
                    {
                        date = gbEntity.NotifyDate;
                    }
                    break;

                case "ClosureMemo":
                    user          = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.AssetActor);
                    var tmpEntity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.ClosureMemo);
                    if (tmpEntity != null)
                    {
                        date = tmpEntity.NotifyDate;
                    }
                    break;

                case "ReopenMemo":
                    user       = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.AssetActor);
                    var entity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.ReopenMemo);
                    date       = entity.NotifyDate;
                    break;
                }
                if (e.MemoCode == "GBMemo")
                {
                    var flowcode = e.FlowCode + "_" + e.MemoCode;
                    var task     = TaskWork.Search(t => t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == flowcode).FirstOrDefault();
                    if (task != null)
                    {
                        if ((task.Url.IndexOf("Approval", StringComparison.OrdinalIgnoreCase) != -1 ||
                             task.Url.IndexOf("Resubmit", StringComparison.OrdinalIgnoreCase) != -1 ||
                             task.Url.IndexOf("Notify", StringComparison.OrdinalIgnoreCase) != -1 ||
                             task.Url.IndexOf("View", StringComparison.OrdinalIgnoreCase) == -1) &&
                            task.ReceiverAccount == ClientCookie.UserCode)
                        {
                            if (task.Url.IndexOf(task.RefID, StringComparison.OrdinalIgnoreCase) < 0)
                            {
                                if (task.Url.IndexOf("?") >= 0)
                                {
                                    task.Url += "&";
                                }
                                else
                                {
                                    task.Url += "?";
                                }
                                task.Url += "projectId=" + task.RefID;
                            }
                            url = task.Url;
                        }
                        else
                        {
                            url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId);
                        }
                    }
                    else
                    {
                        if (user.UserAccount == ClientCookie.UserCode && date == null)
                        {
                            url = string.Format("/{0}/Main#/{1}?projectId={2}", flowCode, e.MemoCode, projectId);
                        }
                        else
                        {
                            url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId);
                        }
                    }
                }
                else
                {
                    if (user.UserAccount == ClientCookie.UserCode)
                    {
                        url = string.Format("/{0}/Main#/{1}?projectId={2}", flowCode, e.MemoCode, projectId);
                    }
                    else
                    {
                        url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId);
                    }
                }


                return(new
                {
                    NotifyDate = date,
                    Name = e.MemoNameENUS,
                    Url = url
                });
            }).ToList();

            return(Ok(navs));
        }
示例#7
0
        public void ChangeProjectTeamMembers(string projectId, ProjectTeamMembers projectTeamMembers)
        {
            using (var scope = new TransactionScope())
            {
                #region update ProjectUsers
                var projectUsers = ProjectUsers.Search(e => e.ProjectId == projectId).AsNoTracking().ToList();
                foreach (var projectUser in projectUsers)
                {
                    switch (projectUser.RoleCode)
                    {
                    case ProjectUserRoleCode.AssetActor:
                        if (projectTeamMembers.AssetActor != null)
                        {
                            projectUser.UserAccount  = projectTeamMembers.AssetActor.UserAccount;
                            projectUser.UserNameENUS = projectTeamMembers.AssetActor.UserNameENUS;
                            projectUser.UserNameZHCN = projectTeamMembers.AssetActor.UserNameZHCN;
                        }
                        break;

                    case ProjectUserRoleCode.Finance:
                    case "Finance Team":
                        projectUser.UserAccount  = projectTeamMembers.Finance.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.Finance.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.Finance.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.Legal:
                        if (projectTeamMembers.Legal != null)
                        {
                            projectUser.UserAccount  = projectTeamMembers.Legal.UserAccount;
                            projectUser.UserNameENUS = projectTeamMembers.Legal.UserNameENUS;
                            projectUser.UserNameZHCN = projectTeamMembers.Legal.UserNameZHCN;
                        }
                        break;

                    case ProjectUserRoleCode.PM:
                        projectUser.UserAccount  = projectTeamMembers.PM.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.PM.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.PM.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.AssetRep:
                        projectUser.UserAccount  = projectTeamMembers.AssetRep.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.AssetRep.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.AssetRep.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.AssetManager:
                        projectUser.UserAccount  = projectTeamMembers.AssetMgr.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.AssetMgr.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.AssetMgr.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.CM:
                        projectUser.UserAccount  = projectTeamMembers.CM.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.CM.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.CM.UserNameZHCN;
                        break;
                    }
                }

                ProjectUsers.Update(projectUsers.ToArray());


                #endregion

                #region update project tasks
                var projectTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                   e.Status == TaskWorkStatus.UnFinish &&
                                                   e.ActivityName == "Start").AsNoTracking().ToList();

                foreach (var projectTask in projectTasks)
                {
                    UpdateProjectTaskUser(projectTask, projectTeamMembers);
                }

                UpdateProjectCreateUser(projectTeamMembers);

                TaskWork.Update(projectTasks.ToArray());
                #endregion

                #region update workflow tasks
                var workflowTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                    e.Status == TaskWorkStatus.UnFinish &&
                                                    e.K2SN != null).ToList();

                ChangeProjectApprover(workflowTasks, projectTeamMembers);
                #endregion
                TaskWork.Update(workflowTasks.ToArray());

                scope.Complete();
            }
        }
        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));
        }
示例#9
0
        public IHttpActionResult GetFinishedTasks(string sourceCode, string refID)
        {
            var list = TaskWork.Search(c => c.Status == TaskWorkStatus.Finished && c.SourceCode == sourceCode && c.RefID == refID);

            return(Ok(list));
        }
示例#10
0
        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));
        }
示例#11
0
        public IHttpActionResult TopNav(string projectId, string flowCode, string subCode)
        {
            var tasks    = TaskWork.Search(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == 0).ToList();
            var projects = ProjectInfo.Search(p => p.ProjectId == projectId);
            var navs     = FlowInfo.Search(f => f.ParentCode == flowCode).OrderBy(f => f.LayoutSequence).ToList().Select(f =>
            {
                var task    = tasks.FirstOrDefault(t => t.TypeCode == f.Code);
                var project = projects.FirstOrDefault(p => p.FlowCode == f.Code) ?? new ProjectInfo();
                var nav     = new TopNavigator();
                if (f.Code == subCode)
                {
                    nav.IsSelected = true;
                }
                else
                {
                    nav.IsSelected = false;
                }
                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;
                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 && project.CreateUserAccount == ClientCookie.UserCode)
                {
                    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);
                }
                return(nav);
            }).ToList();

            navs.Insert(0, new TopNavigator
            {
                NameENUS   = "Project Detail",
                NameZHCN   = "Project Detail",
                Code       = "Detail",
                Url        = "/Home/Main#/project/detail/" + projectId + "?flowCode=" + flowCode,
                IsSelected = subCode == "Detail"
            });
            return(Ok(navs));
        }