Exemplo n.º 1
0
        private void LoadTradesFromFile(DateCollection newCol)
        {
            WFile f = new WFile(GetFilePath(newCol.Date));

            if (!f.Exists())
            {
                return;
            }
            var strings = f.ReadAllLines();

            strings.ForEach <string>((s) => {
                if (s.Empty())
                {
                    return;
                }
                var dataTrade   = s.Split('\t');
                var trade       = new Trade();
                trade.Number    = dataTrade[0].ToLong();
                trade.Price     = dataTrade[2].ToDecimal();
                trade.Volume    = dataTrade[3].ToInt32();
                trade.Direction = dataTrade[4] == "B" ? OrderDirection.Buy : OrderDirection.Sell;
                trade.SecCode   = dataTrade[5];

                newCol.Trades.Add(trade);
            });
        }
Exemplo n.º 2
0
        /// <summary> Чтение коллекции из файла в сериализованном виде. </summary>
        /// <param name="filename"></param>
        public void ReadCollectionFromFile(string filename)
        {
            Qlog.CatchException(() =>
            {
                this.TimeLastSave = DateTime.Now;
                WFile file        = new WFile(filename);
                if (!file.Exists())
                {
                    return;
                }
                //this.WasReadHistory = true;
                Stream stream       = File.Open(filename, FileMode.Open);
                stream.Position     = 0;
                var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                lock (syncLock)
                {
                    this.ObjCollection.Collection = (List <CandleData>)binaryFormatter.Deserialize(stream);
                }
                stream.Close();

                /*	using (Stream stream = File.Open(filename, FileMode.Open))
                 *              {
                 *                      var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                 *                      this.Collection = (List<CandleData>)binaryFormatter.Deserialize(stream);
                 *              }*/
            }, filename, () => { return; });
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public bool Load()
        {
            WFile file = new WFile(FullFileName);

            if (!file.Exists())
            {
                return(false);
            }
            Stream stream = File.Open(FullFileName, FileMode.Open);

            stream.Position = 0;
            var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            lock (objSync)
            {
                Collection = (List <T>)binaryFormatter.Deserialize(stream);
            }
            stream.Close();
            return(true);
        }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public bool Load()
 {
     try {
         WFile file = new WFile(FullFileName);
         if (!file.Exists())
         {
             return(false);
         }
         Stream stream = File.Open(FullFileName, FileMode.Open);
         stream.Position = 0;
         var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
         lock (objSync)
         {
             ListOrders = (List <ConditionOrder>)binaryFormatter.Deserialize(stream);
         }
         stream.Close();
         return(true);
     }
     catch (Exception e)
     {
         Qlog.Write("Ошибка при получении данный из файла FullFileName." + e.ToString());
         return(false);
     }
 }