コード例 #1
0
        /// <summary>
        /// Получение входных данных.
        /// </summary>
        private async Task <TestResultRepositiry> GetInputData()
        {
            runTime = String.Empty;
            TimeSpan _runTime;
            DateTime _startRun = DateTime.Now;

            List <Task> _tasks = new List <Task>();

            string[] filePathes = StaticService.GetPathFiles(folderInput, patern1);

            testResultRepo = new TestResultRepositiry();

            // очищаем папки
            StaticService.DeleteAllFile(folderOutTestResult, patern1);
            StaticService.DeleteAllFile(folderOutTestTradesSimple, patern1);
            StaticService.DeleteAllFile(folderOutTestTradesOPT, patern1);

            foreach (string _path in filePathes) // проходим по файлам
            {
                _tasks.Add(TrendAlgoritmTest(_path));
            }

            await Task.WhenAll(_tasks);

            StaticService.Serializes(testResultRepo, folderOutTestResult + "!_actul_result");

            _runTime = DateTime.Now - _startRun;
            runTime  = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", _runTime.Hours, _runTime.Minutes, _runTime.Seconds, _runTime.Milliseconds);

            return(testResultRepo);
        }
コード例 #2
0
ファイル: ConvertToDat.cs プロジェクト: zubr404/Optimizer
        /// <summary>
        /// Синхронная конвертация в .dat
        /// </summary>
        private void ConvertMy()
        {
            StreamReader file;

            string[] filePathes = StaticService.GetPathFiles(folder, patern1);

            foreach (string _path in filePathes) // проходим по файлам
            {
                MarketTradesRepository marketTradRepo;
                string  _date  = String.Empty;
                string  _time  = String.Empty;
                decimal _price = 0;

                using (file = new StreamReader(_path))
                {
                    string line;
                    marketTradRepo = new MarketTradesRepository();
                    int _id = 0;

                    while ((line = file.ReadLine()) != null) // проходим по стркам
                    {
                        string[] _splites = Regex.Split(line, paternRegEx1);

                        _id++;
                        _date = _splites[0];
                        _time = _splites[1];

                        try
                        {
                            _price = Convert.ToDecimal(_splites[2]);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }

                        marketTradRepo.Add(new ParametrMarketTrades(_id.ToString(), _date, _time, 0, _price, ""));
                    }
                }

                if (marketTradRepo.Count > 0)
                {
                    StaticService.Serializes(marketTradRepo, folder + marketTradRepo[0].DateTimeTrades.ToShortDateString());
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Получение входных данных для расчета Болинжера
        /// </summary>
        private async Task <string> GetInputData(SettingsClass _sc)
        {
            TimeSpan _runTime;
            DateTime _startRun = DateTime.Now;

            List <Task> _tasks = new List <Task>();

            string[] filePathes = StaticService.GetPathFiles(folderInput, patern1);

            foreach (string _path in filePathes) // проходим по файлам
            {
                _tasks.Add(TaskMultiParametrBB(_path, _sc));
            }

            await Task.WhenAll(_tasks);

            _runTime = DateTime.Now - _startRun;
            return(String.Format("{0:00}:{1:00}:{2:00}.{3:000}", _runTime.Hours, _runTime.Minutes, _runTime.Seconds, _runTime.Milliseconds));
        }
コード例 #4
0
ファイル: ConvertToDat.cs プロジェクト: zubr404/Optimizer
        /// <summary>
        /// Асинхронная конвертация в .dat
        /// </summary>
        /// <returns></returns>
        private async Task <string> ConvertAsync()
        {
            TimeSpan _runTime;
            DateTime _startRun = DateTime.Now;

            List <Task>       tasks         = new List <Task>();
            List <FileStream> sourceStreams = new List <FileStream>();

            string[] filePathes = StaticService.GetPathFiles(folder, patern1);

            int idTask = 0;

            foreach (string _path in filePathes) // проходим по файлам
            {
                int sourceLength;

                try
                {
                    FileStream sourceStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.None, bufferSize: 4096, useAsync: true);
                    sourceLength = (int)sourceStream.Length;

                    byte[] _result = new byte[sourceLength];
                    await sourceStream.ReadAsync(_result, 0, sourceLength); // асинх. чтение

                    Task theTask = TaskConvert(_result, idTask++.ToString());
                    sourceStreams.Add(sourceStream);
                    tasks.Add(theTask);
                }
                finally
                {
                    foreach (FileStream _fs in sourceStreams)
                    {
                        _fs.Close();
                    }
                }
            }

            await Task.WhenAll(tasks);

            _runTime = DateTime.Now - _startRun;
            return(String.Format("{0:00}:{1:00}:{2:00}.{3:000}", _runTime.Hours, _runTime.Minutes, _runTime.Seconds, _runTime.Milliseconds));
        }