/// <inheritdoc/> public bool Remove(IEnumerable <string> tags) { ThrowExceptionIfFaulty(); var isOk = !IsEnabled || false; if (!isOk && !GlobalStorageHelper.IsFaulty) { isOk = LocalStorageService.RemoveData(tags); if (isOk && GlobalStorageService != null) { GlobalStorageService.RemoveData(tags); GlobalStorageHelper.PublishToRemoveData(tags); } } return(isOk); }
/// <inheritdoc/> public async Task <bool> InvalidateAsync(IEnumerable <string> tags) { ThrowExceptionIfFaulty(); var isOk = !IsEnabled || false; if (!isOk) { isOk = LocalStorageService.RemoveData(tags); if (isOk && GlobalStorageService != null) { await GlobalStorageService.RemoveDataAsync(tags).CoreBaseExtTaskWithCurrentCulture(false); await GlobalStorageHelper.PublishToRemoveDataAsync(tags).CoreBaseExtTaskWithCurrentCulture(false); } } return(isOk); }
private async Task RefreshStorageAccounts() { this.Accounts.Clear(); var storageService = new LocalStorageService(); var accounts = await storageService.GetStorageAccounts(); foreach (var item in accounts) { try { var client = new AzureStorageClient(item); item.IsConnected = true; } catch (Exception ex) { // error item.IsConnected = false; } this.Accounts.Add(item); } }
private async void OneDrivePage_Loaded(object sender, RoutedEventArgs e) { // create example data if no exist var localStorageService = new LocalStorageService(); var folder = localStorageService.GetFolderAsync("Data"); if (folder == null) { await localStorageService.CreateOrGetFolderAsync("Data"); var file = await localStorageService.CreateOrGetFileAsync("loremipsum.txt"); using (var stream = await file.OpenStreamForWriteAsync()) { using (var sw = new StreamWriter(stream)) { await sw.WriteAsync("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."); } } } }
/// <inheritdoc/> public T Get <T>(CoreCachingKey key) { ThrowExceptionIfFaulty(); T result = default; if (IsEnabled && !GlobalStorageHelper.IsFaulty) { result = LocalStorageService.GetData <T>(key); if (result != null) { return(result); } if (GlobalStorageService != null) { result = GlobalStorageService.GetData <T>(key); } } return(result); }
protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender) { DateTime lastVisit = DateTime.Today.AddDays(-14); if (await LocalStorageService.ContainKeyAsync("LastVisit")) // JS Interop - musíme až do AfterRender { lastVisit = await LocalStorageService.GetItemAsync <DateTime>("LastVisit"); } if ((await NastenkaWebApiClient.GetVzkazyAsync()).Vzkazy.Any(vzkaz => vzkaz.DatumVlozeni > lastVisit)) { ShowNastenkaLink = true; StateHasChanged(); } await LocalStorageService.SetItemAsync("LastVisit", DateTime.Now); await JSRuntime.InvokeVoidAsync("setTitle", "Volejbal - Přihlašování"); } }
/// <inheritdoc/> public async Task <T> GetAsync <T>(CoreCachingKey key) { ThrowExceptionIfFaulty(); T result = default; if (IsEnabled) { result = LocalStorageService.GetData <T>(key); if (result != null) { return(result); } if (GlobalStorageService != null) { result = await GlobalStorageService.GetDataAsync <T>(key).CoreBaseExtTaskWithCurrentCulture(false); } } return(result); }
/// <summary> /// Initializes the user using a valid user token /// </summary> public static async Task <TaskResult> InitializeUser(string token, LocalStorageService storage, IMapper mapper) { string response = await Http.GetStringAsync($"User/GetUserWithToken?token={token}"); TaskResult <User> result = JsonConvert.DeserializeObject <TaskResult <User> >(response); if (result.Success) { User = result.Data; UserSecretToken = token; Console.WriteLine($"Initialized user {User.Username}"); // Store token for future use await StoreToken(storage); // Refresh user planet membership await RefreshPlanetsAsync(mapper); return(new TaskResult(true, "Initialized user successfully!")); } return(new TaskResult(false, "An error occured retrieving the user.")); }
/// <inheritdoc/> public AuthenticationModule(BlazoradeTeamsOptions appOptions, IJSRuntime jsRuntime, NavigationManager navMan, BlazoradeMsalService msalService, LocalStorageService localStorage) : base(appOptions, jsRuntime) { this.NavMan = navMan ?? throw new ArgumentNullException(nameof(navMan)); this.MsalService = msalService ?? throw new ArgumentNullException(nameof(msalService)); this.LocalStorage = localStorage ?? throw new ArgumentNullException(nameof(localStorage)); }
public async Task Persist <TState>(TState state) { await LocalStorageService.SetItemAsync(state.GetType().Name, state); }
public UserTimeProvider(LocalStorageService localStorage) { _localStorage = localStorage; _serverTimeZone = TimeZoneInfo.FromSerializedString("Eastern Standard Time;-300;(UTC-05:00) Eastern Time (US & Canada);Eastern Standard Time;Eastern Daylight Time;[01:01:0001;12:31:2006;60;[0;02:00:00;4;1;0;];[0;02:00:00;10;5;0;];][01:01:2007;12:31:9999;60;[0;02:00:00;3;2;0;];[0;02:00:00;11;1;0;];];"); _ = InitializeAsync(); }
public LoginEffect(ApiService api, LocalStorageService localStorage, IUriHelper uriHelper) { this.api = api; this.localStorage = localStorage; this.uriHelper = uriHelper; }
protected async Task JoinTable() { await LocalStorageService.SetItemAsync("currentTable", Table.Id); NavigationManager.NavigateTo("/Game"); }
protected async void TempSave() { await LocalStorageService.SetAsync("Employee", Employee); NavigationManager.NavigateTo("/employeeoverview"); }
public async ValueTask SetItem(string key, string content) { LocalStorageService.SetItem(key, content); await Task.Delay(1); }
protected override async Task OnInitializedAsync() { userId = await LocalStorageService.GetStringAsync(LocalStorageAttributes.UserIdKeyName); }
public async ValueTask RemoveItem(string key) { LocalStorageService.RemoveItem(key); await Task.Delay(1); }
public SettingsViewModel() { this.localStorage = new LocalStorageService(); }
public HttpRequestService(HttpClient client, LocalStorageService storage) { httpClient = client; localStorage = storage; }
async Task HandleLogout() { await LocalStorageService.ClearAsync(); NavigationManager.NavigateTo("/"); }
protected async Task AllIn() { await _hubConnection.SendAsync("ActionAllIn", await LocalStorageService.GetItemAsync <int>("currentTable")); }
public async Task Save() { var storageService = new LocalStorageService(); await storageService.AddStorageAccount(CurrentAccount); }
public async Task<bool> CreateExpressLogin() { if (ExpLogin != null && !string.IsNullOrEmpty(ExpLogin.Password)) { var list = await GetExpressLogins(); if (list == null) list = new List<ExpressLogin>(); var el = new ExpressLogin() { Id = this.User.Id, UserId = this.AzureClient.CurrentUser.UserId, MobileServiceAuthenticationToken = this.AzureClient.CurrentUser.MobileServiceAuthenticationToken, Password = ExpLogin.Password }; if (list.Any(x => x.Password == el.Password)) return false; if (list.Any(x => x.Id == el.Id)) { var existingItem = list.First(x => x.Id == el.Id); var index = list.IndexOf(existingItem); list[index] = el; } else { list.Add(el); } var lss = new LocalStorageService(); lss.SaveIsolatedStorage<List<ExpressLogin>>("SkadooshLogin", list); return true; } else { return false; } }
private async Task<List<ExpressLogin>> GetExpressLogins() { var lss = new LocalStorageService(); var eps = await lss.GetIsolatedStorage<List<ExpressLogin>>("SkadooshLogin"); return eps; }
public AuthenticationClient(RestClientManager clientManager, LocalStorageService localStorageService) { _localStorageService = localStorageService; client = clientManager.GetRestClient(); }
/// <inheritdoc/> public AuthenticationModule(BlazoradeTeamsOptions appOptions, IJSRuntime jsRuntime, NavigationManager navMan, LocalStorageService localStorage, IServiceProvider serviceProvider) : base(appOptions, jsRuntime) { this.NavMan = navMan ?? throw new ArgumentNullException(nameof(navMan)); this.LocalStorage = localStorage ?? throw new ArgumentNullException(nameof(localStorage)); this.MsalService = serviceProvider.GetService <BlazoradeMsalService>(); }
protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); CurrentTable = await LocalStorageService.GetItemAsync <int>("currentTable"); }
protected override async Task OnInitializedAsync() { Result = await LocalStorageService.GetItemAsync <string>("Result"); await Task.Delay(TimeSpan.FromSeconds(3)); }
public async Task CleanupAsync() { IStorageService storageService = new LocalStorageService(); await storageService.DeleteFolderAsync(@"Data"); }
public IdentityService(IHttpContextAccessor contextAccess, HttpClient http, LogHttpResponse log, LocalStorageService storage) { this.contextAccess = contextAccess; this.http = http; this.log = log; this.storage = storage; }
protected override async Task OnInitializedAsync() { AuthState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); _hubConnection = new HubConnectionBuilder() .WithUrl(NavigationManager.ToAbsoluteUri("/gameHub")) .Build(); _hubConnection.On("ReceiveMessage", (object message) => { var newMessage = JsonConvert.DeserializeObject <GetMessageResult>(message.ToString()); ChatMessages.Add(newMessage); StateHasChanged(); }); _hubConnection.On("ReceiveStartingHand", (object hand) => { var newHand = JsonConvert.DeserializeObject <List <Card> >(hand.ToString()); GameInformation.Hand.AddRange(newHand); StateHasChanged(); }); _hubConnection.On("ReceiveTurnPlayer", (string currentPlayer) => { GameInformation.CurrentPlayer = currentPlayer; StateHasChanged(); }); _hubConnection.On("ReceiveFlop", (object flopjson) => { var flop = JsonConvert.DeserializeObject <List <Card> >(flopjson.ToString()); GameInformation.TableCards.AddRange(flop); StateHasChanged(); }); _hubConnection.On("ReceiveTurnOrRiver", (object card) => { var turnOrRiverCard = JsonConvert.DeserializeObject <List <Card> >(card.ToString()); GameInformation.TableCards.AddRange(turnOrRiverCard); StateHasChanged(); }); _hubConnection.On("ReceiveWinner", (string winner) => { GameInformation.Winner = winner; StateHasChanged(); }); _hubConnection.On("ReceiveStateRefresh", (object playerState) => { var playerStateModel = JsonConvert.DeserializeObject <PlayerStateModel>(playerState.ToString()); GameInformation.Players = playerStateModel.Players; GameInformation.TableCards = playerStateModel.CommunityCards ?? new List <Card>(); GameInformation.Hand = playerStateModel.HandCards ?? new List <Card>(); GameInformation.GameInProgress = playerStateModel.GameInProgress; GameInformation.RaiseAmount = playerStateModel.RaiseAmount; GameInformation.Pots = playerStateModel.Pots ?? new List <Pot>(); if (GameInformation.GameInProgress == false) { foreach (var gameInformationPlayer in GameInformation.Players) { gameInformationPlayer.IsPlaying = false; } } GameInformation.Winner = null; StateHasChanged(); }); _hubConnection.On("ReceiveKick", async() => { await LocalStorageService.RemoveItemAsync("currentTable"); NavigationManager.NavigateTo("/"); }); await _hubConnection.StartAsync(); await _hubConnection.SendAsync("AddToUsers", await LocalStorageService.GetItemAsync <int>("currentTable")); GameInformation.PlayersNotes = (await PlayerNoteService.GetList()).PlayerNotes; await base.OnInitializedAsync(); }
private async Task SetCulture(string culture) { await LocalStorageService.SetItemAsStringAsync("culture", culture); NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true); }