private bool TryToShowMainWindow(bool isAuthenticated) { logger.Debug("TryToShowMainWindow called; isAuthenticated - {0}", isAuthenticated); if (!isAuthenticated) { logger.Error("Cant show main window - not authenticated"); return(false); } logger.Debug("Getting device"); Device device = pbData.GetDevice(pbData.InstallationUUID); if (device != null) { pbData.DeviceUUID = device.UUID; logger.Debug("found device - {0}", pbData.DeviceUUID); } else { logger.Error("Cant find device"); Application.Current.Dispatcher.Invoke((Action) delegate { string _message = System.Windows.Application.Current.FindResource("ProblemReadingDeviceIdLoginMessage") as string; CustomInformationMessageBoxWindow c = new CustomInformationMessageBoxWindow(_message); c.ShowDialog(); }); return(true); } IPBWebAPI pbWebAPI = resolver.GetInstanceOf <IPBWebAPI>(); logger.Debug("Get countries"); if (pbData.GetCountries().Count == 0) { logger.Debug("Get countries - request from web API"); dynamic countries = pbWebAPI.RequestCountry(String.Format("{0}|{1}", pbData.ActiveUser, pbData.DeviceUUID)); pbData.AddCounties(countries); } logger.Debug("GetConfigurationByAccountAndKey {0} < {1}", UserEmail, DefaultProperties.Configuration_Key_RememberEmail); var rememberLoginEmail = pbData.GetConfigurationByAccountAndKey(UserEmail, DefaultProperties.Configuration_Key_RememberEmail); if (rememberLoginEmail == null) { logger.Debug("GetConfigurationByAccountAndKey failed, adding configuration"); rememberLoginEmail = new Configuration() { AccountEmail = UserEmail, Key = DefaultProperties.Configuration_Key_RememberEmail, Value = true.ToString() }; pbData.AddOrUpdateConfiguration(rememberLoginEmail); logger.Debug("Condifuration added"); } bool isEnabledRememberLoginEmail = false; logger.Debug("TRying to parse rememberLoginEmail"); if (bool.TryParse(rememberLoginEmail.Value, out isEnabledRememberLoginEmail)) { logger.Debug("rememberLoginEmail parsed - {0}", isEnabledRememberLoginEmail); if (isEnabledRememberLoginEmail) { var lastLogin = new Configuration() { AccountEmail = DefaultProperties.Configuration_DefaultAccount, Key = DefaultProperties.Configuration_Key_LastLoginEmail, Value = UserEmail }; pbData.AddOrUpdateConfiguration(lastLogin); logger.Debug("Configuration updated"); } } bool isDeviceTrusted = false; var isDeviceTrustedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrusted); if (!string.IsNullOrWhiteSpace(isDeviceTrustedStr)) { bool.TryParse(isDeviceTrustedStr, out isDeviceTrusted); } logger.Debug("IsDeviceTrusted - {0}", isDeviceTrusted); if (isDeviceTrusted) { DateTimeOffset lastCheckedDateTimeOffset = new DateTimeOffset(); DateTime lastCheckedDate = new DateTime(); var isDeviceTrustedLastCheckedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrustedLastChecked); bool isParsed = DateTimeOffset.TryParse(isDeviceTrustedLastCheckedStr, out lastCheckedDateTimeOffset); if (isParsed) { lastCheckedDate = lastCheckedDateTimeOffset.UtcDateTime; var totalDaysCount = (DateTime.UtcNow - lastCheckedDate).TotalDays; if (totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays) { logger.Debug("device not trusted - totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays"); isDeviceTrusted = false; //notify we need to enter this info } } else { isDeviceTrusted = false; } } logger.Debug("IsTurningPassSavingExecuted - {0}", IsTurningPassSavingExecuted); if (!IsTurningPassSavingExecuted) { IsTurningPassSavingExecuted = true; bool turnOffPassSaving = false; Boolean.TryParse(pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_TurnOffPassSaving), out turnOffPassSaving); logger.Debug("TurnOffPassSaving - {0}", turnOffPassSaving); if (turnOffPassSaving) { pbData.DisableStoringPasswordInBrowsers(); } else { pbData.EnableStoringPasswordInBrowsers(); } } //Task.Factory.StartNew(() => CheckRSA(generateKeysStep, pbData, webApi)); logger.Debug("CheckRsa Calling generateKeysStep - {0}", generateKeysStep); CheckRSA(generateKeysStep, pbData, webApi); //pbData.TryToClearMessageHistory(); logger.Debug("OpenMainUI - {0}", OpenMainUI); if (OpenMainUI) { ShowMainWindowIfNeeded(isDeviceTrusted); } else { Application.Current.Dispatcher.BeginInvoke((Action)(() => { CloseLoginWindow(); MainWindow mainWindow = ((PBApp)Application.Current).FindWindow <MainWindow>(); if (mainWindow == null) { mainWindow = new MainWindow(resolver); } })); } return(true); }