Beispiel #1
0
 public ActionResult ApprovalContent(ApprovalTask _param)
 {
     ViewBag.ApprvalData = ApprovalRepository.SelApproval(new Approval {
         OID = _param.ApprovalOID
     });
     return(PartialView("Dialog/dlgApprovalContent"));
 }
Beispiel #2
0
        public JsonResult SelApprovalHistory(DObject _param)
        {
            List <ApprovalTask> displayTask = new List <ApprovalTask>();
            Approval            approval    = ApprovalRepository.SelApproval(new Approval {
                TargetOID = _param.OID
            });

            if (approval != null)
            {
                approval.InboxStep.ForEach(step =>
                {
                    step.InboxTask.ForEach(task =>
                    {
                        task.Ord        = step.Ord;
                        task.CurrentNum = approval.CurrentNum;
                        displayTask.Add(task);
                    });
                });
            }
            return(Json(displayTask));
        }
Beispiel #3
0
        public JsonResult PromoteApprovalTask(ApprovalTask _param)
        {
            try
            {
                DaoFactory.BeginTransaction();
                DObjectRepository.StatusPromote(false, CommonConstant.TYPE_APPROVAL_TASK, Convert.ToString(_param.BPolicyOID), Convert.ToInt32(_param.OID), Convert.ToInt32(_param.OID), _param.ActionType, "");
                ApprovalTaskRepository.UdtInboxTask(new ApprovalTask {
                    ActionType = _param.ActionType, Comment = _param.Comment, OID = _param.OID
                });

                if (_param.ActionType == CommonConstant.ACTION_REJECT)
                {
                    Approval tmpApproval = ApprovalRepository.SelApprovalNonStep(new Approval {
                        OID = _param.ApprovalOID
                    });
                    DObjectRepository.StatusPromote(false, CommonConstant.TYPE_APPROVAL, Convert.ToString(tmpApproval.BPolicyOID), Convert.ToInt32(tmpApproval.OID), Convert.ToInt32(tmpApproval.OID), _param.ActionType, "");

                    DObject targetDobj = DObjectRepository.SelDObject(new DObject {
                        OID = tmpApproval.TargetOID
                    });
                    DObjectRepository.StatusPromote(false, targetDobj.Type, Convert.ToString(targetDobj.BPolicyOID), Convert.ToInt32(targetDobj.OID), Convert.ToInt32(targetDobj.OID), _param.ActionType, "");
                    DaoFactory.Commit();
                    return(Json(CommonConstant.RETURN_SUCCESS));
                }

                bool         allSuccess      = true;
                ApprovalStep tmpApprovalStep = ApprovalStepRepository.SelApprovalStep(new ApprovalStep {
                    OID = _param.StepOID
                });
                tmpApprovalStep.InboxTask.ForEach(task =>
                {
                    if (task.BPolicy.Name != CommonConstant.POLICY_APPROVAL_COMPLETED)
                    {
                        allSuccess = false;
                    }
                });

                if (allSuccess)
                {
                    Approval tmpApproval = ApprovalRepository.SelApprovalNonStep(new Approval {
                        OID = _param.ApprovalOID
                    });
                    int cntCurrent = Convert.ToInt32(tmpApproval.CurrentNum);
                    cntCurrent += 1;
                    if (tmpApproval.ApprovalCount >= cntCurrent)
                    {
                        ApprovalRepository.UdtApproval(new Approval {
                            CurrentNum = cntCurrent, OID = tmpApproval.OID
                        });
                        ApprovalRepository.SelApproval(new Approval {
                            OID = tmpApproval.OID
                        }).InboxStep.Find(step => step.Ord == cntCurrent).InboxTask.ForEach(task =>
                        {
                            DObjectRepository.StatusPromote(false, CommonConstant.TYPE_APPROVAL_TASK, Convert.ToString(task.BPolicyOID), Convert.ToInt32(task.OID), Convert.ToInt32(task.OID), _param.ActionType, "");
                        });
                    }
                    else if (tmpApproval.ApprovalCount < cntCurrent)
                    {
                        ApprovalRepository.UdtApproval(new Approval {
                            CurrentNum = cntCurrent, OID = tmpApproval.OID
                        });
                        DObjectRepository.StatusPromote(false, CommonConstant.TYPE_APPROVAL, Convert.ToString(tmpApproval.BPolicyOID), Convert.ToInt32(tmpApproval.OID), Convert.ToInt32(tmpApproval.OID), _param.ActionType, "");

                        DObject targetDobj = DObjectRepository.SelDObject(new DObject {
                            OID = tmpApproval.TargetOID
                        });
                        DObjectRepository.StatusPromote(false, targetDobj.Type, Convert.ToString(targetDobj.BPolicyOID), Convert.ToInt32(targetDobj.OID), Convert.ToInt32(targetDobj.OID), _param.ActionType, "");
                    }
                }
                DaoFactory.Commit();
            }
            catch (Exception ex)
            {
                DaoFactory.Rollback();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
            return(Json(CommonConstant.RETURN_SUCCESS));
        }