/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Retrieve the parameter for the jobs to delete and add a domain to it // // NOTE: Add the domain in this function because the Workflow Manager // connection/extension/etc. is not necessarily available when ParameterInfo // is first accessed. WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = paramMap.GetParam(C_PARAM_JOB_TO_DELETE); IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_JOB_TO_DELETE); if (param.Domain == null) { // If there isn't a domain on this parameter yet, that means that it // still needs to be populated. In that case, do so at this time. paramEdit.Domain = Common.WmauGpDomainBuilder.BuildJobIdDomain(this.WmxDatabase); } }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Build a hash of which parameter is at which index for ease of access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 notificationParam = paramMap.GetParam(C_PARAM_EMAIL_NOTIFIER); IGPParameterEdit3 notificationParamEdit = paramMap.GetParamEdit(C_PARAM_EMAIL_NOTIFIER); // Add a domain to the notification parameter if (notificationParam.Domain == null || (notificationParam.Domain as IGPCodedValueDomain).CodeCount <= 0) { notificationParamEdit.Domain = Common.WmauGpDomainBuilder.BuildEmailNotificationDomain(this.WmxDatabase); } }
/* * Called each time the user changes a parameter in the tool dialog or Command Line. * This updates the output data of the tool, which extremely useful for building models. * After returning from UpdateParameters(), geoprocessing calls its internal validation routine checkng that a given set of parameter values * are of the appropriate number, DataType, and value. * This method will update the output parameter value with the unique field. */ public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { m_Parameters = paramvalues; // Retrieve the input parameter value IGPValue parameterValue = m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0)); // Retrieve the unique field parameter value IGPParameter3 fieldNameParameter = (IGPParameter3)paramvalues.get_Element(3); // Get the output feature class schema and empty the additional fields. This will ensure // you don't get dublicate entries. IGPParameter3 outputFeatures = (IGPParameter3)paramvalues.get_Element(2); IGPFeatureSchema schema = (IGPFeatureSchema)outputFeatures.Schema; schema.AdditionalFields = null; // If we have an unique field value, create a new field based on the unique field name the user entered. if (fieldNameParameter.Value.IsEmpty() == false) { string fieldName = fieldNameParameter.Value.GetAsText(); IField uniqueField = m_GPUtilities.FindField(parameterValue, fieldName); IFieldsEdit fieldsEdit = new FieldsClass(); fieldsEdit.AddField(uniqueField); IFields fields = fieldsEdit as IFields; schema.AdditionalFields = fields; } }
// This method will update the output parameter value with the additional area field. public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { m_Parameters = paramvalues; // Retrieve the input parameter value IGPValue parameterValue = m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0)); // Get the derived output feature class schema and empty the additional fields. This will ensure you don't get duplicate entries. IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(2); IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema; schema.AdditionalFields = null; // If we have an input value, create a new field based on the field name the user entered. if (parameterValue.IsEmpty() == false) { IGPParameter3 fieldNameParameter = (IGPParameter3)paramvalues.get_Element(1); string fieldName = fieldNameParameter.Value.GetAsText(); // Check if the user's input field already exists IField areaField = m_GPUtilities.FindField(parameterValue, fieldName); if (areaField == null) { IFieldsEdit fieldsEdit = new FieldsClass(); IFieldEdit fieldEdit = new FieldClass(); fieldEdit.Name_2 = fieldName; fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; fieldsEdit.AddField(fieldEdit); // Add an additional field for the area values to the derived output. IFields fields = fieldsEdit as IFields; schema.AdditionalFields = fields; } } }
/// <summary> /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed. /// </summary> /// <param name="paramValues"></param> /// <param name="trackCancel"></param> /// <param name="envMgr"></param> /// <param name="msgs"></param> public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs) { // Do some common error-checking base.Execute(paramValues, trackCancel, envMgr, msgs); try { // Ensure that the current user has admin access to the current Workflow Manager DB if (!CurrentUserIsWmxAdministrator()) { throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR); } // Retrieve the parameter in which the list of MXDs will be stored WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = paramMap.GetParam(C_PARAM_MAP_DOCUMENT_LIST); IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_MAP_DOCUMENT_LIST); // Set up the multi-value objects IGPMultiValue mvValue = new GPMultiValueClass(); mvValue.MemberDataType = param.DataType; // Get the list of MXD names and add them all to the multivalue SortedList <string, string> mapDocuments = this.ListMapDocumentsInDatabase(); foreach (string mapDocName in mapDocuments.Keys) { IGPString strVal = new GPStringClass(); strVal.Value = mapDocName; mvValue.AddValue(strVal as IGPValue); msgs.AddMessage("Map Document: " + mapDocName); } paramEdit.Value = (IGPValue)mvValue; msgs.AddMessage(Properties.Resources.MSG_DONE); } catch (WmauException wmEx) { try { msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message); } catch { // Catch anything else that possibly happens } } catch (Exception ex) { try { WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR); msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message); } catch { // Catch anything else that possibly happens } } }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Build a hash of the parameters for ease of access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 dataWorkspace = paramMap.GetParam(C_PARAM_DATA_WORKSPACE); IGPParameterEdit3 dataWorkspaceEdit = paramMap.GetParamEdit(C_PARAM_DATA_WORKSPACE); // Apply a domain to the data workspace list, if necessary if (dataWorkspace.Domain == null || (dataWorkspace.Domain as IGPCodedValueDomain).CodeCount <= 0) { dataWorkspaceEdit.Domain = Common.WmauGpDomainBuilder.BuildWorkspaceDomain(this.WmxDatabase); } }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } WmauParameterMap paramMap = new WmauParameterMap(paramValues); // Retrieve the parameter for source name and add a domain to it IGPParameter3 param = paramMap.GetParam(C_PARAM_MXD_NAME); IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_MXD_NAME); if (param.Domain == null) { // If there isn't a domain on this parameter yet, that means that it has // not yet had a list of possible MXDs populated. In that case, do // so at this time. paramEdit.Domain = Common.WmauGpDomainBuilder.BuildMapDocumentDomain(this.WmxDatabase); } }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Build a hash of the parameters for ease of access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 snName = paramMap.GetParam(C_PARAM_SPATIAL_NOTIFICATION); IGPParameterEdit3 snNameEdit = paramMap.GetParamEdit(C_PARAM_SPATIAL_NOTIFICATION); IGPParameter3 useJobAoi = paramMap.GetParam(C_PARAM_USE_JOB_AOI); IGPParameterEdit3 alternateAoiEdit = paramMap.GetParamEdit(C_PARAM_ALTERNATE_AOI); // Apply a domain to the list of spatial notifications, if possible if (snName.Domain == null || (snName.Domain as IGPCodedValueDomain).CodeCount <= 0) { snNameEdit.Domain = Common.WmauGpDomainBuilder.BuildChangeRulesDomain(this.WmxDatabase); } // Enable/disable the alternate AOI parameter based on the status of the // "use job AOI" parameter alternateAoiEdit.Enabled = !(useJobAoi.Value as IGPBoolean).Value; }
/// <summary> /// Helper function for the "UpdateParameters" interface; meant to be called directly by /// child classes who override "UpdateParameters", rather than calling "UpdateParameters" /// itself. /// </summary> /// <param name="paramValues">The IArray of parameters passed into UpdateParameters</param> /// <param name="pEnvMgr">The GP environment manager object</param> protected void UpdateParametersCommon(IArray paramValues, IGPEnvironmentManager pEnvMgr) { WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters the parent class // is maintaining param = paramMap.GetParam(C_PARAM_WMX_DATABASE_ALIAS); string newDbAlias = param.Value.GetAsText(); // If the WMX database has changed, update it. if (!newDbAlias.Equals(m_wmxDbAlias)) { ChangeWmxDatabase(newDbAlias, paramMap); } // Ensure that the default Workflow Manager database is set. if (!IsWorkflowManagerDatabaseSet()) { throw new WmxDefaultDbNotSetException(); } if (paramValues == null || pEnvMgr == null) { throw new NullReferenceException(); } }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Get the parameters as a map for easier access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 jobId = paramMap.GetParam(C_PARAM_JOB_ID); IGPParameterEdit3 jobIdEdit = paramMap.GetParamEdit(C_PARAM_JOB_ID); // Set the domains for any parameters that need them // Set the job ID domain if it hasn't already been populated if (jobId.Domain == null) { jobIdEdit.Domain = Common.WmauGpDomainBuilder.BuildNonClosedJobIdDomain(this.WmxDatabase); } }
/// <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(); }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_NAME); m_snName = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_SUBJECT); m_subject = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_MESSAGE); m_message = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_SUBSCRIBERS); m_subscribers = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_SENDER_EMAIL); m_senderEmail = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_SENDER_NAME); m_senderName = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_DESCRIPTION); m_snDescription = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_SUMMARIZE); m_summarize = bool.Parse(param.Value.GetAsText()); }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Build a hash of which parameter is at which index for ease of access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 userParam = paramMap.GetParam(C_PARAM_USER_NAME); IGPParameterEdit3 userParamEdit = paramMap.GetParamEdit(C_PARAM_USER_NAME); // Add a domain to the users parameter if (userParam.Domain == null || (userParam.Domain as IGPCodedValueDomain).CodeCount <= 0) { userParamEdit.Domain = Common.WmauGpDomainBuilder.BuildUsersDomain(this.WmxDatabase, new string[] { C_OPT_ALL_USERS }); } }
// 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) { // Check for error messages IGPMessage msg = (IGPMessage)Messages; if (msg.IsError()) { return; } // Get the first Input Parameter IGPParameter parameter = (IGPParameter)paramvalues.get_Element(0); // UnPackGPValue. This ensures you get the value either form the dataelement or GpVariable (ModelBuilder) IGPValue parameterValue = m_GPUtilities.UnpackGPValue(parameter); // Open the Input Dataset - Use DecodeFeatureLayer as the input might be a layer file or a feature layer from ArcMap. IFeatureClass inputFeatureClass; IQueryFilter qf; m_GPUtilities.DecodeFeatureLayer(parameterValue, out inputFeatureClass, out qf); IGPParameter3 fieldParameter = (IGPParameter3)paramvalues.get_Element(1); string fieldName = fieldParameter.Value.GetAsText(); // Check if the field already exists and provide a warning. int indexA = inputFeatureClass.FindField(fieldName); if (indexA > 0) { Messages.ReplaceWarning(1, "Field already exists. It will be overwritten."); } return; }
/// <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 dataWorkspace = paramMap.GetParam(C_PARAM_DATA_WORKSPACE); // 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> /// Helper function to enable/disable a particular parameter based on the possible values /// in its domain. /// </summary> /// <param name="paramObj"> /// The parameter to enabled/disable. The domain for this parameter must be a /// IGPCodedValueDomain. /// </param> private void EnableDisableParamBasedOnDomain(object paramObj) { IGPParameter3 param = paramObj as IGPParameter3; IGPParameterEdit3 paramEdit = paramObj as IGPParameterEdit3; IGPCodedValueDomain domain = param.Domain as IGPCodedValueDomain; paramEdit.Enabled = (domain != null && domain.CodeCount > 0); }
/// <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> /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed. /// </summary> /// <param name="paramValues"></param> /// <param name="trackCancel"></param> /// <param name="envMgr"></param> /// <param name="msgs"></param> public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs) { // Do some common error-checking base.Execute(paramValues, trackCancel, envMgr, msgs); try { WmauParameterMap paramMap = new WmauParameterMap(paramValues); // Retrieve the parameter in which the list of workbook names will be stored IGPParameter3 param = paramMap.GetParam(C_PARAM_JOB_ID_LIST); IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_JOB_ID_LIST); IGPParameter3 filterParam = paramMap.GetParam(C_PARAM_SQL_QUERY_FILTER); // Get the multivalue object into which the output will be stored IGPMultiValue outputValues = new GPMultiValueClass(); outputValues.MemberDataType = param.DataType; for (int i = 0; i < outputValues.Count; i++) { outputValues.Remove(i); } // Get the list of job IDs and add them all to the multivalue SortedList <int, string> jobs = this.ListJobsInDatabase(filterParam.Value.GetAsText()); msgs.AddMessage("Jobs matching query:"); foreach (KeyValuePair <int, string> item in jobs) { IGPLong value = new GPLongClass(); value.Value = item.Key; outputValues.AddValue(value as IGPValue); msgs.AddMessage(" " + value.Value.ToString() + " (" + item.Value + ")"); } paramEdit.Value = (IGPValue)outputValues; msgs.AddMessage(Properties.Resources.MSG_DONE); } catch (WmauException wmEx) { try { msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message); } catch { // Catch anything else that possibly happens } } catch (Exception ex) { WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR); msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message); } }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Ensure that the various parameter values are all restored to their // defaults because of how this function works ResetVariables(); // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_PREVIEW_CHANGES); m_previewChanges = (param.Value as IGPBoolean).Value; param = paramMap.GetParam(C_PARAM_CHECKLIST); IGPValue paramValue = m_gpUtilities.UnpackGPValue(param); IGPMultiValue paramMultiValue = paramValue as IGPMultiValue; for (int i = 0; i < paramMultiValue.Count; i++) { IGPValue check = paramMultiValue.get_Value(i); string strVal = check.GetAsText(); if (strVal.Equals(C_OPT_CLEAN_WORKFLOWS)) { m_cleanWorkflows = true; } else if (strVal.Equals(C_OPT_CLEAN_STEP_TYPES)) { m_cleanStepTypes = true; } else if (strVal.Equals(C_OPT_CLEAN_STATUS_TYPES)) { m_cleanStatusTypes = true; } else if (strVal.Equals(C_OPT_CLEAN_PRIORITIES)) { m_cleanPriorities = true; } else if (strVal.Equals(C_OPT_CLEAN_TA_WORKBOOKS)) { m_cleanTaWorkbooks = true; } else if (strVal.Equals(C_OPT_CLEAN_USERS)) { m_cleanUsers = true; } else if (strVal.Equals(C_OPT_CLEAN_MAP_DOCS)) { m_cleanMapDocs = true; } } }
/// <summary> /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed. /// </summary> /// <param name="paramValues"></param> /// <param name="trackCancel"></param> /// <param name="envMgr"></param> /// <param name="msgs"></param> public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs) { // Do some common error-checking base.Execute(paramValues, trackCancel, envMgr, msgs); try { // Retrieve the parameter in which the list of workbook names will be stored WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = paramMap.GetParam(C_PARAM_TAM_WORKBOOK_LIST); IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_TAM_WORKBOOK_LIST); // Set up the multi-value objects IGPMultiValue mvValue = new GPMultiValueClass(); mvValue.MemberDataType = param.DataType; // Get the list of TA workbook names and add them all to the multivalue SortedList <string, string> tamWorkbooks = this.ListTamWorkbooksInDatabase(); foreach (string workbookAlias in tamWorkbooks.Keys) { IGPString strVal = new GPStringClass(); strVal.Value = workbookAlias; mvValue.AddValue(strVal as IGPValue); msgs.AddMessage("Workbook: " + workbookAlias); } paramEdit.Value = (IGPValue)mvValue; msgs.AddMessage(Properties.Resources.MSG_DONE); } catch (WmauException wmEx) { try { msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message); } catch { // Catch anything else that possibly happens } } catch (Exception ex) { try { WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR); msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message); } catch { // Catch anything else that possibly happens } } }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_JOB_TO_DELETE); m_jobToDelete = int.Parse(param.Value.GetAsText()); }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_OUT_EXCEL_FILE_PATH); m_excelFilePath = param.Value.GetAsText(); }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_MXD_NAME); m_mxdName = param.Value.GetAsText(); }
public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr) { IGPUtilities3 gpUtilities3 = new GPUtilitiesClass(); IGPParameter3 inputLayersParameter = paramvalues.get_Element(in_LayersNumber) as IGPParameter3; IGPMultiValue inputLayersGPValue = gpUtilities3.UnpackGPValue(inputLayersParameter) as IGPMultiValue; if (inputLayersGPValue == null) { return; } // check if there are input layer provided if (inputLayersGPValue.Count == 0) { return; } IGPParameter3 outputLayerParameter = paramvalues.get_Element(out_groupLayerNumber) as IGPParameter3; IGPValue outputLayerGPValue = gpUtilities3.UnpackGPValue(outputLayerParameter); // if the output layer value is still empty and build a proposal for a name if (outputLayerGPValue.IsEmpty()) { // read the proposed name from the resources string proposedOutputLayerName = resourceManager.GetString("GPTools_GPCombineLayers_outputgrouplayer_proposedname"); string proposedOutputLayerNameTest = proposedOutputLayerName; int layerIndex = 2; // check if a layer with the same name already exists // if it does then attempt to append some index numbers to build a unique, new name ILayer foundLayer = gpUtilities3.FindMapLayer(proposedOutputLayerNameTest); while (foundLayer != null) { proposedOutputLayerNameTest = proposedOutputLayerName + " (" + layerIndex + ")"; foundLayer = gpUtilities3.FindMapLayer(proposedOutputLayerNameTest); layerIndex = layerIndex + 1; if (layerIndex > 10000) { break; } } outputLayerGPValue.SetAsText(proposedOutputLayerNameTest); gpUtilities3.PackGPValue(outputLayerGPValue, outputLayerParameter); } }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; param = paramMap.GetParam(C_PARAM_JXL_FILE_PATH); m_jxlFilePath = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_PRETTY_PRINT); m_prettyPrint = (param.Value as IGPBoolean).Value; }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_JOB_ID); m_jobId = int.Parse(param.Value.GetAsText()); param = paramMap.GetParam(C_PARAM_NOTIFICATION_NAME); m_notificationName = param.Value.GetAsText(); }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected void ExtractParametersCommon(IArray paramValues) { WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters the parent class // is maintaining param = paramMap.GetParam(C_PARAM_WMX_DATABASE_ALIAS); string newDbAlias = param.Value.GetAsText(); // If the WMX database has changed, update it. if (!newDbAlias.Equals(m_wmxDbAlias)) { ChangeWmxDatabase(newDbAlias, paramMap); } }
/// <summary> /// Helper function to add a new parameter object to the internal mapping /// </summary> /// <param name="value">The object to be added (should meet the IGPParameter3 interface)</param> private void AddParam(object value) { if (value == null) { throw new NullReferenceException(); } else if (!(value is IGPParameter3)) { throw new ArgumentException(); } else { IGPParameter3 param = value as IGPParameter3; int newIndex = m_indexMapping.Count; m_indexMapping.Add(param.Name, newIndex); } }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_JOB_ID); m_jobId = int.Parse(param.Value.GetAsText()); param = paramMap.GetParam(C_PARAM_ATTACHMENT); m_attachmentPath = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_ATTACHMENT_TYPE); m_attachmentType = param.Value.GetAsText(); }
/// <summary> /// Updates the internal values used by this tool based on the parameters from an input array /// </summary> /// <param name="paramValues"></param> protected override void ExtractParameters(IArray paramValues) { // Get the values for any parameters common to all GP tools ExtractParametersCommon(paramValues); WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 param = null; // Update the internal values of whatever parameters we're maintaining param = paramMap.GetParam(C_PARAM_USER_GROUP); m_userGroup = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_GROUP_GROUP); m_groupGroup = param.Value.GetAsText(); param = paramMap.GetParam(C_PARAM_PRESERVE_CURRENT_USER); m_preserveCurrentUser = (param.Value as IGPBoolean).Value; }