public ControllerSlaveService(
            ISettingsService settingsService,
            ISchedulerService scheduler,
            IDateTimeService dateTimeService,
            IOutdoorTemperatureService outdoorTemperatureService,
            IOutdoorHumidityService outdoorHumidityService,
            IDaylightService daylightService,
            IWeatherService weatherService)
        {
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (scheduler == null) throw new ArgumentNullException(nameof(scheduler));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (outdoorTemperatureService == null) throw new ArgumentNullException(nameof(outdoorTemperatureService));
            if (outdoorHumidityService == null) throw new ArgumentNullException(nameof(outdoorHumidityService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));
            if (weatherService == null) throw new ArgumentNullException(nameof(weatherService));

            _dateTimeService = dateTimeService;
            _outdoorTemperatureService = outdoorTemperatureService;
            _outdoorHumidityService = outdoorHumidityService;
            _daylightService = daylightService;
            _weatherService = weatherService;

            settingsService.CreateSettingsMonitor<ControllerSlaveServiceSettings>(s => Settings = s);

            scheduler.RegisterSchedule("ControllerSlavePolling", TimeSpan.FromMinutes(5), PullValues);
        }
        public OpenWeatherMapService(
            IOutdoorTemperatureService outdoorTemperatureService,
            IOutdoorHumidityService outdoorHumidityService,
            IDaylightService daylightService,
            IWeatherService weatherService,
            IDateTimeService dateTimeService, 
            ISchedulerService schedulerService, 
            ISystemInformationService systemInformationService,
            ISettingsService settingsService, 
            IStorageService storageService)
        {
            if (outdoorTemperatureService == null) throw new ArgumentNullException(nameof(outdoorTemperatureService));
            if (outdoorHumidityService == null) throw new ArgumentNullException(nameof(outdoorHumidityService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));
            if (weatherService == null) throw new ArgumentNullException(nameof(weatherService));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (systemInformationService == null) throw new ArgumentNullException(nameof(systemInformationService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (storageService == null) throw new ArgumentNullException(nameof(storageService));

            _outdoorTemperatureService = outdoorTemperatureService;
            _outdoorHumidityService = outdoorHumidityService;
            _daylightService = daylightService;
            _weatherService = weatherService;
            _dateTimeService = dateTimeService;
            _systemInformationService = systemInformationService;
            _storageService = storageService;

            settingsService.CreateSettingsMonitor<OpenWeatherMapServiceSettings>(s => Settings = s);

            LoadPersistedData();

            schedulerService.RegisterSchedule("OpenWeatherMapServiceUpdater", TimeSpan.FromMinutes(5), Refresh);
        }
        public NotificationService(
            IDateTimeService dateTimeService, 
            IApiService apiService, 
            ISchedulerService schedulerService, 
            ISettingsService settingsService,
            IStorageService storageService,
            IResourceService resourceService)
        {
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (apiService == null) throw new ArgumentNullException(nameof(apiService));
            if (schedulerService == null) throw new ArgumentNullException(nameof(schedulerService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (storageService == null) throw new ArgumentNullException(nameof(storageService));
            if (resourceService == null) throw new ArgumentNullException(nameof(resourceService));

            _dateTimeService = dateTimeService;
            _storageService = storageService;
            _resourceService = resourceService;

            settingsService.CreateSettingsMonitor<NotificationServiceSettings>(s => Settings = s);

            apiService.StatusRequested += HandleApiStatusRequest;

            schedulerService.RegisterSchedule("NotificationCleanup", TimeSpan.FromMinutes(15), Cleanup);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportService"/> class.
 /// </summary>
 /// <param name="settingsService">
 /// Провайдер настроек
 /// </param>
 /// <param name="fileSystemService">
 /// Сервис файловой системы
 /// </param>
 /// <param name="logService">
 /// Сервис логирования
 /// </param>
 /// <param name="dateTimeService">
 /// Сервис даты/времени
 /// </param>
 public ImportService(IAlbumeSettingsService settingsService, IFileSystemService fileSystemService, ILogService logService, IDateTimeService dateTimeService)
 {
     this.settingsService = settingsService;
     this.fileSystemService = fileSystemService;
     this.logService = logService;
     this.dateTimeService = dateTimeService;
 }
 public TrainingWordProvider(
     IWordRepository wordRepository,
     IDateTimeService dateTimeService)
 {
     _wordRepository = wordRepository;
     _dateTimeService = dateTimeService;
 }
Пример #6
0
 public RequestService(IUnitOfWorkFactory unitOfWorkFactory, IDateTimeService dateTimeService, IStateManagerService stateManagerService, ITuWebService tuWebService)
 {
     _unitOfWorkFactory = unitOfWorkFactory;
     _dateTimeService = dateTimeService;
     _stateManagerService = stateManagerService;
     _tuWebService = tuWebService;
 }
        public AutomationFactory(
            ISchedulerService schedulerService,
            INotificationService notificationService,
            IDateTimeService dateTimeService,
            IDaylightService daylightService,
            IOutdoorTemperatureService outdoorTemperatureService,
            IComponentService componentService,
            ISettingsService settingsService,
            IResourceService resourceService)
        {
            if (schedulerService == null) throw new ArgumentNullException(nameof(schedulerService));
            if (notificationService == null) throw new ArgumentNullException(nameof(notificationService));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));
            if (outdoorTemperatureService == null) throw new ArgumentNullException(nameof(outdoorTemperatureService));
            if (componentService == null) throw new ArgumentNullException(nameof(componentService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (resourceService == null) throw new ArgumentNullException(nameof(resourceService));

            _schedulerService = schedulerService;
            _notificationService = notificationService;
            _dateTimeService = dateTimeService;
            _daylightService = daylightService;
            _outdoorTemperatureService = outdoorTemperatureService;
            _componentService = componentService;
            _settingsService = settingsService;
            _resourceService = resourceService;
        }
 public MonthPickerViewModel(IDateTimeService dateTimeService)
 {
     CurrentDate = dateTimeService.Now;
     
     NextMonthCommand = new RelayCommand(GoToNextMonth);
     PreviousMonthCommand = new RelayCommand(GoToPrevMonth);
 }
        public TimeRangeCondition(IDateTimeService dateTimeService)
        {
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));

            _dateTimeService = dateTimeService;

            WithExpression(() => Check());
        }
Пример #10
0
 public void Stop(DateTime? stopTime, string comment, IDateTimeService dateTimeService)
 {
     if (lastStartTime == null)
     {
         throw new InvalidOperationException("Task already stopped");
     }
     ApplyChange(new TaskStopped(id, stopTime.GetValueOrDefault(dateTimeService.GetUtcNow()), comment));
 }
Пример #11
0
        public IsNightCondition(IDaylightService daylightService, IDateTimeService dateTimeService)
            : base(dateTimeService)
        {
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));

            WithStart(daylightService.Sunset);
            WithEnd(daylightService.Sunrise);
        }
Пример #12
0
 /// <summary>
 /// Constructor. Sets up maths reference and initial colour.
 /// </summary>
 /// <param name="mathService"></param>
 /// <param name="dateTimeService"></param>
 /// <param name="initialColor"></param>
 public Hands(IMathService mathService, IDateTimeService dateTimeService, Color initialColor)
 {
     _mathService = mathService;
     _dateTimeService = dateTimeService;
     _secondBrush = new SolidBrush(initialColor);
     _minuteBrush = new SolidBrush(initialColor);
     _hourlyBrush = new SolidBrush(initialColor);
 }
Пример #13
0
 public PackageBuilder(ICryptoService cryptoService, 
                       IDateTimeService dateTimeService,
                       IGuidGenerator guidGenerator
     )
 {
     this.cryptoService = cryptoService;
     this.dateTimeService = dateTimeService;
     this.guidGenerator = guidGenerator;
 }
Пример #14
0
        public HomeController(IDateTimeService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            DateTimeService = service;
        }
        public ListGoodManager(IListGoodRepository listGoodRepository, ListManager listManager, IGoodRepository goodRepository, IDateTimeService dateTimeService)
        {
            _listGoodRepository = listGoodRepository;

            _goodRepository = goodRepository;
            _listManager = listManager;

            _dateTimeService = dateTimeService;
        }
Пример #16
0
        public SchedulerService(ITimerService timerService, IDateTimeService dateTimeService)
        {
            if (timerService == null) throw new ArgumentNullException(nameof(timerService));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));

            _timerService = timerService;
            _dateTimeService = dateTimeService;

            _timer = new Timer(e => ExecuteSchedules(), null, -1, Timeout.Infinite);
        }
        public ConditionalOnAutomation(AutomationId id, ISchedulerService schedulerService, IDateTimeService dateTimeService, IDaylightService daylightService)
            : base(id)
        {
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));

            _dateTimeService = dateTimeService;
            _daylightService = daylightService;

            WithTrigger(new IntervalTrigger(TimeSpan.FromMinutes(1), schedulerService));
        }
Пример #18
0
        public WeatherService(IDateTimeService dateTimeService, IApiService apiService)
        {
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));

            _dateTimeService = dateTimeService;

            apiService.StatusRequested += (s, e) =>
            {
                e.Context.Response.Merge(JObject.FromObject(this));
            };
        }
 public ExchangeConferenceRoomService(ExchangeService exchangeService, IMeetingRepository meetingRepository, ISecurityRepository securityRepository, IBroadcastService broadcastService, IDateTimeService dateTimeService, IMeetingCacheService meetingCacheService, IChangeNotificationService changeNotificationService, IConcurrencyLimiter concurrencyLimiter)
 {
     _exchangeService = exchangeService;
     _meetingRepository = meetingRepository;
     _securityRepository = securityRepository;
     _broadcastService = broadcastService;
     _dateTimeService = dateTimeService;
     _meetingCacheService = meetingCacheService;
     _changeNotificationService = changeNotificationService;
     _concurrencyLimiter = concurrencyLimiter;
     _ignoreFree = bool.Parse(ConfigurationManager.AppSettings["ignoreFree"] ?? "false");
     _useChangeNotification = bool.Parse(ConfigurationManager.AppSettings["useChangeNotification"] ?? "true");
 }
        public TurnOnAndOffAutomation(AutomationId id, IDateTimeService dateTimeService, ISchedulerService schedulerService, ISettingsService settingsService, IDaylightService daylightService)
            : base(id)
        {
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (schedulerService == null) throw new ArgumentNullException(nameof(schedulerService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));

            _dateTimeService = dateTimeService;
            _schedulerService = schedulerService;
            _daylightService = daylightService;

            settingsService.CreateSettingsMonitor<TurnOnAndOffAutomationSettings>(Id, s => Settings = s);
        }
        public JenkinsServerManager(IWebRequestFactory webRequestFactory, IJenkinsApiFactory apiFactory, IDateTimeService dateTimeService)
        {
            if (webRequestFactory == null)
                throw new ArgumentNullException("webRequestFactory");

            if (apiFactory == null)
                throw new ArgumentNullException("apiFactory");

            if (dateTimeService == null)
                throw new ArgumentNullException("dateTimeService");

            _webRequestFactory = webRequestFactory;
            _apiFactory = apiFactory;
            _dateTimeService = dateTimeService;
        }
Пример #22
0
        public UserService(IEntityStorage<User> userStorage, IDateTimeService dateTimeService)
        {
            if (null == userStorage)
            {
                throw new ArgumentNullException(nameof(userStorage));
            }

            if (null == dateTimeService)
            {
                throw new ArgumentNullException(nameof(dateTimeService));
            }

            this._userStorage = userStorage;
            this._dateTimeService = dateTimeService;
        }
        public RollerShutterAutomation(
            AutomationId id, 
            INotificationService notificationService,
            ISchedulerService schedulerService,
            IDateTimeService dateTimeService,
            IDaylightService daylightService,
            IOutdoorTemperatureService outdoorTemperatureService,
            IComponentService componentService,
            ISettingsService settingsService,
            IResourceService resourceService)
            : base(id)
        {
            if (notificationService == null) throw new ArgumentNullException(nameof(notificationService));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));
            if (outdoorTemperatureService == null) throw new ArgumentNullException(nameof(outdoorTemperatureService));
            if (componentService == null) throw new ArgumentNullException(nameof(componentService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (resourceService == null) throw new ArgumentNullException(nameof(resourceService));

            _notificationService = notificationService;
            _dateTimeService = dateTimeService;
            _daylightService = daylightService;
            _outdoorTemperatureService = outdoorTemperatureService;
            _componentService = componentService;
            _settingsService = settingsService;
            _componentService = componentService;

            resourceService.RegisterText(
                RollerShutterAutomationNotification.AutoClosingDueToHighOutsideTemperature,
                "Closing roller shutter because outside temperature reaches {AutoCloseIfTooHotTemperaure}°C.");

            settingsService.CreateSettingsMonitor<RollerShutterAutomationSettings>(Id, s => Settings = s);

            // TODO: Consider timer service here.
            schedulerService.RegisterSchedule("RollerShutterAutomation-" + Guid.NewGuid(), TimeSpan.FromMinutes(1), PerformPendingActions);
        }
Пример #24
0
 public DateHelper(IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService;
 }
Пример #25
0
 public GreeterController(IGreeterService greeterService, IDateTimeService dateTimeService)
 {
     _greeterService = greeterService;
     _dateTimeService = dateTimeService;
 }
Пример #26
0
 public GatewaysController(IUserRepository userRep, INetworkRepository networkRep,
                           IGatewayRepository gatewayRep, ICredentialService credentials, IDateTimeService dateTime,
                           IMapper mapper, IMessageService messages)
 {
     _userRep     = userRep;
     _networkRep  = networkRep;
     _gatewayRep  = gatewayRep;
     _credentials = credentials;
     _dateTime    = dateTime;
     _mapper      = mapper;
     _messages    = messages;
 }
Пример #27
0
        public async Task ImageInfoTagOutput()
        {
            Mock <IManifestService> manifestToolService = new Mock <IManifestService>();

            manifestToolService
            .Setup(o => o.GetManifestAsync("repo1:sharedtag2", It.IsAny <IRegistryCredentialsHost>(), false))
            .ReturnsAsync(new ManifestQueryResult("digest1", new JsonObject()));
            manifestToolService
            .Setup(o => o.GetManifestAsync("repo2:sharedtag3", It.IsAny <IRegistryCredentialsHost>(), false))
            .ReturnsAsync(new ManifestQueryResult("digest2", new JsonObject()));

            DateTime         manifestCreatedDate = DateTime.UtcNow;
            IDateTimeService dateTimeService     = Mock.Of <IDateTimeService>(o => o.UtcNow == manifestCreatedDate);

            PublishManifestCommand command = new PublishManifestCommand(
                manifestToolService.Object, Mock.Of <ILoggerService>(), dateTimeService);

            using TempFolderContext tempFolderContext = new TempFolderContext();

            command.Options.Manifest      = Path.Combine(tempFolderContext.Path, "manifest.json");
            command.Options.ImageInfoPath = Path.Combine(tempFolderContext.Path, "image-info.json");

            string dockerfile1 = CreateDockerfile("1.0/repo1/os", tempFolderContext);
            string dockerfile2 = CreateDockerfile("1.0/repo2/os", tempFolderContext);
            string dockerfile3 = CreateDockerfile("1.0/repo3/os", tempFolderContext);

            const string digest1 = "sha256:123";
            const string digest2 = "sha256:ABC";
            const string digest3 = "sha256:DEF";

            ImageArtifactDetails imageArtifactDetails = new ImageArtifactDetails
            {
                Repos =
                {
                    new RepoData
                    {
                        Repo   = "repo1",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    CreatePlatform(dockerfile1, digest: digest1, simpleTags: new List <string>{
                                        "tag1"
                                    }),
                                    new PlatformData
                                    {
                                    }
                                },
                                Manifest = new ManifestData
                                {
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag2"
                                    }
                                }
                            }
                        }
                    },
                    new RepoData
                    {
                        Repo   = "repo2",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    CreatePlatform(dockerfile2, digest: digest2, simpleTags: new List <string>{
                                        "tag2"
                                    })
                                },
                                Manifest = new ManifestData
                                {
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag3"
                                    }
                                }
                            }
                        }
                    },
                    new RepoData
                    {
                        Repo   = "repo3",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    CreatePlatform(dockerfile3, digest: digest3, simpleTags: new List <string>{
                                        "tag3"
                                    })
                                }
                            }
                        }
                    }
                }
            };

            File.WriteAllText(command.Options.ImageInfoPath, JsonHelper.SerializeObject(imageArtifactDetails));

            Manifest manifest = CreateManifest(
                CreateRepo("repo1",
                           CreateImage(
                               new Platform[]
            {
                CreatePlatform(dockerfile1, new string[] { "tag1" })
            },
                               new Dictionary <string, Tag>
            {
                { "sharedtag2", new Tag() },
                { "sharedtag1", new Tag() }
            })),
                CreateRepo("repo2",
                           CreateImage(
                               new Platform[]
            {
                CreatePlatform(dockerfile2, new string[] { "tag2" })
            },
                               new Dictionary <string, Tag>
            {
                { "sharedtag3", new Tag() },
                { "sharedtag1", new Tag() }
            })),
                CreateRepo("repo3",
                           CreateImage(
                               new Platform[]
            {
                CreatePlatform(dockerfile3, new string[] { "tag3" })
            })),
                CreateRepo("unpublishedrepo",
                           CreateImage(
                               new Platform[]
            {
                CreatePlatform(
                    CreateDockerfile("1.0/unpublishedrepo/os", tempFolderContext),
                    new string[] { "tag" })
            },
                               new Dictionary <string, Tag>
            {
                { "sharedtag", new Tag() }
            }))
                );

            File.WriteAllText(command.Options.Manifest, JsonHelper.SerializeObject(manifest));

            command.LoadManifest();
            await command.ExecuteAsync();

            string actualOutput = File.ReadAllText(command.Options.ImageInfoPath);

            ImageArtifactDetails actualImageArtifactDetails = JsonConvert.DeserializeObject <ImageArtifactDetails>(actualOutput);

            ImageArtifactDetails expectedImageArtifactDetails = new()
            {
                Repos =
                {
                    new RepoData
                    {
                        Repo   = "repo1",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    new PlatformData
                                    {
                                        Dockerfile   = "1.0/repo1/os/Dockerfile",
                                        OsType       = "Linux",
                                        OsVersion    = "focal",
                                        Architecture = "amd64",
                                        Digest       = digest1,
                                        SimpleTags   = new List <string> {
                                            "tag1"
                                        }
                                    },
                                    new PlatformData()
                                },
                                Manifest = new ManifestData
                                {
                                    Created    = manifestCreatedDate,
                                    Digest     = "repo1@digest1",
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag2"
                                    }
                                }
                            }
                        }
                    },
                    new RepoData
                    {
                        Repo   = "repo2",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    new PlatformData
                                    {
                                        Dockerfile   = "1.0/repo2/os/Dockerfile",
                                        OsType       = "Linux",
                                        OsVersion    = "focal",
                                        Architecture = "amd64",
                                        Digest       = digest2,
                                        SimpleTags   = new List <string> {
                                            "tag2"
                                        }
                                    }
                                },
                                Manifest = new ManifestData
                                {
                                    Created    = manifestCreatedDate,
                                    Digest     = "repo2@digest2",
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag3"
                                    }
                                }
                            }
                        }
                    },
                    new RepoData
                    {
                        Repo   = "repo3",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    new PlatformData
                                    {
                                        Dockerfile   = "1.0/repo3/os/Dockerfile",
                                        OsType       = "Linux",
                                        OsVersion    = "focal",
                                        Architecture = "amd64",
                                        Digest       = digest3,
                                        SimpleTags   = new List <string> {
                                            "tag3"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            string expectedOutput = JsonHelper.SerializeObject(expectedImageArtifactDetails);

            Assert.Equal(expectedOutput, actualOutput);
        }
Пример #28
0
        public PAKNService(IConfiguration config, IHttpService httpService, ILoginService loginService, IDateTimeService dateTimeService)
        {
            _config          = config;
            _httpService     = httpService;
            _loginService    = loginService;
            _dateTimeService = dateTimeService;

            _loginToken = _loginService.GetToken();

            _urlFilter = _config.GetSection("PAKN:filter:address").Value;

            _urlGet   = _config.GetSection("PAKN:get:address").Value;
            _tokenGet = _config.GetSection("PAKN:get:bearToken").Value;

            _urlAdd = _config.GetSection("PAKN:add:address").Value;

            _fromDate  = _config.GetSection("fromDate:date").Value;
            _fromMonth = Convert.ToInt32(_config.GetSection("fromDate:month").Value);
            _fromYear  = Convert.ToInt32(_config.GetSection("fromDate:year").Value);
            _toDate    = _config.GetSection("toDate:date").Value;
            _toMonth   = Convert.ToInt32(_config.GetSection("toDate:month").Value);
            _toYear    = Convert.ToInt32(_config.GetSection("toDate:year").Value);
            _limit     = Convert.ToInt32(_config.GetSection("limit").Value);
        }
 public DateTimeHelpers(IHandlebars context, IDateTimeService dateTimeService) : base(context)
 {
     _dateTimeService = dateTimeService;
 }
Пример #30
0
 public GreeterService(IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService;
 }
Пример #31
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, IDateTimeService dateTime, IAuthenticatedUserService authenticatedUser) : base(options)
 {
     ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
     _dateTime          = dateTime;
     _authenticatedUser = authenticatedUser;
 }
Пример #32
0
 public ConferenceDeletionPolicy(IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService;
 }
Пример #33
0
 public DeleteExercisesCommandHandler(SqlConnection sqlConnection, IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService;
     _sqlConnection   = sqlConnection;
 }
Пример #34
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, IDateTimeService dateTime) : base(options)
 {
     ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
     _dateTime = dateTime;
 }
Пример #35
0
 public static MemoryCacheEntryOptions DefaultMemoryCacheEntryOptions(
     IDateTimeService dateTimeService,
     ILogger logger,
     int absoluteExpirationInSeconds = DefaultCacheExpiryInSeconds,
     int slidingExpirationInSeconds  = DefaultCacheExpiryInSeconds,
     int size = 1) =>
Пример #36
0
 public ValuesController(IDateTimeService service)
 {
     this._service = service;
 }
Пример #37
0
 public TicketsFactory(IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService;
 }
Пример #38
0
 public CommandFactory(OperationContext currentContext, IGuidService guidService, IDateTimeService dateTimeService)
 {
     _currentContext  = currentContext;
     _guidService     = guidService;
     _dateTimeService = dateTimeService;
 }
 /// <summary>
 /// Create a new repo decorator.
 /// </summary>
 /// <param name="innerRepository">The repository to be decorated</param>
 /// <param name="now">A datetime service that provides the time the entity was updated</param>
 /// <param name="currentUserAccessor">An accessor for the current user's properties</param>
 internal SoftDeletableWithOffsetRepositoryDecorator(IWritableRepository <T> innerRepository, IDateTimeService now, ICurrentUserAccessor currentUserAccessor) : base(innerRepository)
 {
     _now = now;
     _currentUserAccessor = currentUserAccessor;
 }
Пример #40
0
 public CheckDueCommandHandler(DbLibrary db, IBusPublisher bus, IDateTimeService dateTimeService)
 {
     _db              = db;
     _bus             = bus;
     _dateTimeService = dateTimeService;
 }
 public PointPiorityQueue(IDateTimeService dateTimeService)
 {
     _pointsInQueue   = new List <PointTransactionDetail>();
     _dateTimeService = dateTimeService;
 }
Пример #42
0
 public DocumentChecker(IDateTimeService dateTimeService)
 {
     this.dateTimeService = dateTimeService;
 }
 public LoginController(IZohoClient zohoClient, IDialogService dialogService, IDateTimeService dateTimeService)
 {
     this.zohoClient = zohoClient;
     this.dialogService = dialogService;
     this.dateTimeService = dateTimeService;
 }
 public RemovePendingPackagesTask(IFileSystem fileSystem, IDateTimeService dateTimeService)
 {
     _fileSystem      = fileSystem;
     _dateTimeService = dateTimeService;
 }
 public RemovePendingPackagesTask(IFileSystem fileSystem, IDateTimeService dateTimeService)
 {
     _fileSystem = fileSystem;
     _dateTimeService = dateTimeService;
 }
Пример #46
0
 public RepeatDaysController(IDateTimeService dateTimeService)
 {
 }
Пример #47
0
        public async Task SyndicatedTag()
        {
            string expectedManifest1 =
                @"image: mcr.microsoft.com/repo:sharedtag2
tags: [sharedtag1]
manifests:
- image: mcr.microsoft.com/repo:tag1
  platform:
    architecture: amd64
    os: linux
- image: mcr.microsoft.com/repo:tag3
  platform:
    architecture: amd64
    os: linux
";

            string expectedManifest2 =
                @"image: mcr.microsoft.com/repo2:sharedtag2a
tags: [sharedtag2b]
manifests:
- image: mcr.microsoft.com/repo2:tag2
  platform:
    architecture: amd64
    os: linux
";

            bool manifest1Found = false;
            bool manifest2Found = false;

            Mock <IManifestService> manifestToolService = new Mock <IManifestService>();

            manifestToolService
            .Setup(o => o.PushFromSpec(It.IsAny <string>(), false))
            .Callback((string manifestFile, bool isDryRun) =>
            {
                string manifestContents = File.ReadAllText(manifestFile);

                if (manifestContents.NormalizeLineEndings(expectedManifest1) == expectedManifest1)
                {
                    manifest1Found = true;
                }
                else if (manifestContents.NormalizeLineEndings(expectedManifest2) == expectedManifest2)
                {
                    manifest2Found = true;
                }
            });

            manifestToolService
            .Setup(o => o.GetManifestAsync(It.IsAny <string>(), It.IsAny <IRegistryCredentialsHost>(), false))
            .ReturnsAsync(new ManifestQueryResult("digest", new JsonObject()));

            DateTime         manifestCreatedDate = DateTime.UtcNow;
            IDateTimeService dateTimeService     = Mock.Of <IDateTimeService>(o => o.UtcNow == manifestCreatedDate);

            PublishManifestCommand command = new PublishManifestCommand(
                manifestToolService.Object, Mock.Of <ILoggerService>(), dateTimeService);

            using TempFolderContext tempFolderContext = new TempFolderContext();

            command.Options.Manifest      = Path.Combine(tempFolderContext.Path, "manifest.json");
            command.Options.ImageInfoPath = Path.Combine(tempFolderContext.Path, "image-info.json");

            string dockerfile1 = CreateDockerfile("1.0/repo/os", tempFolderContext);
            string dockerfile2 = CreateDockerfile("1.0/repo/os2", tempFolderContext);

            ImageArtifactDetails imageArtifactDetails = new ImageArtifactDetails
            {
                Repos =
                {
                    new RepoData
                    {
                        Repo   = "repo",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    CreatePlatform(dockerfile1,
                                                   simpleTags: new List <string>
                                    {
                                        "tag1",
                                        "tag2"
                                    })
                                },
                                Manifest = new ManifestData
                                {
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag2"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            File.WriteAllText(command.Options.ImageInfoPath, JsonHelper.SerializeObject(imageArtifactDetails));

            const string syndicatedRepo2 = "repo2";

            Platform platform1;
            Platform platform2;

            Manifest manifest = CreateManifest(
                CreateRepo("repo",
                           CreateImage(
                               new Platform[]
            {
                platform1 = CreatePlatform(dockerfile1, Array.Empty <string>()),
                platform2 = CreatePlatform(dockerfile2, Array.Empty <string>())
            },
                               new Dictionary <string, Tag>
            {
                {
                    "sharedtag2",
                    new Tag
                    {
                        Syndication = new TagSyndication
                        {
                            Repo            = syndicatedRepo2,
                            DestinationTags = new string[]
                            {
                                "sharedtag2a",
                                "sharedtag2b"
                            }
                        }
                    }
                },
                { "sharedtag1", new Tag() }
            }))
                );

            manifest.Registry = "mcr.microsoft.com";
            platform1.Tags    = new Dictionary <string, Tag>
            {
                { "tag1", new Tag() },
                { "tag2", new Tag
                  {
                      Syndication = new TagSyndication
                      {
                          Repo            = syndicatedRepo2,
                          DestinationTags = new string[]
                          {
                              "tag2"
                          }
                      }
                  } },
            };

            platform2.Tags = new Dictionary <string, Tag>
            {
                { "tag3", new Tag() }
            };

            File.WriteAllText(command.Options.Manifest, JsonHelper.SerializeObject(manifest));

            command.LoadManifest();
            await command.ExecuteAsync();

            Assert.True(manifest1Found);
            Assert.True(manifest2Found);
            manifestToolService
            .Verify(o => o.PushFromSpec(It.IsAny <string>(), false), Times.Exactly(2));

            ImageArtifactDetails expectedImageArtifactDetails = new ImageArtifactDetails
            {
                Repos =
                {
                    new RepoData
                    {
                        Repo   = "repo",
                        Images =
                        {
                            new ImageData
                            {
                                Platforms =
                                {
                                    CreatePlatform(dockerfile1,
                                                   simpleTags: new List <string>
                                    {
                                        "tag1",
                                        "tag2"
                                    })
                                },
                                Manifest = new ManifestData
                                {
                                    Digest            = "mcr.microsoft.com/repo@digest",
                                    Created           = manifestCreatedDate,
                                    SyndicatedDigests = new List <string>
                                    {
                                        "mcr.microsoft.com/repo2@digest"
                                    },
                                    SharedTags =
                                    {
                                        "sharedtag1",
                                        "sharedtag2"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            string expectedOutput = JsonHelper.SerializeObject(expectedImageArtifactDetails);
            string actualOutput   = File.ReadAllText(command.Options.ImageInfoPath);

            Assert.Equal(expectedOutput, actualOutput);
        }
Пример #48
0
        public HealthService(
            IConfigurationService configurationService,
            IController controller,
            ITimerService timerService,
            IGpioService gpioService,
            IDateTimeService dateTimeService,
            ISystemInformationService systemInformationService,
            ILogService logService)
        {
            if (configurationService == null)
            {
                throw new ArgumentNullException(nameof(configurationService));
            }
            if (controller == null)
            {
                throw new ArgumentNullException(nameof(controller));
            }
            if (timerService == null)
            {
                throw new ArgumentNullException(nameof(timerService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }

            _log = logService?.CreatePublisher(nameof(HealthService)) ?? throw new ArgumentNullException(nameof(logService));

            var startupTimestamp = dateTimeService.Now;

            systemInformationService.Set("Health/SystemTime", () => dateTimeService.Now);
            systemInformationService.Set("Health/TimerDuration/Average", () => _averageTimerDuration);
            systemInformationService.Set("Health/TimerDuration/AverageMax", () => _maxTimerDuration);
            systemInformationService.Set("Health/TimerDuration/AverageMin", () => _minTimerDuration);
            systemInformationService.Set("Health/StartupTimestamp", startupTimestamp);
            systemInformationService.Set("Health/UpTime", () => dateTimeService.Now - startupTimestamp);
            systemInformationService.Set("Log/Errors/Count", () => logService.ErrorsCount);
            systemInformationService.Set("Log/Warnings/Count", () => logService.WarningsCount);

            controller.StartupCompleted += (sender, args) =>
            {
                _log.Info("Startup completed after " + args.Duration);
                systemInformationService.Set("Health/StartupDuration", args.Duration);
            };

            controller.StartupFailed += (sender, args) =>
            {
                _log.Error(args.Exception, "Startup failed after " + args.Duration);
            };

            timerService.Tick += UpdateStatistics;

            var configuration = configurationService.GetConfiguration <HealthServiceConfiguration>("HealthServiceConfiguration");

            if (configuration.StatusLed.Gpio.HasValue)
            {
                var gpio = gpioService.GetOutput(configuration.StatusLed.Gpio.Value);
                if (configuration.StatusLed.IsInverted)
                {
                    gpio = gpio.WithInvertedState();
                }

                var statusLed = new StatusLed(gpio);
                timerService.Tick += (s, e) => statusLed.Update();
            }
        }
 public JenkinsServerManagerSingletonFactory(IWebRequestFactory webRequestFactory, IJenkinsApiFactory jenkinsApiFactory, IDateTimeService dateTimeService)
 {
     _webRequestFactory = webRequestFactory;
     _jenkinsApiFactory = jenkinsApiFactory;
     _dateTimeService = dateTimeService;
 }
Пример #50
0
 public DateTimeScriptProxy(IDateTimeService dateTimeService)
 {
     _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));
 }
 public LoginWithRefreshTokenQueryHandler(IApplicationDbContext context, ITokenService tokenService, IDateTimeService dateTimeService)
 {
     _context         = context;
     _tokenService    = tokenService;
     _dateTimeService = dateTimeService;
 }
Пример #52
0
 public PatientFilesController(IBlobStorageManager storage, IDateTimeService datetimeService)
 {
     this.storage = storage;
     this.datetimeService = datetimeService;
 }
Пример #53
0
 public GreeterController()
 {
     _dateTimeService = new DateTimeService();
     _greeterService = new GreeterService(_dateTimeService);
 }
 public DiabetesRiskService(IPatientService patientService, IPatientNoteService patientNoteService, IDateTimeService dateTimeService)
 {
     _patientService     = patientService;
     _patientNoteService = patientNoteService;
     _dateTimeService    = dateTimeService;
 }
Пример #55
0
 public Service(IWorkOrderService workOrderService, IDateTimeService dateTimeService)
 {
     WorkOrderService = workOrderService;
     DateTimeService  = dateTimeService;
 }
Пример #56
0
 public Location(IDateTimeService dateTimeService)
     : base(dateTimeService)
 {
     this.AkaLocations = new List <Location>();
     this.Reviews      = new List <Review>();
 }
Пример #57
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, IDateTimeService dateTime, IAuthenticatedUserService authenticatedUser) : base(options)
 {
     _dateTime          = dateTime;
     _authenticatedUser = authenticatedUser;
 }
Пример #58
0
 public UpdateCommand(IDatabaseContext databaseContext, IValidator<T> validator, IDateTimeService dateTimeService) : base(databaseContext)
 {
     _validator = validator;
     _dateTimeService = dateTimeService;
 }
Пример #59
0
 public BlazorHeroContext(DbContextOptions <BlazorHeroContext> options, ICurrentUserService currentUserService, IDateTimeService dateTimeService)
     : base(options)
 {
     _currentUserService = currentUserService;
     _dateTimeService    = dateTimeService;
 }
Пример #60
0
 public EmployeeRegisteredEvent(IDateTimeService dateTimeService, Employee employee) : base(dateTimeService) => Employee = employee ?? throw new ArgumentNullException(nameof(employee));