Пример #1
0
        public ServerProcess(int port, bool wait)
        {
            try
            {
                IMS.Port = port;
                System.Environment.CurrentDirectory = gView.Framework.system.SystemVariables.ApplicationDirectory;

                // init globals....
                IMS dummy = new IMS();
                gView.Framework.system.SystemVariables dummy2 = new gView.Framework.system.SystemVariables();

                Start();

                if (wait)
                {
                    ManualResetEvent resetEvent = new ManualResetEvent(false);
                    resetEvent.WaitOne();

                    Stop();
                }
            }
            catch (Exception ex)
            {
                if (Functions.log_errors)
                {
                    Logger.Log(loggingMethod.error, "Service Create: " + ex.Message);
                }
            }
        }
Пример #2
0
        public void Start()
        {
            try
            {
                IMS.mapDocument.MapAdded   += new gView.Framework.UI.MapAddedEvent(IMS.mapDocument_MapAdded);
                IMS.mapDocument.MapDeleted += new gView.Framework.UI.MapDeletedEvent(IMS.mapDocument_MapDeleted);
                IMS.LoadConfigAsync();

                _channel = new HttpServerChannel(IMS.Port);
                ChannelServices.RegisterChannel(_channel, false); //Register channel

                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(MapServerInstanceType),
                    "MapServer",
                    WellKnownObjectMode.Singleton);

                //Console.WriteLine("Server ON at port number:"+Functions.Port);
                //Console.WriteLine("Please press enter to stop the server.");
            }
            catch (Exception ex)
            {
                if (Functions.log_errors)
                {
                    Logger.Log(loggingMethod.error, "Server Start: " + ex.Message);
                }

                System.Threading.Thread.Sleep(3000);
                System.Environment.Exit(1);
            }
        }
Пример #3
0
        public bool RemoveMap(string mapName, string usr, string pwd)
        {
            if (IMS.acl != null && !IMS.acl.HasAccess(Identity.FromFormattedString(usr), pwd, "admin_removemap"))
            {
                return(false);
            }

            bool found = false;

            foreach (IMapService service in ListOperations <IMapService> .Clone(IMS.mapServices))
            {
                if (service.Name == mapName)
                {
                    IMS.mapServices.Remove(service);
                    found = true;
                }
            }

            foreach (IMap m in ListOperations <IMap> .Clone(IMS.mapDocument.Maps))
            {
                if (m.Name == mapName)
                {
                    _doc.RemoveMap(m);
                    found = true;
                }
            }
            IMS.RemoveConfig(mapName);

            return(found);
        }
Пример #4
0
        private void RegisterPort(int port)
        {
            IMS.ServicesPath = gView.Framework.system.SystemVariables.ApplicationDirectory + @"\mapServer\Services\" + port;
            IMS.Port         = port;

            IMS.mapDocument.MapAdded   += new gView.Framework.UI.MapAddedEvent(IMS.mapDocument_MapAdded);
            IMS.mapDocument.MapDeleted += new gView.Framework.UI.MapDeletedEvent(IMS.mapDocument_MapDeleted);
            IMS.LoadConfigAsync();

            _channel = new HttpServerChannel(port);
            ChannelServices.RegisterChannel(_channel); //Register channel

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(MapServerInstanceType),
                "MapServer",
                WellKnownObjectMode.Singleton);
        }
Пример #5
0
        public ImageService()
        {
            try
            {
                InitializeComponent();

                System.Environment.CurrentDirectory = gView.Framework.system.SystemVariables.ApplicationDirectory;

                // init globals....
                IMS dummy = new IMS();
                gView.Framework.system.SystemVariables dummy2 = new gView.Framework.system.SystemVariables();
            }
            catch (Exception ex)
            {
                if (Functions.log_errors)
                {
                    Logger.Log(loggingMethod.error, "Service Create: " + ex.Message);
                }
            }
        }
Пример #6
0
        private Map FindMap(string name, IServiceRequestContext context)
        {
            foreach (IMap map in IMS.mapDocument.Maps)
            {
                if (map.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && map is Map)
                {
                    return((Map)map);
                }
            }

            if (name.Contains(","))
            {
                return(null);
            }

            IMap m = IMS.LoadMap(name, context);

            if (m is Map)
            {
                return((Map)m);
            }

            return(null);
        }
Пример #7
0
        public bool AddMap(string mapName, string MapXML, string usr, string pwd)
        {
            if (String.IsNullOrEmpty(MapXML))
            {
                return(ReloadMap(mapName, usr, pwd));
            }

            if (IMS.acl != null && !IMS.acl.HasAccess(Identity.FromFormattedString(usr), pwd, "admin_addmap"))
            {
                return(false);
            }

            if (IMS.mapServer.Maps.Count >= IMS.mapServer.MaxServices)
            {
                // Überprüfen, ob schon eine Service mit gleiche Namen gibt...
                // wenn ja, ist es nur einem Refresh eines bestehenden Services
                bool found = false;
                foreach (IMapService map in IMS.mapServer.Maps)
                {
                    if (map.Name == mapName)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    return(false);
                }
            }

            if (MapXML.IndexOf("<IServiceableDataset") == 0)
            {
                XmlStream xmlStream = new XmlStream("");

                StringReader sr = new StringReader("<root>" + MapXML + "</root>");
                if (!xmlStream.ReadStream(sr))
                {
                    return(false);
                }

                IServiceableDataset sds = xmlStream.Load("IServiceableDataset", null) as IServiceableDataset;
                if (sds != null && sds.Datasets != null)
                {
                    IMS.SaveServiceableDataset(sds, mapName);
                    AddMapService(mapName, MapServiceType.SVC);
                }
            }
            else if (MapXML.IndexOf("<ServiceCollection") == 0)
            {
                XmlStream stream = new XmlStream("");

                StringReader sr = new StringReader(MapXML);
                if (!stream.ReadStream(sr))
                {
                    return(false);
                }

                IMS.SaveServiceCollection(mapName, stream);
            }
            else  // Map
            {
                XmlStream xmlStream = new XmlStream("IMap");

                StringReader sr = new StringReader(MapXML);
                if (!xmlStream.ReadStream(sr))
                {
                    return(false);
                }

                Map map = new Map();
                map.Load(xmlStream);
                map.Name = mapName;

                foreach (IMap m in ListOperations <IMap> .Clone(_doc.Maps))
                {
                    if (m.Name == map.Name)
                    {
                        _doc.RemoveMap(m);
                    }
                }

                if (!_doc.AddMap(map))
                {
                    return(false);
                }
                AddMapService(mapName, MapServiceType.MXL);

                IMS.SaveConfig(map);
            }

            /*
             * // Alle Layer sichtbar schalten...
             * IEnum layers = map.MapLayers;
             * IDatasetElement element;
             * while((element=(IDatasetElement)layers.Next)!=null)
             * {
             *  ITOCElement tocElement = map.TOC.GetTOCElement(element);
             *  if (tocElement != null) tocElement.LayerVisible = true;
             * }
             */

            return(true);
        }