Esempio n. 1
0
        protected override bool GetData(databases.baseDS.exchangeDetailRow exchangeDetailRow, ref MarketData vnIdx, ref MarketData vn30Idx)
        {
            clientSSI.AjaxWebServiceSoapClient client = null;
            try
            {
                client = new clientSSI.AjaxWebServiceSoapClient();
                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;

                CultureInfo   dataCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
                String        s           = client.GetMarketAllIndex(0);
                List <string> tradeList   = new List <string>(s.Split('$'));
                for (int i = 0; i < tradeList.Count; i++)
                {
                    List <string> tradeData = new List <string>(tradeList[i].Split('|'));
                    if (tradeData[0].Trim() == "" || tradeData[1].Trim() == "" ||
                        tradeData[8].Trim() == "" || tradeData[9].Trim() == "")
                    {
                        continue;
                    }
                    vnIdx.Value    = decimal.Parse(tradeData[0], dataCulture);
                    vnIdx.TotalQty = decimal.Parse(tradeData[1], dataCulture);
                    vnIdx.TotalAmt = decimal.Parse(tradeData[2], dataCulture);

                    vn30Idx.Value    = decimal.Parse(tradeData[11], dataCulture);
                    vn30Idx.TotalQty = decimal.Parse(tradeData[14], dataCulture);
                    vn30Idx.TotalAmt = decimal.Parse(tradeData[15], dataCulture);
                    return(true);
                }
            }
            catch (WebException e)
            {
                return(false);
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    client.Close();
                }
            }

            return(true);
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
0
        protected bool GetData(databases.baseDS.exchangeDetailRow exchangeDetailRow, ref MarketData hnIdx, ref MarketData hnIdx30)
        {
            clientSSI.AjaxWebServiceSoapClient client = null;
            try
            {
                client = new clientSSI.AjaxWebServiceSoapClient();
                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;

                CultureInfo dataCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
                String s = client.GetMarketAllIndex(0);//.GetDataHaSTC2_Index();
                List<string> tradeList = new List<string>(s.Split('#'));
                for (int i = 0; i < tradeList.Count; i++)
                {
                    List<string> tradeData = new List<string>(tradeList[i].Split('|'));
                    if (tradeData[5].Trim() == "")
                    {
                        continue;
                    }
                    hnIdx.Value = decimal.Parse(tradeData[5], dataCulture);
                    hnIdx.TotalQty = decimal.Parse(tradeData[3], dataCulture);
                    hnIdx.TotalAmt = decimal.Parse(tradeData[4], dataCulture);

                    hnIdx30.Value = decimal.Parse(tradeData[10], dataCulture);
                    hnIdx30.TotalQty = decimal.Parse(tradeData[11], dataCulture);
                    hnIdx30.TotalAmt = decimal.Parse(tradeData[12], dataCulture);
                    return true;
                }
            }
            catch (WebException e)
            {
                return false;
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                    client.Close();
            }

            return true;
        }
Esempio n. 4
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();
                }
            }
        }