Exemple #1
0
 public ExposureDetectionService
 (
     ILoggerService loggerService,
     IUserDataRepository userDataRepository,
     IExposureDataRepository exposureDataRepository,
     ILocalNotificationService localNotificationService,
     IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
     IExposureRiskCalculationService exposureRiskCalculationService,
     IExposureConfigurationRepository exposureConfigurationRepository,
     IEventLogService eventLogService,
     IDebugExposureDataCollectServer exposureDataCollectServer,
     IDateTimeUtility dateTimeUtility,
     IDeviceInfoUtility deviceInfoUtility
 )
 {
     _loggerService                  = loggerService;
     _userDataRepository             = userDataRepository;
     _exposureDataRepository         = exposureDataRepository;
     _localNotificationService       = localNotificationService;
     _exposureRiskCalculationService = exposureRiskCalculationService;
     _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
     _exposureConfigurationRepository = exposureConfigurationRepository;
     _eventLogService           = eventLogService;
     _exposureDataCollectServer = exposureDataCollectServer;
     _dateTimeUtility           = dateTimeUtility;
     _deviceInfoUtility         = deviceInfoUtility;
 }
        public HomePageViewModel(
            INavigationService navigationService,
            ILoggerService loggerService,
            IUserDataRepository userDataRepository,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            AbsExposureNotificationApiService exposureNotificationApiService,
            ILocalNotificationService localNotificationService,
            AbsExposureDetectionBackgroundService exposureDetectionBackgroundService,
            IExposureConfigurationRepository exposureConfigurationRepository,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
            ICheckVersionService checkVersionService,
            IEssentialsService essentialsService,
            IDialogService dialogService,
            IExternalNavigationService externalNavigationService
            ) : base(navigationService)
        {
            Title = AppResources.HomePageTitle;

            this.loggerService                                  = loggerService;
            this._userDataRepository                            = userDataRepository;
            this._exposureDataRepository                        = exposureDataRepository;
            this._exposureRiskCalculationService                = exposureRiskCalculationService;
            this.exposureNotificationApiService                 = exposureNotificationApiService;
            this.localNotificationService                       = localNotificationService;
            this.exposureDetectionBackgroundService             = exposureDetectionBackgroundService;
            this.exposureConfigurationRepository                = exposureConfigurationRepository;
            this.exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
            this.checkVersionService                            = checkVersionService;
            this.essentialsService                              = essentialsService;
            this.dialogService                                  = dialogService;
            this.externalNavigationService                      = externalNavigationService;
        }
        public ExposureCheckPageViewModel(
            INavigationService navigationService,
            ILoggerService loggerService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            ILocalPathService localPathService,
            IExposureDataExportService exposureDataExportService,
            IUserDataRepository userDataRepository,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
            IDateTimeUtility dateTimeUtility
            ) : base(navigationService)
        {
            _loggerService                  = loggerService;
            _exposureDataRepository         = exposureDataRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;
            _localPathService               = localPathService;
            _exposureDataExportService      = exposureDataExportService;
            _userDataRepository             = userDataRepository;
            _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
            _dateTimeUtility = dateTimeUtility;

            ExposureCheckScores = new ObservableCollection <ExposureCheckScoreModel>();
            UtcDescription      = string.Format(
                AppResources.LowRiskContactPageAnnotationDecription2,
                TimeZoneInfo.Local.StandardName
                );
        }
 public SettingsPageViewModel(
     INavigationService navigationService,
     ILoggerService loggerService,
     IUserDataRepository userDataRepository,
     IExposureDataRepository exposureDataRepository,
     IExposureConfigurationRepository exposureConfigurationRepository,
     ISendEventLogStateRepository sendEventLogStateRepository,
     IEventLogRepository eventLogRepository,
     ILogFileService logFileService,
     AbsExposureNotificationApiService exposureNotificationApiService,
     ICloseApplicationService closeApplicationService,
     IEssentialsService essentialsService
     ) : base(navigationService)
 {
     Title                                = AppResources.SettingsPageTitle;
     AppVer                               = essentialsService.AppVersion;
     this.loggerService                   = loggerService;
     this.userDataRepository              = userDataRepository;
     this.exposureDataRepository          = exposureDataRepository;
     this.exposureConfigurationRepository = exposureConfigurationRepository;
     _sendEventLogStateRepository         = sendEventLogStateRepository;
     _eventLogRepository                  = eventLogRepository;
     this.logFileService                  = logFileService;
     this.exposureNotificationApiService  = exposureNotificationApiService;
     this.closeApplicationService         = closeApplicationService;
 }
Exemple #5
0
 public DebugPageViewModel(
     INavigationService navigationService,
     ITermsUpdateService termsUpdateService,
     IExposureConfigurationRepository exposureConfigurationRepository,
     IUserDataRepository userDataRepository,
     IExposureDataRepository exposureDataRepository,
     AbsExposureNotificationApiService exposureNotificationApiService,
     AbsExposureDetectionBackgroundService exposureDetectionBackgroundService,
     ICloseApplicationService closeApplicationService,
     IServerConfigurationRepository serverConfigurationRepository,
     ILocalNotificationService localNotificationService,
     ISendEventLogStateRepository sendEventLogStateRepository,
     IEventLogRepository eventLogRepository,
     IEventLogService eventLogService
     ) : base(navigationService)
 {
     Title = "Title:Debug";
     _termsUpdateService = termsUpdateService;
     _exposureConfigurationRepository = exposureConfigurationRepository;
     _userDataRepository                 = userDataRepository;
     _exposureDataRepository             = exposureDataRepository;
     _exposureNotificationApiService     = exposureNotificationApiService;
     _exposureDetectionBackgroundService = exposureDetectionBackgroundService;
     _closeApplicationService            = closeApplicationService;
     _serverConfigurationRepository      = serverConfigurationRepository;
     _localNotificationService           = localNotificationService;
     _sendEventLogStateRepository        = sendEventLogStateRepository;
     _eventLogRepository                 = eventLogRepository;
     _eventLogService = eventLogService;
 }
Exemple #6
0
 public ManageExposureDataPageViewModel(
     INavigationService navigationService,
     IExposureDataRepository exposureDataRepository,
     IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository
     ) : base(navigationService)
 {
     Title = "Manage ExposureData";
     _exposureDataRepository = exposureDataRepository;
     _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
 }
        public ExposureCheckPageViewModel(
            INavigationService navigationService,
            ILoggerService loggerService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationService exposureRiskCalculationService
            ) : base(navigationService)
        {
            _loggerService                  = loggerService;
            _exposureDataRepository         = exposureDataRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;

            ExposureCheckScores = new ObservableCollection <ExposureCheckScoreModel>();
        }
Exemple #8
0
 public ExposureDataExportService(
     ILoggerService loggerService,
     IExposureDataRepository exposureDataRepository,
     IExposureConfigurationRepository exposureConfigurationRepository,
     AbsExposureNotificationApiService exposureNotificationApiService,
     IEssentialsService essentialsService
     )
 {
     _loggerService                   = loggerService;
     _exposureDataRepository          = exposureDataRepository;
     _exposureConfigurationRepository = exposureConfigurationRepository;
     _exposureNotificationApiService  = exposureNotificationApiService;
     _essentialsService               = essentialsService;
 }
        public ContactedNotifyPageViewModel(
            INavigationService navigationService,
            ILoggerService loggerService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository) : base(navigationService)
        {
            this.loggerService              = loggerService;
            _exposureDataRepository         = exposureDataRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;
            _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;

            Title = AppResources.TitileUserStatusSettings;
        }
        public ExposuresPageViewModel(
            INavigationService navigationService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            ILoggerService loggerService
            ) : base(navigationService)
        {
            _exposureDataRepository = exposureDataRepository;
            _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;
            _loggerService = loggerService;

            Title     = AppResources.MainExposures;
            Exposures = new ObservableCollection <ExposureSummary>();
        }
        public HomePageViewModelTests()
        {
            mockRepository                      = new MockRepository(MockBehavior.Default);
            mockNavigationService               = mockRepository.Create <INavigationService>();
            mockLoggerService                   = mockRepository.Create <ILoggerService>();
            mockDateTimeUtility                 = mockRepository.Create <IDateTimeUtility>();
            mockPreferenceService               = mockRepository.Create <IPreferencesService>();
            mockSecureStorageService            = mockRepository.Create <ISecureStorageService>();
            mockExposureNotificationApiService  = mockRepository.Create <AbsExposureNotificationApiService>(mockLoggerService.Object);
            mockLocalNotificationService        = mockRepository.Create <ILocalNotificationService>();
            mockServerConfigurationRepository   = mockRepository.Create <IServerConfigurationRepository>();
            mockExposureConfigurationRepository = mockRepository.Create <IExposureConfigurationRepository>();
            mockExposureRiskCalculationConfigurationRepository = mockRepository.Create <IExposureRiskCalculationConfigurationRepository>();
            mockLocalNotificationService       = mockRepository.Create <ILocalNotificationService>();
            mockLocalPathService               = mockRepository.Create <ILocalPathService>();
            mockDialogService                  = mockRepository.Create <IDialogService>();
            mockExposureRiskCalculationService = mockRepository.Create <IExposureRiskCalculationService>();
            mockCheckVersionService            = mockRepository.Create <ICheckVersionService>();
            mockEssentialsService              = mockRepository.Create <IEssentialsService>();
            mockExternalNavigationService      = mockRepository.Create <IExternalNavigationService>();

            userDataRepository = new UserDataRepository(
                mockPreferenceService.Object,
                mockDateTimeUtility.Object,
                mockLoggerService.Object
                );
            mockExposureDetectionBackgroundService = mockRepository.Create <AbsExposureDetectionBackgroundService>(
                mockRepository.Create <IDiagnosisKeyRepository>().Object,
                mockExposureNotificationApiService.Object,
                mockRepository.Create <IExposureConfigurationRepository>().Object,
                mockLoggerService.Object,
                userDataRepository,
                mockServerConfigurationRepository.Object,
                mockLocalPathService.Object,
                mockDateTimeUtility.Object
                );
            exposureDataRepository = new ExposureDataRepository(
                mockSecureStorageService.Object,
                mockDateTimeUtility.Object,
                mockLoggerService.Object
                );

            var mockUserDialogs = mockRepository.Create <IUserDialogs>();

            UserDialogs.Instance = mockUserDialogs.Object;
        }
        public ExposureCheckPageViewModel(
            INavigationService navigationService,
            ILoggerService loggerService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            IUserDataRepository userDataRepository,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
            IDateTimeUtility dateTimeUtility
            ) : base(navigationService)
        {
            _loggerService                  = loggerService;
            _exposureDataRepository         = exposureDataRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;
            _userDataRepository             = userDataRepository;
            _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
            _dateTimeUtility = dateTimeUtility;

            ExposureCheckScores = new ObservableCollection <ExposureCheckScoreModel>();
        }
Exemple #13
0
 public SettingsPageViewModel(
     INavigationService navigationService,
     ILoggerService loggerService,
     IUserDataRepository userDataRepository,
     IExposureDataRepository exposureDataRepository,
     IExposureConfigurationRepository exposureConfigurationRepository,
     ILogFileService logFileService,
     AbsExposureNotificationApiService exposureNotificationApiService,
     ICloseApplicationService closeApplicationService
     ) : base(navigationService)
 {
     Title                                = AppResources.SettingsPageTitle;
     AppVer                               = AppInfo.VersionString;
     this.loggerService                   = loggerService;
     this.userDataRepository              = userDataRepository;
     this.exposureDataRepository          = exposureDataRepository;
     this.exposureConfigurationRepository = exposureConfigurationRepository;
     this.logFileService                  = logFileService;
     this.exposureNotificationApiService  = exposureNotificationApiService;
     this.closeApplicationService         = closeApplicationService;
 }
Exemple #14
0
 public ExposureDetectionService
 (
     ILoggerService loggerService,
     ISendEventLogStateRepository sendEventLogStateRepository,
     IExposureDataRepository exposureDataRepository,
     ILocalNotificationService localNotificationService,
     IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
     IExposureRiskCalculationService exposureRiskCalculationService,
     IExposureConfigurationRepository exposureConfigurationRepository,
     IEventLogRepository eventLogRepository,
     IDateTimeUtility dateTimeUtility
 )
 {
     _loggerService = loggerService;
     _sendEventLogStateRepository    = sendEventLogStateRepository;
     _exposureDataRepository         = exposureDataRepository;
     _localNotificationService       = localNotificationService;
     _exposureRiskCalculationService = exposureRiskCalculationService;
     _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
     _exposureConfigurationRepository = exposureConfigurationRepository;
     _eventLogRepository = eventLogRepository;
     _dateTimeUtility    = dateTimeUtility;
 }
        public ExposuresPageViewModel(
            INavigationService navigationService,
            IExposureDataRepository exposureDataRepository,
            IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository,
            IExposureRiskCalculationService exposureRiskCalculationService,
            ILocalPathService localPathService,
            IExposureDataExportService exposureDataExportService,
            ILoggerService loggerService
            ) : base(navigationService)
        {
            _exposureDataRepository = exposureDataRepository;
            _exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;
            _exposureRiskCalculationService = exposureRiskCalculationService;
            _localPathService          = localPathService;
            _exposureDataExportService = exposureDataExportService;
            _loggerService             = loggerService;

            Title          = AppResources.MainExposures;
            Exposures      = new ObservableCollection <ExposureSummary>();
            UtcDescription = string.Format(
                AppResources.ExposuresPageToUtcDescription,
                TimeZoneInfo.Local.StandardName
                );
        }
        public async Task InitExposures()
        {
            var exposures = new ObservableCollection <ExposureSummary>();

            var exposureRiskCalculationConfiguration
                = await _exposureRiskCalculationConfigurationRepository.GetExposureRiskCalculationConfigurationAsync(preferCache : false);

            _loggerService.Info(exposureRiskCalculationConfiguration.ToString());

            var dailySummaryList
                = await _exposureDataRepository.GetDailySummariesAsync(AppConstants.TermOfExposureRecordValidityInDays);

            var dailySummaryMap = dailySummaryList.ToDictionary(ds => ds.GetDateTime());

            var exposureWindowList
                = await _exposureDataRepository.GetExposureWindowsAsync(AppConstants.TermOfExposureRecordValidityInDays);

            var userExposureInformationList
                = _exposureDataRepository.GetExposureInformationList(AppConstants.TermOfExposureRecordValidityInDays);

            if (dailySummaryList.Count() > 0)
            {
                foreach (var ew in exposureWindowList.GroupBy(exposureWindow => exposureWindow.GetDateTime()))
                {
                    if (!dailySummaryMap.ContainsKey(ew.Key))
                    {
                        _loggerService.Warning($"ExposureWindow: {ew.Key} found, but that is not contained the list of dailySummary.");
                        continue;
                    }

                    var dailySummary = dailySummaryMap[ew.Key];

                    RiskLevel riskLevel = _exposureRiskCalculationService.CalcRiskLevel(
                        dailySummary,
                        ew.ToList(),
                        exposureRiskCalculationConfiguration
                        );
                    if (riskLevel < RiskLevel.High)
                    {
                        continue;
                    }

                    var ens = new ExposureSummary()
                    {
                        Timestamp    = ew.Key,
                        ExposureDate = IExposureDataRepository.ConvertToTerm(dailySummary.GetDateTime()),
                    };
                    var exposureDurationInSec = ew.Sum(e => e.ScanInstances.Sum(s => s.SecondsSinceLastScan));
                    ens.SetExposureTime(exposureDurationInSec);

                    exposures.Add(ens);
                }
            }

            if (userExposureInformationList.Count() > 0)
            {
                foreach (var ei in userExposureInformationList.GroupBy(userExposureInformation => userExposureInformation.Timestamp))
                {
                    var ens = new ExposureSummary()
                    {
                        Timestamp    = ei.Key,
                        ExposureDate = IExposureDataRepository.ConvertToTerm(ei.Key),
                    };
                    ens.SetExposureCount(ei.Count());
                    exposures.Add(ens);
                }
            }

            Exposures.Clear();
            foreach (var exposure in exposures.OrderByDescending(exposureSummary => exposureSummary.Timestamp))
            {
                Exposures.Add(exposure);
            }
        }