Пример #1
0
        private void GetStockTableData(HtmlAgilityPack.HtmlDocument html, string stockExchange)
        {
            double value = 0;
            //Stocks
            HtmlNodeCollection Rows = html.DocumentNode.SelectNodes("//*[@id='tableQuote']/tbody/tr");
            foreach (HtmlNode row in Rows)
            {
                //Console.WriteLine("Row=" + row.InnerText);

                HtmlNodeCollection Cols = row.SelectNodes("td");
                PageStockRow stockRow = new PageStockRow();
                stockRow.stockExchange = stockExchange;
                if (Cols[0].InnerText != "" && Cols[0].InnerText != null) stockRow.stockCode = Cols[0].InnerText;
                for (int i = 1; i <= 24; i++)
                {
                    if (Double.TryParse(Cols[i].InnerText, out value))
                    {
                        switch (i)
                        {
                            case 1:
                                stockRow.ceiling = value; break;
                            case 2:
                                stockRow.floor = value; break;
                            case 3:
                                stockRow.reference = value; break;
                            case 4:
                                stockRow.bidVolume3 = value; break;
                            case 5:
                                stockRow.bidPrice3 = value; break;
                            case 6:
                                stockRow.bidVolume2 = value; break;
                            case 7:
                                stockRow.bidPrice2 = value; break;
                            case 8:
                                stockRow.bidVolume1 = value; break;
                            case 9:
                                stockRow.bidPrice1 = value; break;
                            case 10:
                                stockRow.price = value; break;
                            case 11:
                                stockRow.actualVolume = value; break;
                            case 12:
                                stockRow.valueChange = value; break;
                            case 13:
                                stockRow.askPrice1 = value; break;
                            case 14:
                                stockRow.askVolume1 = value; break;
                            case 15:
                                stockRow.askPrice2 = value; break;
                            case 16:
                                stockRow.askVolume2 = value; break;
                            case 17:
                                stockRow.askPrice3 = value; break;
                            case 18:
                                stockRow.askVolume3 = value; break;
                            case 19:
                                stockRow.high = value; break;
                            case 20:
                                stockRow.low = value; break;
                            case 21:
                                stockRow.average = value; break;
                            case 22:
                                stockRow.totalVolume = value; break;
                            case 23:
                                stockRow.boughtForeign = value; break;
                            case 24:
                                stockRow.room = value; break;
                            default:
                                break;
                        }
                    }
                }
                //stockRow.Print();
                AddStock(stockRow.stockCode, stockRow);
            }
        }
Пример #2
0
 public void AddStock(string key, PageStockRow value)
 {
     if (dictStocks.ContainsKey(key))
     {
         dictStocks[key] = value;
     }
     else
     {
         dictStocks.Add(key, value);
     }
 }