/// <summary> /// Event fire when the Details item menu is selected from the /// context menu /// </summary> private void Details_MenuItem_Click(object sender, EventArgs e) { try { // Get our snapshot file name SnapshotFile sFile = SnapshotView.SelectedItems[0].Tag as SnapshotFile; if (sFile == null) return; // Load up the snapshot, and display the Game Result Window Snapshot Snapshot = new Snapshot(File.ReadAllText(sFile.FilePath)); using (GameResultForm F = new GameResultForm(Snapshot as GameResult, Snapshot.IsProcessed)) { F.ShowDialog(); } } catch { } }
/// <summary> /// Imports the provided snapshot files into the stats database /// </summary> /// <param name="Files">List of snapshot file paths to import</param> /// <param name="CancelToken">Cancellation token, to cancel the import</param> private void ImportSnaphotFiles(List<SnapshotFile> Files, CancellationToken CancelToken) { // Number of snapshots we have processed int processed = 0; // Do Work foreach (SnapshotFile SnapshotFile in Files) { // If we have a cancelation request if (CancelToken.IsCancellationRequested) break; // Make sure we arent processing twice if (SnapshotFile.IsProcessed) continue; // Process the snapshot try { // Update status and run snapshot TaskForm.Progress.Report(new TaskProgressUpdate(String.Format("Processing: \"{0}\"", SnapshotFile))); Snapshot Snapshot = new Snapshot(File.ReadAllText(SnapshotFile.FilePath)); // Avoid processing exception if (Snapshot.IsProcessed) continue; else // Do snapshot Snapshot.ProcessData(); // Move the Temp snapshot to the Processed folder File.Move( Path.Combine(Paths.SnapshotTempPath, SnapshotFile.FileName), Path.Combine(Paths.SnapshotProcPath, SnapshotFile.FileName) ); } catch (Exception E) { using (ExceptionForm Form = new ExceptionForm(E, true)) { Form.Message = "An exception was thrown while trying to import the snapshot." + "If you click Continue, the application will continue proccessing the remaining " + "snapshot files. If you click Quit, the operation will be aborted."; DialogResult Result = Form.ShowDialog(); // User Abort if (Result == DialogResult.Abort) break; } } // Whether we failed or succeeded, we are finished with this step // and should move the progress bar 1 step TaskForm.Progress.Report(new TaskProgressUpdate(++processed)); } // Let progress bar update to 100% TaskForm.Progress.Report(new TaskProgressUpdate("Done! Cleaning up...")); Thread.Sleep(250); }