/// <summary>
        /// Get trading information about "(Main Board) up to day" .
        /// </summary>
        /// <returns>a instance of the Class TradingInfo which is about the Main01_10 trading News Info.</returns>
        public TradingInfo GetMain01_10TradingInfo()
        {
            string url = configObj.MainBoard_URI;
            //  "/eng/stat/smstat/ssturnover/ncms/ASHTMAIN.HTM";
            //  url = MiscUtil.UrlCombine(configObj.BASE_URI, url);

            TradingInfo main01_10TradingInfo = new TradingInfo();

            main01_10TradingInfo.StockList = new List <StockInfo>();
            List <string> valueList       = new List <string>();
            string        tradingNewsInfo = string.Empty;
            string        dateStr         = DateTime.Now.ToString("dddd dd/MM/yyyy");

            main01_10TradingInfo.DateStr = string.Format("Recorded as of {0} 04:00 pm :-", dateStr);

            var htmlDoc = WebClientUtil.GetHtmlDocument(url, 180000);

            tradingNewsInfo = htmlDoc.DocumentNode.SelectSingleNode("//body/pre/font").InnerText;
            using (StringReader sr = new StringReader(tradingNewsInfo))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    //Parse the stock info

                    string[] frags = line.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries);
                    int      ric   = 0;
                    if (frags.Length == 4 && int.TryParse(frags[0].Trim(), out ric))
                    {
                        StockInfo stockInfo = new StockInfo();
                        stockInfo.Ric       = string.Format("<{0}.HK>", ric.ToString("D4"));
                        stockInfo.StockName = frags[1].Trim();
                        stockInfo.Shares    = frags[2].Trim();
                        stockInfo.Turnover  = frags[3].Trim();
                        main01_10TradingInfo.StockList.Add(stockInfo);
                        continue;
                    }
                    else if (frags.Length == 4 && !int.TryParse(frags[0].Trim(), out ric))
                    {
                        Regex regExpression = new Regex("[0-9]+");
                        Match match         = regExpression.Match(frags[0].Trim());
                        if (match.Success)
                        {
                            StockInfo stockInfo = new StockInfo();
                            stockInfo.Ric       = string.Format("<{0}.HK>", match.Value);
                            stockInfo.StockName = frags[1].Trim();
                            stockInfo.Shares    = frags[2].Trim();
                            stockInfo.Turnover  = frags[3].Trim();
                            main01_10TradingInfo.StockList.Add(stockInfo);
                            continue;
                        }
                    }

                    frags = line.Split(':');
                    if (frags.Length == 2 && frags[1].Trim() != "")
                    {
                        valueList.Add(line.Trim());
                    }
                }

                //Parse to get the summary info of Main Board
                if (valueList != null && valueList.Count > 0)
                {
                    main01_10TradingInfo.DesignatedSecuritiesRecordingSum  = valueList[1];
                    main01_10TradingInfo.DesignatedSharesShortSoldSum      = valueList[2];
                    main01_10TradingInfo.DesignatedShortSellTurnoverShares = valueList[3];
                    main01_10TradingInfo.DesignatedShortSellTurnoverValue  = valueList[4];
                    main01_10TradingInfo.HKDTurnoverValue = valueList[5];
                }
            }
            return(main01_10TradingInfo);
        }
        //
        /// <summary>
        /// Get trading information from the HK-MAIN01-10.xls file.
        /// </summary>
        /// <param name="pageNum">the page number to copy.</param>
        /// <param name="lineNumEachPage">the line number of each page to copy.</param>
        /// <returns>the Main01_10 trading News Information.</returns>
        public TradingInfo GetTradingInfoFromMain01_10File(int pageNum, int lineNumEachPage)
        {
            TradingInfo tradingInfo = new TradingInfo();

            tradingInfo.StockList = new List <StockInfo>();

            //Open HK-MAIN01-10.xls
            using (ExcelApp app = new ExcelApp(false, false))
            {
                var workbook  = ExcelUtil.CreateOrOpenExcelFile(app, configObj.HKMAIN01_10_CONFIG.WORKBOOK_PATH);
                var worksheet = ExcelUtil.GetWorksheet(configObj.HKMAIN01_10_CONFIG.WORKSHEET_NAME, workbook);
                if (worksheet == null)
                {
                    logger.LogErrorAndRaiseException(string.Format("Cannot get worksheet {0} from workbook {1}", configObj.HKMAIN01_10_CONFIG.WORKSHEET_NAME, workbook.Name));
                }

                using (ExcelLineWriter reader = new ExcelLineWriter(worksheet, 1, 1, ExcelLineWriter.Direction.Right))
                {
                    tradingInfo.DateStr = ExcelUtil.GetRange(1, 1, worksheet).Text.ToString();
                    reader.PlaceNext(4, 1);
                    //Range range = ExcelUtil.GetRange(reader.Row, 1, worksheet);
                    while ((reader.Row < (pageNum * lineNumEachPage) + 11))
                    {
                        if (ExcelUtil.GetRange(reader.Row, 1, worksheet).Text != null)
                        {
                            string firstColText = ExcelUtil.GetRange(reader.Row, 1, worksheet).Text.ToString().Trim();
                            if (firstColText.StartsWith("<"))
                            {
                                StockInfo stockInfo = new StockInfo();
                                stockInfo.Ric       = reader.ReadLineCellText();
                                stockInfo.StockName = reader.ReadLineCellText();
                                stockInfo.Shares    = reader.ReadLineCellText();
                                stockInfo.Turnover  = reader.ReadLineCellText();
                                tradingInfo.StockList.Add(stockInfo);
                                reader.PlaceNext(reader.Row + 1, 1);
                            }

                            else
                            {
                                if (firstColText != string.Empty)
                                {
                                    tradingInfo.DesignatedSecuritiesRecordingSum  = ExcelUtil.GetRange(reader.Row, 1, worksheet).Text.ToString().Trim();
                                    tradingInfo.DesignatedSharesShortSoldSum      = ExcelUtil.GetRange(reader.Row + 1, 1, worksheet).Text.ToString().Trim();
                                    tradingInfo.DesignatedShortSellTurnoverShares = ExcelUtil.GetRange(reader.Row + 2, 1, worksheet).Text.ToString().Trim();
                                    tradingInfo.DesignatedShortSellTurnoverValue  = ExcelUtil.GetRange(reader.Row + 3, 1, worksheet).Text.ToString().Trim();
                                    if (ExcelUtil.GetRange(reader.Row + 4, 1, worksheet).Text != null)
                                    {
                                        tradingInfo.HKDTurnoverValue = ExcelUtil.GetRange(reader.Row + 4, 1, worksheet).Text.ToString().Trim();
                                    }
                                    reader.PlaceNext(reader.Row + 5, 1);
                                }
                                else
                                {
                                    reader.PlaceNext(reader.Row + 1, 1);
                                }
                            }
                        }
                        else
                        {
                            reader.PlaceNext(reader.Row + 1, 1);
                        }
                    }
                    workbook.Close(false, configObj.HKMAIN01_10_CONFIG.WORKBOOK_PATH, false);
                }
            }
            return(tradingInfo);
        }
        /// <summary>
        /// Get GEM trading News Info.
        /// </summary>
        /// <param name="uri">the uri of the source data which is a html page.</param>
        /// <returns>a instance of the Class TradingInfo which is about the GEM trading News Info.</returns>
        public TradingInfo GetGemTradingInfo(string uri)
        {
            HtmlAgilityPack.HtmlDocument htmlDoc = null;
            htmlDoc = WebClientUtil.GetHtmlDocument(uri, 180000);

            TradingInfo gemTradingInfo = new TradingInfo();

            gemTradingInfo.StockList = new List <StockInfo>();
            List <string> valueList = new List <string>();
            string        dateStr   = DateTime.Now.ToString("dddd dd/MM/yyyy");

            gemTradingInfo.DateStr = string.Format("Recorded as of {0} 04:00 pm :-", dateStr);

            //Get the trading news information
            string gemTradingNewsInfo = htmlDoc.DocumentNode.SelectSingleNode("//body/pre/font").InnerText;

            //Parse and get the required information
            if (!IsNewsExist(gemTradingNewsInfo))
            {
                gemTradingInfo.StockList = null;
            }

            using (StringReader sr = new StringReader(gemTradingNewsInfo))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] frags = line.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries);
                    int      ric   = 0;
                    if (frags.Length == 4 && int.TryParse(frags[0].Trim(), out ric))
                    {
                        StockInfo stockInfo = new StockInfo();
                        stockInfo.Ric       = string.Format("<{0}.HK>", ric.ToString("D4"));
                        stockInfo.StockName = frags[1].Trim();
                        stockInfo.Shares    = frags[2].Trim();
                        stockInfo.Turnover  = frags[3].Trim();
                        gemTradingInfo.StockList.Add(stockInfo);
                        continue;
                    }

                    frags = line.Split(':');
                    if (frags.Length == 2 && frags[1].Trim() != "")
                    {
                        valueList.Add(line.Trim());
                    }
                }
            }

            //Parse to get the summary info of Main Board
            if (valueList != null && valueList.Count > 0)
            {
                gemTradingInfo.DesignatedSecuritiesRecordingSum  = valueList[1];
                gemTradingInfo.DesignatedSharesShortSoldSum      = valueList[2];
                gemTradingInfo.DesignatedShortSellTurnoverShares = valueList[3];
                gemTradingInfo.DesignatedShortSellTurnoverValue  = valueList[4];
                if (valueList[5].Contains("Short Selling Turnover Total Value ($)          : HKD  "))
                {
                    gemTradingInfo.HKDTurnoverValue = valueList[5];
                }
            }
            return(gemTradingInfo);
        }