/// <summary> /// Method that removes an item from the stored list /// </summary> /// <param name="item">the StoredReportCellModel that needs to be removed</param> /// <param name="page">the parent page, used to open popup</param> private void RemoveItemFromList(StoredReportCellModel item, StoredReportsPage page) { ReportListHandler.RemoveReportFromList(item.report).ContinueWith((result) => { Definitions.RefreshMainView = true; page.ClosePopup(); InitializeCollection(result.Result); var popup = page.CreateMessagePopup("Kørsels rapport blev slettet"); page.PopUpLayout.ShowPopup(popup); }, TaskScheduler.FromCurrentSynchronizationContext()); }
/// <summary> /// Constructor that handles initialization of the viewmodel /// </summary> public StoredReportsViewModel() { _storedList = new ObservableCollection <StoredReportCellModel>(); var storage = DependencyService.Get <ISecureStorage>(); var tokenByte = storage.Retrieve(Definitions.AuthKey); _authorization = JsonConvert.DeserializeObject <Authorization>(Encoding.UTF8.GetString(tokenByte, 0, tokenByte.Length)); ReportListHandler.GetReportList().ContinueWith((result) => { InitializeCollection(result.Result); }); Subscribe(); }
/// <summary> /// Method that handles the Store message /// </summary> private void HandleStoreMessage(UploadingPage sender) { ReportListHandler.AddReportToList(Definitions.Report).ContinueWith((result) => { if (result != null) { if (result.Result == true) { Definitions.RefreshMainView = true; Dispose(); App.Navigation.PopToRootAsync(); } } }, TaskScheduler.FromCurrentSynchronizationContext()); }
/// <summary> /// Method that handles the upload result /// </summary> /// <param name="user">the ReturnUserModel the api returned after upload attempt</param> /// <param name="page">the parent page, used to open popup</param> private void HandleUploadResult(ReturnUserModel model, StoredReportsPage page) { if (model.Error != null) { page.ClosePopup(); var popup = page.CreateMessagePopup("Kunne ikke upload på nuværende tidspunkt. Prøv igen senere\nFejl: " + model.Error.Message); page.PopUpLayout.ShowPopup(popup); return; } else { var item = (StoredReportCellModel)page.List.SelectedItem; ReportListHandler.RemoveReportFromList(item.report).ContinueWith((result) => { Definitions.RefreshMainView = true; page.ClosePopup(); InitializeCollection(result.Result); var popup = page.CreateMessagePopup("Kørsels rapport blev uploadet"); page.PopUpLayout.ShowPopup(popup); }, TaskScheduler.FromCurrentSynchronizationContext()); } }
/// <summary> /// Method that handles the Logout message /// </summary> private void HandleLogoutMessage() { // Delete stored token _storage.Delete(Definitions.AuthKey); // delete stored user _storage.Delete(Definitions.UserDataKey); // Remove all stored reports on logout ReportListHandler.DeleteEntireList(); // Clear purpose list //FileHandler.WriteFileContent(Definitions.PurposeFileName, Definitions.PurposeFolderName, String.Empty); // Removed from 1.1.0.5 // Clear definitions Definitions.Report = new DriveReport(); Definitions.Organization = new Employment(); Definitions.Rate = new Rate(); Definitions.Purpose = null; // Push login view Navigation.PushAsync <LoginViewModel>(); }
public App() { var app = Resolver.Resolve <IXFormsApp>(); if (app == null) { return; } // Sets the count of stored reports in the definitions file. ReportListHandler.GetCount(); // Sets the height and width scale so it fits with xamarin SetScreenHeightAndWidth(); //Register pages before initializing the first page RegisterPages(); ViewFactory.EnableCache = false; // The root page of your application this.MainPage = GetMainPage(); }