private static void Main() { var conf = new Configuration(ExecutionEnvironment.Test); BootStrapDependencies(conf); HostFactory.Run(x => { RunAsExtensions.RunAs(x, conf.ServiceUserName, conf.ServiceUserPasswordEncrypted); x.SetDescription("Calculates and provides calendar and product info data."); StartModeExtensions.StartManually(x); x.SetDisplayName(conf.ServiceDisplayName); x.SetServiceName(conf.ServiceName); ServiceExtensions.Service <PricingService>(x, s => { s.ConstructUsing( name => new PricingService(ResolutionExtensions.Resolve <Configuration>(Container))); ServiceConfiguratorExtensions.WhenStarted <PricingService>(s, tc => tc.OnStart()); ServiceConfiguratorExtensions.WhenStopped <PricingService>(s, tc => tc.OnStop()); ServiceConfiguratorExtensions.WhenShutdown <PricingService>(s, tc => tc.OnStop()); }); InstallHostConfiguratorExtensions.BeforeInstall(x, () => NetShellCmdLineTool.RegisterHttpNamespace(conf)); UninstallHostConfiguratorExtensions.AfterUninstall(x, () => NetShellCmdLineTool.UnregisterHttpNamespace(conf)); }); }
public static void Main(string[] args) { try { XmlConfigurator.Configure(); var ioc = IocHelper.Instance; ioc.Install(new Windsor.Installer()); if (args.Length > 0 && args[0] == "now") { try { AbstractController controller = new Jobs.Demo.QuartzController(); controller.ExecuteBusinessJob(); ioc.Dispose(); } catch (Exception ex) { log.Error("An error has ocurred trying to execute job", ex); } } else { HostFactory.Run(hostConfigurator => { hostConfigurator.SetServiceName(ConfigurationManager.AppSettings["ServiceName"]); hostConfigurator.SetDisplayName(ConfigurationManager.AppSettings["ServiceDisplayName"]); hostConfigurator.SetDescription(ConfigurationManager.AppSettings["ServiceDescription"]); RunAsExtensions.RunAsLocalSystem(hostConfigurator); StartModeExtensions.StartAutomatically(hostConfigurator); hostConfigurator.Service <Service>(serviceConfigurator => { serviceConfigurator.ConstructUsing(() => new Service()); serviceConfigurator.WhenStarted(service => service.Start()); serviceConfigurator.WhenStopped(service => service.Stop()); }); }); } } catch (Exception ex) { log.Error("An error has ocurred trying to execute job", ex); } }