static private LogonAsync ( string username, string token ) : System.Threading.Tasks.Task | ||
username | string | |
token | string | |
return | System.Threading.Tasks.Task |
public async Task <bool> RestorePersistentLogonAsync() { var token = await SettingItem.GetValueAsync(LogonTokenKey); if (!(string.IsNullOrEmpty(token))) { var username = await SettingItem.GetValueAsync(LastUsernameKey); if (!(string.IsNullOrEmpty(username))) { // logon... await StreetFooRuntime.LogonAsync(username, token); return(true); } else { return(false); } } else { return(false); } }
private async void DoLogon(CommandExecutionContext context) { // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // get a handler... var proxy = TinyIoCContainer.Current.Resolve <ILogonServiceProxy>(); // call... using (this.EnterBusy()) { var result = await proxy.LogonAsync(this.Username, this.Password); if (!(result.HasErrors)) { // logon... pass through the username as each user gets their own database... await StreetFooRuntime.LogonAsync(this.Username, result.Token); // while we're here - store a setting containing the logon name of the user... await SettingItem.SetValueAsync(LastUsernameKey, this.Username); // remember the user? if (this.RememberMe) { await SettingItem.SetValueAsync(LogonTokenKey, result.Token); } // show the reports page... this.Host.ShowView(typeof(IReportsPageViewModel)); } else { errors.CopyFrom(result); } } } // errors? if (errors.HasErrors) { await this.Host.ShowAlertAsync(errors); } }