public void Execute(IJobExecutionContext context) { if (DbFactory == null) { var nh = new ProducerInterfaceCommon.ContextModels.NHibernate(); nh.Init(); DbFactory = nh.Factory; } var dbSession = DbFactory.OpenSession(); try { var serviceTaskManager = dbSession.Query <ServiceTaskManager>().FirstOrDefault(s => s.JobName == context.JobDetail.Key.Name); if (serviceTaskManager == null) { logger.Error($"Сервис с ключем {context.JobDetail.Key.Name} не найден. Запуск данного сервиса остановлен."); //нужно уточнить, что делать с задачей, если ее нет в БД, останавливать или добалвять в БД var tManager = new TaskManager(); tManager.ServiceQuartzStop(context.JobDetail.Key.Name); } var type = Type.GetType($"{serviceTaskManager.ServiceType}, {typeof (Report).Assembly.FullName}"); var service = (BaseTaskManagerService)Activator.CreateInstance(type); service.ServiceRun(dbSession); serviceTaskManager.LastRun = SystemTime.Now().DateTime; dbSession.Save(serviceTaskManager); } finally { dbSession.Flush(); dbSession.Close(); } }
public void SetupFixture() { Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; SeleniumFixture.GlobalSetup(); server = SeleniumFixture.StartServer("../../../app/"); Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; Test.Support.Setup.BuildConfiguration("db"); var holder = ActiveRecordMediator.GetSessionFactoryHolder(); var cfg = holder.GetConfiguration(typeof(ActiveRecordBase)); var init = new ProducerInterfaceCommon.ContextModels.NHibernate(); init.Configuration = cfg; init.Init(); var factory = holder.GetSessionFactory(typeof(ActiveRecordBase)); IntegrationFixture2.Factory = factory; }
protected void Application_Start() { try { XmlConfigurator.Configure(); Log.Logger.Repository.RendererMap.Put(typeof(Exception), new ExceptionRenderer()); GlobalContext.Properties["version"] = typeof(SlideController).Assembly.GetName().Version; ViewEngines.Engines.Add(new ProducerInterfaceCommon.Heap.MyViewEngine()); AreaRegistration.RegisterAllAreas(); var nh = new ProducerInterfaceCommon.ContextModels.NHibernate(); nh.Init(); GlobalFilters.Filters.Add(new ErrorFilter()); GlobalFilters.Filters.Add(new SessionFilter(nh.Factory)); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } catch (Exception e) { Log.Error("Ошибка при инициализации приложения", e); throw; } }