Exemple #1
0
 public void onClearCall()
 {
     log.Debug("------onClearCall Event--------");
     trans.mne = new MensajeNegocio();
     trans     = new Transaction();
     dg        = new DataGadget();
 }
Exemple #2
0
 private void clearCall()
 {
     onClearCall();
     dg       = new DataGadget();
     dg.state = "READY";
     ie       = null;
     tx       = null;
     count    = 0;
     txCount  = 0;
     reqs     = 0;
 }
Exemple #3
0
        public HttpBridge(int notReadyTime, int afterEndIVRTime, CRMBridge b)
        {
            js       = new JavaScriptSerializer();
            dg       = new DataGadget();
            dg.state = "READY";
            this.b   = b;
            count    = 0;
            txCount  = 0;
            AddrIP aip = new AddrIP();

            localIP              = aip.getIPAddresss();
            this.notReadyTime    = notReadyTime;
            this.afterEndIVRTime = afterEndIVRTime;
            string protocol = System.Configuration.ConfigurationSettings.AppSettings["protocol"];

            log.Info("Protocolo: " + protocol);
            string certHash = System.Configuration.ConfigurationSettings.AppSettings["certHash"];

            log.Debug("Local IP: " + localIP);
            log.Info("Tiempo de espera al cliente: " + notReadyTime);
            log.Info("Tiempo de espera al finalizar IVR: " + afterEndIVRTime);

            listener = new HttpListener();
            //URL's for pci
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/sls/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/dvl/");
            listener.Prefixes.Add(protocol + "://" + localIP + ":8880/pci_bridge/sls/");
            listener.Prefixes.Add(protocol + "://" + localIP + ":8880/pci_bridge/dvl/");
            //URL's for Gadget
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/get-di/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/get-di/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/dialog/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/tx/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/clear/");
            //URL's for IVR
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/ivr/");
            listener.Prefixes.Add(protocol + "://127.0.0.1:8880/pci_bridge/ivr-end/");
            listener.Prefixes.Add(protocol + "://" + localIP + ":8880/pci_bridge/ivr/");
            listener.Prefixes.Add(protocol + "://" + localIP + ":8880/pci_bridge/ivr-end/");

            dg       = new DataGadget();
            dg.state = "READY";
        }
Exemple #4
0
 public Transaction NewRequestEvent(NewRequestArg e)
 {
     dg = new DataGadget();
     log.Debug("---------------   Request parameters for " + (e.param.op == 1 ? "Venta" : "Devolución") + " -----------------");
     dg.op    = e.param.op;
     dg.ip    = e.param.ip;
     dg.state = e.param.state;
     if (dg.op == 1)
     {
         log.Debug("nor: " + e.param.nor);
         log.Debug("bnc: " + e.param.bnc);
         log.Debug("mnt: " + e.param.mnt);
         log.Debug("loc: " + e.param.loc);
         log.Debug("arm: " + e.param.arm);
         if (e.param.nor == "")
         {
             throw new NullFieldException("Número de orden vacio.");
         }
         else
         {
             dg.nor = e.param.nor;
         }
         if (e.param.bnc == "")
         {
             throw new NullFieldException("Banco vacio.");
         }
         else
         {
             dg.bnc = e.param.bnc;
         }
         if (e.param.mnt == "")
         {
             throw new NullFieldException("Monto vacio.");
         }
         else
         {
             dg.mnt = e.param.mnt;
         }
         if (e.param.loc == "")
         {
             throw new NullFieldException("Localidad vacia.");
         }
         else
         {
             dg.loc = e.param.loc;
         }
         dg.arm    = e.param.arm;
         trans.nor = dg.nor;
         trans.mnt = dg.mnt;
         trans.mne = new MensajeNegocio();
     }
     else
     {
         log.Debug("nor: " + e.param.nor);
         log.Debug("tct: " + e.param.tct);
         log.Debug("mnt: " + e.param.mnt);
         if (e.param.nor == "")
         {
             throw new NullFieldException("Número de orden vacio.");
         }
         else
         {
             dg.nor = e.param.nor;
         }
         if (e.param.tct == "")
         {
             throw new NullFieldException("Número de tarjeta trunco vacio.");
         }
         else
         {
             dg.tct = e.param.tct;
         }
         if (e.param.mnt == "")
         {
             throw new NullFieldException("Monto vacio.");
         }
         else
         {
             dg.mnt = e.param.mnt;
         }
         trans.nor = dg.nor;
         trans.mnt = dg.mnt;
         trans.mne = new MensajeNegocio();
     }
     tr             = new Cronos(timeResponse);
     tr.onFinished += new Cronos.Finish(this.onTrTimeFinished);
     log.Debug("Inicia el conteo");
     tr.start();
     return(trans);
 }
Exemple #5
0
        private void processRequest(object ctx)
        {
            var context = ctx as HttpListenerContext;
            HttpListenerRequest  request  = context.Request;
            HttpListenerResponse response = context.Response;
            string        JSONstring      = "";
            NewRequestArg e     = new NewRequestArg();
            Transaction   trans = new Transaction();

            try
            {
                setAccessControlHeaders(response);

                response.ContentType = "application/json";

                bReq = getRequestContent(request);
                if (bReq != "" && !bReq.Contains("cid"))
                {
                    log.Debug("Body Request: " + bReq);
                }

                if ((request.RawUrl.Contains("dvl") || request.RawUrl.Contains("sls")) && dg.nor != null && dg.nor != "")
                {
                    if ((request.RawUrl.Contains("sls") || request.RawUrl.Contains("dvl")) && !bReq.Contains(dg.nor.Trim()))
                    {
                        throw new InProgressException("Una transacción se encuentra en progreso.");
                    }
                }
                if (bReq.Trim() != "" && !request.RawUrl.Contains("ivr"))
                {
                    dg    = js.Deserialize <DataGadget>(bReq);
                    dg.ip = localIP;
                    if (dg.mnt != null && dg.mnt != "")
                    {
                        dg.mnt = Amounts.validaMonto(dg.mnt);
                    }
                }
                if (request.RawUrl.Contains("get-di"))
                {
                    if (b.dg != null)
                    {
                        dg = b.dg;
                    }
                    JSONstring = js.Serialize(dg);
                }
                else if (request.RawUrl.Contains("tx"))
                {
                    log.Debug("Se ha iniciado la TR al IVR");
                    JSONstring = js.Serialize(dg);
                    dg.state   = "NotReady";
                    b.setState(dg.state);
                }
                else if (request.RawUrl.Contains("ivr-end"))
                {
                    log.Debug("Se ha terminado la llamada en el IVR");
                    JSONstring = "{\"ERR_CODE\":0, \"ERR_DESC\":\"SUCCESS\"}";
                    dg.state   = "Waiting";
                    b.setState(dg.state);
                }
                else if (request.RawUrl.Contains("ivr"))
                {
                    log.Debug("Notificacion enviada por el IVR");
                    IVRResult    ivr = js.Deserialize <IVRResult>(bReq);
                    NewNotifyArg n   = new NewNotifyArg();
                    n.param = ivr;
                    OnNewNotify(n);
                    dg.mne     = ivr.mne;
                    JSONstring = "{\"ERR_CODE\":0, \"ERR_DESC\":\"SUCCESS\"}";
                }
                else if (request.RawUrl.Contains("clear"))
                {
                    log.Debug("Se ha Enviado un Clear");
                    if (b.tr != null)
                    {
                        if (b.tr.alive)
                        {
                            b.tr.stop();
                            b.tr = null;
                        }
                    }
                    Thread.Sleep(1500);
                    clearCall();
                    JSONstring = "{\"ERR_CODE\":0, \"ERR_DESC\":\"SUCCESS\"}";
                }
                else if (request.RawUrl.Contains("sls"))
                {
                    if (reqs > 0)
                    {
                        onUpdateTrans();
                    }
                    log.Debug("Se reciben datos de venta");
                    dg.op    = 1;
                    dg.state = "OnCall";
                    dg.cid   = dialog;
                    e.param  = dg;
                    reqs++;
                    trans      = OnNewRequest(e);
                    JSONstring = js.Serialize(trans);
                    reqs       = 0;
                }
                else if (request.RawUrl.Contains("dvl"))
                {
                    if (reqs > 0)
                    {
                        onUpdateTrans();
                    }
                    log.Debug("Se reciben datos de reembolso");
                    dg.op    = 2;
                    dg.state = "OnCall";
                    dg.cid   = dialog;
                    e.param  = dg;
                    reqs++;
                    trans      = OnNewRequest(e);
                    JSONstring = js.Serialize(trans);
                    JSONstring = JSONstring.Replace(",\"pro\":null,", ",");
                    JSONstring = JSONstring.Replace(",\"trx\":null,", ",");
                    reqs       = 0;
                }
                else if (request.RawUrl.Contains("dialog"))
                {
                    log.Debug("Receiving Dialog...");
                    dialog     = dg.cid;
                    JSONstring = "{\"ERR_CODE\":0, \"ERR_DESC\":\"SUCCESS\"}";
                }

                if (!request.RawUrl.Contains("get-di"))
                {
                    log.Debug("Response sended:" + JSONstring);
                }
                sendResponse(response, JSONstring);
            }
            catch (Exception ex)
            {
                if (ex.Message != "La operación de E/S se anuló por una salida de subproceso o por una solicitud de aplicación")
                {
                    log.Error(ex.Message);
                    dg                 = js.Deserialize <DataGadget>(bReq.Replace("\"mnt\":\"\"", "\"mnt\":\"0.00\""));
                    trans.mne          = new MensajeNegocio();
                    trans.mne.ERR_CODE = ex is InvalidDecimalException ? -2 : (ex is NullFieldException ? -3 : (ex is InProgressException ? -4 : -1));
                    trans.mne.ERR_DESC = "An exception has occurred: " + ex.Message;
                    trans.mne.msg      = "ERROR";
                    trans.fec          = DateTime.Now.ToString("yyyyMMdd");
                    trans.hor          = DateTime.Now.ToString("HH:mm:ss");
                    trans.mnt          = dg.mnt;
                    JSONstring         = js.Serialize(trans);
                    log.Debug("Response sended:" + JSONstring);
                    sendResponse(response, JSONstring);
                }
            }
        }