예제 #1
0
        public Task ExecuteAsync()
        {
            if (_preferencesService.ContainsKey(START_DATETIME))
            {
                MigrateDateTimeToEpoch(START_DATETIME, PreferenceKey.StartDateTimeEpoch, TimeSpan.Zero, DateTime.UtcNow);
            }

            if (_preferencesService.ContainsKey(TERMS_OF_SERVICE_LAST_UPDATE_DATETIME))
            {
                MigrateDateTimeToEpoch(
                    TERMS_OF_SERVICE_LAST_UPDATE_DATETIME,
                    PreferenceKey.TermsOfServiceLastUpdateDateTimeEpoch,
                    -TIME_DIFFERENCIAL_JST_UTC,
                    FALLBACK_DATETIME
                    );
            }

            if (_preferencesService.ContainsKey(PRIVACY_POLICY_LAST_UPDATE_DATETIME))
            {
                MigrateDateTimeToEpoch(
                    PRIVACY_POLICY_LAST_UPDATE_DATETIME,
                    PreferenceKey.PrivacyPolicyLastUpdateDateTimeEpoch,
                    -TIME_DIFFERENCIAL_JST_UTC,
                    FALLBACK_DATETIME
                    );
            }

            return(Task.CompletedTask);
        }
예제 #2
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();
        }
예제 #3
0
        public Task ExecuteAsync()
        {
            if (_preferencesService.ContainsKey(START_DATETIME))
            {
                MigrateDateTimeToEpoch(START_DATETIME, PreferenceKey.StartDateTimeEpoch,
                                       timeZoneInfo: null,
                                       fallbackDateTime: DateTime.UtcNow
                                       );
            }

            if (_preferencesService.ContainsKey(TERMS_OF_SERVICE_LAST_UPDATE_DATETIME))
            {
                MigrateDateTimeToEpoch(
                    TERMS_OF_SERVICE_LAST_UPDATE_DATETIME,
                    PreferenceKey.TermsOfServiceLastUpdateDateTimeEpoch,
                    timeZoneInfo: AppConstants.TIMEZONE_JST,
                    fallbackDateTime: AppConstants.COCOA_FIRST_RELEASE_DATE
                    );
            }

            if (_preferencesService.ContainsKey(PRIVACY_POLICY_LAST_UPDATE_DATETIME))
            {
                MigrateDateTimeToEpoch(
                    PRIVACY_POLICY_LAST_UPDATE_DATETIME,
                    PreferenceKey.PrivacyPolicyLastUpdateDateTimeEpoch,
                    timeZoneInfo: AppConstants.TIMEZONE_JST,
                    fallbackDateTime: AppConstants.COCOA_FIRST_RELEASE_DATE
                    );
            }

            return(Task.CompletedTask);
        }
예제 #4
0
 private Version GuessVersion()
 {
     if (_preferencesService.ContainsKey(PreferenceKey.StartDateTimeEpoch))
     {
         return(VERSION_1_3_0);
     }
     if (_preferencesService.ContainsKey(PREFERENCE_KEY_START_DATETIME))
     {
         return(VERSION_1_2_2);
     }
     return(VERSION_1_0_0);
 }
예제 #5
0
        public SendEventLogState GetSendEventLogState(EventType eventType)
        {
            string stateString = EMPTY_DICT;

            try
            {
                _loggerService.StartMethod();

                if (!_preferencesService.ContainsKey(PreferenceKey.SendEventLogState))
                {
                    return(SendEventLogState.NotSet);
                }

                stateString = _preferencesService.GetStringValue(
                    PreferenceKey.SendEventLogState,
                    EMPTY_DICT
                    );

                IDictionary <string, int> stateDict
                    = JsonConvert.DeserializeObject <IDictionary <string, int> >(stateString);

                if (!stateDict.ContainsKey(eventType.ToString()))
                {
                    return(SendEventLogState.NotSet);
                }

                int value = stateDict[eventType.ToString()];
                return((SendEventLogState)Enum.ToObject(typeof(SendEventLogState), value));
            }
            catch (JsonReaderException exception)
            {
                _preferencesService.SetStringValue(PreferenceKey.SendEventLogState, EMPTY_DICT);

                _loggerService.Exception($"JsonSerializationException {stateString}", exception);
                _loggerService.Warning($"Preference-key {PreferenceKey.SendEventLogState} has been initialized.");
            }
            finally
            {
                _loggerService.EndMethod();
            }

            return(SendEventLogState.NotSet);
        }
예제 #6
0
 public bool IsAllAgreed()
 {
     return(_preferencesService.ContainsKey(PreferenceKey.TermsOfServiceLastUpdateDateTimeEpoch) && _preferencesService.ContainsKey(PreferenceKey.PrivacyPolicyLastUpdateDateTimeEpoch))
     ;
 }