private async void Start() { IsLoading = true; IsListViewsVisible = false; string path = DependencyService.Get <ICrossPlatformDownloadManager>().DefaultPathToDownloadedFiles; string finalPath = Path.Combine(path, "plan.xml"); bool FileExists = DependencyService.Get <ICrossPlatformDownloadManager>().DownloadedFileExists(finalPath); if ((Application.Current.Properties.Count <= 0) || (!FileExists)) { string DownloadPath = await DependencyService.Get <ICrossPlatformDownloadManager>().DownloadFileAsync(Settings.MetaServer + "plan.xml", "plan.xml"); if (DownloadPath == null) { await App.Current.MainPage.DisplayAlert("Błąd", "Brak połączenia z internetem!", "Anuluj"); DependencyService.Get <IMyApplication>().Exit(); } else { await ChoosedBranch.ShowDialogChooseBranch(DownloadPath); } } else { Settings.Load(); } LoadPlan(finalPath); IsLoading = false; IsListViewsVisible = true; }
private async void ChooseGroupAsync() { if (!IsLoading) { string path = DependencyService.Get <ICrossPlatformDownloadManager>().DefaultPathToDownloadedFiles; string finalPath = Path.Combine(path, "plan.xml"); bool FileExists = DependencyService.Get <ICrossPlatformDownloadManager>().DownloadedFileExists(finalPath); if (FileExists) { IsLoading = true; IsListViewsVisible = false; await ChoosedBranch.ShowDialogChooseBranch(finalPath); LoadPlan(finalPath); } else { await App.Current.MainPage.DisplayAlert("Błąd", "Nie można odnaleźć pliku!", "OK"); } IsLoading = false; IsListViewsVisible = true; } }
private async void LoadPlan(string path) { Title = ChoosedBranch.Name; ClearPlan(); try { XmlPlanInterpreter xmlInterpreter = new XmlPlanInterpreter(path); // if (IsChangesInListOfBranches(xmlInterpreter)) { ChoosedBranch.id = -1; await ChoosedBranch.ShowDialogChooseBranch(path); Title = ChoosedBranch.Name; } if (ChoosedBranch.id == -1) { Title = "Nie wybrano klasy!"; } // List <string> Hours = xmlInterpreter.GetHours(); for (int a = 0; a != 5; a++) { if (a == 0) { for (int n = 1; n <= Hours.Count; n++) { MondayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Poniedziałek"), 14)); } } if (a == 1) { for (int n = 1; n <= Hours.Count; n++) { TuesdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Wtorek"), 14)); } } if (a == 2) { for (int n = 1; n <= Hours.Count; n++) { WednesdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Środa"), 14)); } } if (a == 3) { for (int n = 1; n <= Hours.Count; n++) { ThursdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Czwartek"), 14)); } } if (a == 4) { for (int n = 1; n <= Hours.Count; n++) { FridayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Piątek"), 14)); } } } } catch (Exception) { await App.Current.MainPage.DisplayAlert("Błąd!", "Wystąpił błąd podczas odczytywania pliku z planem. Prawdopodobnie plik jest uszkodzony lub używasz nieaktualnej wersji programu!", "OK"); } }