Example #1
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            // Different culture has differebr strt of week, ie in VN culture : start of week is Monday (not Sunday)
            if (myCulture == null)
            {
                myCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
            }

            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            ForexData goldData = ImportKitco(exchangeDetailRow.address);

            if (null == goldData)
            {
                return(null);
            }

            AddImportRow(updateTime, goldData, false, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);

            return(priceTbl);
        }
Example #2
0
        // Return common.extSortedList that store the mapping [Column in web page] -> [importPrice column]
        private common.extSortedList CreateMapping(metaStock meta, databases.importDS.importPriceDataTable dataTbl)
        {
            common.extSortedList list = new common.extSortedList();

            list.Add(meta.closePriceColId.ToString(), dataTbl.closePriceColumn.ColumnName);
            list.Add(meta.volumeColId.ToString(), dataTbl.volumeColumn.ColumnName);
            return(list);
        }
Example #3
0
        // importPrice->priceData
        private static void AddImportPrice(databases.importDS.importPriceDataTable importPriceTbl,
                                           DailyData dailyPrice, databases.baseDS.priceDataDataTable priceDataTbl)
        {
            databases.baseDS.priceDataSumRow dailyPriceRow;
            databases.baseDS.priceDataRow    priceDataRow;
            decimal volume = 0;

            for (int idx = 0; idx < importPriceTbl.Count; idx++)
            {
                //Invalid price, ignore
                if (importPriceTbl[idx].closePrice <= 0)
                {
                    continue;
                }

                volume = importPriceTbl[idx].volume;
                // If this is total volume then minus the last volume to get the real volume in the period
                if (importPriceTbl[idx].isTotalVolume)
                {
                    dailyPriceRow = dailyPrice.GetData(importPriceTbl[idx]);
                    if (dailyPriceRow != null)
                    {
                        volume -= dailyPriceRow.volume;
                    }
                    if (volume <= 0)
                    {
                        continue;
                    }
                }

                priceDataRow = priceDataTbl.NewpriceDataRow();
                databases.AppLibs.InitData(priceDataRow);
                priceDataRow.onDate     = importPriceTbl[idx].onDate;
                priceDataRow.stockCode  = importPriceTbl[idx].stockCode;
                priceDataRow.closePrice = importPriceTbl[idx].closePrice;
                priceDataRow.openPrice  = importPriceTbl[idx].closePrice;
                priceDataRow.highPrice  = importPriceTbl[idx].closePrice;
                priceDataRow.lowPrice   = importPriceTbl[idx].closePrice;
                priceDataRow.volume     = volume;
                //Fix other invalid price
                if (priceDataRow.highPrice <= 0)
                {
                    priceDataRow.highPrice = priceDataRow.closePrice;
                }
                if (priceDataRow.lowPrice <= 0)
                {
                    priceDataRow.highPrice = priceDataRow.lowPrice;
                }
                if (priceDataRow.openPrice <= 0)
                {
                    priceDataRow.highPrice = priceDataRow.openPrice;
                }
                priceDataTbl.AddpriceDataRow(priceDataRow);

                //Update the last row
                dailyPrice.UpdateData(importPriceTbl[idx]);
            }
        }
        /// <summary>
        /// Private - SU dung ASPWebservices
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        private databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            try
            {
                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();

                if (ssiPage==null)
                    ssiPage = new SSIPage("http://banggia2.ssi.com.vn/", "http://banggia2.ssi.com.vn/Hnx.aspx");
                    //ssiPage = new SSIPage("file:///C:/Temp/selenium/HOSE%20-%20CTCP%20ch%E1%BB%A9ng%20kho%C3%A1n%20S%C3%A0i%20G%C3%B2n%20-%20B%E1%BA%A3ng%20gi%C3%A1%20tr%E1%BB%B1c%20tuy%E1%BA%BFn.html", "file:///C:/Temp/selenium/HNX%20-%20CTCP%20ch%E1%BB%A9ng%20kho%C3%A1n%20S%C3%A0i%20G%C3%B2n%20-%20B%E1%BA%A3ng%20gi%C3%A1%20tr%E1%BB%B1c%20tuy%E1%BA%BFn.html");

                ssiPage.getHOSEData();
                ssiPage.getHNXData();
                //SaveDatatoImportPriceDataTable(updateTime,importPriceTbl);
                databases.importDS.importPriceRow importRow = null;
                databases.importDS.importPriceRow oldImportRow;

                foreach (var stock in ssiPage.dictStocks)
                {
                    importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.onDate = updateTime;
                    importRow.stockCode = stock.Key;
                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    //importRow.isTotalVolume = true;
                    importRow.isTotalVolume = false;

                    importRow.closePrice=(decimal)stock.Value.price;

                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    //importRow.volume = (decimal)stock.Value.totalVolume;
                    importRow.volume = (decimal)stock.Value.actualVolume;

                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    if (importRow.closePrice > 0)
                    {
                        //Only add new when there are some changes
                        oldImportRow = lastImportData.Find(importRow);
                        if (!lastImportData.IsSameData(importRow, oldImportRow))
                        {
                            importPriceTbl.AddimportPriceRow(importRow);
                            lastImportData.Update(importRow);
                        }
                        else importRow.CancelEdit();
                    }
                    else importRow.CancelEdit();
                }

                return importPriceTbl;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return null;
        }
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            if (!Get_IDX_HASTC(exchangeDetailRow.address, ref hastcIdx)) return null;
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            AddImportRow(updateTime, hastcIdx, true, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return priceTbl;
        }
Example #6
0
        /// <summary>
        /// Override method - /// Import stock data of HOSE and HASTC from  http://banggia.ssi.com.vn/AjaxWebService.asmx
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            databases.importDS.importPriceDataTable importPriceTbl = GetPriceFromWeb(updateTime, exchangeDetailRow);
            if (importPriceTbl == null)
            {
                return(null);
            }

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);
            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return(priceTbl);
        }
Example #7
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            if (!Get_IDX_HASTC(exchangeDetailRow.address, ref hastcIdx))
            {
                return(null);
            }
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            AddImportRow(updateTime, hastcIdx, true, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return(priceTbl);
        }
Example #8
0
 //Detect new stockCode and create new one
 public static void AddNewCode(string market, databases.importDS.importPriceDataTable tbl, OnCodeAdded onAddstockCodeFunc)
 {
     databases.baseDS.stockCodeDataTable stockCodeTbl = new databases.baseDS.stockCodeDataTable();
     for (int count = 0; count < tbl.Count; count++)
     {
         if (tbl[count].RowState == DataRowState.Deleted)
         {
             continue;
         }
         if (AddNewCode(tbl[count].stockCode, market, stockCodeTbl) != null &&
             onAddstockCodeFunc != null)
         {
             onAddstockCodeFunc(tbl[count].stockCode);
         }
     }
     databases.DbAccess.UpdateData(stockCodeTbl);
 }
Example #9
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            if (!GetData(exchangeDetailRow, ref hnIdx, ref hnIdx30))
            {
                return(null);
            }
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            AddImportRow(updateTime, hnIdx, true, importPriceTbl);
            //AddImportRow(updateTime, vn30Idx, false, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return(priceTbl);
        }
Example #10
0
            public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
            {
                // Different culture has differebr strt of week, ie in VN culture : start of week is Monday (not Sunday) 
                if (myCulture == null)
                    myCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);

                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
                ForexData goldData = ImportKitco(exchangeDetailRow.address);
                if (null == goldData) { return null; }

                AddImportRow(updateTime, goldData, false, importPriceTbl);

                Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
                databases.DbAccess.UpdateData(importPriceTbl);

                databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
                Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
                databases.DbAccess.UpdateData(priceTbl);

                return priceTbl;
            }
Example #11
0
        public static void AddNewCode(databases.importDS.importPriceDataTable tbl, OnCodeAdded onAddstockCodeFunc)
        {
            databases.tmpDS.stockCodeRow        shortCodeRow;
            databases.baseDS.stockCodeDataTable stockCodeTbl = new databases.baseDS.stockCodeDataTable();
            for (int count = 0; count < tbl.Count; count++)
            {
                if (tbl[count].RowState == DataRowState.Deleted)
                {
                    continue;
                }
                shortCodeRow = databases.AppLibs.FindAndCache_StockCodeShort(tbl[count].stockCode);
                if (shortCodeRow == null)
                {
                    continue;
                }

                if (AddNewCode(tbl[count].stockCode, shortCodeRow.stockExchange, stockCodeTbl) != null &&
                    onAddstockCodeFunc != null)
                {
                    onAddstockCodeFunc(tbl[count].stockCode);
                }
            }
            databases.DbAccess.UpdateData(stockCodeTbl);
        }
Example #12
0
        /// <summary>
        /// Import data from URL to tables : importPrice
        /// The function also detect and add new companies to the database
        /// </summary>
        /// <param name="url">URL to get data</param>
        /// <param name="priceMeta">meta describe the webpage structure</param>
        /// <param name="stockExchangeCode">stock exchange code of imported data </param>
        /// <param name="importPriceTbl"> where to store imported data </param>
        public databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, metaStock priceMeta, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            bool bHaveData = false; //Kiem tra xem bang co du lieu hay ko
            //Data in
            CultureInfo CultureInfoUS = common.language.GetCulture("en-US");

            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            this.mappingList = CreateMapping(priceMeta, importPriceTbl);

            // Get the URL specified
            var webGet   = new HtmlWeb();
            var document = webGet.Load(exchangeDetailRow.address);

            // Get <a> tags that have a href attribute and non-whitespace inner text
            var linksOnPage = from item in document.DocumentNode.Descendants()
                              where item.Name == "td" && item.Attributes["id"] == null
                              select new
            {
                Text = item.InnerText
            };

            bool    fError = false;
            int     igmoreRowCount = 0, columnCount = 0;
            decimal val = 0;

            databases.importDS.importPriceRow importRow = null;
            databases.importDS.importPriceRow oldImportRow;
            string stockCode;

            foreach (var item in linksOnPage)
            {
                //Check whether to ignore some items at the first
                if (++igmoreRowCount <= priceMeta.noRowIgnore)
                {
                    continue;
                }
                if (fError)
                {
                    break;
                }

                if (columnCount == priceMeta.startAtColId)
                {
                    stockCode = item.Text.Trim();
                    importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.onDate        = updateTime;
                    importRow.stockCode     = stockCode;
                    importRow.isTotalVolume = true;
                    columnCount++;
                    continue;
                }
                //Last column
                if (columnCount == priceMeta.endAtColId)
                {
                    if (importRow.closePrice > 0)
                    {
                        //Only add new when there are some changes
                        oldImportRow = lastImportData.Find(importRow);
                        if (!lastImportData.IsSameData(importRow, oldImportRow))
                        {
                            importPriceTbl.AddimportPriceRow(importRow);
                            lastImportData.Update(importRow);
                        }
                        else
                        {
                            importRow.CancelEdit();
                        }
                    }
                    else
                    {
                        importRow.CancelEdit();
                    }
                    columnCount = 0;
                    continue;
                }
                object obj = this.mappingList.GetValue(columnCount.ToString());
                if (obj != null)
                {
                    val = 0; common.system.StrToDecimal(item.Text, CultureInfoUS, out val);

                    //15/07: Kiem tra gia tri co bang 0 hay ko. Neu co thi se co loi doc du lieu
                    if (val != 0)
                    {
                        bHaveData = true;
                    }
                    importRow[(string)obj] = val;
                }
                columnCount++;
            }

            //Neu ko co du lieu
            if (!bHaveData)
            {
                throw new Exception();
            }

            return(importPriceTbl);
        }
Example #13
0
        /// <summary>
        /// Private - SU dung ASPWebservices
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        private databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            int idx = 0;

            clientSSI.AjaxWebServiceSoapClient client = null;
            try
            {
                client = new clientSSI.AjaxWebServiceSoapClient();
                //client = new clientSSI.AjaxWebServiceSoapClient(exchangeDetailRow.address);
                //HoSTC_ServiceSoapClient
                client.Endpoint.Address = new System.ServiceModel.EndpointAddress(exchangeDetailRow.address);
                System.ServiceModel.BasicHttpBinding binding = (client.Endpoint.Binding as System.ServiceModel.BasicHttpBinding);

                binding.OpenTimeout  = TimeSpan.FromSeconds(Consts.constWebServiceTimeOutInSecs);
                binding.CloseTimeout = binding.OpenTimeout;
                binding.SendTimeout  = binding.OpenTimeout;

                binding.MaxReceivedMessageSize = Consts.constWebServiceMaxReceivedMessageSize;
                binding.MaxBufferSize          = Consts.constWebServiceMaxReceivedMessageSize;

                binding.ReaderQuotas.MaxStringContentLength = Consts.constWebServiceMaxStringContentLength;
                binding.ReaderQuotas.MaxBytesPerRead        = Consts.constWebServiceMaxBytesPerRead;

                String s = String.Empty;
                switch (exchangeDetailRow.code.ToUpper().Trim())
                {
                case "HOSE_SSI":
                    //s = client.GetDataHoSTC2();
                    s = client.GetHoseStockQuote(0);
                    break;

                case "HASTC_SSI":
                    //s = client.GetDataHaSTC2();
                    break;

                default: return(null);
                }
                //Parsing
                List <string> tradeList = new List <string>(s.Split('#'));
                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
                CultureInfo dataCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
                for (idx = 0; idx < tradeList.Count; idx++)
                {
                    List <string> tradeData = new List <string>(tradeList[idx].Split('|'));
                    if (tradeData[8].Trim() == "" || tradeData[9].Trim() == "")
                    {
                        continue;
                    }
                    databases.importDS.importPriceRow importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.stockCode     = tradeData[0].ToString();
                    importRow.onDate        = updateTime;
                    importRow.closePrice    = decimal.Parse(tradeData[8], dataCulture);
                    importRow.volume        = decimal.Parse(tradeData[9], dataCulture);
                    importRow.isTotalVolume = false;//day ko phai total volume. Cai nay la volume tung thoi diem
                    importPriceTbl.AddimportPriceRow(importRow);
                }
                return(importPriceTbl);
            }
            catch (Exception er)
            {
                common.SysLog.WriteLog("Error : " + er.Message);
                return(null);
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    client.Close();
                }
            }
        }
Example #14
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            if (!GetData(exchangeDetailRow, ref hnIdx, ref hnIdx30)) return null;
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            AddImportRow(updateTime, hnIdx, true, importPriceTbl);
            //AddImportRow(updateTime, vn30Idx, false, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return priceTbl;
        }
Example #15
0
 public static void AddImportPrice(databases.importDS.importPriceDataTable importPriceTbl,
                                   databases.baseDS.priceDataDataTable priceDataTbl)
 {
     AddImportPrice(importPriceTbl, myDailyData, priceDataTbl);
 }
Example #16
0
 public ImportData()
 {
     dataTbl = new databases.importDS.importPriceDataTable();
     dataTbl.DefaultView.Sort = dataTbl.stockCodeColumn.ColumnName;
 }
Example #17
0
        protected virtual void AddImportRow(DateTime updateTime, MarketData marketValue, bool isTotalVolume, databases.importDS.importPriceDataTable tbl)
        {
            databases.importDS.importPriceRow oldImportRow;
            databases.importDS.importPriceRow importRow = tbl.NewimportPriceRow();
            databases.AppLibs.InitData(importRow);
            importRow.isTotalVolume = isTotalVolume;
            importRow.onDate        = updateTime;
            importRow.stockCode     = marketValue.Code;
            importRow.volume        = marketValue.TotalQty;
            importRow.closePrice    = marketValue.Value;

            //Only add new when there are some changes
            oldImportRow = lastImportData.Find(importRow);
            if (!lastImportData.IsSameData(importRow, oldImportRow))
            {
                tbl.AddimportPriceRow(importRow);
                lastImportData.Update(importRow);
            }
            else
            {
                importRow.CancelEdit();
            }
        }
Example #18
0
        /// <summary>
        /// Import data from URL to tables : importPrice 
        /// The function also detect and add new companies to the database
        /// </summary>
        /// <param name="url">URL to get data</param>
        /// <param name="priceMeta">meta describe the webpage structure</param>
        /// <param name="stockExchangeCode">stock exchange code of imported data </param>
        /// <param name="importPriceTbl"> where to store imported data </param>
        public databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, metaStock priceMeta,databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            bool bHaveData = false; //Kiem tra xem bang co du lieu hay ko
            //Data in
            CultureInfo CultureInfoUS = common.language.GetCulture("en-US");
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            this.mappingList = CreateMapping(priceMeta, importPriceTbl);

            // Get the URL specified
            var webGet = new HtmlWeb();
            var document = webGet.Load(exchangeDetailRow.address);

            // Get <a> tags that have a href attribute and non-whitespace inner text
            var linksOnPage = from item in document.DocumentNode.Descendants()
                              where item.Name == "td" && item.Attributes["id"] == null
                              select new
                              {
                                  Text = item.InnerText
                              };

            bool fError = false;
            int igmoreRowCount = 0, columnCount = 0;
            decimal val = 0;
            databases.importDS.importPriceRow importRow = null;
            databases.importDS.importPriceRow oldImportRow;
            string stockCode;
            foreach (var item in linksOnPage)
            {
                //Check whether to ignore some items at the first
                if (++igmoreRowCount <= priceMeta.noRowIgnore) continue;
                if (fError) break;

                if (columnCount == priceMeta.startAtColId)
                {
                    stockCode = item.Text.Trim();
                    importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.onDate = updateTime;
                    importRow.stockCode = stockCode;
                    importRow.isTotalVolume = true;
                    columnCount++;
                    continue;
                }
                //Last column
                if (columnCount == priceMeta.endAtColId)
                {
                    if (importRow.closePrice > 0)
                    {
                        //Only add new when there are some changes 
                        oldImportRow = lastImportData.Find(importRow);
                        if (!lastImportData.IsSameData(importRow, oldImportRow))
                        {
                            importPriceTbl.AddimportPriceRow(importRow);
                            lastImportData.Update(importRow);
                        }
                        else importRow.CancelEdit();
                    }
                    else importRow.CancelEdit();
                    columnCount = 0;
                    continue;
                }
                object obj = this.mappingList.GetValue(columnCount.ToString());
                if (obj != null)
                {
                    val = 0; common.system.StrToDecimal(item.Text, CultureInfoUS, out val);

                    //15/07: Kiem tra gia tri co bang 0 hay ko. Neu co thi se co loi doc du lieu
                    if (val != 0)
                        bHaveData = true;                    
                    importRow[(string)obj] = val;
                }
                columnCount++;
            }

            //Neu ko co du lieu
            if (!bHaveData) 
                throw new Exception();
            
            return importPriceTbl;
            
        }
Example #19
0
        /// <summary>
        /// Private - SU dung ASPWebservices
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        private databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            int idx = 0;
            clientSSI.AjaxWebServiceSoapClient client = null;
            try
            {
                client = new clientSSI.AjaxWebServiceSoapClient();
                //client = new clientSSI.AjaxWebServiceSoapClient(exchangeDetailRow.address);
                //HoSTC_ServiceSoapClient
                client.Endpoint.Address = new System.ServiceModel.EndpointAddress(exchangeDetailRow.address);
                System.ServiceModel.BasicHttpBinding binding = (client.Endpoint.Binding as System.ServiceModel.BasicHttpBinding);

                binding.OpenTimeout = TimeSpan.FromSeconds(Consts.constWebServiceTimeOutInSecs);
                binding.CloseTimeout = binding.OpenTimeout;
                binding.SendTimeout = binding.OpenTimeout;

                binding.MaxReceivedMessageSize = Consts.constWebServiceMaxReceivedMessageSize;
                binding.MaxBufferSize = Consts.constWebServiceMaxReceivedMessageSize;

                binding.ReaderQuotas.MaxStringContentLength = Consts.constWebServiceMaxStringContentLength;
                binding.ReaderQuotas.MaxBytesPerRead = Consts.constWebServiceMaxBytesPerRead;

                String s = String.Empty;
                switch (exchangeDetailRow.code.ToUpper().Trim())
                {
                    case "HOSE_SSI":
                        //s = client.GetDataHoSTC2();
                        s = client.GetHoseStockQuote(0);
                        break;
                    case "HASTC_SSI":
                        //s = client.GetDataHaSTC2();
                        break;
                    default: return null;
                }
                //Parsing
                List<string> tradeList = new List<string>(s.Split('#'));
                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
                CultureInfo dataCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
                for (idx = 0; idx < tradeList.Count; idx++)
                {
                    List<string> tradeData = new List<string>(tradeList[idx].Split('|'));
                    if (tradeData[8].Trim() == "" || tradeData[9].Trim() == "")
                    {
                        continue;
                    }
                    databases.importDS.importPriceRow importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.stockCode = tradeData[0].ToString();
                    importRow.onDate = updateTime;
                    importRow.closePrice = decimal.Parse(tradeData[8], dataCulture);
                    importRow.volume = decimal.Parse(tradeData[9], dataCulture);
                    importRow.isTotalVolume = false;//day ko phai total volume. Cai nay la volume tung thoi diem
                    importPriceTbl.AddimportPriceRow(importRow);
                }
                return importPriceTbl;
            }
            catch (Exception er)
            {
                common.SysLog.WriteLog("Error : " + er.Message);
                return null;
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                    client.Close();
            }
        }
Example #20
0
 public ImportData()
 { 
     dataTbl = new databases.importDS.importPriceDataTable();
     dataTbl.DefaultView.Sort = dataTbl.stockCodeColumn.ColumnName;
 }