/// <summary>
        ///     Opens the table object specified by the given geoprocessing value object.
        /// </summary>
        /// <param name="utilities">The utilities.</param>
        /// <param name="value">The geoprocessing value object.</param>
        /// <returns>
        ///     Returns a <see cref="IObjectClass" /> representing the table object.
        /// </returns>
        public static IObjectClass OpenTable(this IGPUtilities2 utilities, IGPValue value)
        {
            if (!value.IsEmpty())
            {
                IDataset dataset = utilities.OpenDataset(value);
                if (dataset != null)
                {
                    return(dataset as IObjectClass);
                }
            }

            return(null);
        }
        /// <summary>
        ///     Gets the workspace specified by the given geoprocessing value object.
        /// </summary>
        /// <param name="utilities">The utilities.</param>
        /// <param name="value">The geoprocessing value object.</param>
        /// <returns>
        ///     Returns a <see cref="IWorkspace" /> representing the workspace object.
        /// </returns>
        public static IWorkspace GetWorkspace(this IGPUtilities2 utilities, IGPValue value)
        {
            if (!value.IsEmpty())
            {
                IDataset dataset = utilities.OpenDataset(value);
                if (dataset != null)
                {
                    return(dataset.Workspace);
                }
            }

            return(null);
        }
        /// <summary>
        ///     Opens the relationship class specified by the given geoprocessing value object.
        /// </summary>
        /// <param name="utilities">The utilities.</param>
        /// <param name="value">The geoprocessing value object.</param>
        /// <returns>
        ///     Returns a <see cref="IRelationshipClass" /> representing the table object.
        /// </returns>
        public static IRelationshipClass OpenRelationshipClass(this IGPUtilities2 utilities, IGPValue value)
        {
            if (!value.IsEmpty())
            {
                IDataset dataset = utilities.OpenDataset(value);
                if (dataset != null)
                {
                    return(dataset as IRelationshipClass);
                }
            }

            return(null);
        }
Exemple #4
0
        public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr)
        {
            IGPUtilities2 gpUtil = null;

            try
            {
                gpUtil = new GPUtilitiesClass();

                IGPParameter targetDatasetParameter = paramvalues.get_Element(in_osmFeatureDataset) as IGPParameter;
                IDataElement dataElement            = gpUtil.UnpackGPValue(targetDatasetParameter) as IDataElement;
                string       osmDatasetPath         = dataElement.CatalogPath;

                IGPParameter gppNetworkDataset = paramvalues.get_Element(out_NetworkDataset) as IGPParameter;
                IGPValue     gpvNetworkDataset = gpUtil.UnpackGPValue(gppNetworkDataset);
                string       ndsPath           = gpvNetworkDataset.GetAsText();

                string ndsDir = string.Empty;
                if (!string.IsNullOrEmpty(ndsPath))
                {
                    ndsDir = System.IO.Path.GetDirectoryName(ndsPath);
                }

                if (!ndsDir.Equals(osmDatasetPath))
                {
                    string ndsName = System.IO.Path.GetFileName(ndsPath);
                    if (string.IsNullOrEmpty(ndsName))
                    {
                        ndsName = _defaultNetworkDatasetName;
                    }

                    ndsName = System.IO.Path.GetFileName(osmDatasetPath) + "_" + ndsName;
                    gpvNetworkDataset.SetAsText(System.IO.Path.Combine(osmDatasetPath, ndsName));
                    gpUtil.PackGPValue(gpvNetworkDataset, gppNetworkDataset);
                }
            }
            finally
            {
                if (gpUtil != null)
                {
                    ComReleaser.ReleaseCOMObject(gpUtil);
                }
            }
        }
        /// <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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IRelationshipClass relClass = utilities.OpenRelationshipClass(value);
                if (relClass != null)
                {
                    IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                    configTopLevel.Workspace = utilities.GetWorkspace(value);

                    var values = configTopLevel.GetAutoValues(relClass, mmEditEvent.mmEventRelationshipCreated);
                    IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_create"];
                    parameter.Domain = base.CreateDomain <IMMRelationshipAUStrategy>(values);

                    values           = configTopLevel.GetAutoValues(relClass, mmEditEvent.mmEventRelationshipDeleted);
                    parameter        = (IGPParameterEdit3)parameters["in_delete"];
                    parameter.Domain = base.CreateDomain <IMMRelationshipAUStrategy>(values);
                }
            }
        }
Exemple #6
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IObjectClass  table      = utilities.OpenTable(parameters["in_table"]);
            IGPMultiValue modelNames = (IGPMultiValue)parameters["in_class_model_names"];

            if (modelNames.Count > 0)
            {
                foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText()))
                {
                    messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} class model name.", modelName);

                    ModelNameManager.Instance.RemoveClassModelName(table, modelName);
                }

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #7
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;
                }
            }
        }
Exemple #8
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPMultiValue tables     = (IGPMultiValue)parameters["in_tables"];
            IGPMultiValue modelNames = (IGPMultiValue)parameters["in_class_model_names"];
            int           addedCount = 0;

            if (tables.Count > 0 && modelNames.Count > 0)
            {
                foreach (var table in tables.AsEnumerable())
                {
                    IObjectClass dataElement = utilities.OpenTable(table);

                    foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText()))
                    {
                        messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Adding the {0} class model name to the {1} table.", modelName, dataElement.AliasName);

                        ModelNameManager.Instance.AddClassModelName(dataElement, modelName);
                        addedCount++;
                    }
                }
            }

            if (addedCount == tables.Count)
            {
                // Success
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #9
0
 /// <summary>
 ///     Executes the geoprocessing function using the given array of parameter values.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
 /// <param name="messages">The messages that are reported to the user.</param>
 /// <param name="utilities">
 ///     The utilities object that provides access to the properties and methods of a geoprocessing
 ///     objects.
 /// </param>
 protected abstract void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities);
Exemple #10
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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IRelationshipClass relClass = utilities.OpenRelationshipClass(value);
                if (relClass != null)
                {
                    var components = this.LoadComponents <IMMRelationshipAUStrategy>(RelationshipAutoupdateStrategy.CatID);

                    IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_create"];
                    parameter.Domain = base.CreateDomain(components, o => o.Enabled[relClass, mmEditEvent.mmEventRelationshipCreated]);

                    parameter        = (IGPParameterEdit3)parameters["in_delete"];
                    parameter.Domain = base.CreateDomain(components, o => o.Enabled[relClass, mmEditEvent.mmEventRelationshipDeleted]);
                }
            }
        }
Exemple #11
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.
                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;
                    }
                }
            }
        }
Exemple #12
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPValue     value = parameters["in_table"];
            IObjectClass table = utilities.OpenTable(value);

            if (table != null)
            {
                IGPMultiValue onCreate = (IGPMultiValue)parameters["in_create"];
                IGPMultiValue onUpdate = (IGPMultiValue)parameters["in_update"];
                IGPMultiValue onDelete = (IGPMultiValue)parameters["in_delete"];

                IGPMultiValue onBeforeSplit = (IGPMultiValue)parameters["in_before"];
                IGPMultiValue onSplit       = (IGPMultiValue)parameters["in_split"];
                IGPMultiValue onAfterSplit  = (IGPMultiValue)parameters["in_after"];

                // Load "Special" AUs.
                var uids = new Dictionary <mmEditEvent, IEnumerable <IUID> >();
                uids.Add(mmEditEvent.mmEventFeatureCreate, onCreate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventFeatureUpdate, onUpdate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventFeatureDelete, onDelete.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventBeforeFeatureSplit, onBeforeSplit.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventFeatureSplit, onSplit.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventAfterFeatureSplit, onAfterSplit.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));

                IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                configTopLevel.Workspace = utilities.GetWorkspace(value);

                // Load all of the subtypes when the user specified "All" or "-1".
                int subtype      = parameters["in_subtype"].Cast(-1);
                var subtypeCodes = new List <int>(new[] { subtype });
                if (subtype == -1)
                {
                    ISubtypes subtypes = (ISubtypes)table;
                    subtypeCodes.AddRange(subtypes.Subtypes.AsEnumerable().Select(o => o.Key));
                }

                // Enumerate through all of the subtypes making changes.
                foreach (var subtypeCode in subtypeCodes)
                {
                    // Load the configurations for the table and subtype.
                    ID8List list = (ID8List)configTopLevel.GetSubtypeByID(table, subtypeCode, false);

                    // Update the list to have these UIDs removed.
                    this.Add(uids, list, messages);
                }

                // Commit the changes to the database.
                configTopLevel.SaveFeatureClassToDB(table);

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #13
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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IObjectClass table = utilities.OpenTable(value);
                if (table != null)
                {
                    IGPParameterEdit3 subtypeParameter = (IGPParameterEdit3)parameters["in_subtype"];
                    subtypeParameter.Domain = this.GetSubtypes(table);

                    var components = this.LoadComponents <IMMSpecialAUStrategyEx>(SpecialAutoUpdateStrategy.CatID);

                    IGPParameterEdit3 prameter = (IGPParameterEdit3)parameters["in_create"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventFeatureCreate]);

                    // Load the "OnUpdate" components for table.
                    prameter        = (IGPParameterEdit3)parameters["in_update"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventFeatureUpdate]);

                    // Load the "OnDelete" components for table.
                    prameter        = (IGPParameterEdit3)parameters["in_delete"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventFeatureDelete]);

                    // Load the "OnBeforeSplit" components for table.
                    prameter        = (IGPParameterEdit3)parameters["in_before"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventBeforeFeatureSplit]);

                    // Load the "OnSplit" components for table.
                    prameter        = (IGPParameterEdit3)parameters["in_split"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventFeatureSplit]);

                    // Load the "OnAfterSplit" components for table.
                    prameter        = (IGPParameterEdit3)parameters["in_after"];
                    prameter.Domain = base.CreateDomain(components, o => o.Enabled[table, mmEditEvent.mmEventAfterFeatureSplit]);
                }
            }
        }
Exemple #14
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 virtual void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities)
 {
 }
Exemple #15
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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IObjectClass table = utilities.OpenTable(value);
                if (table != null)
                {
                    IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_field"];
                    parameter.Domain = base.GetFields(table);

                    parameter        = (IGPParameterEdit3)parameters["in_subtype"];
                    parameter.Domain = base.GetSubtypes(table);
                }
            }
        }
Exemple #16
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;
                    }
                }
            }
        }
Exemple #17
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPValue     value = parameters["in_table"];
            IObjectClass table = utilities.OpenTable(value);

            if (table != null)
            {
                IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                configTopLevel.Workspace = utilities.GetWorkspace(value);

                // Load all of the subtypes when the user specified "All" or "-1".
                int subtype      = parameters["in_subtype"].Cast(-1);
                var subtypeCodes = new List <int>(new[] { subtype });
                if (subtype == -1)
                {
                    ISubtypes subtypes = (ISubtypes)table;
                    subtypeCodes.AddRange(subtypes.Subtypes.AsEnumerable().Select(o => o.Key));
                }

                var actions = ((IGPMultiValue)parameters["in_actions"]).AsEnumerable().Select(o => o.GetAsText());
                var values  = ((IGPAutoValue)parameters["in_value"]).UID;
                var uids    = new Dictionary <mmEditEvent, IEnumerable <IUID> >();

                IGPMultiValue fields     = (IGPMultiValue)parameters["in_field"];
                var           fieldNames = fields.AsEnumerable().Select(o => o.GetAsText());
                var           indexes    = table.Fields.ToDictionary(o => fieldNames.Contains(o.Name)).Select(o => o.Value);
                foreach (var index in indexes)
                {
                    // Enumerate through all of the subtypes making changes.
                    foreach (var subtypeCode in subtypeCodes)
                    {
                        // Load the configurations for the table and subtype.
                        IMMSubtype mmsubtype = configTopLevel.GetSubtypeByID(table, subtypeCode, false);

                        // Load the field configurations.
                        IMMField mmfield = null;
                        mmsubtype.GetField(index, ref mmfield);

                        // Update the list to have these UIDs removed.
                        ID8List list = (ID8List)mmfield;
                        base.Add(uids, list, messages);
                    }
                }

                // Commit the changes to the database.
                configTopLevel.SaveFeatureClassToDB(table);

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #18
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPValue      field      = parameters["in_field"];
            IObjectClass  table      = utilities.OpenTable(parameters["in_table"]);
            IGPMultiValue modelNames = (IGPMultiValue)parameters["in_field_model_names"];

            if (!field.IsEmpty() && modelNames.Count > 0)
            {
                var fieldName = field.GetAsText();
                int index     = table.FindField(fieldName);

                foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText()))
                {
                    messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} field model name from the {1} field.", modelName, fieldName);

                    ModelNameManager.Instance.RemoveFieldModelName(table, table.Fields.Field[index], modelName);
                }

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #19
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPValue           value    = parameters["in_table"];
            IRelationshipClass relClass = utilities.OpenRelationshipClass(value);

            if (relClass != null)
            {
                IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                configTopLevel.Workspace = utilities.GetWorkspace(value);

                IGPMultiValue onCreate = (IGPMultiValue)parameters["in_create"];
                IGPMultiValue onDelete = (IGPMultiValue)parameters["in_delete"];

                var uids = new Dictionary <mmEditEvent, IEnumerable <IUID> >();
                uids.Add(mmEditEvent.mmEventRelationshipCreated, onCreate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventRelationshipDeleted, onDelete.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));

                // Update the list to have these UIDs.
                ID8List list = (ID8List)configTopLevel.GetRelationshipClass(relClass);
                base.Add(uids, list, messages);

                // Commit the changes to the database.
                configTopLevel.SaveRelationshipClasstoDB(relClass);

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Exemple #20
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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IObjectClass table = utilities.OpenTable(value);
                if (table != null)
                {
                    IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_field"];
                    parameter.Domain = base.GetFields(table);
                    string fieldName = utilities.UnpackGPValue(parameter).GetAsText();

                    parameter        = (IGPParameterEdit3)parameters["in_subtype"];
                    parameter.Domain = base.GetSubtypes(table);

                    IGPValue subtype = utilities.UnpackGPValue(parameter);
                    if (!subtype.IsEmpty())
                    {
                        if (!string.IsNullOrEmpty(fieldName))
                        {
                            var subtypeCode = subtype.Cast(-1);
                            IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                            configTopLevel.Workspace = utilities.GetWorkspace(value);

                            var values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureCreate, fieldName);
                            parameter        = (IGPParameterEdit3)parameters["in_create"];
                            parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]);

                            values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureUpdate, fieldName);
                            parameter        = (IGPParameterEdit3)parameters["in_update"];
                            parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]);

                            values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureDelete, fieldName);
                            parameter        = (IGPParameterEdit3)parameters["in_delete"];
                            parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]);
                        }
                    }
                }
            }
        }
Exemple #21
0
        public void Execute(IArray paramvalues, ITrackCancel TrackCancel, IGPEnvironmentManager envMgr, IGPMessages message)
        {
            IAoInitialize     aoInitialize = new AoInitializeClass();
            esriLicenseStatus naStatus     = esriLicenseStatus.esriLicenseUnavailable;

            IGPUtilities2 gpUtil     = null;
            IDataset      osmDataset = null;

            try
            {
                if (!aoInitialize.IsExtensionCheckedOut(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork))
                {
                    naStatus = aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);
                }

                gpUtil = new GPUtilitiesClass();

                // OSM Dataset Param
                IGPParameter osmDatasetParam = paramvalues.get_Element(in_osmFeatureDataset) as IGPParameter;
                IDEDataset2  osmDEDataset    = gpUtil.UnpackGPValue(osmDatasetParam) as IDEDataset2;
                if (osmDEDataset == null)
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), osmDatasetParam.Name));
                    return;
                }

                osmDataset = gpUtil.OpenDatasetFromLocation(((IDataElement)osmDEDataset).CatalogPath) as IDataset;

                // Network Config File Param
                IGPParameter osmNetConfigParam = paramvalues.get_Element(in_NetworkConfigurationFile) as IGPParameter;
                IGPValue     osmNetConfigFile  = gpUtil.UnpackGPValue(osmNetConfigParam) as IGPValue;
                if ((osmNetConfigFile == null) || (string.IsNullOrEmpty(osmNetConfigFile.GetAsText())))
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), osmNetConfigParam.Name));
                    return;
                }

                // Target Network Dataset Param
                IGPParameter ndsParam = paramvalues.get_Element(out_NetworkDataset) as IGPParameter;
                IDataElement deNDS    = gpUtil.UnpackGPValue(ndsParam) as IDataElement;
                if (deNDS == null)
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), ndsParam.Name));
                    return;
                }

                // Create Network Dataset
                using (NetworkDataset nd = new NetworkDataset(osmNetConfigFile.GetAsText(), osmDataset, deNDS.Name, message, TrackCancel))
                {
                    if (nd.CanCreateNetworkDataset())
                    {
                        nd.CreateNetworkDataset();
                    }
                }
            }
            catch (UserCancelException ex)
            {
                message.AddWarning(ex.Message);
            }
            catch (Exception ex)
            {
                message.AddError(120008, ex.Message);
#if DEBUG
                message.AddError(120008, ex.StackTrace);
#endif
            }
            finally
            {
                if (osmDataset != null)
                {
                    ComReleaser.ReleaseCOMObject(osmDataset);
                }

                if (naStatus == esriLicenseStatus.esriLicenseCheckedOut)
                {
                    aoInitialize.CheckInExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);
                }

                if (gpUtil != null)
                {
                    ComReleaser.ReleaseCOMObject(gpUtil);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Exemple #22
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)
        {
            IGPValue value = utilities.UnpackGPValue(parameters["in_table"]);

            if (!value.IsEmpty())
            {
                IObjectClass table = utilities.OpenTable(value);
                if (table != null)
                {
                    // Populate the subtype parameter with the subtypes from the table and ensure the it's editable.
                    IGPParameterEdit3 subtypeParameter = (IGPParameterEdit3)parameters["in_subtype"];
                    subtypeParameter.Domain = this.GetSubtypes(table);

                    // Populate the auto updater values for the object class for the specific subtype.
                    IGPValue subtype = utilities.UnpackGPValue(subtypeParameter);
                    if (!subtype.IsEmpty())
                    {
                        var subtypeCode = subtype.Cast(-1);
                        IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                        configTopLevel.Workspace = utilities.GetWorkspace(value);

                        var values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureCreate);
                        IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_create"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);

                        values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureUpdate);
                        parameter        = (IGPParameterEdit3)parameters["in_update"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);

                        values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureDelete);
                        parameter        = (IGPParameterEdit3)parameters["in_delete"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);

                        values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventBeforeFeatureSplit);
                        parameter        = (IGPParameterEdit3)parameters["in_before"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);

                        values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureSplit);
                        parameter        = (IGPParameterEdit3)parameters["in_split"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);

                        values           = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventAfterFeatureSplit);
                        parameter        = (IGPParameterEdit3)parameters["in_after"];
                        parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]);
                    }
                }
            }
        }