public bool AddFile(TapeFile file) { if (Files.Any(f => f.File == file.File)) { TapeFile removeMe = Files.FirstOrDefault(f => f.File == file.File); Files.Remove(removeMe); } Files.Add(file); return(true); }
public bool AddFile(TapeFile file) { if (file.Partition != 0) { ErrorMessage = "Unsupported feature"; return(false); } byte[] marker = Encoding.ASCII.GetBytes("CPTP:MRK\n"); dataStream.Write(marker, 0, marker.Length); return(true); }
private void btnStopOperation_Click(object sender, EventArgs e) { if (MessageBox.Show((IWin32Window)this, "Do you really want to stop operation?", "Stop", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } TapeFile tapeFile = this.currentTape; if (tapeFile != null) { this.currentSkipped = true; tapeFile.Stop(); } this.worker.CancelAsync(); }
private void btnSkipCurrent_Click(object sender, EventArgs e) { if (MessageBox.Show((IWin32Window)this, "Do you really want to skip current file?", "Skip", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } TapeFile tapeFile = this.currentTape; if (tapeFile == null) { return; } this.currentSkipped = true; tapeFile.Stop(); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { foreach (TaskInfo taskInfo in this.tasks) { TapeFile tapeFile = new TapeFile(taskInfo.File.FullName); this.currentTask = taskInfo; this.currentTape = tapeFile; PlaybackOptions playbackOptions = new PlaybackOptions(); playbackOptions.Symbols = new List <string>((IEnumerable <string>) this.instruments.Keys).ToArray(); playbackOptions.Trades = this.settings.Trades; playbackOptions.Quotes = this.settings.Quotes; playbackOptions.BeginTime = this.settings.From; playbackOptions.EndTime = this.settings.To; this.OnCurrentTaskBegin(); if (this.worker.CancellationPending) { e.Cancel = true; this.OnCurrentTaskDone((Exception)null); } else { Exception error = (Exception)null; try { this.currentSkipped = false; this.currentWriter = !this.settings.Advanced.WriteDataAsync ? (DataWriter) new SyncDataWriter() : (DataWriter) new AsyncDataWriter(this.settings.Advanced.MaxBufferSize); this.currentWriter.BeginWrite(); tapeFile.Play((IMessageReceiver)this, playbackOptions); } catch (Exception ex) { error = ex; } finally { try { this.currentWriter.EndWrite(); } catch (Exception ex) { error = ex; } this.OnCurrentTaskDone(error); } } } }