Example #1
0
        public AlarmsRunTarget(
            AlarmCategory alarmCategory,
            INotificationReporter reporter,
            IAlarmsRepository repository,
            IProject project,
            ITimeService timeService,
            INpgsqlConnectionFactory connectionFactory)
        {
            _name = string.Format("{0} \"{1}\"", Res.Alarms, alarmCategory.Name);
            _reporter = reporter;
            _timeService = timeService;
            _repository = repository;
            _project = project;
            _connectionFactory = connectionFactory;
            if (alarmCategory.TimeToStoreDb.HasValue)
            {
                _timeToStore = new TimeSpan(alarmCategory.TimeToStoreDb.Value);
            }

            _alarmDigitalValues = new Dictionary<int, AlarmStatus>(alarmCategory.AlarmTags.Count);
            foreach (var t in alarmCategory.AlarmTags)
            {
                _alarmDigitalValues.Add(t.Id, new AlarmStatus(t.Acknowledgeable));
                _alarmPrivileges.Add(t.Id, t.Privilege);
            }

            _updateAlarmTagsDigitalValues = () => UpdateAlarmDigitalValues(GetIoDeviceGroups(alarmCategory));
        }
Example #2
0
 public ProjectRunner(
     string projectName,
     IModelContext context,
     ITimeService timeService,
     IReporter reporter,
     string dataDbConnectionString,
     IDataDbCreatorFactory dataDbCreatorFactory,
     IUsersRunnerFactory usersRunnerFactory,
     IServiceRunnerFactory serviceRunnerFactory,
     ICyclicRunnerFactory cyclicRunnerFactory,
     IIoDeviceRunTargetFactory ioDeviceRunTargetFactory,
     IAlarmsRunTargetFactory alarmsRunTargetFactory,
     ITrendsRunTargetFactory trendsRunTargetFactory,
     ILogRunTargetFactory logMaintainerFactory)
 {
     _projectName = projectName;
     _context = context;
     _timeService = timeService;
     _reporter = reporter;
     _dataDbConnectionString = dataDbConnectionString;
     _dataDbCreator = dataDbCreatorFactory.Create(_dataDbConnectionString, _reporter);
     _usersRunnerFactory = usersRunnerFactory;
     _serviceRunnerFactory = serviceRunnerFactory;
     _cyclicRunnerFactory = cyclicRunnerFactory;
     _ioDeviceRunTargetFactory = ioDeviceRunTargetFactory;
     _alarmsRunTargetFactory = alarmsRunTargetFactory;
     _trendsRunTargetFactory = trendsRunTargetFactory;
     _logMaintainerFactory = logMaintainerFactory;
 }
Example #3
0
 public IIoDeviceRunTarget Create(ITimeService timeService, IoDevice ioDevice)
 {
     return new IoDeviceRunTarget(
         ioDevice,
         new IoDeviceWrapperFactory(string.Format("{0} domain", ioDevice.Name)),
         new NotificationReporter(timeService){LifeTime = TimeSpan.FromTicks(0)});
 }
Example #4
0
 public MeazureRunner(ITaskService taskService, ITimeService timeService, IInputService inputService, IProjectService projectService)
 {
     _taskService = taskService;
     _timeService = timeService;
     _inputService = inputService;
     _projectService = projectService;
 }
Example #5
0
        // constructors
        public Database(EntityApp app, DbSettings settings)
        {
            _app = app;
              Settings = settings;
              _driver = Settings.ModelConfig.Driver;
              _entityModel = app.Model;
              _timeService = _app.TimeService;
              //Set list of all schemas
              var allSchemas = app.Areas.Select(a => settings.ModelConfig.GetSchema(a));
              settings.SetSchemas(allSchemas);

              //Check if model is shared
              bool modelIsShared = Settings.ModelConfig.Options.IsSet(DbOptions.ShareDbModel);
              lock (_lock) { //we need lock to prevent collision on shared model
              if (modelIsShared)
            DbModel = Settings.ModelConfig.SharedDbModel;
              if (DbModel == null) {
            var dbmBuilder = new DbModelBuilder(app.Model, settings.ModelConfig, app.ActivationLog);
            DbModel = dbmBuilder.Build();
            if (modelIsShared)
              Settings.ModelConfig.SharedDbModel = DbModel;
              }
            }//lock

              //Save
        }
Example #6
0
 private static void Query( ITimeService service )
 {
     for ( int i = 0; i < QUERIES; i++ )
     {
         Console.WriteLine( "Server time:\t{0}", service.WhatTimeIsIt() );
         Thread.Sleep( SLEEP );
     }
 }
Example #7
0
 public HomeAssembler(
     IEntryService entryService, 
     ITimeService timeService,
     IUserSettingsService userSettingService)
 {
     _entryService = entryService;
     _timeService = timeService;
     _userSettingsService = userSettingService;
 }
Example #8
0
 public NaggerRunner(ITimeService timeService,
     IInputService inputService, IOutputService outputService, IRemoteRunner remoteRunner, ISettingsService settingsService)
 {
     _timeService = timeService;
     _inputService = inputService;
     _outputService = outputService;
     _remoteRunner = remoteRunner;
     _settingsService = settingsService;
 }
Example #9
0
 public DbUpgradeManager(DataSource dataSource)
 {
     _dataSource = dataSource;
       _dataAccess = (DataAccessService) _dataSource.App.DataAccess;
       _database = _dataSource.Database;
       _app = _database.DbModel.EntityApp;
       _log = _app.ActivationLog;
       _timeService = _app.GetService<ITimeService>();
 }
 public GherkinFileGitPollingSynchronizerFactory(IGherkinFileRepository gherkinFileRepository, ICommandBuilderFactory commandBuilderFactory, IBoundaryFactory boundaryFactory, IBoundary boundary, ILogger logger, ITimeService timeService)
 {
     this.gherkinFileRepository = gherkinFileRepository;
     this.commandBuilderFactory = commandBuilderFactory;
     this.boundaryFactory = boundaryFactory;
     this.boundary = boundary;
     this.logger = logger;
     this.timeService = timeService;
 }
Example #11
0
 public JiraRunner(IOutputService outputService, ITaskService taskService, ITimeService timeService,
     IProjectService projectService, IInputService inputService)
 {
     _outputService = outputService;
     _taskService = taskService;
     _timeService = timeService;
     _projectService = projectService;
     _inputService = inputService;
 }
        public SchedulingService(ITimeService timeService)
        {
            Argument.IsNotNull(() => timeService);

            _timeService = timeService;
            _timer = new Timer(OnTimerTick);

            IsEnabled = true;
        }
Example #13
0
 public LogMaintainer(
     logs log,
     ILogRepository repository,
     ITimeService timeService,
     INpgsqlConnectionFactory connectionFactory)
 {
     _repository = repository;
     _timeService = timeService;
     _connectionFactory = connectionFactory;
     _timeToStore = log.time_to_store.HasValue ? new TimeSpan(log.time_to_store.Value) as TimeSpan? : null;
 }
Example #14
0
 public LogMaintainer(
     PHmiModel.Entities.Log log,
     ILogRepository repository,
     ITimeService timeService,
     INpgsqlConnectionFactory connectionFactory)
 {
     _repository = repository;
     _timeService = timeService;
     _connectionFactory = connectionFactory;
     _timeToStore = log.TimeToStoreDb.HasValue ? new TimeSpan(log.TimeToStoreDb.Value) as TimeSpan? : null;
 }
Example #15
0
 public ProjectRunnerFactory(
     ITimeService timeService, 
     IReporter reporter,
     IModelContextFactory contextFactory,
     INpgHelper npgHelper)
 {
     _timeService = timeService;
     _reporter = reporter;
     _contextFactory = contextFactory;
     _npgHelper = npgHelper;
 }
		public SimultaneousKeys(bool stateA, bool stateB, ITimeService timeService)
		{
			_timeService = timeService;
			_keyState = new bool[2];
			_keyState[0] = stateA;
			_keyState[1] = stateB;

			_keyWhen = new DateTime[2];
			_keyWhen[0] = _timeService.Now();
			_keyWhen[1] = _timeService.Now();
		}
        public HomeViewModel (
            IRepository repository, 
            ITimeService timeService, 
            ITwitterService twitterService)
		{
            _repository = repository;
            _timeService = timeService;
			_twitterService = twitterService;

			CurrentSessions = new List<HomeCurrentSessionViewModel> ();
			Tweets = new List<TweetCellViewModel> ();

		}
        public static bool IsExpired(this RunningTask runningTask, ITimeService timeService)
        {
            Argument.IsNotNull(() => runningTask);
            Argument.IsNotNull(() => timeService);

            var duration = timeService.CurrentDateTime - runningTask.Started;
            if (duration > runningTask.ScheduledTask.MaximumDuration)
            {
                return true;
            }

            return false;
        }
Example #19
0
 public EntryService(IEntryRepository entryRepository, 
                     ILocationRepository locationRepository, 
                     ITagRepository tagRepository,
                     ITimelineColorService timelineColorService,
                     ITimeService timeService,
                     IScope scope)
 {
     _entryRepository = entryRepository;
     _locationRepository = locationRepository;
     _tagRepository = tagRepository;
     _timelineColorService = timelineColorService;
     _timeService = timeService;
     _scope = scope;
 }
Example #20
0
 public ILogMaintainer Create(string connectionString, PHmiModel.Entities.Log log, ITimeService timeService)
 {
     var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
     var logRepository = new LogRepository(log.Id);
     using (var connection = npgsqlConnectionFactory.Create())
     {
         logRepository.EnsureTable(connection);
     }
     return new LogMaintainer(
         log,
         logRepository,
         timeService,
         npgsqlConnectionFactory);
 }
Example #21
0
 public EntryService(IEntryRepository entryRepository, 
                     ILocationRepository locationRepository, 
                     ITagRepository tagRepository,
                     ITimelineColorService timelineColorService,
                     ITimeService timeService,
                     IUnitOfWork unitOfWork)
 {
     _entryRepository = entryRepository;
     _locationRepository = locationRepository;
     _tagRepository = tagRepository;
     _timelineColorService = timelineColorService;
     _timeService = timeService;
     _unitOfWork = unitOfWork;
 }
Example #22
0
 public EntityCache(EntityApp app, CacheSettings settings, Database database)
 {
     _app = app;
       Settings = settings;
       _dataStore = database;
       _sparseCache = new SparseEntityCache(Settings);
       var dbIsCaseInsensitive = database.Settings.Driver.Features.IsSet(Data.Driver.DbFeatures.DefaultCaseInsensitive);
       var caseMode = dbIsCaseInsensitive ? StringCaseMode.CaseInsensitive : StringCaseMode.CaseSensitive;
       _fullSetCache = new FullSetEntityCache(_app, Settings, _dataStore, caseMode);
       _timeService = _app.GetService<ITimeService>();
       _logService = _app.GetService<IOperationLogService>();
       _errorLog = _app.GetService<IErrorLogService>();
       MarkCachedEntities();
       _app.AppEvents.SavedChanges += Events_SavedChanges;
 }
Example #23
0
 public IAlarmsRunTarget Create(string connectionString, IProject project, alarm_categories alarmCategory, ITimeService timeService)
 {
     var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
     var alarmsRepository = new AlarmsRepository(alarmCategory.id);
     using (var connection = npgsqlConnectionFactory.Create())
     {
         alarmsRepository.EnsureTable(connection);
     }
     return new AlarmsRunTarget(
         alarmCategory,
         new NotificationReporter(timeService) {LifeTime = TimeSpan.FromTicks(0)},
         alarmsRepository,
         project,
         timeService,
         npgsqlConnectionFactory);
 }
Example #24
0
        // MonoBehaviour
        //

        void Awake() {
            // time service
            time = IOC.Resolve<ITimeService>();
            time.TimeUpdated += UpdateTimeText;

            // score service
            score = IOC.Resolve<IScoreService>();
            score.ScoreUpdated += UpdateScoreText;

            // registry service
            registry = IOC.Resolve<IRegistryService>();
            registry.Register<IGameUI>("GameUI", this);

            // animator component
            animator = GetComponent<Animator>();

            // game ready behaviour
            gameReadyBehaviour = animator.GetBehaviour<GameReadyBehaviour>();
            gameReadyBehaviour.gameUI = this;
        }
Example #25
0
        public ITrendsRunTarget Create(string connectionString, IProject project, trend_categories trendCategory, ITimeService timeService)
        {
            var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
            var repositoryFactory = new TrendsRepositoryFactory(
                npgsqlConnectionFactory,
                trendCategory.id,
                trendCategory.trend_tags.Select(t => t.id).ToArray());
            using (var repository = repositoryFactory.Create())
            {
                repository.EnsureTables();
            }

            return new TrendsRunTarget(
                trendCategory,
                new NotificationReporter(timeService) { LifeTime = TimeSpan.FromTicks(0) },
                repositoryFactory,
                project,
                timeService,
                new TrendTableSelector());
        }
Example #26
0
        // Monobehaviour
        //

        /// <summary>
        /// Set up internal data objects. Resolve references to services.
        /// </summary>
        void Awake() {
            
            // create new list to hold enemy references
            enemyList = new List<IEnemy>();

            // resolve services
            enemies = IOC.Resolve<IEnemyFactory>();
            time = IOC.Resolve<ITimeService>();
            registry = IOC.Resolve<IRegistryService>();
            shipController = IOC.Resolve<IShipController>();
            endGameController = IOC.Resolve<IEndGameController>();

            // initialize wave info
            currentWaveIndex = 0;

            // get pointer to current wave
            currentWave = waveData.waves[0];

            // set start time on countdown
            time.SetCountdown(waveData.startTime);
        }
Example #27
0
 public TrendsRunTarget(
     trend_categories trendCategory,
     INotificationReporter reporter,
     ITrendsRepositoryFactory repositoryFactory,
     IProject project,
     ITimeService timeService,
     ITrendTableSelector tableSelector)
 {
     _name = string.Format("{0} \"{1}\"", Res.Trends, trendCategory.name);
     _timeToStore = trendCategory.time_to_store.HasValue ? new TimeSpan(trendCategory.time_to_store.Value) as TimeSpan? : null;
     foreach (var t in trendCategory.trend_tags.ToArray())
     {
         Func<bool> triggerValueGetter;
         if (t.dig_tags == null)
         {
             triggerValueGetter = () => true;
         }
         else
         {
             var trIoDevId = t.dig_tags.io_devices.id;
             var trId = t.dig_tags.id;
             triggerValueGetter = () => project.IoDeviceRunTargets[trIoDevId].GetDigitalValue(trId) == true;
         }
         var ioDeviceId = t.num_tags.io_devices.id;
         var tagId = t.num_tags.id;
         var trendInfo = new TrendTagInfo(
             t.id,
             triggerValueGetter,
             () => project.IoDeviceRunTargets[ioDeviceId].GetNumericValue(tagId));
         _trendsInfo.Add(t.id, trendInfo);
     }
     _reporter = reporter;
     _repositoryFactory = repositoryFactory;
     _timeService = timeService;
     _tableSelector = tableSelector;
 }
Example #28
0
 public void Destroy()
 {
     _timeService.Destroy();
     _timeService = null;
 }
 protected abstract T CreateStorage(ITimeService timeService);
 public TimeEntryRivalsResolver(ITimeService timeService)
 {
     this.timeService = timeService;
 }
Example #31
0
 public BaseWebTest()
 {
     timeService = new ManagedTimeService();
     httpClient  = GetClient();
 }
Example #32
0
 protected override MemoryStorage CreateStorage(ITimeService timeService)
 {
     return(new MemoryStorage(timeService));
 }
Example #33
0
 public RegisterTimeServiceSystem(Contexts contexts, ITimeService timeService)
 {
     _context     = contexts.game;
     _timeService = timeService;
 }
Example #34
0
        public ProjectsDataSource(IIdProvider idProvider, IRepository <IDatabaseProject> repository, ITimeService timeService)
        {
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(repository, nameof(repository));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.repository  = repository;
            this.idProvider  = idProvider;
            this.timeService = timeService;
        }
        //public DbSet<TodoList> TodoLists { get; set; }

        public TodoListContext(DbContextOptions options, ITimeService clock)
            : base(options, clock)
        {
        }
Example #36
0
 public Builder WithTimeService(ITimeService timeService)
 {
     TimeService = timeService;
     return(this);
 }
Example #37
0
        public void BuildAdvice(IEnumerable <Candle> candles, decimal currentPrice, ITimeService timeService)
        {
            if (this._traceStatusId != TraceStatus.Started.Id)
            {
                throw new TrendAnalysisDomainException("Building Advice can only happened after started.");
            }
            if (this._tradeStrategies.Where(t => t.IsUpToDate(timeService) == false).Any())
            {
                return;
            }

            var decision = this.CalculateDecisionByWeight();

            TradeAdvice tradeAdvice = null;


            if (decision.Id == TradingSignalType.Buy.Id)
            {
                var targetPrice = CalculateTargetPrice(candles, currentPrice);

                var advice = new TradeAdvice(
                    Guid.NewGuid().ToString(),
                    this.TraceId,
                    timeService.GetCurrentDateTime(),
                    decision.Id,
                    currentPrice,
                    targetPrice
                    );

                tradeAdvice = advice;

                /*var targetIndex = 0;
                 *
                 * for (int index = 0; index < (fibonacci.Count - 1); index++)
                 * {
                 *  if (fibonacci[index].Value == top)
                 *  {
                 *      targetIndex = index + 1;
                 *  }
                 * }*/
            }

            if (decision.Id == TradingSignalType.Hold.Id)
            {
                var advice = new TradeAdvice(
                    Guid.NewGuid().ToString(),
                    this.TraceId,
                    timeService.GetCurrentDateTime(),
                    decision.Id,
                    currentPrice,
                    currentPrice
                    );

                tradeAdvice = advice;
            }

            if (decision.Id == TradingSignalType.Sell.Id)
            {
                var advice = new TradeAdvice(
                    Guid.NewGuid().ToString(),
                    this.TraceId,
                    timeService.GetCurrentDateTime(),
                    decision.Id,
                    currentPrice,
                    currentPrice
                    );

                tradeAdvice = advice;
            }


            this._tradeAdvices.Add(tradeAdvice);

            this.AddDomainEvent(new TradeAdviceCreatedDomainEvent(tradeAdvice, decision, candles));
        }
Example #38
0
 public StunProcessSystem(Contexts contexts)
 {
     stunedEntities = contexts.game.GetGroup(GameMatcher.EffectData);
     _timeService   = contexts.service.timeService.instance;
 }
Example #39
0
        public SignupViewModel(
            IApiFactory apiFactory,
            IUserAccessManager userAccessManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IPlatformInfo platformInfo)
        {
            Ensure.Argument.IsNotNull(apiFactory, nameof(apiFactory));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(errorHandlingService, nameof(errorHandlingService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));

            this.apiFactory           = apiFactory;
            this.userAccessManager    = userAccessManager;
            this.analyticsService     = analyticsService;
            this.onboardingStorage    = onboardingStorage;
            this.navigationService    = navigationService;
            this.errorHandlingService = errorHandlingService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;
            this.schedulerProvider    = schedulerProvider;
            this.rxActionFactory      = rxActionFactory;
            this.platformInfo         = platformInfo;

            Login        = rxActionFactory.FromAsync(login);
            Signup       = rxActionFactory.FromAsync(signup);
            GoogleSignup = rxActionFactory.FromAsync(googleSignup);
            PickCountry  = rxActionFactory.FromAsync(pickCountry);

            var emailObservable = emailSubject.Select(email => email.TrimmedEnd());

            Shake = shakeSubject.AsDriver(this.schedulerProvider);

            Email = emailObservable
                    .Select(email => email.ToString())
                    .DistinctUntilChanged()
                    .AsDriver(this.schedulerProvider);

            Password = passwordSubject
                       .Select(password => password.ToString())
                       .DistinctUntilChanged()
                       .AsDriver(this.schedulerProvider);

            IsLoading = isLoadingSubject
                        .DistinctUntilChanged()
                        .AsDriver(this.schedulerProvider);

            IsCountryErrorVisible = isCountryErrorVisibleSubject
                                    .DistinctUntilChanged()
                                    .AsDriver(this.schedulerProvider);

            ErrorMessage = errorMessageSubject
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);

            CountryButtonTitle = countryNameSubject
                                 .DistinctUntilChanged()
                                 .AsDriver(this.schedulerProvider);

            IsPasswordMasked = isPasswordMaskedSubject
                               .DistinctUntilChanged()
                               .AsDriver(this.schedulerProvider);

            IsShowPasswordButtonVisible = Password
                                          .Select(password => password.Length > 1)
                                          .CombineLatest(isShowPasswordButtonVisibleSubject.AsObservable(), CommonFunctions.And)
                                          .DistinctUntilChanged()
                                          .AsDriver(this.schedulerProvider);

            HasError = ErrorMessage
                       .Select(string.IsNullOrEmpty)
                       .Select(CommonFunctions.Invert)
                       .AsDriver(this.schedulerProvider);

            SignupEnabled = emailObservable
                            .CombineLatest(
                passwordSubject.AsObservable(),
                IsLoading,
                countryNameSubject.AsObservable(),
                (email, password, isLoading, countryName) => email.IsValid && password.IsValid && !isLoading && (countryName != Resources.SelectCountry))
                            .DistinctUntilChanged()
                            .AsDriver(this.schedulerProvider);

            SuccessfulSignup = successfulSignupSubject
                               .AsDriver(this.schedulerProvider);
        }
 public BackgroundServiceTest()
 {
     TimeService = Substitute.For <ITimeService>();
 }
Example #41
0
        public DateTime GetCurrentCandleDateTime(ITimeService timeService)
        {
            if (timeService == null)
            {
                throw new ArgumentNullException();
            }

            var dateTime = timeService.GetCurrentDateTime();

            var minute = this.GetPeriodMinute();
            var hour   = this.GetPeriodHour();
            var day    = this.GetPeriodDay();
            var week   = this.GetPeriodWeek();

            if (minute == 0 && hour == 0 && day == 0)
            {
                DateTime monday = dateTime;
                while (monday.DayOfWeek != DayOfWeek.Monday)
                {
                    monday = monday.AddDays(-1);
                }

                return(new DateTime(monday.Year, monday.Month, monday.Day, 0, 0, 0, 0));
            }
            else if (minute == 0 && hour == 0)
            {
                if (dateTime.Hour != 0 || dateTime.Minute != 0 || dateTime.Second != 0 || dateTime.Millisecond != 0)
                {
                    var substractDays = dateTime.AddDays(-1);
                    return(new DateTime(substractDays.Year, substractDays.Month, substractDays.Day, 0, 0, 0, 0));
                }
                else
                {
                    return(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, 0));
                }
            }
            else if (minute == 0)
            {
                if (dateTime.Hour % hour != 0 ||
                    dateTime.Minute != 0 || dateTime.Second != 0 || dateTime.Millisecond != 0)
                {
                    int hoursToSub = dateTime.Hour % hour;
                    var subHours   = dateTime.AddHours(-hoursToSub);
                    return(new DateTime(subHours.Year, subHours.Month, subHours.Day, subHours.Hour, 0, 0, 0));
                }
                else
                {
                    return(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0, 0));
                }
            }
            else
            {
                if (dateTime.Minute % minute != 0 ||
                    dateTime.Second != 0 || dateTime.Millisecond != 0)
                {
                    int minutesToSub = dateTime.Minute % minute;
                    var subMinutes   = dateTime.AddMinutes(-minutesToSub);
                    return(new DateTime(subMinutes.Year, subMinutes.Month, subMinutes.Day, subMinutes.Hour, subMinutes.Minute, 0, 0));
                }
                else
                {
                    return(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0, 0));
                }
            }
        }
Example #42
0
 public TokenService(ITimeService timeService, DatabaseContext context, UserApplicationFactory userApplicationFactory)
 {
     _timeService            = timeService;
     _context                = context;
     _userApplicationFactory = userApplicationFactory;
 }
Example #43
0
 public Service(IProject project, string guid, ITimeService timeService)
 {
     _project = project;
     _guid = guid;
     _timeService = timeService;
 }
Example #44
0
 public MyClass(ITimeService timeService)
 {
     _timeService = timeService;
 }
Example #45
0
 public virtual void OnTimeServiceUpdated(ITimeService time)
 {
     _IsDirty = true;
     //this.State = ModelObjectState.Ready;
 }
Example #46
0
        public void CandleUpdated(IEnumerable <Candle> candles, CandlePeriod candlePeriod, ITimeService timeService, IIndicatorService indicatorService, string strategyId = null)
        {
            if (timeService == null)
            {
                throw new TrendAnalysisDomainException("Time service is not provided when operating on trace.");
            }

            if (indicatorService == null)
            {
                throw new TrendAnalysisDomainException("Indicator service is not provided when operating on trace.");
            }

            if (this.TraceStatus.Id != TraceStatus.Started.Id)
            {
                throw new TrendAnalysisDomainException("Updating candles can only happened before closed and after started.");
            }

            if (this.DateStarted == null)
            {
                throw new TrendAnalysisDomainException(nameof(this.DateStarted));
            }



            var signalUpdated = false;

            if (strategyId != null)
            {
                var strategy = this._tradeStrategies.Where(s => s.StrategyId == strategyId).SingleOrDefault();
                if (strategy == null)
                {
                    throw new TrendAnalysisDomainException("Strategy to update not found");
                }

                if (!this.HasCompleteCandlesBetween(
                        candles,
                        candlePeriod,
                        this.CalculateCandleStartDateWithWarmUp(candlePeriod, strategy.WarmUp),
                        timeService.GetCurrentDateTime()
                        ))
                {
                    throw new TrendAnalysisDomainException("The candles data provided are not completed, each candles from started date to current date must be provided.");
                }

                var orignalSignal = strategy.TradeSignal;

                strategy.Analysis(candles, indicatorService);

                if (strategy.TradeSignal.GetSignalType().Id != orignalSignal.TradingSignalType.Id)
                {
                    signalUpdated = true;
                }
            }
            else
            {
                var matchedStrategies = this._tradeStrategies.Where(s => s.GetIdealPeriod().Id == candlePeriod.Id);
                foreach (var strategy in matchedStrategies)
                {
                    if (!this.HasCompleteCandlesBetween(
                            candles,
                            candlePeriod,
                            this.CalculateCandleStartDateWithWarmUp(candlePeriod, strategy.WarmUp),
                            timeService.GetCurrentDateTime()
                            ))
                    {
                        throw new TrendAnalysisDomainException("The candles data provided are not completed, each candles from started date to current date must be provided.");
                    }

                    var orignalSignal = strategy.TradeSignal;

                    strategy.Analysis(candles, indicatorService);

                    if (strategy.TradeSignal.GetSignalType().Id != orignalSignal.TradingSignalType.Id)
                    {
                        signalUpdated = true;
                    }
                }
            }


            if (signalUpdated == true)
            {
                this.AddDomainEvent(
                    new TradeSignalUpdatedDomainEvent(this, candles, timeService)
                    );
            }

            //var currentCandleTime=
        }
Example #47
0
 public AchsenUpdateService(ITransactionScopeProvider transactionScopeProvider, IErfassungsPeriodService erfassungsPeriodService, ISecurityService securityService, IEreignisLogService ereignisLogService, INHibernateConfigurationProvider nHibernateConfigurationProvider, ILocalizationService localizationService, ITimeService timeService)
 {
     this.nHibernateConfigurationProvider = nHibernateConfigurationProvider;
     this.transactionScopeProvider        = transactionScopeProvider;
     this.erfassungsPeriodService         = erfassungsPeriodService;
     this.securityService     = securityService;
     this.ereignisLogService  = ereignisLogService;
     this.localizationService = localizationService;
     this.timeService         = timeService;
 }
Example #48
0
 public IncreaseTimeCommand(ITimeService timeService)
 {
     _timeService = timeService;
 }
Example #49
0
 public CurrencyRateRepository(CurrencyRateContext dbContext, ITimeService timeService) :
     base(dbContext) => this.timeService = timeService;
 public UnitMoveSystem(IEntityService entityService, ITimeService timeService, ILogger logger)
 {
     _entityService = entityService;
     _timeService   = timeService;
     _logger        = logger;
 }
Example #51
0
 public ChoresController(IUnitOfWorkAsync unitOfWorkAsync, IChoreService choreService, ITimeService time)
 {
     _unitOfWorkAsync = unitOfWorkAsync;
     _choreService    = choreService;
     _time            = time;
 }
Example #52
0
 public RegisterCronHandler(ICronRepository cronRepository, ITimeService timeService)
 {
     _cronRepository = cronRepository;
     _timeService    = timeService;
 }
Example #53
0
 public LogFormater(ITimeService timeService)
 {
     _timeService = timeService;
 }
Example #54
0
 public AcquiredLockServices(AcquiredDbParameters acquiredDbParameters, ILockService lockService, ITimeService timeService, ILeaseLockObject lockObject)
 {
     this.AcquiredDbParameters = acquiredDbParameters;
     this.LockService          = lockService;
     this.TimeService          = timeService;
     this.LockObject           = lockObject;
 }
Example #55
0
 public static DateTimeOffset UtcNow(this ITimeService timeService)
 {
     _ = timeService ?? throw new ArgumentNullException(nameof(timeService));
     return(timeService.Current().Result);
 }
Example #56
0
 public HeartbeatController(ITimeService timeService)
 {
     this.timeService = timeService;
 }
Example #57
0
        public LoginViewModel(
            IUserAccessManager userAccessManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            INavigationService navigationService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IInteractorFactory interactorFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(errorHandlingService, nameof(errorHandlingService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));

            this.timeService          = timeService;
            this.userAccessManager    = userAccessManager;
            this.analyticsService     = analyticsService;
            this.onboardingStorage    = onboardingStorage;
            this.errorHandlingService = errorHandlingService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.schedulerProvider    = schedulerProvider;
            this.interactorFactory    = interactorFactory;

            var emailObservable = emailSubject.Select(email => email.TrimmedEnd());

            Signup         = rxActionFactory.FromAsync(signup);
            ForgotPassword = rxActionFactory.FromAsync(forgotPassword);

            Shake = shakeSubject.AsDriver(this.schedulerProvider);

            Email = emailObservable
                    .Select(email => email.ToString())
                    .DistinctUntilChanged()
                    .AsDriver(this.schedulerProvider);

            Password = passwordSubject
                       .Select(password => password.ToString())
                       .DistinctUntilChanged()
                       .AsDriver(this.schedulerProvider);

            IsLoading = isLoadingSubject
                        .DistinctUntilChanged()
                        .AsDriver(this.schedulerProvider);

            ErrorMessage = errorMessageSubject
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);

            IsPasswordMasked = isPasswordMaskedSubject
                               .DistinctUntilChanged()
                               .AsDriver(this.schedulerProvider);

            IsShowPasswordButtonVisible = Password
                                          .Select(password => password.Length > 1)
                                          .CombineLatest(isShowPasswordButtonVisibleSubject.AsObservable(), CommonFunctions.And)
                                          .DistinctUntilChanged()
                                          .AsDriver(this.schedulerProvider);

            HasError = ErrorMessage
                       .Select(string.IsNullOrEmpty)
                       .Select(CommonFunctions.Invert)
                       .AsDriver(this.schedulerProvider);

            LoginEnabled = emailObservable
                           .CombineLatest(
                passwordSubject.AsObservable(),
                IsLoading,
                (email, password, isLoading) => email.IsValid && password.IsValid && !isLoading)
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);
        }
Example #58
0
 public FileService(IFileRepository fileRepository, IConfiguration configuration, ITimeService timeService,
                    IAzureStorageService azureStorageService)
 {
     _fileRepository      = fileRepository;
     _configuration       = configuration;
     _timeService         = timeService;
     _azureStorageService = azureStorageService;
 }
Example #59
0
 public ShipService(ITimeService timeService, EventService eventService)
 {
     this.timeService = timeService;
     this.eventService = eventService;
 }
Example #60
0
 public OverviewRepository(ITimeService time, MilvanethDbContext context)
 {
     _time    = time;
     _context = context;
 }