示例#1
0
        public void Execute()
        {
            if (_currencyTypesNames.Count > 1)
            {
                for (short i = 1; i < _currencyTypesNames.Count; i++)
                {
                    string abr = _currencyTypesNames[i];
                    abr = abr.Remove(abr.Length - 1).Remove(0, abr.IndexOf("(") + 1);
                    string filePath = string.Format(PathToExchangeArchiveSql, PathToSolution, abr);
                    using (var fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write))
                    {
                        using (var sw = new StreamWriter(fs, Encoding.Unicode))
                        {
                            sw.WriteLine("INSERT INTO [TestPlan].[dbo].[ExchangeArchive]([Id],[Version],[Date],[Ratio],[FirstCurrency_id],[SecondCurrency_id])");
                            var ratios = GetRatios(_currencyTypesNames[i]);

                            for (int j = 0; j < ratios.Count; j++)
                            {
                                var str = string.Format("SELECT '{0}',{1},'{2}', {3},'{4}','{5}'",
                                                        GeneratorHelper.ToGuid(i, j),
                                                        1,
                                                        ratios[j].DateTime.ToString(CultureInfo.InvariantCulture),
                                                        ratios[j].Ratio.ToString(CultureInfo.InvariantCulture),
                                                        IdMainCurrencyTypes,
                                                        GeneratorHelper.ToGuid(i));
                                if (j < ratios.Count - 1)
                                {
                                    sw.WriteLine(str + " UNION ALL");
                                }
                                else
                                {
                                    sw.WriteLine(str);
                                }
                            }
                            sw.WriteLine("GO");
                        }
                    }
                }
            }
        }
示例#2
0
 public ExchangeArchiveGenerator(List <string> currencyTypesNames, string maincurrencyTypesName, string pathToSolution)
 {
     _currencyTypesNames = currencyTypesNames;
     IdMainCurrencyTypes = GeneratorHelper.ToGuid(currencyTypesNames.IndexOf(maincurrencyTypesName));
     PathToSolution      = pathToSolution;
 }