当前位置: 首页>>代码示例>>C#>>正文


C# ESRI.ReplaceError方法代码示例

本文整理汇总了C#中ESRI.ReplaceError方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.ReplaceError方法的具体用法?C# ESRI.ReplaceError怎么用?C# ESRI.ReplaceError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ESRI的用法示例。


在下文中一共展示了ESRI.ReplaceError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            // check for a valid download url
            IGPParameter downloadURLParameter = paramvalues.get_Element(in_downloadURLNumber) as IGPParameter;

            if (downloadURLParameter.HasBeenValidated == false)
            {
                IGPString downloadURLGPString = downloadURLParameter.Value as IGPString;


                if (downloadURLGPString != null)
                {
                    if (String.IsNullOrEmpty(downloadURLGPString.Value) == false)
                    {
                        try
                        {
                            Uri downloadURI = new Uri(downloadURLGPString.Value);


                            // attempt a download request from the given URL to get the server capabilities
                            m_osmAPICapabilities = CheckValidServerURL(downloadURLGPString.Value);

                            // if we can construct a valid URI  class then we are accepting the value and store it in the user settings as well
                            if (m_editorConfigurationSettings != null)
                            {
                                if (m_editorConfigurationSettings.ContainsKey("osmbaseurl"))
                                {
                                    m_editorConfigurationSettings["osmbaseurl"] = downloadURLGPString.Value;
                                }
                                else
                                {
                                    m_editorConfigurationSettings.Add("osmbaseurl", downloadURLGPString.Value);
                                }

                                OSMGPFactory.StoreOSMEditorSettings(m_editorConfigurationSettings);
                            }
                        }
                        catch (Exception ex)
                        {
                            StringBuilder errorMessage = new StringBuilder();
                            errorMessage.AppendLine(resourceManager.GetString("GPTools_OSMGPDownload_invaliddownloadurl"));
                            errorMessage.AppendLine(ex.Message);
                            Messages.ReplaceError(in_downloadURLNumber, -3, errorMessage.ToString());
                            m_osmAPICapabilities = null;
                        }
                    }
                }
            }


            if (m_osmAPICapabilities == null)
            {
                return;
            }

            // check for extent
            IGPParameter downloadExtentParameter = paramvalues.get_Element(in_downloadExtentNumber) as IGPParameter;

            if (downloadExtentParameter.HasBeenValidated == false)
            {
                IGPValue downloadExtent = gpUtilities3.UnpackGPValue(downloadExtentParameter);

                if (downloadExtent != null)
                {
                    esriGPExtentEnum gpExtent;
                    IEnvelope downloadEnvelope = gpUtilities3.GetExtent(downloadExtent, out gpExtent);

                    if (downloadEnvelope == null)
                        return;

                    if (downloadEnvelope.IsEmpty == true)
                        return;

                    ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass() as ISpatialReferenceFactory;
                    ISpatialReference wgs84 = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984) as ISpatialReference;

                    downloadEnvelope.Project(wgs84);

                    Marshal.ReleaseComObject(wgs84);
                    Marshal.ReleaseComObject(spatialReferenceFactory);

                    IArea downloadArea = downloadEnvelope as IArea;
                    double maximumAcceptableOSMArea = Convert.ToDouble(m_osmAPICapabilities.area.maximum, new CultureInfo("en-US"));

                    if (downloadArea.Area > maximumAcceptableOSMArea)
                    {
                        Messages.ReplaceError(in_downloadExtentNumber, -3, resourceManager.GetString("GPTools_OSMGPDownload_exceedDownloadROI"));
                    }
                }
            }

            // check for valid geodatabase path
            // if the user is pointing to a valid directory on disk, flag it as an error
            IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter;
            IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter);

            if (targetDatasetGPValue == null)
            {
//.........这里部分代码省略.........
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPDownload.cs

示例2: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            // check for a valid download url
            IGPParameter uploadURLParameter = paramvalues.get_Element(in_uploadURLNumber) as IGPParameter;
            IGPString uploadURLGPString = uploadURLParameter.Value as IGPString;

            if (uploadURLGPString == null)
            {
                Messages.ReplaceError(in_uploadURLNumber, -198, String.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), uploadURLParameter.Value.GetAsText()));
            }
            else
            {
                try
                {
                    if (uploadURLParameter.HasBeenValidated == false)
                    {
                        Uri downloadURI = new Uri(uploadURLGPString.Value);

                        // check base url
                        api osmAPICapabilities = OSMGPDownload.CheckValidServerURL(uploadURLGPString.Value);

                        // if we can construct a valid URI  class then we are accepting the value and store it in the user settings as well
                        if (m_editorConfigurationSettings != null)
                        {
                            if (m_editorConfigurationSettings.ContainsKey("osmbaseurl"))
                            {
                                m_editorConfigurationSettings["osmbaseurl"] = uploadURLGPString.Value;
                            }
                            else
                            {
                                m_editorConfigurationSettings.Add("osmbaseurl", uploadURLGPString.Value);
                            }

                            OSMGPFactory.StoreOSMEditorSettings(m_editorConfigurationSettings);
                        }
                    }
                }
                catch (Exception ex)
                {
                    StringBuilder errorMessage = new StringBuilder();
                    errorMessage.AppendLine(resourceManager.GetString("GPTools_OSMGPUpload_invaliduploadurl"));
                    errorMessage.AppendLine(ex.Message);
                    Messages.ReplaceError(in_uploadURLNumber, -3, errorMessage.ToString());
                }
            }

            IGPParameter revisionTableParameter = paramvalues.get_Element(in_changesTablesNumber) as IGPParameter;
            IGPValue revisionTableGPValue = gpUtilities3.UnpackGPValue(revisionTableParameter);

            if (revisionTableGPValue.IsEmpty())
                return;

            ITable revisionTable = null;
            IQueryFilter revisionTableQueryFilter = null;

            try
            {
                using (ComReleaser comReleaser = new ComReleaser())
                {
                    gpUtilities3.DecodeTableView(revisionTableGPValue, out revisionTable, out revisionTableQueryFilter);
                    comReleaser.ManageLifetime(revisionTable);

                    if (revisionTable is IFeatureClass)
                    {
                        Messages.ReplaceError(in_changesTablesNumber, -4, resourceManager.GetString("GPTools_OSMGPUpload_notarevisiontable"));
                        return;
                    }

                    IDatasetEdit datasetEdit = revisionTable as IDatasetEdit;
                    comReleaser.ManageLifetime(datasetEdit);

                    if (datasetEdit == null)
                    {
                        return;
                    }

                    if (datasetEdit.IsBeingEdited())
                    {
                        Messages.ReplaceError(in_changesTablesNumber, -4, resourceManager.GetString("GPTools_OSMGPUpload_inputnotvalidduringedit"));
                    }
                }

                gpUtilities3.ReleaseInternals();
            }
            catch
            {
                // check if we are dealing with a variable -- if we do then leave this string alone
                string tableName = revisionTableGPValue.GetAsText();
                string tableNameModified = tableName.Replace("%", String.Empty);

                if (((tableName.Length - tableNameModified.Length) % 2) == 0)
                {
                    Messages.Replace(in_changesTablesNumber, new GPMessageClass());
                }
            }
        }
开发者ID:weepingdog,项目名称:arcgis-osm-editor,代码行数:98,代码来源:OSMGPUpload.cs

示例3: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter;
            try
            {
                gpUtilities3.QualifyOutputDataElement(gpUtilities3.UnpackGPValue(targetDatasetParameter));
            }
            catch
            {
                Messages.ReplaceError(out_targetDatasetNumber, -2, resourceManager.GetString("GPTools_OSMGPFileReader_targetDataset_notexist"));
            }

            // check for valid geodatabase path
            // if the user is pointing to a valid directory on disk, flag it as an error
            IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter);

            if (targetDatasetGPValue.IsEmpty() == false)
            {
                if (System.IO.Directory.Exists(targetDatasetGPValue.GetAsText()))
                {
                    Messages.ReplaceError(out_targetDatasetNumber, -4, resourceManager.GetString("GPTools_OSMGPDownload_directory_is_not_target_dataset"));
                }
            }

            // check one of the output feature classes for version compatibility
            IGPParameter pointFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter;
            IDEFeatureClass pointDEFeatureClass = gpUtilities3.UnpackGPValue(pointFeatureClassParameter) as IDEFeatureClass;

            if (pointDEFeatureClass != null)
            {
                if (((IGPValue)pointDEFeatureClass).IsEmpty() == false)
                {
                    if (gpUtilities3.Exists((IGPValue)pointDEFeatureClass))
                    {
                        IFeatureClass ptfc = gpUtilities3.Open(gpUtilities3.UnpackGPValue(pointFeatureClassParameter)) as IFeatureClass;
                        IPropertySet osmExtensionPropertySet = ptfc.ExtensionProperties;

                        if (osmExtensionPropertySet == null)
                        {
                            Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                        }
                        else
                        {
                            try
                            {
                                int extensionVersion = Convert.ToInt32(osmExtensionPropertySet.GetProperty("VERSION"));

                                if (extensionVersion != OSMClassExtensionManager.Version)
                                {
                                    Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                }
                            }
                            catch
                            {
                                Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            }
                        }
                    }
                }
            }

            gpUtilities3.ReleaseInternals();

            if (gpUtilities3 != null)
                ComReleaser.ReleaseCOMObject(gpUtilities3);

        }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:78,代码来源:OSMGPFileLoader.cs

示例4: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 execute_Utilities = new GPUtilitiesClass();
            IGPValue inputFeatureDatasetGPValue = execute_Utilities.UnpackGPValue(paramvalues.get_Element(in_featureDatasetParameterNumber));

            // get the name of the feature dataset
            int fdDemlimiterPosition = inputFeatureDatasetGPValue.GetAsText().LastIndexOf("\\");

            if (fdDemlimiterPosition == -1)
            {
                Messages.ReplaceError(in_featureDatasetParameterNumber, -33, resourceManager.GetString("GPTools_OSMGPExport2OSM_invalid_featuredataset"));
            }
        }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:13,代码来源:OSMGPExport2OSM.cs

示例5: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter inputFCParameter = paramvalues.get_Element(in_osmFeaturesNumber) as IGPParameter;
            IGPValue osmFCGPValue = gpUtilities3.UnpackGPValue(inputFCParameter);

            if (osmFCGPValue.IsEmpty())
            {
                return;
            }

            IFeatureClass osmFeatureClass = null;
            IQueryFilter queryFilter = null;

            if (osmFCGPValue is IGPFeatureLayer)
            {
                gpUtilities3.DecodeFeatureLayer(osmFCGPValue, out osmFeatureClass, out queryFilter);

                int osmTagFieldIndex = osmFeatureClass.Fields.FindField("osmTags");

                if (osmTagFieldIndex == -1)
                {
                    Messages.ReplaceError(in_osmFeaturesNumber, -1, resourceManager.GetString("GPTools_OSMGPAddExtension_noosmtagfield"));
                }
            }

        }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:28,代码来源:OSMGPAddExtension.cs

示例6: UpdateMessages

        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter inputFCParameter = paramvalues.get_Element(in_osmFeaturesNumber) as IGPParameter;
            IGPValue osmFCGPValue = gpUtilities3.UnpackGPValue(inputFCParameter);

            if (osmFCGPValue.IsEmpty())
            {
                return;
            }

            IFeatureClass osmFeatureClass = null;
            IQueryFilter queryFilter = null;

            if (osmFCGPValue is IGPFeatureLayer)
            {
                gpUtilities3.DecodeFeatureLayer(osmFCGPValue, out osmFeatureClass, out queryFilter);

                if (osmFeatureClass.EXTCLSID != null)
                {
                    UID osmEditorExtensionCLSID = osmFeatureClass.EXTCLSID;

                    if (osmEditorExtensionCLSID.Value.ToString().Equals("{65CA4847-8661-45eb-8E1E-B2985CA17C78}", StringComparison.InvariantCultureIgnoreCase) == false)
                    {
                        Messages.ReplaceError(in_osmFeaturesNumber, -1, resourceManager.GetString("GPTools_OSMGPRemoveExtension_noEXTCLSID")); 
                    }
                }
                else
                {
                    Messages.ReplaceError(in_osmFeaturesNumber, -1, resourceManager.GetString("GPTools_OSMGPRemoveExtension_noEXTCLSID"));
                }
            }

        }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:35,代码来源:OSMGPRemoveExtension.cs


注:本文中的ESRI.ReplaceError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。