Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
 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);
             }
         }
     }
 }