public void Start() { var config = CfgUtils.LookupDefaultConfigs(); var serviceOptions = new ServiceOptions(); var exchangeSection = config.GetSection("Exchange"); var serviceOptionSection = exchangeSection.GetSection("Service"); serviceOptionSection?.Bind(serviceOptions); CfgUtils.SetupIoC(config); ImportDataService <HostControl> .Configuration = config; //RedmineImportWorker.Configuration = Configuration; //инициализация сервиса switch (serviceOptions.Type) { case "ProcessService": HostFactory.Run(x => { x.Service <ProcessDataService>(); //Как описание использовать ConverterService x.RunAsLocalSystem(); //Запускать под учетной записью System x.StartManually(); //Запуск вручную //x.UseNLog(); x.SetServiceName(serviceOptions.Name); x.SetDescription($"{serviceOptions.Name} - {serviceOptions.Description} "); x.SetDisplayName(serviceOptions.Name); }); break; case "ExportService": HostFactory.Run(x => { x.Service <ExportDataService>(); //Как описание использовать ConverterService x.RunAsLocalSystem(); //Запускать под учетной записью System x.StartManually(); //Запуск вручную // x.UseNLog(); x.SetServiceName(serviceOptions.Name); x.SetDescription($"{serviceOptions.Name} - {serviceOptions.Description} "); x.SetDisplayName(serviceOptions.Name); }); break; case "ImportService": HostFactory.Run(x => { x.Service <ImportDataService>(); //Как описание использовать ConverterService x.RunAsLocalSystem(); //Запускать под учетной записью System x.StartManually(); //Запуск вручную // x.UseNLog(); x.SetServiceName(serviceOptions.Name); x.SetDescription($"{serviceOptions.Name} - {serviceOptions.Description} "); x.SetDisplayName(serviceOptions.Name); }); break; } }
public virtual void Init() { #if NET452 Assembly assembly = Assembly.GetCallingAssembly(); AppDomainManager manager = new AppDomainManager(); FieldInfo entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic); entryAssemblyfield.SetValue(manager, assembly); AppDomain domain = AppDomain.CurrentDomain; FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic); domainManagerField.SetValue(domain, manager); #endif var config = CfgUtils.LookupDefaultConfigs(); var serviceOptions = new ServiceOptions(); var exchangeSection = config.GetSection("Exchange"); var serviceOptionSection = exchangeSection.GetSection("Service"); serviceOptionSection?.Bind(serviceOptions); CfgUtils.SetupIoC(config); ProcessDataService <Task> .Configuration = config; ImportDataService <Task> .Configuration = config; ExportDataService <Task> .Configuration = config; }