public static void Main() { try { // preparation for use with Fody.Costura: DotLiquid.Hash h = new DotLiquid.Hash(); Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations r = new Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations(); Nancy.Json.JsonSettings.MaxJsonLength = Int32.MaxValue; string cwd = System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); System.IO.Directory.SetCurrentDirectory(cwd ?? "."); log.InfoFormat("{0} started.", Environment.GetCommandLineArgs()[0]); } catch (Exception) { } HostFactory.Run(x => { var log4net_config = new System.IO.FileInfo("log4net.xml"); log4net.Config.XmlConfigurator.ConfigureAndWatch(log4net_config); BauerLib.log4netAdoProviderHelper.ConfigureConnectionStringToAllLoggers(); BauerLib.MemoryAppenderWithEvents.RemoveAppender("HttpAppender"); // prevent recursion BauerLib.MemoryAppenderWithEvents.AddAppenderToAllLoggersEvent(HandleLogEvent); //x.UseLog4Net(); x.RunAsLocalSystem(); x.SetDescription("Bauer Logistics Site redirect"); x.SetDisplayName("WIP Redirect"); x.SetServiceName("WIP Redirect"); x.Service <BauerWIPService>(s => { s.ConstructUsing(name => new BauerWIPService()); s.WhenStarted(tc => { tc.Start(); /*gel_plc_status_timer.Start();*/ }); s.WhenStopped(tc => { tc.Stop(); /*gel_plc_status_timer.Stop();*/ }); }); }); }
public static void Main() { try { // preparation for use with Fody.Costura: DotLiquid.Hash h = new DotLiquid.Hash(); Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations r = new Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations(); Nancy.Json.JsonSettings.MaxJsonLength = Int32.MaxValue; string cwd = System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); System.IO.Directory.SetCurrentDirectory(cwd ?? "."); log.InfoFormat("{0} started.", Environment.GetCommandLineArgs()[0]); } catch (Exception) { } ip_address = Registry.PlcAddress; //var gel_plc_status_timer = new System.Timers.Timer(5000); //gel_plc_status_timer.Elapsed += (s, e) => //{ // var plc = 0; // BauerPLC.SingleCommands.com(Program.ip_address); // int stat = 0; // BauerPLC.SingleCommands.GetStatusWord(plc); // int cnt = 1; // BauerPLC.SingleCommands.GetCounter(plc); // lock (StatusController.status_lock) // { // if (stat > 0 && cnt>0) // { // StatusController.last_status = stat; // BauerWIPService.RfzCounter = cnt; // StatusController.last_status_get = DateTime.Now; // } // } //}; HostFactory.Run(x => { try { var log4net_config = new System.IO.FileInfo("log4net.xml"); log4net.Config.XmlConfigurator.ConfigureAndWatch(log4net_config); BauerLib.log4netAdoProviderHelper.ConfigureConnectionStringToAllLoggers(); BauerLib.MemoryAppenderWithEvents.RemoveAppender("HttpAppender"); // prevent recursion BauerLib.MemoryAppenderWithEvents.AddAppenderToAllLoggersEvent(HandleLogEvent); log4net.LogManager.GetRepository().ConfigurationChanged += (s, e) => { try { BauerLib.log4netAdoProviderHelper.ConfigureConnectionStringToAllLoggers(); BauerLib.MemoryAppenderWithEvents.RemoveAppender("HttpAppender"); // prevent recursion BauerLib.MemoryAppenderWithEvents.AddAppenderToAllLoggersEvent(HandleLogEvent); } catch { } }; } catch { } x.UseLog4Net(); x.RunAsLocalSystem(); x.SetDescription("Bauer Logistics WIP Storage Site"); x.SetDisplayName("WIP Site"); x.SetServiceName("WIP Site"); x.Service <BauerWIPService>(s => { s.ConstructUsing(name => new BauerWIPService()); s.WhenStarted(tc => { tc.Start(); /*gel_plc_status_timer.Start();*/ }); s.WhenStopped(tc => { tc.Stop(); /*gel_plc_status_timer.Stop();*/ }); }); }); }