Esempio n. 1
0
 public LogTranslation(BlackMaple.MachineFramework.JobDB jDB,
                       BlackMaple.MachineFramework.JobLogDB logDB,
                       MazakSchedulesAndLoadActions mazakSch,
                       BlackMaple.MachineFramework.FMSSettings settings,
                       Action <LogEntry> onMazakLogMessage)
 {
     _jobDB          = jDB;
     _log            = logDB;
     _mazakSchedules = mazakSch;
     _settings       = settings;
     _onMazakLog     = onMazakLogMessage;
     _jobs           = new Dictionary <string, JobPlan>();
 }
Esempio n. 2
0
        public static void Run(bool useService, Func <IConfiguration, FMSSettings, FMSImplementation> initalize, bool outputConfigToLog = true)
        {
            var(cfg, serverSt) = LoadConfig();
            EnableSerilog(serverSt: serverSt, enableEventLog: useService);

            FMSImplementation fmsImpl;
            FMSSettings       fmsSt;

            try
            {
                fmsSt = new FMSSettings(cfg);
                if (outputConfigToLog)
                {
                    Log.Information("Starting FMS Insight with settings {@ServerSettings} and {@FMSSettings}. " +
                                    " Using ContentRoot {ContentRoot} and Config {ConfigDir}.",
                                    serverSt, fmsSt, ServerSettings.ContentRootDirectory, ServerSettings.ConfigDirectory);
                }
                fmsImpl = initalize(cfg, fmsSt);
            }
            catch (Exception ex)
            {
                Serilog.Log.Error(ex, "Error initializing FMS Insight");
                return;
            }
            var host = BuildWebHost(cfg, serverSt, fmsSt, fmsImpl);

#if SERVICE_AVAIL
            if (useService)
            {
                Microsoft.AspNetCore.Hosting.WindowsServices.WebHostWindowsServiceExtensions
                .RunAsService(host);
            }
            else
            {
                host.Run();
            }
#else
            host.Run();
#endif
        }
Esempio n. 3
0
 public static IWebHost BuildWebHost(IConfiguration cfg, ServerSettings serverSt, FMSSettings fmsSt, FMSImplementation fmsImpl)
 {
     return(new WebHostBuilder()
            .UseConfiguration(cfg)
            .ConfigureServices(s =>
     {
         s.AddSingleton <FMSImplementation>(fmsImpl);
         s.AddSingleton <FMSSettings>(fmsSt);
         s.AddSingleton <ServerSettings>(serverSt);
     })
            .SuppressStatusMessages(suppressStatusMessages: true)
            .UseKestrel(options =>
     {
         var address = IPAddress.IPv6Any;
         if (!string.IsNullOrEmpty(serverSt.TLSCertFile))
         {
             options.Listen(address, serverSt.Port, listenOptions =>
             {
                 listenOptions.UseHttps(serverSt.TLSCertFile);
             });
         }
         else
         {
             options.Listen(address, serverSt.Port);
         }
     })
            .UseContentRoot(ServerSettings.ContentRootDirectory)
            .UseSerilog()
            .UseStartup <Startup>()
            .Build());
 }
Esempio n. 4
0
 public Startup(FMSImplementation fmsImpl, ServerSettings serverSt, FMSSettings fmsSt)
 {
     _fmsImpl  = fmsImpl;
     _serverSt = serverSt;
     _fmsSt    = fmsSt;
 }