private IJTXChangeRule GetChangeRuleByName(string name) { IJTXChangeRule retVal = null; IJTXSpatialNotificationManager snManager = this.WmxDatabase.SpatialNotificationManager; IJTXChangeRuleSet allChangeRules = snManager.ChangeRules; // Find the type of change rule specified for (int i = 0; i < allChangeRules.Count; i++) { IJTXChangeRule rule = allChangeRules.get_Item(i); if (rule.Name.Equals(name)) { retVal = rule; break; } } return(retVal); }
/// <summary> /// Post validates the given set of values. /// This is where you flag parameters with warnings and error messages, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> /// <param name="msgs"></param> public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs) { // Call the base class function first try { UpdateMessagesCommon(paramValues, pEnvMgr, msgs); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } // Build a hash of which parameter is at which index for ease of access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 snNameParam = paramMap.GetParam(C_PARAM_NAME); IGPParameterEdit3 snNameParamEdit = paramMap.GetParamEdit(C_PARAM_NAME); // Ensure that the named spatial notification doesn't already exist if (snNameParam.Value != null && !snNameParam.Value.GetAsText().Equals(string.Empty)) { IJTXDatabase2 db = this.WmxDatabase as IJTXDatabase2; string changeRuleName = snNameParam.Value.GetAsText(); IJTXChangeRuleSet allChangeRules = db.SpatialNotificationManager.ChangeRules; for (int i = 0; i < allChangeRules.Count; i++) { IJTXChangeRule tempRule = allChangeRules.get_Item(i); if (tempRule.Name.Equals(snNameParam.Value.GetAsText())) { WmauError error = new WmauError(WmauErrorCodes.C_SN_EXISTS_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_NAME), error.ErrorCodeAsInt, error.Message); break; } } } }
/// <summary> /// Set up a coded value domain containing the names of all the spatial notifications /// (a.k.a. "change rules") currently in the database. /// </summary> /// <param name="wmxDb">A reference to the active Workflow Manager database</param> /// <returns>A coded value domain as an IGPDomain</returns> public static IGPDomain BuildChangeRulesDomain(IJTXDatabase3 wmxDb) { IGPCodedValueDomain domain = new GPCodedValueDomainClass(); SortedList <string, string> sortedValues = new SortedList <string, string>(); IJTXChangeRuleSet allChangeRules = wmxDb.SpatialNotificationManager.ChangeRules; // Sort the types first for (int i = 0; i < allChangeRules.Count; i++) { IJTXChangeRule tempRule = allChangeRules.get_Item(i); sortedValues.Add(tempRule.Name, null); } // Add the sorted types to the domain foreach (string value in sortedValues.Keys) { IGPValue tempGpVal = new GPStringClass(); tempGpVal.SetAsText(value); domain.AddCode(tempGpVal, value); } return(domain as IGPDomain); }