public async Task <bool> LoadAsync() { if (string.IsNullOrEmpty(Path)) { return(false); } try { FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read); byte[] data = new byte[fs.Length]; await fs.ReadAsync(data, 0, data.Length).ConfigureAwait(false); List <ProblemViewModel> ps = new List <ProblemViewModel>(); data = DocumentHelper.UnpackData(data); if (data == null) { return(false); } MemoryStream ms = new MemoryStream(data); while (ms.Position < ms.Length) { ProblemViewModel problem = null; Dispatcher.BeginInvoke((Action)(() => { problem = ProblemViewModel.CreateFromStream(ms); })).Wait(); if (problem == null) { return(false); } if (!await Task.Factory.StartNew(() => { if (problem == null || !problem.Load(ms)) { return(false); } return(true); }).ConfigureAwait(false)) { return(false); } ps.Add(problem); } ms.Close(); Dispatcher.BeginInvoke((Action)(() => { Problems.Clear(); foreach (var problem in ps) { Problems.Add(problem); } })); IsDirty = false; return(true); } catch (Exception) { return(false); } }
public void Close() { foreach (var p in Problems) { p.Close(); } Problems.Clear(); FixWhat.Close(); }
public void CloseFile() { SqliteDb.GetInstance().CloseConnection(); Path = string.Empty; IsFileOpen = false; Problems.Clear(); CurrentProblem = null; Graph = new Graphing.RootCauseGraph(); NotifyFileChanged(); }
public void RemoveAll() { Problems.Clear(); }