コード例 #1
0
        private void btnGetAllResource_Click(object sender, EventArgs e)
        {
            this.ResourcescheckedListBox.Items.Clear();
            IAGSServerConnectionFactory factory        = new AGSServerConnectionFactoryClass();
            IPropertySet         pConnectionProperties = this.method_5();
            IAGSServerConnection connection            = null;

            try
            {
                connection = factory.Open(pConnectionProperties, 0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                return;
            }
            IAGSEnumServerObjectName serverObjectNames = connection.ServerObjectNames;

            serverObjectNames.Reset();
            for (IAGSServerObjectName name2 = serverObjectNames.Next(); name2 != null; name2 = serverObjectNames.Next())
            {
                this.ilist_0.Add(name2);
                this.ResourcescheckedListBox.Items.Add(new Class7(name2));
            }
            connection = null;
            factory    = null;
        }
コード例 #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.txtTempFolder.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入过渡文件夹");
     }
     else
     {
         string path = Environment.SystemDirectory.Substring(0, 2) +
                       @"\Users\Administrator\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         string text = this.txtMUrl.Text;
         if (text.IndexOf("http://") == 0)
         {
             text = text.Substring(7);
         }
         else
         {
             this.txtMUrl.Text = "http://" + this.txtMUrl.Text;
         }
         string[] strArray = text.Split(new char[] { '/' });
         IAGSServerConnectionFactory factory        = new AGSServerConnectionFactoryClass();
         IPropertySet         pConnectionProperties = this.method_2(this.ConnectionFile, strArray[0]);
         IAGSServerConnection connection            = null;
         try
         {
             connection = factory.Open(pConnectionProperties, 0);
             if (connection == null)
             {
                 return;
             }
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.ToString());
             return;
         }
         if (Directory.Exists(path))
         {
             IGxAGSConnection connection2 = new GxAGSConnection
             {
                 AGSServerConnectionName = connection.FullName as IAGSServerConnectionName
             };
             connection2.SaveToFile(this.ConnectionFile);
             this.igxObject_0 = connection2 as IGxObject;
         }
         base.DialogResult = DialogResult.OK;
     }
 }
コード例 #3
0
ファイル: GxAGSConnection.cs プロジェクト: secondii/Yutai
 public void Connect()
 {
     try
     {
         IAGSServerConnectionFactory2 factory = new AGSServerConnectionFactoryClass();
         if (this.ipropertySet_0 == null)
         {
             this.ipropertySet_0 = factory.ReadConnectionPropertiesFromFile(this.string_0);
         }
         this.iagsserverConnection2_0 = factory.Open(this.ipropertySet_0, 0) as IAGSServerConnection2;
         this.Init(null);
         this.method_1();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         Logger.Current.Error("", exception, "");
     }
 }
コード例 #4
0
 private void method_0(object sender, EventArgs e)
 {
     this.Cursor       = Cursors.WaitCursor;
     this.imapServer_0 = null;
     try
     {
         IAGSServerConnectionFactory factory = new AGSServerConnectionFactoryClass();
         IPropertySet pConnectionProperties  = new PropertySetClass();
         this.iagsserverConnection_0 = factory.Open(pConnectionProperties, 0);
         IAGSEnumServerObjectName serverObjectNames = this.iagsserverConnection_0.ServerObjectNames;
         while (serverObjectNames.Next() != null)
         {
             this.Cursor = Cursors.Default;
         }
     }
     catch (Exception exception)
     {
         this.Cursor = Cursors.Default;
         MessageBox.Show(exception.Message, "An error has occurred");
     }
 }
コード例 #5
0
        /// <summary>
        /// Parse ArcGIS MapServer Service
        /// </summary>
        /// <param name="urlAGS"></param>
        public void OpenAGS(string urlAGS)
        {
            try
            {
                ///Parse the url for MapServer -- get the service url and the service name
                string   strUrl      = urlAGS;
                string[] strUrlParts = strUrl.Split('/');
                string   strUrlSvr   = null;
                string   strSvrName  = null;

                for (int i = 0; i < strUrlParts.Length; i++)
                {
                    if (strUrlParts[i] == "services")
                    {
                        strUrlSvr = string.Join("/", strUrlParts.Take(i + 1).ToArray());

                        for (int j = i + 1; j < strUrlParts.Length - 1; j++)
                        {
                            if (strSvrName != null)
                            {
                                strSvrName += "/";
                            }
                            strSvrName += strUrlParts[j];
                        }
                        break;
                    }
                }


                ///Set up ArcGIS Service connection factory, which includes the list of services
                IAGSServerConnectionFactory pAGSSvrConnFactory = new AGSServerConnectionFactoryClass();
                IPropertySet pPropSet = new PropertySetClass();
                pPropSet.SetProperty("URL", strUrlSvr);
                IAGSServerConnection pAGSSvrConn = pAGSSvrConnFactory.Open(pPropSet, 0);

                ///Get the list of services
                IAGSEnumServerObjectName pEnumSOName = pAGSSvrConn.ServerObjectNames;
                IAGSServerObjectName     pAGSSOName  = pEnumSOName.Next();

                ///Get the specific service with the service name
                while (pAGSSOName != null)
                {
                    //Debug.WriteLine(pAGSSOName.Name + ":" + pAGSSOName.Type);

                    if (pAGSSOName.Name == strSvrName && pAGSSOName.Type == "MapServer")
                    {
                        break;
                    }

                    pAGSSOName = pEnumSOName.Next();
                }

                ///Open the specific service
                IName      pName      = pAGSSOName as IName;
                IMapServer pMapServer = pName.Open() as IMapServer;

                IMapServerLayer pMapSvrLayer = new MapServerLayerClass();
                pMapSvrLayer.ServerConnect(pAGSSOName, pMapServer.DefaultMapName);

                ///Configure the layer before adding it to the map
                ILayer pLayer = pMapSvrLayer as ILayer;
                AddLayer(pLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
コード例 #6
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (((this.radioGroup1.SelectedIndex >= 1) && !this.chkUseDefaultFolder.Checked) &&
         (this.txtTempFolder.Text.Trim().Length == 0))
     {
         MessageBox.Show("请输入过渡文件夹");
     }
     else
     {
         IPropertySet set;
         object       obj2;
         object       obj3;
         string       path = Environment.SystemDirectory.Substring(0, 2) +
                             @"\Users\Administrator\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         string str2 = "";
         string text = "";
         if (this.radioGroup1.SelectedIndex == 0)
         {
             text = this.txtServer.Text;
         }
         else
         {
             text = this.txtMUrl.Text;
         }
         string str4 = "";
         if (this.radioGroup1.SelectedIndex == 0)
         {
             str4 = "(用户)";
         }
         else if (this.radioGroup1.SelectedIndex == 1)
         {
             str4 = "(系统管理员)";
         }
         else if (this.radioGroup1.SelectedIndex == 2)
         {
             str4 = "(发布者)";
         }
         if (text.IndexOf("http://") == 0)
         {
             text = text.Substring(7);
         }
         else
         {
             this.txtServer.Text = "http://" + this.txtServer.Text;
         }
         string[] strArray = text.Split(new char[] { '/' });
         string   str5     = strArray[0];
         if (strArray.Length > 0)
         {
             str2 = path + "arcgis on" + strArray[0].Replace(":", "_") + str4 + ".ags";
         }
         else
         {
             str2 = path + "arcgis on" + str4 + ".ags";
         }
         str2 = this.method_1(str2);
         IAGSServerConnectionFactory factory = new AGSServerConnectionFactoryClass();
         if (this.radioGroup1.SelectedIndex == 0)
         {
             set = this.method_2(str2, str5);
         }
         else
         {
             set = this.method_3(str2, str5);
         }
         set.GetAllProperties(out obj2, out obj3);
         IAGSServerConnection connection = null;
         try
         {
             connection = factory.Open(set, 0);
             if (connection == null)
             {
                 return;
             }
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.ToString());
             return;
         }
         if (Directory.Exists(path))
         {
             IGxAGSConnection connection2 = new GxAGSConnection
             {
                 AGSServerConnectionName = connection.FullName as IAGSServerConnectionName
             };
             connection2.SaveToFile(str2);
             this.igxObject_0 = connection2 as IGxObject;
         }
         base.DialogResult = DialogResult.OK;
     }
 }