private void StopRunner() { _runner.Stop(); Busy = false; _runner = null; RestartRunner(); }
public Worker( ILogger <Worker> logger, IConfigService configService, IProjectGenerator projectGenerator, IProjectRunner projectRunner ) { _logger = logger; _configService = configService; _projectGenerator = projectGenerator; _projectRunner = projectRunner; }
protected override void OnStop() { try { _runner.Stop(); } catch (Exception exception) { _reporter.Report(Res.StopError, exception); } finally { _runner = null; } }
protected override void OnStop() { try { _runner.Stop(); } catch (Exception exception) { _reporter.Report(Res.StopError, exception); } finally { _runner = null; } }
private void RestartRunner() { if (_runner == null) { if (_connectionParameters != null) { _runner = _runnerFactory.Create(_connectionParameters.Database, _connectionParameters.ConnectionString); Busy = true; _actionHelper.Async(StartRunner); } } else { Busy = true; _actionHelper.Async(StopRunner); } }
protected override void OnStart(string[] args) { try { var connectionStringHelper = new ConnectionStringHelper(); var connectionString = connectionStringHelper.Get(PHmiConstants.PHmiConnectionStringName); connectionStringHelper.Protect(); var connectionParameters = new NpgConnectionParameters(); connectionParameters.Update(connectionString); _runner = _runnerFactory.Create(connectionParameters.Database, connectionString); _runner.Start(); } catch (Exception exception) { _reporter.Report(Res.StartError, exception); } }
protected override void OnStart(string[] args) { try { var connectionStringHelper = new ConnectionStringHelper(); var connectionString = connectionStringHelper.Get(PHmiConstants.PHmiConnectionStringName); connectionStringHelper.Protect(); var connectionParameters = new NpgConnectionParameters(); connectionParameters.Update(connectionString); _runner = _runnerFactory.Create(connectionParameters.Database, connectionString); _runner.Start(); } catch (Exception exception) { _reporter.Report(Res.StartError, exception); } }
protected override void EstablishContext() { base.EstablishContext(); Context = new Mock <IModelContext>(); TimeService = new Mock <ITimeService>(); Reporter = new Mock <IReporter>(); ServiceRunnerFactory = new Mock <IServiceRunnerFactory>(); CyclicRunnerFactory = new Mock <ICyclicRunnerFactory>(); IoDeviceRunTargetFactory = new Mock <IIoDeviceRunTargetFactory>(); DataDbCreatorFactory = new Mock <IDataDbCreatorFactory>(); DataDbCreator = new Mock <IDataDbCreator>(); DataDbCreatorFactory.Setup(f => f.Create(DataDbConStr, Reporter.Object)) .Returns(DataDbCreator.Object); UsersRunner = new Mock <IUsersRunner>(); UsersRunnerFactory = new Mock <IUsersRunnerFactory>(); UsersRunnerFactory.Setup(f => f.Create(Context.Object, DataDbConStr)).Returns( UsersRunner.Object); AlarmsRunTargetFactory = new Mock <IAlarmsRunTargetFactory>(); TrendsRunTargetFactory = new Mock <ITrendsRunTargetFactory>(); LogRunTargetFactory = new Mock <ILogRunTargetFactory>(); ProjectRunner = new ProjectRunner( ProjectName, Context.Object, TimeService.Object, Reporter.Object, DataDbConStr, DataDbCreatorFactory.Object, UsersRunnerFactory.Object, ServiceRunnerFactory.Object, CyclicRunnerFactory.Object, IoDeviceRunTargetFactory.Object, AlarmsRunTargetFactory.Object, TrendsRunTargetFactory.Object, LogRunTargetFactory.Object); ServiceRunner = new Mock <IRunner>(); ServiceRunnerFactory.Setup(f => f.Create(ProjectRunner, Server, null, TimeService.Object)) .Returns(ServiceRunner.Object); Settings = new Settings { Server = Server }; Context.Setup(c => c.Get <Settings>()).Returns(new EnumerableQuery <Settings>(new[] { Settings })); }
protected override void EstablishContext() { base.EstablishContext(); Runner = RunnerFactory.Create(ProjectName, ConnectionString); }
protected override void EstablishContext() { base.EstablishContext(); Runner = RunnerFactory.Create(ProjectName, ConnectionString); }
protected override void EstablishContext() { base.EstablishContext(); Context = new Mock<IModelContext>(); TimeService = new Mock<ITimeService>(); Reporter = new Mock<IReporter>(); ServiceRunnerFactory = new Mock<IServiceRunnerFactory>(); CyclicRunnerFactory = new Mock<ICyclicRunnerFactory>(); IoDeviceRunTargetFactory = new Mock<IIoDeviceRunTargetFactory>(); DataDbCreatorFactory = new Mock<IDataDbCreatorFactory>(); DataDbCreator = new Mock<IDataDbCreator>(); DataDbCreatorFactory.Setup(f => f.Create(DataDbConStr, Reporter.Object)).Returns(DataDbCreator.Object); UsersRunner = new Mock<IUsersRunner>(); UsersRunnerFactory = new Mock<IUsersRunnerFactory>(); UsersRunnerFactory.Setup(f => f.Create(Context.Object, DataDbConStr)).Returns( UsersRunner.Object); AlarmsRunTargetFactory = new Mock<IAlarmsRunTargetFactory>(); TrendsRunTargetFactory = new Mock<ITrendsRunTargetFactory>(); LogRunTargetFactory = new Mock<ILogRunTargetFactory>(); ProjectRunner = new ProjectRunner( ProjectName, Context.Object, TimeService.Object, Reporter.Object, DataDbConStr, DataDbCreatorFactory.Object, UsersRunnerFactory.Object, ServiceRunnerFactory.Object, CyclicRunnerFactory.Object, IoDeviceRunTargetFactory.Object, AlarmsRunTargetFactory.Object, TrendsRunTargetFactory.Object, LogRunTargetFactory.Object); ServiceRunner = new Mock<IRunner>(); ServiceRunnerFactory.Setup(f => f.Create(ProjectRunner, Server, null, TimeService.Object)).Returns(ServiceRunner.Object); Settings = new Settings { Server = Server }; Context.Setup(c => c.Get<Settings>()).Returns(new EnumerableQuery<Settings>(new[] { Settings })); }