Example #1
0
        public AuthService(IDeviceStorageRepository deviceStorageRepository)
        {
            _deviceStorageRepository = deviceStorageRepository;

            if (!_deviceStorageRepository.ContainsKey(AuthStorageKey))
            {
                return;
            }

            var storageModel = _deviceStorageRepository.GetObj <AuthStorageModel>(AuthStorageKey);

            _token        = storageModel.Token;
            _refreshToken = storageModel.RefreshToken;
            _userName     = storageModel.UserName;
            _save         = storageModel.Save;
        }
Example #2
0
        /// <summary>
        /// Read app language from AppLangKey property
        /// If never set save default read by I18NPortable
        /// </summary>
        /// <returns>string locale code</returns>
        private string ReadLocale()
        {
            if (_deviceStorageRepository.ContainsKey(AppLangKey))
            {
                var locale = _deviceStorageRepository.GetObj <string>(AppLangKey);
                if (string.IsNullOrEmpty(locale))
                {
                    SaveLocale(LangCode);
                    return(LangCode);
                }

                _log.Info(ClassTag, "read " + LangCode + " language");
                return(locale);
            }

            SaveLocale(LangCode);
            return(LangCode);
        }
Example #3
0
        public void ClearLogsMonthly()
        {
            var today = DateTime.Today;

            if (_deviceStorageRepository.ContainsKey(LogClearDateKey))
            {
                var savedClearDate = _deviceStorageRepository.GetObj <DateTime>(LogClearDateKey);

                if (today - savedClearDate > TimeSpan.FromDays(7))
                {
                    ClearLogs();
                    _deviceStorageRepository.SaveObj(LogClearDateKey, today);
                }
            }
            else
            {
                ClearLogs();
                _deviceStorageRepository.SaveObj(LogClearDateKey, today);
            }
        }