public Transfertable(STFReader stf, Simulator simulator) : base(stf, simulator)
        {
            signalRef = Simulator.Signals;
            string animation;

            WorldPosition.XNAMatrix.M44 = 100000000; //WorlPosition not yet defined, will be loaded when loading related tile
            stf.MustMatch("(");
            stf.ParseBlock(new[] {
                new STFReader.TokenProcessor("wfile", () => {
                    WFile = stf.ReadStringBlock(null);
                    WorldPosition.TileX = int.Parse(WFile.Substring(1, 7));
                    WorldPosition.TileZ = int.Parse(WFile.Substring(8, 7));
                }),
                new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }),
                new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null);
                                                                  Animations.Add(animation.ToLower()); }),
                new STFReader.TokenProcessor("length", () => { Length = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
                new STFReader.TokenProcessor("xoffset", () => { CenterOffset.X = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
                new STFReader.TokenProcessor("zoffset", () => { CenterOffset.Z = -stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
                new STFReader.TokenProcessor("trackshapeindex", () =>
                {
                    TrackShapeIndex = stf.ReadIntBlock(-1);
                    InitializeOffsetsAndTrackNodes();
                }),
            });
        }
Example #2
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);
            });
        }
Example #3
0
        public Turntable(STFReader stf, Simulator simulator)
            : base(stf, simulator)
        {
            signalRef = Simulator.SignalEnvironment;
            string animation;
            Matrix position = Matrix.Identity;

            position.M44 = 100000000; //WorlPosition not yet defined, will be loaded when loading related tile;
            stf.MustMatch("(");
            stf.ParseBlock(new[] {
                new STFReader.TokenProcessor("wfile", () => {
                    WFile         = stf.ReadStringBlock(null);
                    WorldPosition = new WorldPosition(int.Parse(WFile.Substring(1, 7)), int.Parse(WFile.Substring(8, 7)), position);
                }),
                new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }),
                new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null);
                                                                  Animations.Add(animation.ToLower()); }),
                new STFReader.TokenProcessor("diameter", () => { Length = stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("xoffset", () => { CenterOffset.X = stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("zoffset", () => { CenterOffset.Z = -stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("trackshapeindex", () =>
                {
                    TrackShapeIndex = stf.ReadIntBlock(-1);
                    InitializeAnglesAndTrackNodes();
                }),
            });
        }
Example #4
0
        private bool saveConnected  = true; // Transfertable is connected to a track

        internal TransferTable(STFReader stf)
        {
            string animation;
            Matrix location = Matrix.Identity;

            location.M44 = 100_000_000; //WorlPosition not yet defined, will be loaded when loading related tile;
            stf.MustMatch("(");
            stf.ParseBlock(new[] {
                new STFReader.TokenProcessor("wfile", () => {
                    WFile    = stf.ReadStringBlock(null);
                    position = new WorldPosition(int.Parse(WFile.Substring(1, 7), CultureInfo.InvariantCulture), int.Parse(WFile.Substring(8, 7), CultureInfo.InvariantCulture), location);
                }),
                new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }),
                new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null);
                                                                  Animations.Add(animation); }),
                new STFReader.TokenProcessor("verticaltransfer", () => { verticalTransfer = stf.ReadBoolBlock(false); }),
                new STFReader.TokenProcessor("length", () => { Length = stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("xoffset", () => { offset.X = stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("zoffset", () => { offset.Z = -stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("yoffset", () => { offset.Y = stf.ReadFloatBlock(STFReader.Units.None, null); }),
                new STFReader.TokenProcessor("trackshapeindex", () =>
                {
                    TrackShapeIndex = stf.ReadIntBlock(-1);
                    InitializeOffsetsAndTrackNodes();
                }),
            });
        }
Example #5
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; });
        }
Example #6
0
        private void loadTextDescription()
        {
            var   rootDir  = Global.GetPathData();
            var   filename = rootDir + "/description.txt";
            WFile file     = new WFile(filename);

            labelDescription.Text = textBoxDescription.Text = file.ReadAll();
        }
Example #7
0
        private void buttonDescSave_Click(object sender, EventArgs e)
        {
            var   rootDir  = Global.GetPathData();
            var   filename = rootDir + "/description.txt";
            WFile file     = new WFile(filename);

            file.WriteFileNew(textBoxDescription.Text);
            labelDescription.Text = textBoxDescription.Text;
        }
Example #8
0
        public void Add(string user, byte[] data, string filename)
        {
            string ext = filename.Substring(filename.LastIndexOf('.'));

            filename = filename.Substring(0, filename.LastIndexOf('.'));
            WFile wFile = new WFile(filename, ext, user);

            wFile.Path = filestoragedao.AddFile(data, filename + ext, user);
            wFile.Id   = fileDAO.Add(wFile);
        }
Example #9
0
        private void AppendTradeFile(Trade trade)
        {
            WFile f = new WFile(GetFilePath(trade.DateTrade.GetDateTime()));
            //if (!f.Exists()) f.Append("");
            string text = trade.Number.ToString() + '\t' +
                          trade.DateTrade.ToString() + '\t' +
                          trade.Price.ToString() + '\t' +
                          trade.Volume.ToString() + '\t' +
                          (trade.IsBuy() ? 'B' : 'S') + '\t' +
                          trade.Sec.Code + ':' + trade.Sec.Class.Code;

            f.Append(text);
        }
Example #10
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);
        }
Example #11
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);
     }
 }
Example #12
0
        public int Add(WFile file)
        {
            using (var connection = new SqlConnection(path))
            {
                var command = connection.CreateCommand();
                command.CommandText = "AddWFile";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@name",
                    Value         = file.Name,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@path",
                    Value         = file.Path,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@owner",
                    Value         = file.Owner,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@ext",
                    Value         = file.Extention,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@protected",
                    Value         = file.Protected,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@visible",
                    Value         = file.Visible,
                    SqlDbType     = System.Data.SqlDbType.Int,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@add_date",
                    Value         = DateTime.Now,
                    SqlDbType     = System.Data.SqlDbType.DateTime,
                    Direction     = System.Data.ParameterDirection.Input
                });
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@change_date",
                    Value         = DateTime.Now,
                    SqlDbType     = System.Data.SqlDbType.DateTime,
                    Direction     = System.Data.ParameterDirection.Input
                });
                string tags = "";
                foreach (var item in file.Tags)
                {
                    tags += item + " ";
                }
                command.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@tags",
                    Value         = tags,
                    SqlDbType     = System.Data.SqlDbType.NVarChar,
                    Direction     = System.Data.ParameterDirection.Input
                });
                var id = new SqlParameter
                {
                    ParameterName = "@Id",
                    SqlDbType     = System.Data.SqlDbType.Int,
                    Direction     = System.Data.ParameterDirection.Output
                };
                command.Parameters.Add(id);

                connection.Open();
                command.ExecuteNonQuery();
                return((int)id.Value);
            }
        }
Example #13
0
        private void buttonLoadTicks_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();

            file.Multiselect      = true;
            file.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            file.FilterIndex      = 2;
            file.RestoreDirectory = true;
            if (file.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    labelStatusLoad.GuiAsync(() =>
                    {
                        labelStatusLoad.Text = "";
                    });
                    int CountFiles = file.FileNames.Length;
                    int CountStat  = CountFiles;

                    threadLoadHistory = MThread.InitThread(() =>
                    {
                        Qlog.CatchException(() =>
                        {
                            foreach (string filename in file.FileNames)
                            {
                                WFile wf     = new WFile(filename);
                                var arrayAll = wf.ReadAllLines();
                                labelStatusLoad.GuiAsync(() =>
                                {
                                    labelStatusLoad.Text           = filename + "\r\n" + labelStatusLoad.Text;
                                    progressBalLoadHistory.Maximum = arrayAll.Length + 1;
                                    progressBalLoadHistory.Value   = 1;
                                });
                                int counterRow = 0;
                                int numStep    = 0;
                                foreach (var str in arrayAll)
                                {
                                    if (counterRow == 0)
                                    {
                                        counterRow++;
                                        continue; //пропускаем шапку
                                    }
                                    var tr = Trade.GetConvertTrade(Securities, str);
                                    //Корректируем значения
                                    var modifyTrade = ModifyLoadTrade(tr);
                                    if (modifyTrade.NotIsNull())
                                    {
                                        TrElement.NewTrade(tr, true);
                                        if (numStep > 5000)
                                        {
                                            progressBalLoadHistory.GuiAsync(() =>
                                            {
                                                if (counterRow < progressBalLoadHistory.Maximum)
                                                {
                                                    progressBalLoadHistory.Value = counterRow;
                                                }
                                            });
                                            Thread.Sleep(2);
                                            numStep = 0;
                                        }
                                        numStep++;
                                    }
                                    counterRow++;
                                }
                                CountStat--;
                                labelStatusLoad.GuiAsync(() =>
                                {
                                    labelStatusLoad.Text = "Process: " + CountStat + "/" + CountFiles + "\r\n" + labelStatusLoad.Text;
                                });
                            }
                        });
                    });
                    labelStatusLoad.GuiAsync(() =>
                    {
                        labelStatusLoad.Text = "Files: " + CountFiles + "\r\n" + labelStatusLoad.Text;
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Example #14
0
 public int Add(WFile file, string filepath)
 {
     file.Path = filepath;
     return(_fileDAO.Add(file));
 }
Example #15
0
 public int Add(WFile file)
 {
     return(_fileDAO.Add(file));
 }
Example #16
0
        public string GetPath(int id)
        {
            WFile file = fileDAO.FindFileById(id);

            return(file.Path);
        }