Пример #1
0
        public void Stop(string serverName, string serviceName, bool bDelete)
        {
            IGISServerConnection pGISServerConnection = null;
            IServerObjectAdmin   pServerObjectAdmin   = null;

            try
            {
                serviceName = CleanServiceName(serviceName);

                pGISServerConnection = new GISServerConnection();
                pGISServerConnection.Connect(serverName);

                pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin;
                pServerObjectAdmin.StopConfiguration(serviceName, "MapServer");
                if (bDelete == true)
                {
                    pServerObjectAdmin.DeleteConfiguration(serviceName, "MapServer");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                COMUtil.ReleaseObject(pServerObjectAdmin);
                COMUtil.ReleaseObject(pGISServerConnection);
            }
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmHost host = new frmHost();

            if (host.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string[]           items             = new string[] { host.HostName, host.Description };
                    IServerObjectAdmin serverObjectAdmin = this.iagsserverConnectionAdmin_0.ServerObjectAdmin;
                    IServerMachine     machine           = serverObjectAdmin.CreateMachine();
                    machine.Name        = items[0];
                    machine.Description = items[1];
                    serverObjectAdmin.AddMachine(machine);
                    ListViewItem item = new ListViewItem(items);
                    this.Hostlist.Items.Add(item);
                }
                catch (COMException exception)
                {
                    if (exception.ErrorCode == -2147467259)
                    {
                        MessageBox.Show("服务器不存在!");
                        Logger.Current.Error("", exception, "");
                    }
                }
                catch (Exception exception2)
                {
                    MessageBox.Show(exception2.ToString());
                    Logger.Current.Error("", exception2, "");
                }
            }
        }
Пример #3
0
        public void Start(string serverName, string serviceName, string sAgsAdminUser, string sAgsAdminPwd)
        {
            serviceName = CleanServiceName(serviceName);

            try
            {
                if (!ConnectAGS(serverName, sAgsAdminUser, sAgsAdminPwd)) throw new ApplicationException("Could not get server connection to " + serverName);
                soAdmin.StartConfiguration(serviceName, "MapServer");

                COMUtil.ReleaseObject(soAdmin);
                soAdmin = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public void Start(string serverName, string serviceName)
        {
            serviceName = CleanServiceName(serviceName);

            try
            {
                IGISServerConnection pGISServerConnection = new GISServerConnection();
                pGISServerConnection.Connect(serverName);

                IServerObjectAdmin pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin;
                pServerObjectAdmin.StartConfiguration(serviceName, "MapServer");

                COMUtil.ReleaseObject(pServerObjectAdmin);
                COMUtil.ReleaseObject(pGISServerConnection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        public void Start(string serverName, string serviceName, string sAgsAdminUser, string sAgsAdminPwd)
        {
            serviceName = CleanServiceName(serviceName);

            try
            {
                if (!ConnectAGS(serverName, sAgsAdminUser, sAgsAdminPwd))
                {
                    throw new ApplicationException("Could not get server connection to " + serverName);
                }
                soAdmin.StartConfiguration(serviceName, "MapServer");

                COMUtil.ReleaseObject(soAdmin);
                soAdmin = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        private static bool ConnectAGS(string host, string sAgsAdminUser, string sAgsAdminPwd)
        {
            try
            {
                IPropertySet propertySet = new PropertySetClass();
                propertySet.SetProperty("url", host);
                propertySet.SetProperty("user", sAgsAdminUser);
                propertySet.SetProperty("password", sAgsAdminPwd);
                propertySet.SetProperty("ConnectionMode", esriAGSConnectionMode.esriAGSConnectionModePublisher);
                propertySet.SetProperty("ServerType", esriAGSServerType.esriAGSServerTypeDiscovery);

                IAGSServerConnectionName3 connectName = new AGSServerConnectionNameClass() as IAGSServerConnectionName3;
                connectName.ConnectionProperties = propertySet;

                IAGSServerConnectionAdmin agsAdmin = ((IName)connectName).Open() as IAGSServerConnectionAdmin;
                soAdmin = agsAdmin.ServerObjectAdmin as IServerObjectAdmin;
                return(true);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Error: Couldn't connect to AGSServer: {0}. Message: {1}", host, exc.Message);
                return(false);
            }
        }
 /// <summary>
 /// Validate ServiceName
 /// </summary>
 /// <returns>Convert the config name to the correct case and returns true; if not exist in any cases, returns false </returns>
 private static bool ValidateServiceName(IServerObjectAdmin soAdmin, ref string serviceName, string host)
 {
     IEnumServerObjectConfiguration enumConfigs = soAdmin.GetConfigurations();
     enumConfigs.Reset();
     IServerObjectConfiguration soConfig = enumConfigs.Next();
     while (soConfig != null)
     {
         if (soConfig.Name.ToUpper() == serviceName.ToUpper())
         {
             serviceName = soConfig.Name;
             return true;
         }
         soConfig = enumConfigs.Next();
     }
     Console.WriteLine("Configuration {0} on {1} can not be found.", serviceName, host);
     return false;
 }
        /// <summary>
        /// connect to ags server
        /// </summary>
        /// <param name="host">host</param>
        /// <returns>true if connected</returns>
        private static bool ConnectAGS(string host)
        {
            try
            {
                IPropertySet propertySet = new PropertySetClass();
                propertySet.SetProperty("url", host);
                propertySet.SetProperty("ConnectionMode", esriAGSConnectionMode.esriAGSConnectionModePublisher);
                propertySet.SetProperty("ServerType", esriAGSServerType.esriAGSServerTypeDiscovery);
                propertySet.SetProperty("user", username);
                propertySet.SetProperty("password", password);
                propertySet.SetProperty("ALLOWINSECURETOKENURL", true);

                IAGSServerConnectionName3 connectName = new AGSServerConnectionNameClass() as IAGSServerConnectionName3;
                connectName.ConnectionProperties = propertySet;

                IAGSServerConnectionAdmin agsAdmin = ((IName)connectName).Open() as IAGSServerConnectionAdmin;
                soAdmin = agsAdmin.ServerObjectAdmin;
                return true;
            }
            catch (Exception exc)
            {
                Console.WriteLine("Error: Couldn't connect to AGSServer: {0}. Message: {1}", host, exc.Message);
                return false;
            }
        }