Example #1
0
 public ExportTaskViewItem(ExportTask task) : base(new string[4])
 {
     this.Task             = task;
     this.SubItems[0].Text = string.Format("{0} {1}", (object)DataSeriesHelper.GetDataSeriesInfo(task.DataSeries.Name).Symbol, (object)DataSeriesHelper.SeriesNameToString(task.DataSeries.Name));
     this.SubItems[1].Text = task.OutputFileName;
     this.UpdateState();
 }
Example #2
0
		public ExportTaskViewItem(ExportTask task) : base(new string[4])
		{
			this.Task = task;
			this.SubItems[0].Text = string.Format("{0} {1}", (object)DataSeriesHelper.GetDataSeriesInfo(task.DataSeries.Name).Symbol, (object)DataSeriesHelper.SeriesNameToString(task.DataSeries.Name));
			this.SubItems[1].Text = task.OutputFileName;
			this.UpdateState();
		}
Example #3
0
 private void UpdateTaskState(ExportTask task)
 {
     this.Invoke((Action)(() =>
     {
         ExportTaskViewItem local_0 = this.taskItems[task];
         local_0.UpdateState();
         local_0.EnsureVisible();
     }));
 }
Example #4
0
        public void Init(IDataSeries[] seriesList)
        {
            this.ltvExportTasks.BeginUpdate();
            this.ltvExportTasks.Items.Clear();
            foreach (IDataSeries dataSeries in seriesList)
            {
                string str = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol;
                foreach (char oldChar in Path.GetInvalidFileNameChars())
                {
                    str = str.Replace(oldChar, '_');
                }
                string             outputFileName     = string.Format("{0}.{1}.csv", (object)str, (object)DataSeriesHelper.SeriesNameToString(dataSeries.Name));
                ExportTask         exportTask         = new ExportTask(dataSeries, outputFileName);
                ExportTaskViewItem exportTaskViewItem = new ExportTaskViewItem(exportTask);
                this.taskItems.Add(exportTask, exportTaskViewItem);
                this.ltvExportTasks.Items.Add((ListViewItem)exportTaskViewItem);
            }
            this.ltvExportTasks.EndUpdate();
            this.lblCurrentProgress.Text = "";
            this.pgbTotal.Maximum        = seriesList.Length;
            List <DateTime> list = new List <DateTime>();

            foreach (IDataSeries idataSeries in seriesList)
            {
                if (idataSeries.Count > 0)
                {
                    list.Add(idataSeries.FirstDateTime);
                    list.Add(idataSeries.LastDateTime);
                }
            }
            if (list.Count == 0)
            {
                this.dtpRangeBegin.Value = DateTime.Today;
                this.dtpRangeEnd.Value   = DateTime.Today;
            }
            else
            {
                this.dtpRangeBegin.Value = Enumerable.Min <DateTime>((IEnumerable <DateTime>)list).Date;
                this.dtpRangeEnd.Value   = Enumerable.Max <DateTime>((IEnumerable <DateTime>)list).Date;
            }
            this.OnExportRangeChanged();
        }
Example #5
0
    private void UpdateTaskState(ExportTask task)
    {
			this.Invoke((Action) (() =>
      {
        ExportTaskViewItem local_0 = this.taskItems[task];
        local_0.UpdateState();
        local_0.EnsureVisible();
      }));
    }
Example #6
0
    private void DoExport(ExportSettings settings, ExportTask task)
    {
      try
      {
        IDataSeries dataSeries = task.DataSeries;
        FileInfo fileInfo = new FileInfo(string.Format("{0}\\{1}", (object) settings.Directory.FullName, (object) task.OutputFileName));
        DataType dataType = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType;
        task.State = ExportTaskState.Exporting;
        this.UpdateTaskState(task);
        this.SetLabelText(this.lblCurrentProgress, string.Format("{0} {1} -> {2}", (object) DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol, (object) DataSeriesHelper.SeriesNameToString(dataSeries.Name), (object) fileInfo.FullName));
        this.SetProgressValue(this.pgbCurrent, 0);
        Thread.Sleep(0);
        DataExporter dataExporter;
        switch (dataType)
        {
          case DataType.Trade:
            dataExporter = (DataExporter) new TradeExporter();
            break;
          case DataType.Quote:
            dataExporter = (DataExporter) new QuoteExporter();
            break;
          case DataType.Bar:
            dataExporter = (DataExporter) new BarExporter();
            break;
          case DataType.Daily:
            dataExporter = (DataExporter) new DailyExporter();
            break;
          default:
            throw new NotSupportedException(string.Format("Insupported data type - {0}", (object) dataType));
        }
        StreamWriter streamWriter = new StreamWriter(fileInfo.FullName);
        streamWriter.WriteLine(this.ToString(dataExporter.GetHeader()));
        int num1 = 0;
        int num2 = 0;
        for (int index = 0; index < dataSeries.Count; ++index)
        {
					IDataObject idataObject = dataSeries[index] as IDataObject;
          if (!this.pendingCancel)
          {
            DateTime dateTime = idataObject.DateTime;
            if (!(dateTime < settings.RangeBegin) && !(dateTime > settings.RangeEnd))
              streamWriter.WriteLine(this.ToString(dataExporter.DataObjectToString(idataObject)));
            ++num1;
            int num3 = (int) ((long) num1 * 100L / (long) dataSeries.Count);
            if (num3 > num2)
            {
              num2 = num3;
              this.SetProgressValue(this.pgbCurrent, num2);
            }
            Thread.Sleep(0);
          }
          else
            break;
        }
        streamWriter.Close();
        if (this.pendingCancel)
        {
          task.State = ExportTaskState.Error;
          task.Text = "Aborted";
        }
        else
        {
          task.State = ExportTaskState.Done;
          task.Text = "Completed";
        }
        this.UpdateTaskState(task);
      }
      catch (Exception ex)
      {
        task.State = ExportTaskState.Error;
        task.Text = ((object) ex).ToString();
        this.UpdateTaskState(task);
      }
    }
Example #7
0
 public void Init(IDataSeries[] seriesList)
 {
   this.ltvExportTasks.BeginUpdate();
   this.ltvExportTasks.Items.Clear();
   foreach (IDataSeries dataSeries in seriesList)
   {
     string str = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol;
     foreach (char oldChar in Path.GetInvalidFileNameChars())
       str = str.Replace(oldChar, '_');
     string outputFileName = string.Format("{0}.{1}.csv", (object) str, (object) DataSeriesHelper.SeriesNameToString(dataSeries.Name));
     ExportTask exportTask = new ExportTask(dataSeries, outputFileName);
     ExportTaskViewItem exportTaskViewItem = new ExportTaskViewItem(exportTask);
     this.taskItems.Add(exportTask, exportTaskViewItem);
     this.ltvExportTasks.Items.Add((ListViewItem) exportTaskViewItem);
   }
   this.ltvExportTasks.EndUpdate();
   this.lblCurrentProgress.Text = "";
   this.pgbTotal.Maximum = seriesList.Length;
   List<DateTime> list = new List<DateTime>();
   foreach (IDataSeries idataSeries in seriesList)
   {
     if (idataSeries.Count > 0)
     {
       list.Add(idataSeries.FirstDateTime);
       list.Add(idataSeries.LastDateTime);
     }
   }
   if (list.Count == 0)
   {
     this.dtpRangeBegin.Value = DateTime.Today;
     this.dtpRangeEnd.Value = DateTime.Today;
   }
   else
   {
     this.dtpRangeBegin.Value = Enumerable.Min<DateTime>((IEnumerable<DateTime>) list).Date;
     this.dtpRangeEnd.Value = Enumerable.Max<DateTime>((IEnumerable<DateTime>) list).Date;
   }
   this.OnExportRangeChanged();
 }
Example #8
0
        private void DoExport(ExportSettings settings, ExportTask task)
        {
            try
            {
                IDataSeries dataSeries = task.DataSeries;
                FileInfo    fileInfo   = new FileInfo(string.Format("{0}\\{1}", (object)settings.Directory.FullName, (object)task.OutputFileName));
                DataType    dataType   = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType;
                task.State = ExportTaskState.Exporting;
                this.UpdateTaskState(task);
                this.SetLabelText(this.lblCurrentProgress, string.Format("{0} {1} -> {2}", (object)DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol, (object)DataSeriesHelper.SeriesNameToString(dataSeries.Name), (object)fileInfo.FullName));
                this.SetProgressValue(this.pgbCurrent, 0);
                Thread.Sleep(0);
                DataExporter dataExporter;
                switch (dataType)
                {
                case DataType.Trade:
                    dataExporter = (DataExporter) new TradeExporter();
                    break;

                case DataType.Quote:
                    dataExporter = (DataExporter) new QuoteExporter();
                    break;

                case DataType.Bar:
                    dataExporter = (DataExporter) new BarExporter();
                    break;

                case DataType.Daily:
                    dataExporter = (DataExporter) new DailyExporter();
                    break;

                default:
                    throw new NotSupportedException(string.Format("Insupported data type - {0}", (object)dataType));
                }
                StreamWriter streamWriter = new StreamWriter(fileInfo.FullName);
                streamWriter.WriteLine(this.ToString(dataExporter.GetHeader()));
                int num1 = 0;
                int num2 = 0;
                for (int index = 0; index < dataSeries.Count; ++index)
                {
                    IDataObject idataObject = dataSeries[index] as IDataObject;
                    if (!this.pendingCancel)
                    {
                        DateTime dateTime = idataObject.DateTime;
                        if (!(dateTime < settings.RangeBegin) && !(dateTime > settings.RangeEnd))
                        {
                            streamWriter.WriteLine(this.ToString(dataExporter.DataObjectToString(idataObject)));
                        }
                        ++num1;
                        int num3 = (int)((long)num1 * 100L / (long)dataSeries.Count);
                        if (num3 > num2)
                        {
                            num2 = num3;
                            this.SetProgressValue(this.pgbCurrent, num2);
                        }
                        Thread.Sleep(0);
                    }
                    else
                    {
                        break;
                    }
                }
                streamWriter.Close();
                if (this.pendingCancel)
                {
                    task.State = ExportTaskState.Error;
                    task.Text  = "Aborted";
                }
                else
                {
                    task.State = ExportTaskState.Done;
                    task.Text  = "Completed";
                }
                this.UpdateTaskState(task);
            }
            catch (Exception ex)
            {
                task.State = ExportTaskState.Error;
                task.Text  = ((object)ex).ToString();
                this.UpdateTaskState(task);
            }
        }