示例#1
0
        public Stream AddMap(string name, Stream data)
        {
            try
            {
                if (_serverConfig == null || _serverConfig.Instances.Length == 0)
                {
                    return(WriteException("ServiceType not initialized!"));
                }

                string input = (data != null ? new StreamReader(data).ReadToEnd() : String.Empty);

                MapServerConfig.ServerConfig.InstanceConfig config = _serverConfig.Instances[0];
                InstanceConnection conn = new InstanceConnection("localhost:" + config.Port);

                string user, pwd;
                var    request = Request(out user, out pwd);

                object ret = conn.AddMap(name, input, user, pwd);

                for (int i = 1; i < _serverConfig.Instances.Length; i++)
                {
                    MapServerConfig.ServerConfig.InstanceConfig config2 = _serverConfig.Instances[i];
                    InstanceConnection conn2 = new InstanceConnection("localhost:" + config2.Port);
                    conn2.AddMap(name, String.Empty, user, pwd);  // Refrsh
                }

                return(WriteValue(ret));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }