private async Task <bool> CanRunAsync() { // do we have connectivity? if (!(StreetFooRuntime.HasConnectivity)) { this.Logger.Info("No connectivity - skipping..."); // clear the expiration period... await SettingItem.SetValueAsync(SyncExpirationKey, string.Empty); // return... return(false); } // skip the check if we're debugging... (otherwise it's hard to see what's // going on...) if (!(Debugger.IsAttached)) { // check the expiration... var asString = await SettingItem.GetValueAsync(SyncExpirationKey); if (!(string.IsNullOrEmpty(asString))) { this.Logger.Info("Expiration time: {0}", asString); // parse... var expiration = DateTime.ParseExact(asString, "o", CultureInfo.InvariantCulture).ToUniversalTime(); // if the expiration time is in the future - do nothing... if (expiration > DateTime.UtcNow) { this.Logger.Info("Not expired (expiration is '{0}') - skipping...", expiration); return(false); } } else { this.Logger.Info("No expiration time available."); } } // we're ok - set the new expiration period... var newExpiration = DateTime.UtcNow.AddMinutes(5); await SettingItem.SetValueAsync(SyncExpirationKey, newExpiration.ToString("o")); // try and log the user in... var model = new LogonPageViewModel(); model.Initialize(new NullViewModelHost()); return(await model.RestorePersistentLogonAsync()); }
private async Task<bool> CanRunAsync() { // do we have connectivity? if (!(StreetFooRuntime.HasConnectivity)) { this.Logger.Info("No connectivity - skipping..."); // clear the expiration period... await SettingItem.SetValueAsync(SyncExpirationKey, string.Empty); // return... return false; } // skip the check if we're debugging... (otherwise it's hard to see what's // going on...) if (!(Debugger.IsAttached)) { // check the expiration... var asString = await SettingItem.GetValueAsync(SyncExpirationKey); if (!(string.IsNullOrEmpty(asString))) { this.Logger.Info("Expiration time: {0}", asString); // parse... var expiration = DateTime.ParseExact(asString, "o", CultureInfo.InvariantCulture).ToUniversalTime(); // if the expiration time is in the future - do nothing... if (expiration > DateTime.UtcNow) { this.Logger.Info("Not expired (expiration is '{0}') - skipping...", expiration); return false; } } else this.Logger.Info("No expiration time available."); } // we're ok - set the new expiration period... var newExpiration = DateTime.UtcNow.AddMinutes(5); await SettingItem.SetValueAsync(SyncExpirationKey, newExpiration.ToString("o")); // try and log the user in... var model = new LogonPageViewModel(new NullViewModelHost()); return await model.RestorePersistentLogonAsync(); }