static void Main(string[] args) { System.Net.ServicePointManager.DefaultConnectionLimit = 256; //System.Net.ServicePointManager.MaxServicePoints = 256; System.Net.ServicePointManager.CertificatePolicy = new gView.Framework.Web.SimpleHttpsPolicy(); gView.Framework.system.gViewEnvironment.UserInteractive = false; //int x = 0; //x = 1 / x; try { //Thread thread = new Thread(new ThreadStart(StartThread2)); //thread.Start(); //gView.Framework.system.SystemVariables.ApplicationDirectory = gView.Framework.system.SystemVariables.RegistryApplicationDirectory; Logger.Log(loggingMethod.request, "Service EXE started..."); bool console = false; int port = -1; for (int i = 0; i < args.Length; i++) { if (args[i] == "-c") { console = true; } if (args[i] == "-port") { port = int.Parse(args[i + 1]); } } //port = 8001; //console = true; Logger.Log(loggingMethod.request, "Current Directory: " + System.Environment.CurrentDirectory); //Logger.Log(loggingMethod.request, "Check license..."); //myLicense = new License(false); //Logger.Log(loggingMethod.request, "License Info********"); //Logger.Log(loggingMethod.request, "ProductID: " + myLicense.ProductID); //Logger.Log(loggingMethod.request, "InstallationDate: " + SystemVariables.InstallationTime.ToShortDateString() + " " + SystemVariables.InstallationTime.ToLongTimeString()); //Logger.Log(loggingMethod.request, "LicenseFile: " + myLicense.LicenseFile); //Logger.Log(loggingMethod.request, "LicenseFileExists: " + myLicense.LicenseFileExists.ToString()); //if (myLicense.LicenseComponents != null) //{ // Logger.Log(loggingMethod.request, "Components:"); // foreach (string component in myLicense.LicenseComponents) // Logger.Log(loggingMethod.request, " " + component); //} //LicenseTypes licType = IMS.myLicense.ComponentLicenseType("gview.Server;gview.PersonalMapServer"); //if (licType == LicenseTypes.Unknown || // licType == LicenseTypes.Expired) //{ // Logger.Log(loggingMethod.error, "Server is not licensed..."); // return; //} //Logger.Log(loggingMethod.request, "********************"); // Interpreter suchen... Logger.Log(loggingMethod.request, "Register request interpreters..."); mapServer = new MapServer(port); /* * switch (mapServer.LicType) * { * case MapServer.ServerLicType.Unknown: * Logger.Log(loggingMethod.error, "Unkown License"); * if (console) * { * Console.WriteLine("Unkown License..."); #if(DEBUG) * Console.ReadLine(); #endif * } * return; * case MapServer.ServerLicType.Express: * case MapServer.ServerLicType.Private: * System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("gview.mapserver"); * if (procs.Length > 1) * { * Logger.Log(loggingMethod.error, "Your server license type '" + mapServer.LicType.ToString() + "' allows only one server instance!"); * if (console) * { * Console.WriteLine("Your server license type '" + mapServer.LicType.ToString() + "' allows only one server instance!"); #if(DEBUG) * Console.ReadLine(); #endif * } * return; * } * break; * } * */ PlugInManager compMan = new PlugInManager(); foreach (XmlNode interpreterNode in compMan.GetPluginNodes(Plugins.Type.IServiceRequestInterpreter)) { IServiceRequestInterpreter interpreter = compMan.CreateInstance(interpreterNode) as IServiceRequestInterpreter; if (interpreter == null) { continue; } interpreter.OnCreate(mapServer); _interpreters.Add(interpreter); } try { SetConsoleTitle("gView.MapServer.Instance." + port); } catch { } #if (!DEBUG) if (console) { //ImageService service = new ImageService(); //service.Start(args); Console.WriteLine("Server Instance " + port + " starting..."); ServerProcess process = new ServerProcess(port, false); Console.WriteLine("Server Instance is listing on port " + port); Console.ReadLine(); process.Stop(); //service.Stop(); } else { if (port != -1) { Console.WriteLine("Start Server On Port: " + port); ServerProcess process = new ServerProcess(port, true); } else { System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ImageService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } } #else port = (port != -1) ? port : 8001; Console.WriteLine("Server Instance " + port + " starting..."); ServerProcess process = new ServerProcess(port, false); Console.WriteLine("Server Instance is listing on port " + port); Console.ReadLine(); Console.WriteLine("Stopping Instance on port " + port); process.Stop(); #endif } catch (Exception ex) { Logger.Log(loggingMethod.error, ex.Message); } }
public string ServiceRequest2(string OnlineResource, string service, string request, string InterpreterGUID, string usr, string pwd) { //string clientAddress = CallContext.GetData("ClientAddress").ToString(); try { #if (DEBUG) Logger.LogDebug("Start SendRequest"); #endif Identity id = Identity.FromFormattedString(usr); id.HashedPassword = pwd; if (IMS.acl != null && !IMS.acl.HasAccess(id, pwd, service)) { throw new UnauthorizedAccessException(); //return "ERROR: Not Authorized!"; } if (service == "catalog" && IMS.acl != null) { IMS.acl.ReloadXmlDocument(); } if (service == "catalog" && request == "get_used_servers") { StringBuilder sb = new StringBuilder(); sb.Append("<servers>"); foreach (DataRow server in MapServer.GDIServers.Rows) { sb.Append("<server uri='" + (string)server["Server"] + "' port='" + (int)server["Port"] + "' />"); } sb.Append("</servers>"); return(sb.ToString()); } if (service == "catalog" && request == "get_instance_info") { StringBuilder sb = new StringBuilder(); MapServer mapServer = IMS.mapServer; sb.Append("<instance_info>"); if (mapServer != null) { sb.Append("<output url='" + mapServer.OutputUrl + "' />"); } sb.Append("</instance_info>"); return(sb.ToString()); } Guid guid = new Guid(InterpreterGUID); IServiceRequestInterpreter interperter = null; foreach (IServiceRequestInterpreter i in IMS._interpreters) { if (PlugInManager.PlugInID(i) == guid) { interperter = i; break; } } if (interperter == null) { return("FATAL ERROR: Unknown request interpreger..."); } // User berechtigungen überprüfen ServiceRequest serviceRequest = new ServiceRequest(service, request); serviceRequest.OnlineResource = OnlineResource; //serviceRequest.UserName = usr; serviceRequest.Identity = id; IServiceRequestContext context = new ServiceRequestContext( IMS.mapServer, interperter, serviceRequest); //ManualResetEvent resetEvent = new ManualResetEvent(false); //IMS.threadQueue.AddQueuedThread(interperter.Request, context, resetEvent); //resetEvent.WaitOne(); IMS.threadQueue.AddQueuedThreadSync(interperter.Request, context); return(serviceRequest.Response); #if (DEBUG) Logger.LogDebug("SendRequest Finished"); #endif } catch (Exception ex) { //System.Diagnostics.Process.GetCurrentProcess().Kill(); return("FATAL ERROR: " + ex.Message); } }