コード例 #1
0
        /// <summary>
        ///     Creates the a coded value domain an assigns it to the parameter.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">
        ///     The name is the language-independent name for the parameter (not localized) and must not contain
        ///     spaces and must be unique within a function.
        /// </param>
        /// <param name="displayName">
        ///     The display name is the localized name (as it appears in the dialog) and is contained in
        ///     resource string.
        /// </param>
        /// <param name="parameterType">Type of the parameter.</param>
        /// <param name="parameterDirection">The parameter direction.</param>
        /// <param name="values">The values (strings) for the domain.</param>
        /// <param name="names">The names (strings) for the domain.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <returns>
        ///     Returns a <see cref="IGPParameterEdit3" /> representing the parameter.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     values
        ///     or
        ///     names
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     values;The values and names arrays must contain the same number of
        ///     elements.
        /// </exception>
        public static IGPParameterEdit3 CreateParameter(this IGPFunction source, string name, string displayName, esriGPParameterType parameterType, esriGPParameterDirection parameterDirection, object[] values, object[] names, IGPDataType dataType)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            if (names == null)
            {
                throw new ArgumentNullException("names");
            }

            if (values.Length != names.Length)
            {
                throw new ArgumentOutOfRangeException("values", "The values and names arrays must contain the same number of elements.");
            }

            IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();

            for (int i = 0; i < values.Length; i++)
            {
                codedValueDomain.AddStringCode(values[i].ToString(), names[i].ToString());
            }

            var parameter = source.CreateParameter(name, displayName, parameterType, parameterDirection, dataType);

            parameter.Domain = codedValueDomain as IGPDomain;
            return(parameter);
        }
コード例 #2
0
        /// <summary>
        /// Helper function to set up a GP tool parameter so that the workflow manager
        /// database can be chosen.
        /// </summary>
        /// <returns>A parameter for selecting the target WMX DB</returns>
        protected IGPParameter3 BuildWmxDbParameter()
        {
            IGPParameterEdit    paramEdit = null;
            IGPCodedValueDomain cvDomain  = new GPCodedValueDomainClass();

            // When we first build out the parameter list, ensure that we indicate
            // what the current Workflow Manager database is
            m_wmxDbAlias = string.Empty;
            IsWorkflowManagerDatabaseSet();

            // Parameter allowing specification of the Workflow Manager database
            IGPString strVal = new GPStringClass();

            strVal.Value = m_wmxDbAlias;
            paramEdit    = BuildParameter(
                esriGPParameterDirection.esriGPParameterDirectionInput,
                esriGPParameterType.esriGPParameterTypeOptional,
                Properties.Resources.DESC_COM_WMX_DATABASE,
                C_PARAM_WMX_DATABASE_ALIAS,
                (strVal as IGPValue).DataType,
                strVal as IGPValue);

            IJTXDatabaseConnectionManager connMgr = new JTXDatabaseConnectionManagerClass();

            foreach (string alias in connMgr.DatabaseNames)
            {
                cvDomain.AddStringCode(alias, alias);
            }
            paramEdit.Domain = cvDomain as IGPDomain;

            return(paramEdit as IGPParameter3);
        }
コード例 #3
0
        /// <summary>
        ///     Gets the coded value domain that contains all of the subtypes for the table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <returns>
        ///     Returns a <see cref="IGPDomain" /> representing the coded value domain.
        /// </returns>
        protected IGPDomain GetSubtypes(IObjectClass table)
        {
            // Create a domain of all the subtypes.
            IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();

            codedValueDomain.AddStringCode("-1", "All");

            ISubtypes subtypes = (ISubtypes)table;

            if (subtypes.HasSubtype)
            {
                foreach (var o in subtypes.Subtypes.AsEnumerable())
                {
                    codedValueDomain.AddStringCode(o.Key.ToString(CultureInfo.InvariantCulture), o.Value);
                }
            }

            return(codedValueDomain as IGPDomain);
        }
コード例 #4
0
        /// <summary>
        /// Set up a coded value domain with the supported geometric operations for area
        /// evaluators
        /// </summary>
        /// <returns></returns>
        private IGPDomain BuildGeometricOperationsDomain()
        {
            IGPCodedValueDomain geomOpDomain = new GPCodedValueDomainClass();

            foreach (string s in m_geometricOperations.Keys)
            {
                geomOpDomain.AddStringCode(s, s);
            }

            return(geomOpDomain as IGPDomain);
        }
コード例 #5
0
        /// <summary>
        ///     Gets the coded value domain using fields from the specified <paramref name="table" />
        /// </summary>
        /// <param name="table">The table.</param>
        /// <returns>
        ///     Returns a <see cref="IGPDomain" /> representing the coded value domain.
        /// </returns>
        protected IGPDomain GetFields(IObjectClass table)
        {
            IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();

            foreach (var o in table.Fields.AsEnumerable())
            {
                codedValueDomain.AddStringCode(o.Name, o.Name);
            }

            return((IGPDomain)codedValueDomain);
        }
コード例 #6
0
        /// <summary>
        /// Gets the coded value domain.
        /// </summary>
        /// <param name="names">The names.</param>
        /// <param name="values">The values.</param>
        /// <returns>
        /// Returns a <see cref="IGPDomain" /> representing the coded value domain.
        /// </returns>
        protected IGPDomain CreateDomain(string[] names, string[] values)
        {
            IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();

            for (int i = 0; i < values.Length; i++)
            {
                codedValueDomain.AddStringCode(values[i], names[i]);
            }

            return((IGPDomain)codedValueDomain);
        }
コード例 #7
0
        /// <summary>
        /// Set up a coded value domain with the supported geometric operations for area
        /// evaluators
        /// </summary>
        /// <returns></returns>
        private IGPDomain BuildChangeConditionsDomain()
        {
            IGPCodedValueDomain domain = new GPCodedValueDomainClass();

            foreach (string s in m_optChangeConditions.Keys)
            {
                domain.AddStringCode(s, s);
            }

            return(domain as IGPDomain);
        }
コード例 #8
0
        /// <summary>
        /// Builds a domain consisting of the available job queries in the system.
        /// </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 BuildJobQueryDomain(IJTXDatabase3 wmxDb)
        {
            IGPCodedValueDomain domain = new GPCodedValueDomainClass();

            IJTXConfiguration3    configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3;
            IJTXJobQueryContainer publicQueriesContainer = configMgr.GetPublicQueryContainer();

            // Sort the queries first
            SortedList <string, string> sortedValues = new SortedList <string, string>();

            WmauGpDomainBuilder.AddQueriesFromContainer(publicQueriesContainer, string.Empty, sortedValues);

            // Add the sorted types to the domain
            foreach (string value in sortedValues.Keys)
            {
                domain.AddStringCode(value, value);
            }

            return(domain as IGPDomain);
        }
コード例 #9
0
        /// <summary>
        ///     Pre validates the given set of values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities)
        {
            // Retrieve the input parameter value.
            IGPValue table = utilities.UnpackGPValue(parameters["in_table"]);

            if (!table.IsEmpty())
            {
                // Create the domain based on the fields on the table.
                IObjectClass oclass = utilities.OpenTable(table);
                if (oclass != null)
                {
                    IFields fields = oclass.Fields;
                    if (fields != null)
                    {
                        IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();
                        foreach (var o in fields.AsEnumerable())
                        {
                            codedValueDomain.AddStringCode(o.Name, o.Name);
                        }

                        IGPParameterEdit3 derivedFields = (IGPParameterEdit3)parameters["in_field"];
                        derivedFields.Domain = (IGPDomain)codedValueDomain;
                    }

                    IGPValue field = utilities.UnpackGPValue(parameters["in_field"]);
                    if (!field.IsEmpty())
                    {
                        int index = oclass.FindField(field.GetAsText());

                        IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();
                        foreach (var o in oclass.GetFieldModelNames(oclass.Fields.Field[index]))
                        {
                            codedValueDomain.AddStringCode(o, o);
                        }

                        IGPParameterEdit3 derivedParameter = (IGPParameterEdit3)parameters["in_field_model_names"];
                        derivedParameter.Domain = (IGPDomain)codedValueDomain;
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Builds a domain containing the names of all the task assistant
        /// workbooks embedded 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 BuildTamWorkbookDomain(IJTXDatabase3 wmxDb)
        {
            IGPCodedValueDomain         tamNames       = new GPCodedValueDomainClass();
            SortedList <string, string> sortedTamNames = new SortedList <string, string>();

            IJTXConfiguration3 configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3;
            IJTXTaskAssistantWorkflowRecordSet tamWorkbooks = configMgr.TaskAssistantWorkflowRecords;

            for (int i = 0; i < tamWorkbooks.Count; i++)
            {
                IJTXTaskAssistantWorkflowRecord tamWorkbook = tamWorkbooks.get_Item(i);
                sortedTamNames.Add(tamWorkbook.Alias, null);
            }

            foreach (string tamName in sortedTamNames.Keys)
            {
                tamNames.AddStringCode(tamName, tamName);
            }

            return(tamNames as IGPDomain);
        }
コード例 #11
0
        /// <summary>
        /// Builds a domain containing the names of all the map documents embedded
        /// 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 BuildMapDocumentDomain(IJTXDatabase3 wmxDb)
        {
            IGPCodedValueDomain         mxdNames         = new GPCodedValueDomainClass();
            SortedList <string, string> mapDocumentNames = new SortedList <string, string>();

            IJTXConfiguration3 configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3;
            IJTXMapSet         maps      = configMgr.JTXMaps;

            for (int i = 0; i < maps.Count; i++)
            {
                IJTXMap map = maps.get_Item(i);
                mapDocumentNames.Add(map.Name, null);
            }

            foreach (string mapDocName in mapDocumentNames.Keys)
            {
                mxdNames.AddStringCode(mapDocName, mapDocName);
            }

            return(mxdNames as IGPDomain);
        }
コード例 #12
0
        /// <summary>
        ///     Pre validates the given set of values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities)
        {
            // Retrieve the input parameter value.
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                // Create the domain based on the fields on the table.
                IObjectClass table = utilities.OpenTable(value);
                if (table != null)
                {
                    IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();

                    foreach (var modelName in table.GetClassModelNames())
                    {
                        codedValueDomain.AddStringCode(modelName, modelName);
                    }

                    IGPParameterEdit3 derivedFields = (IGPParameterEdit3)parameters["in_class_model_names"];
                    derivedFields.Domain = (IGPDomain)codedValueDomain;
                }
            }
        }
コード例 #13
0
ファイル: AddFieldModelName.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Pre validates the given set of values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void UpdateParameters(Dictionary<string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities)
        {
            // Retrieve the input parameter value.
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);
            if (!value.IsEmpty())
            {
                // Create the domain based on the fields on the table.
                IDETable table = value as IDETable;
                if (table != null)
                {
                    IFields fields = table.Fields;
                    if (fields != null)
                    {
                        IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();
                        foreach (var field in fields.AsEnumerable())
                            codedValueDomain.AddStringCode(field.Name, field.Name);

                        IGPParameterEdit3 derivedFields = (IGPParameterEdit3) parameters["in_fields"];
                        derivedFields.Domain = (IGPDomain) codedValueDomain;
                    }
                }
            }
        }
        /// <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     jobTypeParam      = paramMap.GetParam(C_PARAM_JOB_TYPE);
            IGPParameterEdit3 jobTypeParamEdit  = paramMap.GetParamEdit(C_PARAM_JOB_TYPE);
            IGPParameter3     dataWorkspace     = paramMap.GetParam(C_PARAM_DATA_WORKSPACE);
            IGPParameterEdit3 dataWorkspaceEdit = paramMap.GetParamEdit(C_PARAM_DATA_WORKSPACE);
            IGPParameter3     parentVersion     = paramMap.GetParam(C_PARAM_PARENT_VERSION);
            IGPParameterEdit3 parentVersionEdit = paramMap.GetParamEdit(C_PARAM_PARENT_VERSION);

            // Set the domains for any parameters that need them
            if (jobTypeParam.Domain == null)
            {
                jobTypeParamEdit.Domain = Common.WmauGpDomainBuilder.BuildJobTypeDomain(this.WmxDatabase);
            }
            if (dataWorkspace.Domain == null)
            {
                dataWorkspaceEdit.Domain = Common.WmauGpDomainBuilder.BuildWorkspaceDomain(
                    this.WmxDatabase,
                    new string[] { C_OPT_NONE });
            }

            // Only update the domain for the parent version field if it hasn't yet been
            // populated, or if the value of the data workspace parameter has changed
            string newDataWorkspace = dataWorkspace.Value.GetAsText();

            if (parentVersion.Domain == null ||
                !m_dataWorkspaceName.Equals(newDataWorkspace))
            {
                IGPDomain    versionDomain = null;
                string       newJobType    = jobTypeParam.Value.GetAsText();
                IJTXJobType3 jobType       = this.WmxDatabase.ConfigurationManager.GetJobType(newJobType) as IJTXJobType3;

                if (newDataWorkspace.Equals(C_OPT_NONE) ||
                    newDataWorkspace.Equals(string.Empty))
                {
                    // Case 1: the only acceptable option for the parent version is "none".
                    IGPCodedValueDomain cvDomain = new GPCodedValueDomainClass();
                    cvDomain.AddStringCode(C_OPT_NONE, C_OPT_NONE);
                    versionDomain = cvDomain as IGPDomain;
                }
                else
                {
                    // Case 2: we need to retrieve the version list for an existing
                    // data workspace
                    try
                    {
                        versionDomain = Common.WmauGpDomainBuilder.BuildVersionsDomain(
                            this.WmxDatabase, newDataWorkspace, new string[] { C_OPT_NONE });
                    }
                    catch (WmauException)
                    {
                        // Use the "null" as an error value; we'll check for this later
                        versionDomain = null;
                    }
                }
                parentVersionEdit.Domain = versionDomain;
            }
        }
コード例 #15
0
        public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                IGPParameter inputOSMParameter = paramvalues.get_Element(in_osmFeatureClassNumber) as IGPParameter;
                IGPValue     inputOSMGPValue   = gpUtilities3.UnpackGPValue(inputOSMParameter);

                if (inputOSMGPValue.IsEmpty() == false)
                {
                    if (inputOSMParameter.Altered == true)
                    {
                        IGPParameter attributeCollectionParameter = paramvalues.get_Element(in_attributeSelectorNumber) as IGPParameter;
                        IGPValue     attributeCollectionGPValue   = gpUtilities3.UnpackGPValue(attributeCollectionParameter);

                        if (inputOSMParameter.HasBeenValidated == false && ((IGPMultiValue)attributeCollectionGPValue).Count == 0)
                        {
                            IFeatureClass osmFeatureClass = null;
                            ITable        osmInputTable   = null;
                            IQueryFilter  osmQueryFilter  = null;

                            try
                            {
                                gpUtilities3.DecodeFeatureLayer(inputOSMGPValue, out osmFeatureClass, out osmQueryFilter);
                                osmInputTable = osmFeatureClass as ITable;
                            }
                            catch { }

                            try
                            {
                                if (osmInputTable == null)
                                {
                                    gpUtilities3.DecodeTableView(inputOSMGPValue, out osmInputTable, out osmQueryFilter);
                                }
                            }
                            catch { }

                            if (osmInputTable == null)
                            {
                                return;
                            }

                            using (ComReleaser comReleaser = new ComReleaser())
                            {
                                ICursor osmCursor = osmInputTable.Search(osmQueryFilter, true);
                                comReleaser.ManageLifetime(osmCursor);

                                IRow          osmRow             = osmCursor.NextRow();
                                List <string> potentialOSMFields = new List <string>();

                                if (osmRow != null)
                                {
                                    IFields osmFields = osmRow.Fields;

                                    for (int fieldIndex = 0; fieldIndex < osmFields.FieldCount; fieldIndex++)
                                    {
                                        if (osmFields.get_Field(fieldIndex).Name.Substring(0, 4).Equals("osm_"))
                                        {
                                            potentialOSMFields.Add(osmFields.get_Field(fieldIndex).Name);
                                        }
                                    }
                                }

                                if (potentialOSMFields.Count == 0)
                                {
                                    return;
                                }

                                IGPCodedValueDomain osmTagKeyCodedValues = new GPCodedValueDomainClass();
                                foreach (string tagOSMField in potentialOSMFields)
                                {
                                    osmTagKeyCodedValues.AddStringCode(tagOSMField, tagOSMField);
                                }

                                ((IGPParameterEdit)attributeCollectionParameter).Domain = (IGPDomain)osmTagKeyCodedValues;
                            }
                        }
                    }
                }
            }
            catch { }
        }
コード例 #16
0
        public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                IGPParameter inputOSMParameter = paramvalues.get_Element(in_osmFeatureClassNumber) as IGPParameter;
                IGPValue inputOSMGPValue = gpUtilities3.UnpackGPValue(inputOSMParameter);

                if (inputOSMGPValue.IsEmpty() == false)
                {
                    if (inputOSMParameter.Altered == true)
                    {

                        IGPParameter attributeCollectionParameter = paramvalues.get_Element(in_attributeSelectorNumber) as IGPParameter;
                        IGPValue attributeCollectionGPValue = gpUtilities3.UnpackGPValue(attributeCollectionParameter);

                        if (inputOSMParameter.HasBeenValidated == false && ((IGPMultiValue)attributeCollectionGPValue).Count == 0)
                        {
                            IFeatureClass osmFeatureClass = null;
                            ITable osmInputTable = null;
                            IQueryFilter osmQueryFilter = null;

                            try
                            {
                                gpUtilities3.DecodeFeatureLayer(inputOSMGPValue, out osmFeatureClass, out osmQueryFilter);
                                osmInputTable = osmFeatureClass as ITable;
                            }
                            catch { }

                            try
                            {
                                if (osmInputTable == null)
                                {
                                    gpUtilities3.DecodeTableView(inputOSMGPValue, out osmInputTable, out osmQueryFilter);
                                }
                            }
                            catch { }

                            if (osmInputTable == null)
                            {
                                return;
                            }

                            using (ComReleaser comReleaser = new ComReleaser())
                            {
                                ICursor osmCursor = osmInputTable.Search(osmQueryFilter, true);
                                comReleaser.ManageLifetime(osmCursor);

                                IRow osmRow = osmCursor.NextRow();
                                List<string> potentialOSMFields = new List<string>();

                                if (osmRow != null)
                                {
                                    IFields osmFields = osmRow.Fields;

                                    for (int fieldIndex = 0; fieldIndex < osmFields.FieldCount; fieldIndex++)
                                    {
                                        if (osmFields.get_Field(fieldIndex).Name.Substring(0, 4).Equals("osm_"))
                                        {
                                            potentialOSMFields.Add(osmFields.get_Field(fieldIndex).Name);
                                        }
                                    }
                                }

                                if (potentialOSMFields.Count == 0)
                                {
                                    return;
                                }

                                IGPCodedValueDomain osmTagKeyCodedValues = new GPCodedValueDomainClass();
                                foreach (string tagOSMField in potentialOSMFields)
                                {
                                    osmTagKeyCodedValues.AddStringCode(tagOSMField, tagOSMField);
                                }

                                ((IGPParameterEdit)attributeCollectionParameter).Domain = (IGPDomain)osmTagKeyCodedValues;

                            }
                        }
                    }
                }
            }
            catch { }
        }