public JsonResult SelMyApproval(ApprovalTask _param) { List <Person> persons = PersonRepository.SelPersons(new Person { }); List <BPolicy> policies = BPolicyRepository.SelBPolicy(new BPolicy { Type = CommonConstant.TYPE_APPROVAL_TASK }); List <ApprovalTask> myApproval = new List <ApprovalTask>(); DaoFactory.GetList <ApprovalTask>("Comm.SelMyApprovalTask", _param).ForEach(approv => { approv.PersonObj = persons.Find(person => person.OID == approv.PersonOID); approv.PersonNm = approv.PersonObj.Name; approv.DepartmentNm = approv.PersonObj.DepartmentNm; approv.BPolicy = policies.Find(policy => policy.OID == approv.BPolicyOID); approv.ApprovalBPolicy = DObjectRepository.SelDObject(new DObject { OID = approv.ApprovalOID }).BPolicy; if (approv.BPolicy.Name == approv.ApprovalBPolicy.Name) { myApproval.Add(approv); } }); return(Json(myApproval)); }
public JsonResult InsRole(Role _param) { int result = 0; try { DaoFactory.BeginTransaction(); DObject dobj = new DObject(); dobj.Type = CommonConstant.TYPE_ROLE; dobj.Name = _param.Name; if (DObjectRepository.SelDObject(dobj) != null) { throw new Exception("Role 중복입니다."); } result = DObjectRepository.InsDObject(dobj); DaoFactory.Commit(); } catch (Exception ex) { DaoFactory.Rollback(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } return(Json(result)); }
public JsonResult SelPersons(Person _param) { List <Person> lPerson = null; if (_param.DepartmentOID == null || _param.DepartmentOID < 0) { lPerson = PersonRepository.SelPersons(_param); } else { DObject dobj = DObjectRepository.SelDObject(new DObject { OID = _param.DepartmentOID }); if (dobj.Type.Equals(CommonConstant.TYPE_COMPANY)) { lPerson = PersonRepository.SelPersons(new Person { }); } else { lPerson = PersonRepository.SelPersons(_param); } } return(Json(lPerson)); }
public ActionResult EditRole(Role _param) { if (_param.OID != null) { ViewBag.Role = DObjectRepository.SelDObject(new DObject { Type = CommonConstant.TYPE_ROLE, OID = _param.OID }); } else { ViewBag.Role = null; } return(PartialView("Dialog/dlgEditRole")); }
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)); }
public JsonResult InsApproval(Approval _param) { int result = 0; try { DaoFactory.BeginTransaction(); DObject dobj = new DObject(); if (_param.TargetOID == null) { dobj.Type = CommonConstant.TYPE_SAVE_APPROVAL; dobj.Name = _param.Name; } else { dobj.Type = CommonConstant.TYPE_APPROVAL; string strApprovalPrefix = dobj.Type + "-" + DateTime.Now.ToString("yyyyMMdd") + "-"; dobj.Name = strApprovalPrefix + SemsUtil.MakeSeq(DObjectRepository.SelNameSeq(new DObject { Type = CommonConstant.TYPE_APPROVAL, Name = strApprovalPrefix + "%" }), "000"); dobj.Description = _param.Description; } dobj.TableNm = CommonConstant.TABLE_APPROVAL; result = DObjectRepository.InsDObject(dobj); _param.OID = result; _param.ApprovalCount = _param.InboxStep.FindAll(step => step.ApprovalType.Equals(CommonConstant.TYPE_APPROVAL_APPROV) || step.ApprovalType.Equals(CommonConstant.TYPE_APPROVAL_AGREE)).Count; ApprovalRepository.InsApproval(_param); List <int> lPromoteOID = new List <int>(); int index = 0; _param.InboxStep.ForEach(step => { step.ApprovalOID = result; int stepResult = ApprovalStepRepository.InsApprovalStep(step); step.InboxTask.ForEach(task => { if (dobj != null) { dobj = null; } dobj = new DObject(); dobj.Type = CommonConstant.TYPE_APPROVAL_TASK; dobj.TableNm = CommonConstant.TABLE_APPROVAL_TASK; string strApprovalPrefix = dobj.Type + "-" + DateTime.Now.ToString("yyyyMMdd") + "-"; dobj.Name = strApprovalPrefix + SemsUtil.MakeSeq(DObjectRepository.SelNameSeq(new DObject { Type = CommonConstant.TYPE_APPROVAL_TASK, Name = strApprovalPrefix + "%" }), "000"); int taskResult = DObjectRepository.InsDObject(dobj); task.ApprovalOID = result; task.StepOID = stepResult; task.OID = taskResult; ApprovalTaskRepository.InsInboxTask(task); if (index == 0) { lPromoteOID.Add(taskResult); } }); index++; }); if (_param.TargetOID != null) { DObject targetDobj = DObjectRepository.SelDObject(new DObject { OID = _param.TargetOID }); DObjectRepository.StatusPromote(false, targetDobj.Type, Convert.ToString(targetDobj.BPolicyOID), Convert.ToInt32(targetDobj.OID), Convert.ToInt32(targetDobj.OID), CommonConstant.ACTION_PROMOTE, null); if (lPromoteOID != null && lPromoteOID.Count > 0) { lPromoteOID.ForEach(promoteOID => { if (dobj != null) { dobj = null; } dobj = DObjectRepository.SelDObject(new DObject { OID = promoteOID }); DObjectRepository.StatusPromote(false, dobj.Type, Convert.ToString(dobj.BPolicyOID), Convert.ToInt32(dobj.OID), Convert.ToInt32(dobj.OID), CommonConstant.ACTION_PROMOTE, null); }); DObject approvDobj = DObjectRepository.SelDObject(new DObject { OID = result }); DObjectRepository.StatusPromote(false, approvDobj.Type, Convert.ToString(approvDobj.BPolicyOID), Convert.ToInt32(approvDobj.OID), Convert.ToInt32(approvDobj.OID), CommonConstant.ACTION_PROMOTE, null); } ApprovalRepository.UdtApproval(new Approval { OID = result, CurrentNum = 1 }); } DaoFactory.Commit(); } catch (Exception ex) { DaoFactory.Rollback(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } return(Json(result)); }