Esempio n. 1
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            if (!_cleanExit)
            {
                return;
            }

            _isRunning.ReleaseMutex();

            PipeServerManager.GetInstance().Dispose();

            //add by gh - 自动启动隐藏后台图标
            if (SettingHelper.Get("Visible", true))
            {
                TrayIconManager.GetInstance().Dispose();
            }
            //----------//

            //comment by gh
            //TrayIconManager.GetInstance().Dispose();
            //----------//

            KeystrokeDispatcher.GetInstance().Dispose();
            ViewWindowManager.GetInstance().Dispose();
        }
Esempio n. 2
0
 private static bool AuthenticateActiveDirectory(string username, string password)
 {
     try
     {
         if (SettingHelper.Get().ActiveDirectoryType == ActiveDirectoryType.LocalMachine)
         {
             using (var principalContext = new PrincipalContext(ContextType.Machine))
             {
                 return(principalContext.ValidateCredentials(username, password));
             }
         }
         else if (SettingHelper.Get().ActiveDirectoryType == ActiveDirectoryType.Server)
         {
             using (var principalContext = new PrincipalContext(ContextType.Domain,
                                                                SettingHelper.Get().ActiveDirectoryDomain,
                                                                SettingHelper.Get().ActiveDirectoryDN))
             {
                 return(principalContext.ValidateCredentials(username, password));
             }
         }
         else
         {
             throw new ArgumentOutOfRangeException("ActiveDirectoryType is not valid");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
        private void UpgradeVersion()
        {
            if (!IsolatedStorageSettings.ApplicationSettings.Contains("MigratedScheduler") && ScheduledActionService.Find("PeriodicAgent") as PeriodicTask != null)
            {
                //1.0.x대의 스케쥴러 삭제
                RemoveAgent("PeriodicAgent");
                IsolatedStorageSettings.ApplicationSettings["MigratedScheduler"] = true;
                //새로운 스케쥴러 등록
                StartPeriodicAgent();
            }

            //2.4 버전 색상값 변경 관련
            if (SettingHelper.ContainsKey(Constants.LOCKSCREEN_BACKGROUND_COLOR))
            {
                ColorItem colorItem = SettingHelper.Get(Constants.LOCKSCREEN_BACKGROUND_COLOR) as ColorItem;
                if (colorItem.Color == Colors.Transparent)
                {
                    SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_COLOR, new ColorItem()
                    {
                        Text  = AppResources.ColorChrome,
                        Color = ColorItem.ConvertColor(0xFF1F1F1F)
                    }, false);
                    SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_OPACITY, 0, false);
                    SettingHelper.Save();
                }
            }
        }
Esempio n. 4
0
        void weatherBug_LiveWeatherCompleted(object sender, LiveWeather liveWeather, Forecasts forecasts)
        {
            //도시검색을 통해서 들어온 경우라면 폰상태 정보의 도시정보를 설정에 저장하고 삭제
            if (PhoneApplicationService.Current.State.ContainsKey(Constants.WEATHER_MAIN_CITY))
            {
                SettingHelper.Set(Constants.WEATHER_MAIN_CITY, PhoneApplicationService.Current.State[Constants.WEATHER_MAIN_CITY], true);
                PhoneApplicationService.Current.State.Remove(Constants.WEATHER_MAIN_CITY);
            }

            if (liveWeather == null || !(liveWeather is LiveWeather) || forecasts == null || !(forecasts is Forecasts))
            {
                WeatherCity city = SettingHelper.Get(Constants.WEATHER_MAIN_CITY) as WeatherCity;

                PIWeather.Header            = city.IsGpsLocation ? AppResources.Refresh : city.CityName;
                GridLiveWeather.Visibility  = System.Windows.Visibility.Collapsed;
                ListBoxForecasts.Visibility = System.Windows.Visibility.Collapsed;
                TxtWeatherNoCity.Visibility = System.Windows.Visibility.Visible;
                TxtWeatherNoCity.Text       = AppResources.MsgNotSupportWeatherLocation;
                return;
            }
            //검색된 결과값 저장
            SettingHelper.Set(Constants.WEATHER_LIVE_RESULT, liveWeather, true);
            //화면에 검색된 결과를 표시
            RenderLiveWeather(liveWeather);
            //조회된 주간예보 정보를 저장
            SettingHelper.Set(Constants.WEATHER_FORECAST_RESULT, forecasts, true);
            //조회된 주간예보 정보를 화면에 표시
            RenderForecast(forecasts);
            //날씨 라이브타일 다시 로드
            CreateWeatherLivetileImage();

            //로딩 레이어 제거
            HideLoadingPanel();
        }
Esempio n. 5
0
 public void LoadConfigCalendar()
 {
     //일정 표시 여부 캐싱
     IsShowAppointment = (bool)SettingHelper.Get(Constants.CALENDAR_SHOW_APPOINTMENT);
     //요일 헤더 로딩
     CalendarHeader.ItemsSource = VsCalendar.GetDayNames(false);
 }
Esempio n. 6
0
        private void CreateBatteryLivetileImage()
        {
            LivetileTemplateItem batteryItem = LivetileSelector.ItemsSource[2] as LivetileTemplateItem;

            batteryItem.Background = new SolidColorBrush((SettingHelper.Get(Constants.LIVETILE_BATTERY_BACKGROUND_COLOR) as ColorItem).Color);
            batteryItem.BackTitle  = AppResources.ApplicationTitle;

            LivetileData data = new LivetileData();

            //배터리 이미지 로드
            LivetileHelper.CreateLivetileImage(data, LiveItems.Battery);
            LoadLivetileImage(batteryItem);
            //배터리 백타일 내용
            batteryItem.LiveBackTileContent = LivetileHelper.GetBatteryBackTextContent();
            batteryItem.Visibility          = System.Windows.Visibility.Visible;
            if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("battery")) != null)
            {
                batteryItem.PinIconOpacity = 1;
                GetAppBarButton(AppResources.PinBatteryLivetile).IsEnabled = false;
                UpdateLiveTile(batteryItem, 0);
            }
            else
            {
                batteryItem.PinIconOpacity = 0.3;
                GetAppBarButton(AppResources.PinBatteryLivetile).IsEnabled = true;
            }
        }
Esempio n. 7
0
        //리스트의 타일 아이콘 탭 이벤트 핸들러
        private void LivetileItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            LivetileTemplateItem templateItem = (sender as FrameworkElement).DataContext as LivetileTemplateItem;

            switch (templateItem.LiveItem)
            {
            case LiveItems.Weather:
                if (SettingHelper.Get(Constants.WEATHER_MAIN_CITY) == null)
                {
                    NavigationService.Navigate(new Uri(string.Format("/View/SearchCityPage.xaml?pi={0}", PILivetile.Name), UriKind.Relative));
                }
                else
                {
                    PanoramaMainView.DefaultItem = PIWeather;
                }
                break;

            case LiveItems.Calendar:
                PanoramaMainView.DefaultItem = PICalendar;
                break;

            case LiveItems.Battery:
                NavigationService.Navigate(new Uri("/View/FlashlightPage.xaml", UriKind.Relative));
                break;
            }
        }
Esempio n. 8
0
        public static List <Day> GetDayNames(bool isForceWhiteForgroundBrush)
        {
            double          normalSize      = (double)Application.Current.Resources["PhoneFontSizeNormal"];
            double          largeSize       = normalSize * 1.3;
            SolidColorBrush foregroundBrush = isForceWhiteForgroundBrush ? new SolidColorBrush(Colors.White) : (SolidColorBrush)Application.Current.Resources["PhoneForegroundBrush"];
            DayOfWeek       dow             = (DayOfWeek)SettingHelper.Get(Constants.CALENDAR_FIRST_DAY_OF_WEEK);
            List <Day>      dtList          = new List <Day>();

            //요일 인덱스 추가
            string[] dayNames = DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames;
            int      startDay = (int)dow;

            for (int i = 0; i < dayNames.Length - startDay; i++)
            {
                dtList.Insert(i, new Day(dayNames[i + startDay])
                {
                    FontSize        = normalSize,
                    ForegroundBrush = foregroundBrush
                });
            }

            for (int i = dayNames.Length - startDay; i < dayNames.Length; i++)
            {
                dtList.Insert(i, new Day(dayNames[i - (dayNames.Length - startDay)])
                {
                    FontSize        = normalSize,
                    ForegroundBrush = foregroundBrush
                });
            }
            return(dtList);
        }
Esempio n. 9
0
        private async void appBarIconBtnPreview_Click(object sender, EventArgs e)
        {
            await Task.Delay(10);

            ApplicationBar.IsVisible      = false;
            LoadingProgressBar.Visibility = System.Windows.Visibility.Visible;
            LoadingText.Text = AppResources.MsgCreatingPreview;

            LockscreenData data = new LockscreenData(false)
            {
                BackgroundBitmap = GetCropImage(),
                DayList          = VsCalendar.GetCalendarOfMonth(DateTime.Now, DateTime.Now, true, true),
                LiveWeather      = SettingHelper.Get(Constants.WEATHER_LIVE_RESULT) as LiveWeather,
                Forecasts        = SettingHelper.Get(Constants.WEATHER_FORECAST_RESULT) as Forecasts
            };

            if ((bool)SettingHelper.Get(Constants.CALENDAR_SHOW_APPOINTMENT))
            {
                Appointments appointments = new Appointments();
                appointments.SearchCompleted += (s, se) =>
                {
                    VsCalendar.MergeCalendar(data.DayList, se.Results);
                    LockscreenHelper.RenderLayoutToBitmap(data);
                    DisplayPreview(data.BackgroundBitmap);
                };
                appointments.SearchAsync(data.DayList[7].DateTime, data.DayList[data.DayList.Count - 1].DateTime, null);
            }
            else
            {
                LockscreenHelper.RenderLayoutToBitmap(data);
                DisplayPreview(data.BackgroundBitmap);
            }
        }
Esempio n. 10
0
        private TrayIconManager()
        {
            _icon = new NotifyIcon
            {
                Text = string.Format(TranslationHelper.Get("Icon_ToolTip"),
                                     Application.ProductVersion),
                Icon        = GetTrayIconByDPI(),
                ContextMenu = new ContextMenu(new[]
                {
                    new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}")
                    {
                        Enabled = false
                    },
                    new MenuItem("-"),
                    new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"), (sender, e) => Updater.CheckForUpdates()),
                    new MenuItem(TranslationHelper.Get("Icon_GetPlugin"),
                                 (sender, e) => Process.Start("https://github.com/QL-Win/QuickLook/wiki/Available-Plugins")),
                    _itemAutorun,
                    new MenuItem(TranslationHelper.Get("Icon_Quit"),
                                 (sender, e) => System.Windows.Application.Current.Shutdown())
                }),
                Visible = SettingHelper.Get("ShowTrayIcon", true)
            };

            _icon.ContextMenu.Popup += (sender, e) => { _itemAutorun.Checked = AutoStartupHelper.IsAutorun(); };
        }
Esempio n. 11
0
        private void UpgradeSettings()
        {
            try
            {
                if (!SettingHelper.Get("Upgraded", true))
                {
                    return;
                }

                Updater.CollectAndShowReleaseNotes();

                SettingHelper.Set("Upgraded", false);
            }
            catch (ConfigurationErrorsException e)
            {
                if (e.Filename != null)
                {
                    File.Delete(e.Filename);
                }
                else if (((ConfigurationErrorsException)e.InnerException)?.Filename != null)
                {
                    File.Delete(((ConfigurationErrorsException)e.InnerException).Filename);
                }

                MessageBox.Show("Configuration file is currupted and has been reseted. Please restart QuickLook.",
                                "QuickLook", MessageBoxButton.OK, MessageBoxImage.Error);

                Process.GetCurrentProcess().Kill(); // just kill current process to avoid subsequence executions
                //return;
            }

            SettingHelper.Set("Upgraded", false);
        }
Esempio n. 12
0
        public JsonResult Set(GeneralSettingsApp setting)
        {
            var generalSettings = SettingHelper.ParseObjectToSettingDataBase(setting);

            using (var context = new AppDbContext())
            {
                var settingDataBase = context.GeneralSettings.ToArray();

                foreach (var item in generalSettings)
                {
                    if (item.SettingName == "SMTPCredentialsPassword")
                    {
                        var actualPassword = SettingHelper.Get(true).SMTPCredentialsPassword;

                        if (!UserChangedSMTPCredentialsPassword(item.ValueString, actualPassword))
                        {
                            continue;
                        }
                    }

                    var settingItem = settingDataBase.Single(x => x.SettingName == item.SettingName);
                    settingItem.ValueBool   = item.ValueBool;
                    settingItem.ValueInt    = item.ValueInt;
                    settingItem.ValueString = item.ValueString;
                }
                context.SaveChanges();
            }

            SettingHelper.RefreshCache();

            return(Json(setting, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            string captchaResponse = Request.Form["g-Recaptcha-Response"];
            string secretKey       = @SettingHelper.Get("Recaptcha Secret Key");

            try
            {
                var result = ReCaptchaValidator.IsValidAsync(captchaResponse, secretKey);
                if (result.Success && ModelState.IsValid && SettingHelper.Get("Recaptcha Site Key").HasValue())
                {
                    return(await ProcessRegistration("_RegistrationForm", model));
                }

                if (!result.Success)
                {
                    foreach (string err in result.ErrorCodes)
                    {
                        ModelState.AddModelError("", err);
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }

            return(View("_RegistrationForm", model));
        }
Esempio n. 14
0
        public SolidColorBrush GetBackgroundBrush(LiveItems item)
        {
            string key = string.Empty;

            if ((bool)SettingHelper.Get(Constants.LIVETILE_RANDOM_BACKGROUND_COLOR))
            {
                int index = new Random().Next(0, ColorItem.UintColors.Length - 1);
                return(new SolidColorBrush(ColorItem.ConvertColor(ColorItem.UintColors[index])));
            }
            else
            {
                switch (item)
                {
                case LiveItems.Calendar:
                    key = Constants.LIVETILE_CALENDAR_BACKGROUND_COLOR;
                    break;

                case LiveItems.Weather:
                    key = Constants.LIVETILE_WEATHER_BACKGROUND_COLOR;
                    break;

                case LiveItems.Battery:
                    key = Constants.LIVETILE_BATTERY_BACKGROUND_COLOR;
                    break;
                }

                return(new SolidColorBrush((SettingHelper.Get(key) as ColorItem).Color));
            }
        }
Esempio n. 15
0
        private void CreateWeatherLivetileImage()
        {
            LivetileTemplateItem weatherItem = LivetileSelector.ItemsSource[0] as LivetileTemplateItem;
            //날씨 데이타
            LivetileData data = new LivetileData()
            {
                LiveWeather = SettingHelper.Get(Constants.WEATHER_LIVE_RESULT) as LiveWeather,
                Forecasts   = SettingHelper.Get(Constants.WEATHER_FORECAST_RESULT) as Forecasts
            };

            //날씨 이미지 로드
            LivetileHelper.CreateLivetileImage(data, LiveItems.Weather);
            LoadLivetileImage(weatherItem);
            weatherItem.Visibility = System.Windows.Visibility.Visible;
            if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("weather")) != null)
            {
                weatherItem.PinIconOpacity = 1;
                GetAppBarButton(AppResources.PinWeatherLivetile).IsEnabled = false;
                UpdateLiveTile(weatherItem, 0);
            }
            else
            {
                weatherItem.PinIconOpacity = 0.3;
                GetAppBarButton(AppResources.PinWeatherLivetile).IsEnabled = true;
            }
        }
Esempio n. 16
0
        public JsonResult Get(bool refresh = false)
        {
            var setting = SettingHelper.Get(refresh);

            HashSensitiveInformation(setting);

            return(Json(setting, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public BlackList()
        {
            this.Items = SettingHelper.Get(Constants.DOMAIN_FILTER) as ObservableCollection <BlackDomain>;

            if (this.Items == null)
            {
                this.Items = new ObservableCollection <BlackDomain>();
            }
        }
Esempio n. 18
0
        public async Task <ActionResult> RegisterSimple(RegisterViewModel model)
        {
            if (ModelState.IsValid && string.IsNullOrEmpty(SettingHelper.Get("Recaptcha Site Key")))
            {
                return(await ProcessRegistration("_RegistrationSimpleForm", model));
            }

            return(View("_RegistrationSimpleForm", model));
        }
Esempio n. 19
0
        public static string GetDirectoryTempPathOrCreateIfNotExists()
        {
            if (!Directory.Exists(SettingHelper.Get().UploadDirectoryTemp))
            {
                Directory.CreateDirectory(SettingHelper.Get().UploadDirectoryTemp);
            }

            return(SettingHelper.Get().UploadDirectoryTemp);
        }
Esempio n. 20
0
        private void InitializeWeatherSetting()
        {
            DisplayUnit       unit = (DisplayUnit)SettingHelper.Get(Constants.WEATHER_UNIT_TYPE);
            List <PickerItem> WeatherUnitSource = new List <PickerItem>();

            WeatherUnitSource.Add(new PickerItem()
            {
                Name = AppResources.WeatherUnitCelsius, Key = DisplayUnit.Celsius
            });
            WeatherUnitSource.Add(new PickerItem()
            {
                Name = AppResources.WeatherUnitFahrenheit, Key = DisplayUnit.Fahrenheit
            });
            WeatherUnitPicker.ItemsSource = WeatherUnitSource;

            foreach (PickerItem item in WeatherUnitSource)
            {
                if ((DisplayUnit)item.Key == unit)
                {
                    WeatherUnitPicker.SelectedItem = item;
                    break;
                }
            }

            WeatherUnitPicker.SelectionChanged += OnWeatherUnitPickerSelectionChanged;

            WeatherIconType       iconType          = (WeatherIconType)SettingHelper.Get(Constants.WEATHER_ICON_TYPE);
            List <IconPickerItem> WeatherIconSource = new List <IconPickerItem>();

            WeatherIconSource.Add(new IconPickerItem()
            {
                WeatherIconType = WeatherIconType.Normal
            });
            WeatherIconSource.Add(new IconPickerItem()
            {
                WeatherIconType = WeatherIconType.Simple01
            });
            WeatherIconPackPicker.ItemsSource = WeatherIconSource;

            foreach (IconPickerItem item in WeatherIconSource)
            {
                if ((WeatherIconType)item.WeatherIconType == iconType)
                {
                    WeatherIconPackPicker.SelectedItem = item;
                    break;
                }
            }

            WeatherIconPackPicker.SelectionChanged += OnWeatherIconPackPickerSelectionChanged;

            bool isUseLocation = (bool)SettingHelper.Get(Constants.WEATHER_USE_LOCATION_SERVICES);

            WeatherLocation.IsChecked  = isUseLocation;
            WeatherLocation.Checked   += WeatherLocation_Checked;
            WeatherLocation.Unchecked += WeatherLocation_Unchecked;
        }
Esempio n. 21
0
        public override Task <BitmapSource> GetRenderedFrame(int index)
        {
            var fullSize = Meta.GetSize();

            return(new Task <BitmapSource>(() =>
            {
                var settings = new MagickReadSettings
                {
                    BackgroundColor = MagickColors.None,
                    Defines = new DngReadDefines
                    {
                        OutputColor = DngOutputColor.SRGB,
                        UseCameraWhitebalance = true,
                        DisableAutoBrightness = false
                    }
                };

                try
                {
                    using (var mi = new MagickImage(Path.LocalPath, settings))
                    {
                        if (SettingHelper.Get("UseColorProfile", false, "QuickLook.Plugin.ImageViewer"))
                        {
                            if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB || mi.ColorSpace == ColorSpace.scRGB)
                            {
                                mi.SetProfile(ColorProfile.SRGB);
                                if (ContextObject.ColorProfileName != null)
                                {
                                    mi.SetProfile(new ColorProfile(ContextObject.ColorProfileName)); // map to monitor color
                                }
                            }
                        }

                        mi.AutoOrient();

                        if (mi.Width != (int)fullSize.Width || mi.Height != (int)fullSize.Height)
                        {
                            mi.Resize((int)fullSize.Width, (int)fullSize.Height);
                        }

                        mi.Density = new Density(DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Horizontal,
                                                 DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Vertical);

                        var img = mi.ToBitmapSourceWithDensity();

                        img.Freeze();
                        return img;
                    }
                }
                catch (Exception e)
                {
                    ProcessHelper.WriteLog(e.ToString());
                    return null;
                }
            }));
        }
Esempio n. 22
0
        private void CheckUpdate()
        {
            if (DateTime.Now.Ticks - SettingHelper.Get <long>("LastUpdateTicks") < TimeSpan.FromDays(30).Ticks)
            {
                return;
            }

            Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true));
            SettingHelper.Set("LastUpdateTicks", DateTime.Now.Ticks);
        }
Esempio n. 23
0
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = true;
            BundleTable.EnableOptimizations = true;

            var cdnRootAddress = SettingHelper.Get("CDN Address");

            RegisterFramework(bundles, cdnRootAddress);
            RegisterPlugins(bundles, cdnRootAddress);
        }
Esempio n. 24
0
        private void CheckUpdate()
        {
            if (DateTime.Now - SettingHelper.Get <DateTime>("LastUpdate") < TimeSpan.FromDays(7))
            {
                return;
            }

            Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true));
            SettingHelper.Set("LastUpdate", DateTime.Now);
        }
Esempio n. 25
0
        private void MainPageWeather()
        {
            //앱바 생성
            CreateWeatherAppBar();

            weatherBug = new WeatherBug();
            weatherBug.DefaultUnitType           = (DisplayUnit)SettingHelper.Get(Constants.WEATHER_UNIT_TYPE);
            weatherBug.RequestFailed            += weatherBug_RequestFailed;
            weatherBug.LiveWeatherBeforeLoad    += weatherBug_LiveWeatherBeforeLoad;
            weatherBug.LiveWeatherCompletedLoad += weatherBug_LiveWeatherCompleted;
        }
Esempio n. 26
0
        public ActionResult Index()
        {
            var model = new RegisterViewModel();

            if (string.IsNullOrEmpty(SettingHelper.Get("Recaptcha Site Key")))
            {
                return(View("_RegistrationSimpleForm", model));
            }

            return(View("_RegistrationForm", model));
        }
Esempio n. 27
0
        public static string CDNFontPath(this Font font)
        {
            var cdnAddress = SettingHelper.Get("CDN Address");

            if (string.IsNullOrWhiteSpace(cdnAddress))
            {
                return(font.FontPath);
            }

            return($"{cdnAddress}{font.FontPath}");
        }
Esempio n. 28
0
        public static string CDNImagePath(this Image image)
        {
            var cdnAddress = SettingHelper.Get("CDN Address");

            if (string.IsNullOrWhiteSpace(cdnAddress))
            {
                return(image.ImagePath);
            }

            return($"{cdnAddress}{image.ImagePath}");
        }
Esempio n. 29
0
        private ColorItem FindSelectedColorItem(List <ColorItem> items, string key)
        {
            ColorItem colorItem = SettingHelper.Get(key) as ColorItem;
            //이전과 표시하는 언어가 다를 수 있으므로 새로 적용된 언어를 다시 찾아오는 과정임.
            ColorItem newColorItem = items.Find(x => x.Color == colorItem.Color);

            if (newColorItem != null)
            {
                colorItem = newColorItem;
            }
            return(colorItem);
        }
        private bool IsPreviousPassword(int userId, string newPassword)
        {
            var passwordHistoryLimit = SettingHelper.Get().PasswordHistoryLimit;

            var IsResusePassword = Users.Where(u => u.Id == userId)
                                   .SelectMany(u => u.PreviousUserPasswords)
                                   .OrderByDescending(x => x.CreationDate)
                                   .Take(passwordHistoryLimit)
                                   .Select(x => x.PasswordHash)
                                   .ToArray()
                                   .Any(x => PasswordHasher.VerifyHashedPassword(x, newPassword) != PasswordVerificationResult.Failed);

            return(IsResusePassword);
        }