public ServicePropertyEditor(MSCFeatureService fs)
        {
            this.mscFeatureService = fs;
            AGSFeatureService parentService = fs.ParentService;

            if (parentService == null)
            {
                throw new Exception("Service not connected");
            }
            this.InitializeComponent();
            if (parentService == null)
            {
                return;
            }
            this.localFeatureService = (AGSFeatureService)Utility.CloneObject(parentService);
            this.localFeatureService.ExportOptions         = (AGSExportOptions)Utility.CloneObject(fs.ExportOptions);
            this.localFeatureService.ExportOptions.Dynamic = !this.mscFeatureService.QueryOnly;
            AGSFeatureServiceLayer aGSFeatureServiceLayer = (AGSFeatureServiceLayer)parentService.MapLayers[fs.ServiceLayerID];

            if (aGSFeatureServiceLayer != null)
            {
                this.spProps.SetService(aGSFeatureServiceLayer, fs.ExportOptions);
            }
            else
            {
                this.spProps.SetService(this.localFeatureService, fs.ExportOptions);
            }
            this.spProps.ExtentOptions.Add(AfaStrings.Current, fs.ExportOptions.BoundingBox);
            this.spProps.cbBoundingBoxTypes.SelectedIndex = this.spProps.ExtentOptions.Count - 1;
        }
Example #2
0
 public void SetService(object o)
 {
     try
     {
         if (!object.Equals(o, this.ThisService))
         {
             this.ThisService = o;
             this.exServiceInfo.Visibility = Visibility.Collapsed;
             this.exExportProps.Visibility = Visibility.Collapsed;
             bool dynamic = true;
             if (this.ExportOptions != null)
             {
                 dynamic = this.ExportOptions.Dynamic;
             }
             if (o != this.lbServiceInfo.ItemsSource)
             {
                 AGSObject aGSObject = o as AGSObject;
                 if (aGSObject != null)
                 {
                     this.IgnoreTextBoxChange       = true;
                     this.lbServiceInfo.ItemsSource = aGSObject.Properties;
                     string text = "";
                     if (this.cbBoundingBoxTypes.SelectedItem != null)
                     {
                         text = this.cbBoundingBoxTypes.SelectedItem.ToString();
                     }
                     this.ExtentOptions = this.BuildExtentOptions(aGSObject);
                     this.cbBoundingBoxTypes.ItemsSource = this.ExtentOptions.Keys;
                     Extent obj;
                     if (this.ExtentOptions.TryGetValue(text, out obj))
                     {
                         this.cbBoundingBoxTypes.SelectedValue = text;
                         this.ctrlBoundingBoxExtent.Content    = Utility.CloneObject(obj);
                     }
                     else
                     {
                         this.cbBoundingBoxTypes.SelectedIndex = 0;
                         this.ctrlBoundingBoxExtent.Content    = Utility.CloneObject(this.ExtentOptions.Values.ElementAt(0));
                     }
                     this.IgnoreTextBoxChange = false;
                 }
                 AGSLayer aGSLayer = o as AGSLayer;
                 if (aGSLayer != null)
                 {
                     this.IgnoreTextBoxChange       = true;
                     this.lbServiceInfo.ItemsSource = aGSLayer.Properties;
                     this.exServiceInfo.Visibility  = Visibility.Visible;
                     string text2 = "";
                     if (this.cbBoundingBoxTypes.SelectedItem != null)
                     {
                         text2 = this.cbBoundingBoxTypes.SelectedItem.ToString();
                     }
                     this.ExtentOptions = this.BuildExtentOptions(aGSLayer.Service);
                     this.cbBoundingBoxTypes.ItemsSource = this.ExtentOptions.Keys;
                     Extent obj2;
                     if (this.ExtentOptions.TryGetValue(text2, out obj2))
                     {
                         this.cbBoundingBoxTypes.SelectedValue = text2;
                         this.ctrlBoundingBoxExtent.Content    = Utility.CloneObject(obj2);
                     }
                     else
                     {
                         this.cbBoundingBoxTypes.SelectedIndex = 0;
                         this.ctrlBoundingBoxExtent.Content    = Utility.CloneObject(this.ExtentOptions.Values.ElementAt(0));
                     }
                     this.IgnoreTextBoxChange      = false;
                     this.exExportProps.Visibility = Visibility.Visible;
                     this.ctrlExportProps.Content  = aGSLayer;
                     this.ExportOptions            = aGSLayer.Service.ExportOptions;
                     this.ExportOptions.Dynamic    = dynamic;
                 }
                 else
                 {
                     AGSFeatureServiceLayer aGSFeatureServiceLayer = o as AGSFeatureServiceLayer;
                     if (aGSFeatureServiceLayer == null)
                     {
                         AGSFeatureService aGSFeatureService = o as AGSFeatureService;
                         if (aGSFeatureService != null)
                         {
                             this.lbServiceInfo.ItemsSource = aGSFeatureService.Properties;
                             this.exServiceInfo.Visibility  = Visibility.Visible;
                             this.exExportProps.Visibility  = Visibility.Visible;
                             this.ctrlExportProps.Content   = aGSFeatureService;
                             this.ExportOptions             = aGSFeatureService.ExportOptions;
                             this.ExportOptions.Dynamic     = dynamic;
                         }
                         AGSService aGSService = o as AGSService;
                         if (aGSService != null)
                         {
                             this.lbServiceInfo.ItemsSource = aGSService.Properties;
                             this.exServiceInfo.Visibility  = Visibility.Visible;
                             this.exExportProps.Visibility  = Visibility.Visible;
                             this.ctrlExportProps.Content   = aGSService;
                             this.ExportOptions             = aGSService.ExportOptions;
                             this.ExportOptions.Dynamic     = dynamic;
                         }
                         AGSImageService aGSImageService = o as AGSImageService;
                         if (aGSImageService != null)
                         {
                             foreach (AGSField current in aGSImageService.Fields.Values)
                             {
                                 if (!(current.Type == "esriFieldTypeOID") && !(current.Type == "esriFieldTypeGeometry"))
                                 {
                                     this.OrderFieldChoices.Add(current.Name);
                                 }
                             }
                             string version = aGSImageService.Version;
                             if (version.StartsWith("9"))
                             {
                                 this.LimitedImageSupport = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("In Catch of SetService");
     }
 }
Example #3
0
        private bool PopulateChildren(IDictionary <string, object> results)
        {
            if (results == null)
            {
                return(false);
            }
            if (this.Parent.ReportCheckCancel())
            {
                this.EmptyChildren();
                return(true);
            }
            bool result;

            try
            {
                if (results.ContainsKey("services"))
                {
                    string text = "";
                    IEnumerable <object> enumerable = results["services"] as IEnumerable <object>;
                    using (IEnumerator <object> enumerator = enumerable.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            IDictionary <string, object> dictionary = (IDictionary <string, object>)enumerator.Current;
                            if (this.Parent.ReportCheckCancel())
                            {
                                this.EmptyChildren();
                                result = true;
                                return(result);
                            }
                            if (dictionary.ContainsKey("url"))
                            {
                                text = AGSFolder.RestToSoapURL(dictionary["url"] as string);
                            }
                            if (dictionary.ContainsKey("name"))
                            {
                                string text2    = dictionary["name"] as string;
                                string fileName = Path.GetFileName(text2);
                                this.Parent.ReportExportStatus(AfaStrings.ReadingServiceDetailsFrom + fileName);
                                IAGSService iAGSService = null;
                                try
                                {
                                    string a = dictionary["type"] as string;
                                    if (a == "MapServer")
                                    {
                                        iAGSService = new AGSMapService(text2, text, this.Parent);
                                    }
                                    else if (a == "FeatureServer")
                                    {
                                        iAGSService = new AGSFeatureService(text2, text, this.Parent);
                                    }
                                    else if (a == "ImageServer")
                                    {
                                        iAGSService = new AGSImageService(text2, this.Parent);
                                    }
                                    else if (a == "GeometryServer")
                                    {
                                        if (string.IsNullOrEmpty(text))
                                        {
                                            text = this.Parent.Soap_URL + "/" + text2 + "/GeometryServer";
                                        }
                                        this.Parent.GeometryService = new AGSGeometryServer(this.Parent, text);
                                    }
                                }
                                catch
                                {
                                    iAGSService = null;
                                }
                                if (iAGSService != null)
                                {
                                    this.Children.Add(iAGSService);
                                }
                            }
                        }
                    }
                }
                if (results.ContainsKey("folders"))
                {
                    IEnumerable <object> enumerable2 = results["folders"] as IEnumerable <object>;
                    using (IEnumerator <object> enumerator2 = enumerable2.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            string     text3      = (string)enumerator2.Current;
                            string     uRL        = this.URL + "/" + text3;
                            IAGSFolder iAGSFolder = new AGSFolder(text3, uRL, this.Parent);
                            this.Parent.ReportExportStatus(AfaStrings.ReadingServicesInFolder + text3);
                            if (this.Parent.ReportCheckCancel())
                            {
                                this.EmptyChildren();
                                result = true;
                                return(result);
                            }
                            iAGSFolder.LoadChildren();
                            if (this.Parent.ReportCheckCancel())
                            {
                                this.EmptyChildren();
                                result = true;
                                return(result);
                            }
                            this.Children.Add(iAGSFolder);
                        }
                    }
                }
                result = true;
            }
            catch (SystemException)
            {
                this.EmptyChildren();
                result = false;
            }
            return(result);
        }
        public object ESRI_AddFeatureService(ResultBuffer rb)
        {
            if (null == Application.DocumentManager.MdiActiveDocument)
            {
                return(null);
            }
            string  assocParam  = LspUtil.GetAssocParam(rb, "URL", null);
            string  assocParam2 = LspUtil.GetAssocParam(rb, "EDITMODE", "EDIT");
            Point2d assocParam3 = LspUtil.GetAssocParam(rb, "EXTMIN", Point2d.Origin);
            Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMAX", Point2d.Origin);
            string  assocParam5 = LspUtil.GetAssocParam(rb, "LAYERIDS", "");
            bool    assocParam6 = LspUtil.GetAssocParam(rb, "EXTRACT", false);

            if (string.IsNullOrEmpty(assocParam))
            {
                return(null);
            }
            object result;

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                string            text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument);
                AGSFeatureService aGSFeatureService = AGSFeatureService.BuildFeatureServiceFromURL(null, assocParam);
                if (aGSFeatureService != null)
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSFeatureService.GetWKT());
                    }
                    if (assocParam2 != "EDIT")
                    {
                        aGSFeatureService.ExportOptions.Dynamic = false;
                    }
                    Extent extent = new Extent(assocParam3, assocParam4);
                    aGSFeatureService.ExportOptions.OutputWKT = text;
                    if (extent.IsValid())
                    {
                        extent.SetWKTFrom(text);
                        aGSFeatureService.ExportOptions.BoundingBox = extent;
                    }
                    List <int> layerList = null;
                    bool       flag;
                    if (!string.IsNullOrEmpty(assocParam5))
                    {
                        string[] array = assocParam5.Split(new char[]
                        {
                            ','
                        });
                        int[] collection = Array.ConvertAll <string, int>(array, new Converter <string, int>(int.Parse));
                        layerList = new List <int>(collection);
                        if (assocParam6)
                        {
                            flag = aGSFeatureService.ExtractService(layerList);
                        }
                        else
                        {
                            flag = aGSFeatureService.AddService(layerList);
                        }
                    }
                    else if (assocParam6)
                    {
                        flag = aGSFeatureService.ExtractService(layerList);
                    }
                    else
                    {
                        flag = aGSFeatureService.AddService(layerList);
                    }
                    Mouse.OverrideCursor = null;
                    if (flag)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    Mouse.OverrideCursor = null;
                    result = null;
                }
            }
            catch
            {
                Mouse.OverrideCursor = null;
                result = null;
            }
            return(result);
        }