Ejemplo n.º 1
0
        public traderBean ToBean()
        {
            traderBean bean = new traderBean();

            bean.ID            = RecordNumber.ToString();
            bean.DATA_NEGOCIO  = TradeDate.ToString("yyyy-MM-dd");
            bean.HORA_NEGOCIO  = HoraNegocio;
            bean.NR_NEGOCIO    = TradeID;
            bean.CODNEG        = Papel;
            bean.SERPAP        = Serie;
            bean.OPERACAO      = Orientation;
            bean.QTDADE        = NumberOfContracts.ToString();
            bean.PDENEG        = Price.ToString(ciEn);
            bean.FC_NOME       = BuyerName;
            bean.NM_EMIT_ORDEM = TraderName;
            bean.MERCADO       = SegmentoBolsa;

            return(bean);
        }
Ejemplo n.º 2
0
        public List <traderBean> GetBeans(string pUser, string pPassword, string pTradeID)
        {
            TradeProcessor    trProc = new TradeProcessor();
            List <traderBean> beans  = new List <traderBean>();

            bool bInTeste = false;

            if (ConfigurationManager.AppSettings["EmTeste"] != null &&
                ConfigurationManager.AppSettings["EmTeste"].ToString().ToLowerInvariant().Equals("true"))
            {
                bInTeste = true;
            }

            DateTime lastTimestamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

            if (bInTeste)
            {
                lastTimestamp = DateTime.MinValue;
            }

            if (!String.IsNullOrEmpty(pTradeID))
            {
                try
                {
                    lastTimestamp = DateTime.ParseExact(pTradeID, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
                }
                catch (Exception ex)
                {
                    logger.Error("Erro ao tentar efetuar parse do parametro pTradeID [" + pTradeID + "]");
                    logger.Error("Assumindo hora default [" + lastTimestamp.ToString("yyyy/MM/dd HH:mm:ss") + "]");
                }
            }

            //string pwd64 = base64Encode(pPassword);
            string user   = ConfigurationManager.AppSettings["username"].ToString();
            string passwd = ConfigurationManager.AppSettings["password"].ToString();

            if (pUser.Equals(user) == false || pPassword.Equals(passwd) == false)
            {
                traderBean bean = new traderBean();
                bean.ID = "pUser or pPassword is invalid!";

                beans.Add(bean);

                return(beans);
            }

            logger.Info("GetBeans(" + lastTimestamp.ToString("yyyy/MM/dd HH:mm:ss") + ") Inicio");

            beans.AddRange(trProc.GetTrades(lastTimestamp));



            //string xmlRet = "<QueryTradesStrResponse>";

            //string xmlRet = "<QueryTradesStrResult>";
            //xmlRet += xmlTrades;
            //xmlRet += "</QueryTradesStrResult>";
            //xmlRet += "<pTradeID>";
            //xmlRet += pTradeID.ToString("yyyy/MM/dd HH:mm:ss");
            //xmlRet += "</pTradeID>";
            //xmlRet += "</QueryTradesStrResponse>";

            //logger.Debug("XML Trades [" + xmlTrades + "]");

            logger.Info("GetBeans(" + lastTimestamp.ToString("yyyy/MM/dd HH:mm:ss") + ") FIM");

            return(beans);

            //QueryTradesStr1 resp = new QueryTradesStr1();
            //resp.pTradeID = pTradeID.ToString("yyyy/MM/dd HH:mm:ss");
            //resp.QueryTradesStrResult = xmlTrades;

            //return resp;
        }