示例#1
0
        public ActionResult BulkOperation(string strCommentIds, CommentBulkOperationType type)
        {
            var commentIds = strCommentIds.Split(',').Select(e => { return(Convert.ToInt32(e)); }).ToArray();

            if (commentIds.Count() == 0)
            {
                return(Json(new { result = false, errmsg = "未选择意见" }));
            }

            var first   = commentIds[0];
            var comment = new CommentService().Get(e => e.Id == first);

            if (comment == null)
            {
                throw new ArgumentNullException(nameof(comment));
            }

            var    result = true;
            string errmsg = "";

            var designCompanyProjectManager = new DesignCompanyProjectManager(CurrentCustomer, comment.EngineeringFile, comment.EngineeringFile.FileVersions.OrderByDescending(e => e.Id).FirstOrDefault());
            var professionalAudit           = new ProfessionalAudit(CurrentCustomer, comment.EngineeringFile, comment.EngineeringFile.FileVersions.OrderByDescending(e => e.Id).FirstOrDefault(), comment.ProfessionId);
            var professionalReAudit         = new ProfessionalReAudit(CurrentCustomer, comment.EngineeringFile, comment.EngineeringFile.FileVersions.OrderByDescending(e => e.Id).FirstOrDefault(), comment.ProfessionId);

            if (type == CommentBulkOperationType.DesignManagerRepaired)
            {
                if (!new PermissionService().CanManagerProject(CurrentCustomer, comment.EngineeringFile.Engineering.Project))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.DesignCompanyManager;

                foreach (var id in commentIds)
                {
                    var dic = new Dictionary <int, bool>();
                    dic.Add(id, true);
                    if (!designCompanyProjectManager.CommentsRepair(dic, "", type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }
            else if (type == CommentBulkOperationType.DesignManagerUnrepaired)
            {
                if (!new PermissionService().CanManagerProject(CurrentCustomer, comment.EngineeringFile.Engineering.Project))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.DesignCompanyManager;

                foreach (var id in commentIds)
                {
                    var dic = new Dictionary <int, bool>();
                    dic.Add(id, false);
                    if (!designCompanyProjectManager.CommentsRepair(dic, "", type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }
            else if (type == CommentBulkOperationType.CheckerAgreeRepaired)
            {
                if (!new PermissionService().CanCheckProject(CurrentCustomer, comment.EngineeringFile.Engineering, comment.ProfessionId))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.Checker;

                foreach (var id in commentIds)
                {
                    if (!professionalAudit.AgreeRepari(id, string.Empty, type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }
            else if (type == CommentBulkOperationType.ChecherDisagreeRepaired)
            {
                if (!new PermissionService().CanCheckProject(CurrentCustomer, comment.EngineeringFile.Engineering, comment.ProfessionId))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.Checker;

                foreach (var id in commentIds)
                {
                    if (!professionalAudit.DisagreeRepari(id, string.Empty, type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }
            else if (type == CommentBulkOperationType.ReviewerAgreeRepaired)
            {
                if (!new PermissionService().CanReviewProject(CurrentCustomer, comment.EngineeringFile.Engineering, comment.ProfessionId))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.Reviewer;

                foreach (var id in commentIds)
                {
                    if (!professionalReAudit.AgreeRepair(id, string.Empty, type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }
            else if (type == CommentBulkOperationType.ReviewerDisagreeRepaired)
            {
                if (!new PermissionService().CanReviewProject(CurrentCustomer, comment.EngineeringFile.Engineering, comment.ProfessionId))
                {
                    return(NoAuthorityJson());
                }
                CurrentCustomer.CurrentRole = Role.Reviewer;

                foreach (var id in commentIds)
                {
                    if (!professionalReAudit.DisagreeRepair(id, string.Empty, type.GetDescription()))
                    {
                        result = false;
                        errmsg = SetBulkOperationErrsmg(errmsg, id);
                    }
                }
            }

            return(Json(new { result = result, errmsg = errmsg }));
        }
示例#2
0
        public ActionResult ReAduitOperateComment(int commentId, ReAduitCommentOperationType operationType, string reason = "")
        {
            var comment = new CommentService().Get(e => e.Id == commentId);

            if (comment == null)
            {
                throw new ArgumentNullException(nameof(comment));
            }

            if (!new PermissionService().CanReviewProject(CurrentCustomer, comment.EngineeringFile.Engineering, comment.ProfessionId))
            {
                return(NoAuthorityJson());
            }

            var professionalReAudit = new ProfessionalReAudit(CurrentCustomer, comment.EngineeringFile, comment.EngineeringFile.FileVersions.OrderByDescending(e => e.Id).FirstOrDefault(), comment.ProfessionId);

            CurrentCustomer.CurrentRole = Role.Reviewer;

            var result = false;

            //完整性检查阶段
            //TODO 输出的文字提示待更新
            if (operationType == ReAduitCommentOperationType.Pre_AgreeComment)
            {
                result = true;
                professionalReAudit.ReauditApproveProfessionalComment(comment, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.Pre_DisAgreeComment)
            {
                result = true;
                professionalReAudit.ReauditRejectProfessionalComment(comment, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.Pre_Back)
            {
                result = professionalReAudit.UndoComment(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.Pre_ReauditDeleteComment)
            {
                result = professionalReAudit.DeleteComment(commentId, string.Empty, operationType.GetDescription(),
                                                           FlowCode.Pre_AuditCompany_ProfessionReaudit_Delete_Comment);
            }
            //设计审查阶段
            else if (operationType == ReAduitCommentOperationType.PassComment)
            {
                result = professionalReAudit.Agree(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.ReturnComment)
            {
                result = professionalReAudit.Disagree(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.DeleteComment)
            {
                result = professionalReAudit.DeleteComment(commentId, string.Empty, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.CancelDelete)
            {
                result = professionalReAudit.UndoComment(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.AgreeDesignReject)
            {
                result = professionalReAudit.AgreeDesignCompanyNoRepairComment(commentId, string.Empty, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.DisagreeDesignReject)
            {
                result = professionalReAudit.DisagreeDesignCompanyNoRepairComment(commentId, "", operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.AgreeRepaired)
            {
                result = professionalReAudit.AgreeRepair(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.DisagreeRepaired)
            {
                result = professionalReAudit.DisagreeRepair(commentId, reason, operationType.GetDescription());
            }
            else if (operationType == ReAduitCommentOperationType.Back)
            {
                result = professionalReAudit.UndoComment(commentId, reason, operationType.GetDescription());
            }

            return(Json(new { result = result, errmsg = "" }));
        }