protected virtual void OnNewNotify(NewNotifyArg e) { log.Debug("New IVR Notify"); NewNotify(e); }
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); } } }