예제 #1
0
 static void Shutdown()
 {
     FoxEventLog.WriteEventLog("Server stopping", EventLogEntryType.Information);
     Debug.WriteLine("===== Cancelling =====");
     WebServerHandler.EndWebServer();
     RemoteNetworkConnectionWSCrosser.ShutdownWS();
     KillConnections();
     MaintenanceTasks.StopThreads();
     ReportingThread.StopThreads();
     ServiceRunning = false;
 }
예제 #2
0
        public static void SMain()
        {
            string ErrorReason;

            Console.WriteLine("Server version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (InstanceID == "" ? "" : " (" + InstanceID + ")"));
            FoxEventLog.WriteEventLog("Server version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " starting" + (InstanceID == "" ? "" : " (" + InstanceID + ")"), EventLogEntryType.Information);
            if (SQLTest.TestSettings(out ErrorReason) == false)
            {
                FoxEventLog.WriteEventLog("Settings are faulty: " + ErrorReason, EventLogEntryType.Error);
                Console.WriteLine("Settings are faulty: " + ErrorReason);
#if !DEBUG
                Process.GetCurrentProcess().Kill();
#endif
                return;
            }
            if (SQLTest.TestServer(out ErrorReason) == false)
            {
                FoxEventLog.WriteEventLog("Cannot connect to the server: " + ErrorReason, EventLogEntryType.Error);
                Console.WriteLine("Cannot connect to the server: " + ErrorReason);
#if !DEBUG
                Process.GetCurrentProcess().Kill();
#endif
                return;
            }
            RESTful.RegisterRESTfulClasses();
            FS_Watcher.InstallFSW();

            if (Utilities.TestSign(out ErrorReason) == false)
            {
                FoxEventLog.WriteEventLog("Cannot test-sign with the certificate " + SettingsManager.Settings.UseCertificate + ": " + ErrorReason, EventLogEntryType.Warning);
            }

#if DEBUG
            if (Fox_LicenseGenerator.SDCLicensing.ValidLicense == false)
            {
                FoxEventLog.WriteEventLog("Writing a crap-license into memory.", EventLogEntryType.Information);
                Fox_LicenseGenerator.SDCLicensing.NumComputers        = 1000;
                Fox_LicenseGenerator.SDCLicensing.AllowContract       = true;
                Fox_LicenseGenerator.SDCLicensing.Data                = new Fox_LicenseGenerator.LicensingData();
                Fox_LicenseGenerator.SDCLicensing.Data.Features       = "";
                Fox_LicenseGenerator.SDCLicensing.Data.LicenseID      = Guid.NewGuid().ToString();
                Fox_LicenseGenerator.SDCLicensing.Data.LicenseType    = "Memory";
                Fox_LicenseGenerator.SDCLicensing.Data.Owner          = "Fox";
                Fox_LicenseGenerator.SDCLicensing.Data.OwnerCustomID  = "";
                Fox_LicenseGenerator.SDCLicensing.Data.SupportValidTo = null;
                Fox_LicenseGenerator.SDCLicensing.Data.UCID           = UCID.GetUCID();
                Fox_LicenseGenerator.SDCLicensing.Data.ValidTo        = null;
                Fox_LicenseGenerator.SDCLicensing.Data.ValidFrom      = DateTime.UtcNow.Date;
                Fox_LicenseGenerator.SDCLicensing.Data.Vacant1        = "1000";
                Fox_LicenseGenerator.SDCLicensing.ValidLicense        = true;
            }
#endif

            try
            {
                Console.CancelKeyPress += Console_CancelKeyPress;
                WebServerHandler.RunWebServer();
                MaintenanceTasks.StartMaintenanceTreads();
                ReportingThread.StartReportingThreads();
                RemoteNetworkConnectionWSCrosser.InitialInitWS();
                Console.WriteLine("=============== Server started ===============");
                Debug.WriteLine("=============== Server started ===============");
                Console.WriteLine(Settings.Default.ListenOn);
                Debug.WriteLine(Settings.Default.ListenOn);
                Console.WriteLine(Settings.Default.WSListenOn);
                Debug.WriteLine(Settings.Default.WSListenOn);
                FoxEventLog.WriteEventLog("Server started", EventLogEntryType.Information);
                ServiceRunning = true;
                Thread tmm = new Thread(new ThreadStart(TimeoutManager));
                tmm.Start();
                do
                {
                    Thread.Sleep(1000);
                } while (ServiceRunning == true);
            }
            catch (Exception ee)
            {
                FoxEventLog.WriteEventLog("Cannot start server " + ee.Message, EventLogEntryType.Error);
                Console.WriteLine("Cannot start server " + ee.Message);
#if !DEBUG
                Process.GetCurrentProcess().Kill();
#endif
                return;
            }
        }