Task reallyImportAsync() { try { progressBar = true; if (SelectedItemI.Id < 0) { p.Description = NamePath; s.Comment = Comment; DataBaseManager.instance.InsertPath(p); s.IdPath = p.Id; } else { s.IdPath = SelectedItemI.Id; } DataBaseManager.instance.InsertSession(s); return(Task.Factory.StartNew(async() => { try { if (await ExportImport.ImportKmlAsync(t.Files[0], false, p, s, this) != null) { //NavigationService.GoBack(); } progressBar = false; } catch (Exception ex) { progressBar = false; ExtraInfo = ex.Message; nowhereman.LittleWatson.instance.Error("really import from Kml", ex); //t0.Text = string.Format("Error {0}", ex.Message); } })); } catch (Exception ex) { progressBar = false; ExtraInfo = ex.Message; nowhereman.LittleWatson.instance.Error("really import from Kml", ex); //t0.Text = string.Format("Error {0}", ex.Message); } return(Task.CompletedTask); }
public override Task OnNavigatedToAsync(object parameter, NavigationMode modeNav, IDictionary <string, object> state) { Comment = "IMPORTED"; NamePath = "IMPORTED " + string.Format(resourceLoader.GetString("PathName"), DateTime.Now.ToString()); t = SessionState["importFile"] as FileActivatedEventArgs; if (t != null) { var listI = new ObservableCollection <Paths>(); p = new Paths(); p.Id = -1; p.Type = "I"; p.Description = string.Format(resourceLoader.GetString("NewPath"), resourceLoader.GetString("I")); listI.Add(p); foreach (var t in DataBaseManager.instance.getPaths("I")) { listI.Add(t); } ListI = listI; SelectedItemI = p; s = new Sessions(); s.IdPath = p.Id; s.DayOfSession = Utils.NOW(); s.Comment = Comment; try { progressBar = true; Task.Factory.StartNew(async() => { string description = null; try { description = await ExportImport.ImportKmlAsync(t.Files[0], true, p, s, this); Duration = (s.Duration.HasValue) ? s.Duration.Value : long.MinValue; Distance = (s.Distance.HasValue) ? s.Distance.Value : double.NaN; } catch (Exception ex) { description = ex.Message; } //await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ progressBar = false; ExtraInfo = "<html><body>" + description + "</body></html>"; //}); }); } catch (Exception ex) { nowhereman.LittleWatson.instance.Error("import from Kml", ex); progressBar = false; //t0.Text = string.Format("Error {0}", ex.Message); } SessionState.Remove("importFile"); } return(Task.CompletedTask); }