public void ExportImage(AGSExportOptions eo, ExportImageEventHandler action)
 {
     try
     {
         string        arg  = base.Parent.URL + "/" + base.FullName + "/ImageServer/exportImage";
         StringBuilder arg2 = this.BuildURIRequest(eo);
         Mouse.OverrideCursor = Cursors.Wait;
         IDictionary <string, object> dictionary = base.Parent.MakeDictionaryRequest(arg + arg2);
         if (dictionary == null)
         {
             Mouse.OverrideCursor = null;
             if (string.IsNullOrEmpty(base.Parent.ErrorMessage))
             {
                 ErrorReport.ShowErrorMessage(AfaStrings.AnUnexpectedErrorOccured);
             }
             else
             {
                 ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage);
             }
             return;
         }
         SpatialReference spatialReference = null;
         if (dictionary != null)
         {
             object obj;
             if (!dictionary.TryGetValue("href", out obj))
             {
                 string text = AfaStrings.Error;
                 if (dictionary.ContainsKey("error"))
                 {
                     IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>;
                     if (dictionary2.ContainsKey("details"))
                     {
                         object obj2;
                         if (dictionary2.TryGetValue("details", out obj2))
                         {
                             object[] array = obj2 as object[];
                             if (array != null)
                             {
                                 text = text + " - " + array[0].ToString();
                             }
                         }
                     }
                     else
                     {
                         text += AfaStrings.UnknownError;
                     }
                 }
                 Mouse.OverrideCursor = null;
                 ErrorReport.ShowErrorMessage(text);
                 return;
             }
             string text2 = obj as string;
             if (text2.Length > 0)
             {
                 ExportedImage exportedImage = new ExportedImage(this, text2);
                 if (dictionary.TryGetValue("width", out obj))
                 {
                     exportedImage.Properties.Add("width", obj);
                 }
                 if (dictionary.TryGetValue("height", out obj))
                 {
                     exportedImage.Properties.Add("height", obj);
                 }
                 if (dictionary.TryGetValue("scale", out obj))
                 {
                     exportedImage.Properties.Add("scale", obj);
                 }
                 if (dictionary.TryGetValue("extent", out obj))
                 {
                     IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>;
                     object obj3;
                     if (dictionary3.TryGetValue("xmin", out obj3))
                     {
                         exportedImage.Properties.Add("xmin", obj3);
                     }
                     if (dictionary3.TryGetValue("xmax", out obj3))
                     {
                         exportedImage.Properties.Add("xmax", obj3);
                     }
                     if (dictionary3.TryGetValue("ymax", out obj3))
                     {
                         exportedImage.Properties.Add("ymax", obj3);
                     }
                     if (dictionary3.TryGetValue("ymin", out obj3))
                     {
                         exportedImage.Properties.Add("ymin", obj3);
                     }
                     if (dictionary3.TryGetValue("spatialReference", out obj3))
                     {
                         IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>;
                         object obj4;
                         if (dictionary4.TryGetValue("wkid", out obj4))
                         {
                             exportedImage.Properties.Add("spatialReference", obj4);
                             int num = int.Parse(obj4.ToString());
                             spatialReference = AGSSpatialReference.SpRefFromWKID(ref num);
                         }
                         else if (dictionary4.TryGetValue("wkt", out obj4))
                         {
                             exportedImage.Properties.Add("spatialReference", obj4);
                             string text3 = obj4.ToString();
                             spatialReference = AGSSpatialReference.SpRefFromWKT(ref text3);
                         }
                     }
                     PointN pointN = new PointN();
                     if (spatialReference != null)
                     {
                         pointN.SpatialReference = spatialReference;
                     }
                     double num2 = double.Parse(exportedImage.Properties["xmin"].ToString());
                     double num3 = double.Parse(exportedImage.Properties["ymin"].ToString());
                     double num4 = double.Parse(exportedImage.Properties["xmax"].ToString());
                     double num5 = double.Parse(exportedImage.Properties["ymax"].ToString());
                     pointN.X = num2;
                     pointN.Y = num3;
                     pointN.Z = 0.0;
                     PointN[] points = new PointN[]
                     {
                         pointN,
                         new PointN
                         {
                             SpatialReference = spatialReference,
                             X = num4,
                             Y = num3,
                             Z = 0.0
                         },
                         new PointN
                         {
                             SpatialReference = spatialReference,
                             X = num2,
                             Y = num5,
                             Z = 0.0
                         }
                     };
                     try
                     {
                         if (File.Exists(eo.OutputFile))
                         {
                             File.Delete(eo.OutputFile);
                             if (App.TempFiles.Contains(eo.OutputFile))
                             {
                                 App.TempFiles.Remove(eo.OutputFile);
                             }
                         }
                         new WebClient();
                         if (!base.Parent.DownloadFile(text2, eo.OutputFile))
                         {
                             eo.OutputFile = text2;
                             if (string.IsNullOrEmpty(eo.OutputFile))
                             {
                                 ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                             }
                         }
                     }
                     catch
                     {
                         eo.OutputFile = text2;
                         if (string.IsNullOrEmpty(eo.OutputFile))
                         {
                             ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                         }
                     }
                     finally
                     {
                         if (action != null)
                         {
                             action(this, new ExportedImageEventArgs(this, eo, points));
                         }
                     }
                     Mouse.OverrideCursor = null;
                     return;
                 }
             }
         }
     }
     catch
     {
         Mouse.OverrideCursor = null;
     }
     Mouse.OverrideCursor = null;
 }
Пример #2
0
 public virtual bool ExportMapNow(AGSExportOptions eo, ExportImageEventHandler action, AGSExportOptions cancelOptions)
 {
     throw new NotImplementedException();
 }