Exemplo n.º 1
0
        public async Task Migrate(TermsType termsType, bool isAgree)
        {
            loggerService.StartMethod();

            var applicationPropertyKey = termsType == TermsType.TermsOfService ? TermsOfServiceLastUpdateDateKey : PrivacyPolicyLastUpdateDateKey;
            var preferenceKey          = termsType == TermsType.TermsOfService ? PreferenceKey.TermsOfServiceLastUpdateDateTime : PreferenceKey.PrivacyPolicyLastUpdateDateTime;

            if (preferencesService.ContainsKey(applicationPropertyKey))
            {
                return;
            }

            if (isAgree)
            {
                if (applicationPropertyService.ContainsKey(applicationPropertyKey))
                {
                    var lastUpdateDate = (DateTime)applicationPropertyService.GetProperties(applicationPropertyKey);
                    preferencesService.SetValue(preferenceKey, lastUpdateDate);
                }
                else
                {
                    preferencesService.SetValue(preferenceKey, new DateTime());
                }
            }

            await applicationPropertyService.Remove(applicationPropertyKey);

            loggerService.EndMethod();
        }
Exemplo n.º 2
0
        public async Task ExecuteAsync()
        {
            _loggerService.StartMethod();

            var existsUserData = _applicationPropertyService.ContainsKey(APPLICATION_PROPERTY_USER_DATA_KEY);

            if (existsUserData)
            {
                _loggerService.EndMethod();
                return;
            }

            var userData = new UserDataModel();
            await _applicationPropertyService.SavePropertiesAsync(APPLICATION_PROPERTY_USER_DATA_KEY, JsonConvert.SerializeObject(userData));

            _loggerService.EndMethod();
        }
Exemplo n.º 3
0
        private UserDataModel GetFromApplicationProperties()
        {
            loggerService.StartMethod();

            var existsUserData = applicationPropertyService.ContainsKey("UserData");

            loggerService.Info($"existsUserData: {existsUserData}");
            if (existsUserData)
            {
                loggerService.EndMethod();
                var userData = applicationPropertyService.GetProperties("UserData");
                return(Utils.DeserializeFromJson <UserDataModel>(userData.ToString()));
            }

            loggerService.EndMethod();
            return(null);
        }
Exemplo n.º 4
0
        public async Task MigrateFromUserData(UserDataModel userData)
        {
            loggerService.StartMethod();

            const string ConfigurationPropertyKey = "ExposureNotificationConfigration";

            if (userData.LastProcessTekTimestamp != null && userData.LastProcessTekTimestamp.Count > 0)
            {
                var stringValue = Utils.SerializeToJson(userData.LastProcessTekTimestamp);
                preferencesService.SetValue(PreferenceKey.LastProcessTekTimestamp, stringValue);
                userData.LastProcessTekTimestamp.Clear();
                loggerService.Info("Migrated LastProcessTekTimestamp");
            }

            if (applicationPropertyService.ContainsKey(ConfigurationPropertyKey))
            {
                var configuration = applicationPropertyService.GetProperties(ConfigurationPropertyKey) as string;
                if (!string.IsNullOrEmpty(configuration))
                {
                    preferencesService.SetValue(PreferenceKey.ExposureNotificationConfiguration, configuration);
                }
                await applicationPropertyService.Remove(ConfigurationPropertyKey);

                loggerService.Info("Migrated ExposureNotificationConfiguration");
            }

            if (userData.ExposureInformation != null)
            {
                secureStorageService.SetValue(PreferenceKey.ExposureInformation, JsonConvert.SerializeObject(userData.ExposureInformation));
                userData.ExposureInformation = null;
                loggerService.Info("Migrated ExposureInformation");
            }

            if (userData.ExposureSummary != null)
            {
                secureStorageService.SetValue(PreferenceKey.ExposureSummary, JsonConvert.SerializeObject(userData.ExposureSummary));
                userData.ExposureSummary = null;
                loggerService.Info("Migrated ExposureSummary");
            }

            loggerService.EndMethod();
        }
Exemplo n.º 5
0
        public bool IsReAgree(TermsType privacyType, TermsUpdateInfoModel termsUpdateInfo)
        {
            loggerService.StartMethod();

            TermsUpdateInfoModel.Detail info = null;
            string key = null;

            switch (privacyType)
            {
            case TermsType.TermsOfService:
                info = termsUpdateInfo.TermsOfService;
                key  = TermsOfServiceLastUpdateDateKey;
                break;

            case TermsType.PrivacyPolicy:
                info = termsUpdateInfo.PrivacyPolicy;
                key  = PrivacyPolicyLastUpdateDateKey;
                break;
            }

            if (info == null)
            {
                loggerService.EndMethod();
                return(false);
            }

            var lastUpdateDate = new DateTime();

            if (applicationPropertyService.ContainsKey(key))
            {
                lastUpdateDate = (DateTime)applicationPropertyService.GetProperties(key);
            }

            loggerService.Info($"privacyType: {privacyType}, lastUpdateDate: {lastUpdateDate}, info.UpdateDateTime: {info.UpdateDateTime}");
            loggerService.EndMethod();

            return(lastUpdateDate < info.UpdateDateTime);
        }