public static int ReviseDObject(DObject _param) { int result = -1; DObject targetDobj = DObjectRepository.SelDObject(new DObject { OID = _param.OID }); DObjectRepository.UdtReleaseLatestDObject(new DObject { OID = _param.OID, IsReleasedLatest = 0 }); targetDobj.BPolicyOID = null; targetDobj.Revision = SemsUtil.MakeMajorRevisonUp(targetDobj.Revision); result = DObjectRepository.InsDObject(targetDobj); return(result); }
public static string StatusCheckPromote(string RelType, string CurrentStatus, int OID, int RootOID, string Action, string Comment) { string result = ""; List <Dictionary <string, string> > checkProgram = BPolicyRepository.SelCheckProgram(new BPolicy { Type = RelType, OID = Convert.ToInt32(CurrentStatus) }); if (checkProgram != null && checkProgram.Count > 0) { checkProgram.ForEach(item => { if (result == null || result.Length < 1) { string returnMessage = SemsUtil.Invoke(item[CommonConstant.POLICY_TRIGGER_CLASS], item[CommonConstant.POLICY_TRIGGER_FUNCTION], new string[] { RelType, CurrentStatus, Convert.ToString(OID), Convert.ToString(RootOID), Action, Comment }); if (returnMessage != null && returnMessage.Length > 0) { result = returnMessage; } } }); } return(result); }
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)); }
public static string StatusPromote(bool Transaction, string RelType, string CurrentStatus, int OID, int RootOID, string Action, string Comment) { string result = ""; try { if (Transaction) { DaoFactory.BeginTransaction(); } string checkProgram = StatusCheckPromote(RelType, CurrentStatus, OID, RootOID, Action, Comment); if (checkProgram != null && checkProgram.Length > 0) { throw new Exception(checkProgram); } List <Dictionary <string, string> > actionProgram = BPolicyRepository.SelActionProgram(new BPolicy { Type = RelType, OID = Convert.ToInt32(CurrentStatus) }); if (actionProgram != null && actionProgram.Count > 0) { actionProgram.ForEach(item => { string returnMessage = SemsUtil.Invoke(item[CommonConstant.POLICY_TRIGGER_CLASS], item[CommonConstant.POLICY_TRIGGER_FUNCTION], new string[] { RelType, CurrentStatus, Convert.ToString(OID), Convert.ToString(RootOID), Action, Comment }); if (returnMessage != null && returnMessage.Length > 0) { throw new Exception(returnMessage); } }); } string strNextAction = BPolicyRepository.SelBPolicy(new BPolicy { Type = RelType, OID = Convert.ToInt32(CurrentStatus) }).First().NextActionOID; string strActionOID = ""; if (strNextAction != null) { strNextAction.Split(',').ToList().ForEach(action => { if (action.IndexOf(Action) > -1) { strActionOID = action.Substring(action.IndexOf(":") + 1); return; } }); } DObjectRepository.UdtDObject(new DObject { OID = OID, BPolicyOID = Convert.ToInt32(strActionOID) }); if (Transaction) { DaoFactory.Commit(); } } catch (Exception ex) { if (Transaction) { DaoFactory.Rollback(); } result = ex.Message; } return(result); }