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 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); }