Beispiel #1
0
        public void Init(int port)
        {
            _serverConfig = MapServerConfig.ServerByPort(port);

            if (_interpreters.Keys.Count == 0)
            {
                List <IServiceRequestInterpreter> interpreters = new List <IServiceRequestInterpreter>();
                PlugInManager compMan = new PlugInManager();
                foreach (XmlNode interpreterNode in compMan.GetPluginNodes(Plugins.Type.IServiceRequestInterpreter))
                {
                    IServiceRequestInterpreter interpreter = compMan.CreateInstance(interpreterNode) as IServiceRequestInterpreter;
                    if (interpreter == null)
                    {
                        continue;
                    }
                    interpreters.Add(interpreter);
                }
                foreach (IServiceRequestInterpreter interpreter in interpreters)
                {
                    string guid = PlugInManager.PlugInID(interpreter).ToString().ToLower();
                    string name = interpreter.IntentityName.ToLower();
                    if (_interpreters.ContainsKey(guid) || _interpreters.ContainsKey(name))
                    {
                        continue;
                    }

                    _interpreters.Add(guid, interpreter);
                    if (!String.IsNullOrEmpty(name))
                    {
                        _interpreters.Add(name, interpreter);
                    }
                }
            }
        }
Beispiel #2
0
 private void btnRefreshConfig_Click(object sender, EventArgs e)
 {
     MapServerConfig.Load();
     txtOutputUrl.Text      = MapServerConfig.DefaultOutputUrl;
     txtOutputPath.Text     = MapServerConfig.DefaultOutputPath;
     txtTilecachePath.Text  = MapServerConfig.DefaultTileCachePath;
     txtOnlineresource.Text = MapServerConfig.DefaultOnlineResource;
 }
Beispiel #3
0
        protected void OnStart(string[] args)
        {
            try
            {
                KillProcesses();

                for (int s = 0; s < MapServerConfig.ServerCount; s++)
                {
                    MapServerConfig.ServerConfig serverConfig = MapServerConfig.Server(s);

                    if (_startInstances)
                    {
                        _running = true;
                        for (int i = 0; i < serverConfig.Instances.Length; i++)
                        {
                            MapServerConfig.ServerConfig.InstanceConfig instanceConfig = serverConfig.Instances[i];
                            if (instanceConfig == null || instanceConfig.Port <= 0)
                            {
                                continue;
                            }

                            Thread thread = new Thread(new ParameterizedThreadStart(ProcessMonitor));
                            thread.Start(instanceConfig.Port);
                        }
                    }

                    TaskerServiceType serviceType = new TaskerServiceType();
                    serviceType.Init(serverConfig.Port);
                    ServiceHost host = new ServiceHost(/*typeof(Service.TaskerServiceType)*/ serviceType, new Uri("http://localhost:" + serverConfig.Port));

                    try
                    {
                        if (host.Description.Endpoints.Count == 1 &&
                            host.Description.Endpoints[0].Binding is System.ServiceModel.WebHttpBinding)
                        {
                            System.ServiceModel.WebHttpBinding binding = (System.ServiceModel.WebHttpBinding)host.Description.Endpoints[0].Binding;
                            binding.MaxReceivedMessageSize = int.MaxValue;
                        }
                    }
                    catch { }

                    host.Open();

                    Console.WriteLine("Tasker is listening on port " + serverConfig.Port);

                    _hosts.Add(host);
                }
                DeleteImageThread del = new DeleteImageThread();
                _delThread = new Thread(new ThreadStart(del.Run));
                _delThread.Start();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Exception: " + ex.Message + "\n" + ex.StackTrace);
                Console.ResetColor();
            }
        }
Beispiel #4
0
        protected override void OnStart(string[] args)
        {
            try
            {
                //XmlDocument doc = new XmlDocument();
                //doc.Load(gView.Framework.system.SystemVariables.ApplicationDirectory + @"\mapServer\Processes.xml");

                bool first = true;
                //foreach (XmlNode procNode in doc.SelectNodes("processes/process[@port]"))
                for (int i = 0; i < MapServerConfig.ServerCount; i++)
                {
                    MapServerConfig.ServerConfig procConfig = MapServerConfig.Server(i);
                    if (procConfig == null)
                    {
                        continue;
                    }

                    if (first)
                    {
                        //RegisterPort(int.Parse(procNode.Attributes["port"].Value));
                        RegisterPort(procConfig.Port);
                        first = false;
                    }
                    else
                    {
                        Process proc = new Process();
                        proc.StartInfo.FileName = gView.Framework.system.SystemVariables.ApplicationDirectory + @"\gView.MapServer.exe";
                        //proc.StartInfo.Arguments = "-port " + procNode.Attributes["port"].Value;
                        proc.StartInfo.Arguments       = "-port " + procConfig.Port;
                        proc.StartInfo.UseShellExecute = false;

                        proc.Start();
                        _procs.Add(proc);
                    }
                }

                DeleteImageThread del = new DeleteImageThread(Functions.outputPath);
                _delThread = new Thread(new ThreadStart(del.Run));
                _delThread.Start();
            }
            catch (Exception ex)
            {
                if (Functions.log_errors)
                {
                    Logger.Log(loggingMethod.error, "Service OnStart: " + ex.Message);
                }
            }
        }
Beispiel #5
0
        private void Delete(string filter)
        {
            try
            {
                string last = String.Empty;
                for (int i = 0; i < MapServerConfig.ServerCount; i++)
                {
                    MapServerConfig.ServerConfig procConfig = MapServerConfig.Server(i);
                    if (procConfig == null || procConfig.OutputPath == last)
                    {
                        continue;
                    }
                    last = procConfig.OutputPath;

                    DirectoryInfo di = new DirectoryInfo(procConfig.OutputPath);

                    foreach (FileInfo fi in di.GetFiles(filter))
                    {
                        TimeSpan ts = DateTime.Now - fi.CreationTime;
                        if (ts.TotalMinutes >= MapServerConfig.RemoveInterval)
                        {
                            try
                            {
                                fi.Delete();
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }