/// <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 snName = paramMap.GetParam(C_PARAM_SPATIAL_NOTIFICATION); IGPParameter3 dataWorkspace = paramMap.GetParam(C_PARAM_DATA_WORKSPACE); // Ensure that there is at least one existing spatial notification in the database if (snName.Domain == null || (snName.Domain as IGPCodedValueDomain).CodeCount <= 0) { WmauError error = new WmauError(WmauErrorCodes.C_NO_SPATIAL_NOTIFICATIONS_FOUND); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_SPATIAL_NOTIFICATION), error.ErrorCodeAsInt, error.Message); } // Ensure that there is at least one data workspace defined in the database if (dataWorkspace.Domain == null || (dataWorkspace.Domain as IGPCodedValueDomain).CodeCount <= 0) { WmauError error = new WmauError(WmauErrorCodes.C_NO_WORKSPACES_DEFINED_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_DATA_WORKSPACE), error.ErrorCodeAsInt, error.Message); } }
/// <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 snName = paramMap.GetParam(C_PARAM_SPATIAL_NOTIFICATION); IGPParameter3 altAoi = paramMap.GetParam(C_PARAM_ALTERNATE_AOI); IGPParameterEdit3 altAoiEdit = paramMap.GetParamEdit(C_PARAM_ALTERNATE_AOI); // Ensure that there is at least one existing spatial notification in the database if (snName.Domain == null || (snName.Domain as IGPCodedValueDomain).CodeCount <= 0) { WmauError error = new WmauError(WmauErrorCodes.C_NO_SPATIAL_NOTIFICATIONS_FOUND); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_SPATIAL_NOTIFICATION), error.ErrorCodeAsInt, error.Message); } // Check the AOI; ensure that there is exactly one feature selected if (altAoi.Value != null && !altAoi.Value.GetAsText().Equals(string.Empty)) { try { ILayer aoiLayer = m_gpUtilities.DecodeLayer(altAoi.Value); IFeatureLayer featLayer = aoiLayer as IFeatureLayer; IFeatureSelection featSel = aoiLayer as IFeatureSelection; ISelectionSet selSet = featSel.SelectionSet as ISelectionSet; if (featLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { WmauError error = new WmauError(WmauErrorCodes.C_AOI_NOT_POLYGON_ERROR); msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.Message); } else if (selSet.Count != 1) { WmauError error = new WmauError(WmauErrorCodes.C_EXPECTED_ONE_SELECTED_FEATURE_ERROR); msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.Message); } } catch (System.Runtime.InteropServices.COMException comEx) { WmauError error = new WmauError(WmauErrorCodes.C_AOI_INPUT_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.ErrorCodeAsInt, error.Message + "; " + comEx.Message); } } }
/// <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) { 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 dataWorkspaceName = paramMap.GetParam(C_PARAM_DATA_WORKSPACE); IGPParameter3 parentVersion = paramMap.GetParam(C_PARAM_PARENT_VERSION); // If there's no domain on the parent version parameter, then something went // awry if (parentVersion.Domain == null) { WmauError error = new WmauError(WmauErrorCodes.C_VERSION_LOOKUP_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_PARENT_VERSION), error.ErrorCodeAsInt, error.Message); } // Store away the latest value of the data workspace m_dataWorkspaceName = dataWorkspaceName.Value.GetAsText(); }
// Called after returning from the update parameters routine. // You can examine the messages created from internal validation and change them if desired. public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages Messages) { try { IGPLinearUnit distVal = (IGPLinearUnit)m_GPUtilities.UnpackGPValue(paramvalues.get_Element(2)); if (distVal.Value <= 0) { Messages.ReplaceError(2, 2, "Zero or a negative distance is invalid when specifying a tolerance."); } } catch (Exception exx) { } }
/// <summary> /// Helper function for the "UpdateMessages" interface; meant to be called directly by /// child classes who override "UpdateMessages", rather than calling "UpdateMessages" /// itself. /// </summary> /// <param name="paramValues">The IArray of parameters passed into UpdateMessages</param> /// <param name="pEnvMgr">The GP environment manager object</param> /// <param name="msgs">The GP messages object to be updated by this function</param> protected void UpdateMessagesCommon(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs) { // Ensure that a Workflow Manager database is set. if (!IsWorkflowManagerDatabaseSet()) { if (msgs.Count > 0) { WmauParameterMap paramMap = new WmauParameterMap(paramValues); WmauError error = new WmauError(WmauErrorCodes.C_INVALID_WMX_DB_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_WMX_DATABASE_ALIAS), error.ErrorCodeAsInt, error.Message); } throw new WmxDefaultDbNotSetException(); } }
/// <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) { 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); // Ensure that the current user has permissions to be adding attachments to jobs if (!CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_MANAGE_ATTACHMENTS)) { WmauError error = new WmauError(WmauErrorCodes.C_NO_MANAGE_ATTACHMENTS_PRIV_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_JOB_ID), error.ErrorCodeAsInt, error.Message); } }
/// <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> /// 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 assigneeType = paramMap.GetParam(C_PARAM_ASSIGNEE_TYPE); IGPParameter3 assignee = paramMap.GetParam(C_PARAM_ASSIGNEE); IGPParameter3 aoi = paramMap.GetParam(C_PARAM_AOI); IGPParameter3 startDate = paramMap.GetParam(C_PARAM_START_DATE); IGPParameter3 dueDate = paramMap.GetParam(C_PARAM_DUE_DATE); IGPParameter3 dataWorkspace = paramMap.GetParam(C_PARAM_DATAWORKSPACE); IGPParameter3 parentVersion = paramMap.GetParam(C_PARAM_PARENTVERSION); // Ensure that the current user has permissions to be creating jobs if (!CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_CREATE_JOB)) { WmauError error = new WmauError(WmauErrorCodes.C_NO_CREATE_JOB_PRIV_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_JOB_TYPE), error.ErrorCodeAsInt, error.Message); } // Check assignments; if a name is specified but a type is not, print a warning if (String.IsNullOrEmpty(assigneeType.Value.GetAsText()) && !String.IsNullOrEmpty(assignee.Value.GetAsText())) { WmauError error = new WmauError(WmauErrorCodes.C_JOB_ASSIGNMENT_IGNORED_ERROR); msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_ASSIGNEE), error.Message); } // Check the AOI; ensure that there is exactly one feature selected if (aoi.Value != null && !aoi.Value.GetAsText().Equals(string.Empty)) { try { ILayer aoiLayer = m_gpUtilities.DecodeLayer(aoi.Value); IFeatureLayer featLayer = aoiLayer as IFeatureLayer; IFeatureSelection featSel = aoiLayer as IFeatureSelection; ISelectionSet selSet = featSel.SelectionSet as ISelectionSet; if (featLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { WmauError error = new WmauError(WmauErrorCodes.C_AOI_NOT_POLYGON_ERROR); msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_AOI), error.Message); } else if (selSet.Count != 1) { WmauError error = new WmauError(WmauErrorCodes.C_EXPECTED_ONE_SELECTED_FEATURE_ERROR); msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_AOI), error.Message); } } catch (System.Runtime.InteropServices.COMException comEx) { WmauError error = new WmauError(WmauErrorCodes.C_AOI_INPUT_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_AOI), error.ErrorCodeAsInt, error.Message + "; " + comEx.Message); } } // Check start date and due date; if they're both defined, make sure that start // date is <= due date if (startDate.Value != null && !startDate.Value.GetAsText().Equals(string.Empty) && dueDate.Value != null && !dueDate.Value.GetAsText().Equals(string.Empty) && DateTime.Parse(dueDate.Value.GetAsText()) < DateTime.Parse(startDate.Value.GetAsText())) { WmauError error = new WmauError(WmauErrorCodes.C_DUE_DATE_LT_START_DATE_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_DUE_DATE), error.ErrorCodeAsInt, error.Message); } // If a workspace has been chosen but the version field is disabled and the user has // permissions to manage versions, something went wrong if (dataWorkspace.Value != null && !dataWorkspace.Value.GetAsText().Equals(string.Empty) && !dataWorkspace.Value.GetAsText().Equals(C_OPT_VAL_NOT_SET) && !parentVersion.Enabled && CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_MANAGE_VERSION)) { WmauError error = new WmauError(WmauErrorCodes.C_WORKSPACE_ERROR); msgs.ReplaceError(paramMap.GetIndex(C_PARAM_DATAWORKSPACE), error.ErrorCodeAsInt, error.Message); } }
protected void Error(string err) { m_errored = true; m_msgs.ReplaceError(m_msgidx, 2, err); }