private void btnRemovePictureCache_Click(object sender, RoutedEventArgs e) { PicturesCache.Instance.RemoveFile(); ApplicationState.ClearOffline(); ApplicationState.Current.ClearTrainingDays(); ApplicationState.Current.Cache = null; clearTips(); #if DEBUG Settings.InitialAsk = false;//TODO:Remove this!!!! #endif }
private void mnuLogout_Click(object sender, EventArgs e) { var page = this.GetParent <MainPage>(); var m = new ServiceManager <GetProfileInformationCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetProfileInformationCompletedEventArgs> operationCompleted) { client1.LogoutAsync(ApplicationState.Current.SessionData.Token); client1.WP7UnregisterAsync(Settings.ClientInstanceId.ToString()); }); m.Run(); //var service = ApplicationState.CreateService(); //if (!ApplicationState.Current.IsOffline) //{ // service.LogoutAsync(ApplicationState.Current.SessionData.Token); // service.WP7UnregisterAsync(Settings.ClientInstanceId.ToString()); //} #if DEBUG ApplicationState.Current.SaveState(false); #endif //remove phone reminders ApplicationState.Current.Cache.Reminders.RemoveAllReminders(); Settings.UserName = null; Settings.Password = null; ApplicationState.Current.SessionData = null; ApplicationState.Current.TempUserName = null; ApplicationState.Current.TempPassword = null; ApplicationState.Current = null; //TODO:uncoment this in release #if RELEASE ApplicationState.ClearOffline(); #endif PhoneApplicationService.Current.State["ApplicationState"] = null; IsolatedStorageSettings.ApplicationSettings.Save(); page.ApplicationBar = null; page.ShowLogin(true); }
async public Task LoginImplementation(string username, string password) { if (!progressBar.IsOperationStarted) {//we should perform login showProgress(true); IsLogining = true; var btnLogin = (ApplicationBarIconButton)ApplicationBar.Buttons[0]; btnLogin.IsEnabled = true; ApplicationState.Current = null; progressBar.ShowProgress(true, ApplicationStrings.Login_ProgressAuthentication); try { currentOperation = new OperationToken(); var sessionData = await BAService.LoginAsync(txtUserName.Text, password.ToSHA1Hash()); if (sessionData == null) { Settings.UserName = null; Settings.Password = null; IsLogining = false; showProgress(false); BAMessageBox.ShowError(ApplicationStrings.ErrUserOrPasswordNotValid); return; } if (currentOperation != null && currentOperation.Cancelled) { IsLogining = false; return; } progressBar.ShowProgress(true, ApplicationStrings.Login_ProgressRetrieveProfile); btnLogin.IsEnabled = true; if (Settings.LiveTileEnabled && Settings.InitialAsk) { try { pushNotification.RegisterDevice(sessionData.Profile.GlobalId); } catch { } } var state = ApplicationState.LoadState(); if (state == null) { state = new ApplicationState(); } else if (state.TempUserName != username) { //if we log as a different user, we should't use cache ApplicationState.ClearOffline(); state = new ApplicationState(); } state.IsOffline = false; ApplicationState.Current = state; ApplicationState.Current.SessionData = sessionData; ApplicationState.Current.TempUserName = username; ApplicationState.Current.TempPassword = password.ToSHA1Hash(); ApplicationState.Current.SessionData.Token.Language = ApplicationState.CurrentServiceLanguage; Settings.UserName = username; Settings.Password = password; try { await getProfileInformation(); } catch (Exception) { showProgress(false); IsLogining = false; BAMessageBox.ShowError(ApplicationStrings.ErrCantRetrieveProfileInfo); } } //catch (NetworkException) //{ // IsLogining = false; // showProgress(false); // BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); //} catch (DatabaseVersionException) { IsLogining = false; showProgress(false); BAMessageBox.ShowError(ApplicationStrings.ErrOldApplicationVersion); } catch (Exception ex) { showProgress(false); IsLogining = false; goToOffline(true); } } else { if (currentOperation != null) { currentOperation.Cancel(); currentOperation = null; } showProgress(false); } }