Exemplo n.º 1
0
        void Init(SKU s)
        {
            MContext       mc  = new MContext();
            List <SkuAnot> lsa = mc.SAs.Where(x => x.ID == s.ID).ToList();

            lValue.Add(lsa[0].Val1);
            lValue.Add(lsa[0].Val2);
            lValue.Add(lsa[0].Val3);
            lValue.Add(lsa[0].Val4);
            lValue.Add(lsa[0].Val5);
            lValue.Add(lsa[0].Val6);
            lValue.Add(lsa[0].Val7);
            lValue.Add(lsa[0].Val8);
            lValue.Add(lsa[0].Val9);
            lValue.Add(lsa[0].Val10);
            lValue.Add(lsa[0].Val11);
            lValue.Add(lsa[0].Val12);

            List <AnotSubCat> lac = mc.ASCs.Where(x => x.ID == s.ID_Subcategory).ToList();

            sa = lac[0];
            lHarac.Add(lac[0].Har1);
            lHarac.Add(lac[0].Har2);
            lHarac.Add(lac[0].Har3);
            lHarac.Add(lac[0].Har4);
            lHarac.Add(lac[0].Har5);
            lHarac.Add(lac[0].Har6);
            lHarac.Add(lac[0].Har7);
            lHarac.Add(lac[0].Har8);
            lHarac.Add(lac[0].Har9);
            lHarac.Add(lac[0].Har10);
            lHarac.Add(lac[0].Har11);
            lHarac.Add(lac[0].Har12);

            Subcategory sub = mc.Subcategories.First(x => x.ID == s.ID_Subcategory);
            PriceFormat pf  = mc.PriceFormat.First(x => x.ID == sub.ID_PriceFormat);

            if (pf.ID != 3)
            {
                SetTitle();
                SetTitleAnatation();
                SetHarac();
                SetPrice();
            }
            else
            {
                SetTitle(true);
                SetTitleAnatation(true);
                int size = SetHarac(true);
                SetPrice(true, size);
            }
        }
        public void Open_price_file()
        {
            var pricesDirectory        = "prices";
            var invalidPricesDirectory = "invalid_prices";
            var pricesFiles            = new string[3] {
                "1.txt", "2.xls", "3.dbf"
            };
            var countsTables = new int[3] {
                1, 2, 1
            };
            var pricesFormats = new PriceFormat[4] {
                PriceFormat.DelimWIN, PriceFormat.XLS, PriceFormat.NativeDbf, PriceFormat.UniversalFormalizer
            };
            var indvalidPricesFiles = new string[3] {
                "1.xls", "2.xls", "3.txt"
            };
            var index = 0;

            foreach (var filename in pricesFiles)
            {
                var path   = Settings.Default.TestDirectoryPath + pricesDirectory + Path.DirectorySeparatorChar + filename;
                var tables = PriceFileHelper.OpenPriceFile(Path.GetFullPath(path),
                                                           pricesFormats[index],
                                                           PriceEncode.Cp1251,
                                                           "tab",
                                                           null);
                Assert.That(tables.Count, Is.EqualTo(countsTables[index++]));
                Assert.That(tables[0].Rows.Count, Is.GreaterThan(0));
            }
            index = 0;
            foreach (var filename in indvalidPricesFiles)
            {
                var path   = Settings.Default.TestDirectoryPath + invalidPricesDirectory + Path.DirectorySeparatorChar + filename;
                var tables = PriceFileHelper.OpenPriceFile(Path.GetFullPath(path),
                                                           pricesFormats[index++],
                                                           PriceEncode.Cp1251,
                                                           "tab",
                                                           null);
                if (tables != null)
                {
                    Assert.That(tables.Count, Is.EqualTo(1));
                    Assert.That(tables[0].Rows.Count, Is.EqualTo(0));
                }
            }
        }
Exemplo n.º 3
0
        private void ADD_Click(object sender, RoutedEventArgs e)
        {
            //по нажаьтию кнопки проверяем есть ли ткое название в базе если нет то добавляем
            MContext mc = new MContext();

            if (mc.Subcategories.Any(x => x.Name == TBTitle.Text))
            {
                MessageBox.Show("Подкатегория {0} уже существует", TBTitle.Text);
                TBTitle.Text = string.Empty;
                TBTitle.Focus();
            }
            else
            {
                Category    c  = CBCategory.SelectedItem as Category;
                PriceFormat pf = CBFP.SelectedItem as PriceFormat;
                Subcategory s  = new Subcategory()
                {
                    Name           = TBTitle.Text, ID_Category = c.ID, UrlComfy = Comfy.Text,
                    UrlAllo        = Allo.Text, UrlEldorado = Eldorado.Text, UrlRozetka = Rozetka.Text,
                    ID_PriceFormat = pf.ID
                };
                mc.Subcategories.Add(s);
                mc.SaveChanges();
                AnotSubCat asc = new AnotSubCat()
                {
                    ID    = s.ID,
                    Har1  = Value1.Text,
                    Har2  = Value2.Text,
                    Har3  = Value3.Text,
                    Har4  = Value4.Text,
                    Har5  = Value5.Text,
                    Har6  = Value6.Text,
                    Har7  = Value7.Text,
                    Har8  = Value8.Text,
                    Har9  = Value9.Text,
                    Har10 = Value10.Text,
                    Har11 = Value11.Text,
                    Har12 = Value12.Text,
                };
                mc.ASCs.Add(asc);
                mc.SaveChanges();
                MessageBox.Show("Подкатегория добавлена");
                this.Close();
            }
        }
Exemplo n.º 4
0
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                // Скрыть Grid
                grid.Visibility = Visibility.Hidden;
                MContext    mc  = new MContext();
                Subcategory sub = mc.Subcategories.First(x => x.ID == s.ID_Subcategory);
                PriceFormat pf  = mc.PriceFormat.First(x => x.ID == sub.ID_PriceFormat);
                // Увеличить размер в 5 раз
                MyCanvas.LayoutTransform = new ScaleTransform(pf.TransX, pf.TransY);
                // Определить поля
                int pageMargin = pf.Margin;

                // Получить размер страницы
                System.Windows.Size pageSize = new System.Windows.Size(pf.X, pf.Y);
                // Инициировать установку размера элемента
                MyCanvas.Measure(pageSize);
                MyCanvas.Arrange(new Rect(pageMargin, pageMargin, pageSize.Width, pageSize.Height));

                // Напечатать элемент
                printDialog.PrintVisual(MyCanvas, "Распечатываем элемент Canvas");

                // Удалить трансформацию и снова сделать элемент видимым
                MyCanvas.LayoutTransform = null;
                grid.Visibility          = Visibility.Visible;
                if (s.TotalPrice != 0)
                {
                    SKU stmp = mc.SKUs.First(x => x.ID == s.ID);
                    stmp.Price       = s.TotalPrice;
                    stmp.TotalPrice  = 0;
                    stmp.Promo       = s.TotalPromo;
                    stmp.ChangePrice = false;
                    mc.SaveChanges();
                }
            }
            this.Close();
        }
Exemplo n.º 5
0
		GetHistoricalPrice(string startDate, string endDate, string BloombergTicker, PriceFormat priceFormat)
		{
			BloombergLib.BloombergLib.CBloomberg objBloomberg;
			CBloombergRemoteFactory objRemoteFactory;
			List<BloombergPrice> HistoricalPrice = new List<BloombergPrice>();

			//取得本機的 IP
			string strLocalIP = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString();
			string strServerIP = "10.5.48.46";  // Bloomberg PC

			if (strLocalIP != strServerIP)
			{
				if (IsRegisterChannel == false)  // 連線設定、只要一次、程式就可重複使用
				{
					//string path1 = Directory.GetCurrentDirectory();
					//string path2 = Directory.GetParent(path1).FullName;
					//string path3 = Directory.GetParent(path2).FullName;
					//string path4 = Directory.GetParent(path3).FullName;
					//string AppConfig = path4 + "\\Bloomberg\\App.Config";
					//RemotingConfiguration.Configure(AppConfig, false);

					RemotingConfiguration.Configure(@"C:\Bloomberg.Config", false);
					RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
					RemotingConfiguration.CustomErrorsEnabled(true);
					IsRegisterChannel = true;
				}
			}

			//產生 object (若有 Remoting, 則object由Server端產生,否則由Client端產生)
			objRemoteFactory = new CBloombergRemoteFactory();
			objBloomberg = objRemoteFactory.GetNewInstance();

			try
			{
				//'清除資料
				objBloomberg.ClearData();

				//'讀取今天的資料
				objBloomberg.RequestType = RequestType.HistoricalDataRequest;  // <======= IMPORTANT!!!

				List<string> lstField = new List<string>();

				if (priceFormat == PriceFormat.UniPrice)
				{
					lstField.Add("PX_LAST"); lstField.Add("PX_LAST"); lstField.Add("PX_LAST"); lstField.Add("PX_LAST");
				}
				else
				{
					lstField.Add("PX_OPEN"); lstField.Add("PX_HIGH"); lstField.Add("PX_LOW"); lstField.Add("PX_LAST");
				}

				objBloomberg.AddSecurities(BloombergTicker);

				foreach (string Field in lstField) objBloomberg.AddFields(Field);

				//string mktdate = DateTime.Today.AddDays(-1).ToString("yyyyMMdd");

				BloombergLib.BloombergLib.CBloombergHistoricalOption objHistoricalOption;
				objHistoricalOption = objBloomberg.GetHistoricalOption();

				objHistoricalOption.periodicityAdjustment = periodicityAdjustment.ACTUAL;
				objHistoricalOption.periodicitySelection = periodicitySelection.DAILY;

				//'設定資料開始日期
				objHistoricalOption.StartDate = startDate; // mktdate; // ' "20110901" 'txtStartDate.Text
				//'設定資料結束日期
				objHistoricalOption.EndDate = endDate; // mktdate; // ' "20110901" 'txtEndDate.Text

				objHistoricalOption.nonTradingDayFillOption = nonTradingDayFillOption.ACTIVE_DAYS_ONLY;

				objHistoricalOption.nonTradingDayFillMethod = nonTradingDayFillMethod.PREVIOUS_VALUE;

				//'讀取Bloomberg資料
				objBloomberg.SendRequest();

				List<string> tmpout = new List<string>();

				foreach (BloombergLib.CBloombergData objBloomberData in objBloomberg.GetData())
				{
					string tempMessage = objBloomberData.HistoryDate.Replace("-", "");// +",";

					foreach (string Field in lstField)
					{
						tempMessage += "," + objBloomberData.get_Field(Field);
					}
					//sw.WriteLine("{0}", tempMessage);
					tmpout.Add(tempMessage);
				}

				if (tmpout.Count > 0)
				{
					foreach (var tmpdata in tmpout)
					{
						BloombergPrice tmpOHLC = new BloombergPrice();
						char[] delimiterChars = { ',' };
						string[] tmpstring = tmpdata.Split(delimiterChars);

						tmpOHLC.Datetime = DateTime.ParseExact(tmpstring[0], "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
						tmpOHLC.Open = double.Parse(tmpstring[1]);
						tmpOHLC.High = double.Parse(tmpstring[2]);
						tmpOHLC.Low = double.Parse(tmpstring[3]);
						tmpOHLC.Close = double.Parse(tmpstring[4]);

						HistoricalPrice.Add(tmpOHLC);
					}
				}


			}
			catch (System.Exception ex)
			{
				throw ex;
			}

			return HistoricalPrice;
		}
Exemplo n.º 6
0
		GetPriceIndividual(string date1, string date2, string opfile, string BloombergTicker, PriceFormat priceFormat)
		{
			BloombergLib.BloombergLib.CBloomberg objBloomberg;
			CBloombergRemoteFactory objRemoteFactory;

			//取得本機的 IP
			string strLocalIP = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString();
			string strServerIP = "10.5.48.46";  // Bloomberg PC

			if (strLocalIP != strServerIP)
			{
				if (IsRegisterChannel == false)  // 連線設定、只要一次、程式就可重複使用
				{
					//string path1 = Directory.GetCurrentDirectory();
					//string path2 = Directory.GetParent(path1).FullName;
					//string path3 = Directory.GetParent(path2).FullName;
					//string path4 = Directory.GetParent(path3).FullName;
					//string AppConfig = path4 + "\\Bloomberg\\App.Config";
					//RemotingConfiguration.Configure(AppConfig, false);

					RemotingConfiguration.Configure(@"C:\Bloomberg.Config", false);
					RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
					RemotingConfiguration.CustomErrorsEnabled(true);
					IsRegisterChannel = true;
				}
			}

			//產生 object (若有 Remoting, 則object由Server端產生,否則由Client端產生)
			objRemoteFactory = new CBloombergRemoteFactory();
			objBloomberg = objRemoteFactory.GetNewInstance();

			try
			{
				//'清除資料
				objBloomberg.ClearData();

				//'讀取今天的資料
				objBloomberg.RequestType = RequestType.HistoricalDataRequest;  // <======= IMPORTANT!!!

				List<string> lstField = new List<string>();

				if (priceFormat == PriceFormat.UniPrice)
				{
					lstField.Add("PX_LAST"); lstField.Add("PX_LAST"); lstField.Add("PX_LAST"); lstField.Add("PX_LAST");
				}
				else
				{
					lstField.Add("PX_OPEN"); lstField.Add("PX_HIGH"); lstField.Add("PX_LOW"); lstField.Add("PX_LAST");
				}

				objBloomberg.AddSecurities(BloombergTicker);

				foreach (string Field in lstField) objBloomberg.AddFields(Field);

				//string mktdate = DateTime.Today.AddDays(-1).ToString("yyyyMMdd");

				BloombergLib.BloombergLib.CBloombergHistoricalOption objHistoricalOption;
				objHistoricalOption = objBloomberg.GetHistoricalOption();

				objHistoricalOption.periodicityAdjustment = periodicityAdjustment.ACTUAL;
				objHistoricalOption.periodicitySelection = periodicitySelection.DAILY;

				//'設定資料開始日期
				objHistoricalOption.StartDate = date1; // mktdate; // ' "20110901" 'txtStartDate.Text
				//'設定資料結束日期
				objHistoricalOption.EndDate = date2; // mktdate; // ' "20110901" 'txtEndDate.Text

				objHistoricalOption.nonTradingDayFillOption = nonTradingDayFillOption.ACTIVE_DAYS_ONLY;

				objHistoricalOption.nonTradingDayFillMethod = nonTradingDayFillMethod.PREVIOUS_VALUE;

				//'讀取Bloomberg資料
				objBloomberg.SendRequest();

				List<string> tmpout = new List<string>();

				foreach (BloombergLib.CBloombergData objBloomberData in objBloomberg.GetData())
				{
					string tempMessage = objBloomberData.HistoryDate.Replace("-", "");// +",";

					foreach (string Field in lstField)
					{
						tempMessage += "," + objBloomberData.get_Field(Field);
					}
					//sw.WriteLine("{0}", tempMessage);
					tmpout.Add(tempMessage);
				}

				if (tmpout.Count > 0)
				{
					StreamWriter sw = new StreamWriter(opfile, false, Encoding.Default);

					foreach (string strout in tmpout)
					{
						Console.WriteLine(strout);
						sw.WriteLine("{0}", strout);
					}
					sw.Close();
				}
				else
					Console.WriteLine("{0} No data from Bloomberg!!!", BloombergTicker);

				Console.WriteLine("Done!");

			}
			catch (System.Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}


		}
Exemplo n.º 7
0
 public CsvHappinnessPriceItemBuilder(PriceFormat priceFormat)
 {
     _priceFormat = priceFormat;
 }
Exemplo n.º 8
0
 public CsvPriceLoader(string encoding, PriceFormat priceFormat)
 {
     _encoding    = encoding;
     _priceFormat = priceFormat;
 }