/*
         # URL of web service
         #      $this->m_fullURL  = $this->m_baseURL."/OPSSwitchBoardAccount.aspx"."?"."TelNumber=".$this->m_callidnum."&Date=".$this->m_calldt;
         #              <?xml version="1.0" encoding="ISO-8859-1" ?>
         #              <r>
         #                      <usr>0</usr>  ( -1: No existe usuario o no tiene matricula,
         #                                                      -2: Tarjeta caducada
         #                                                      -3: Cuenta no activa
         #                                                      -4: Saldo inferior al mínimo (en este momento 0)
         #                                                       0: Todo ok
         #                                                       1: tarjeta proxima a caducar
         #                                                       2: Saldo superior al minimo pero inferior a un valor )
         #                      <m>2345AAA</m>  (matricula)
         #                      <m2>2345AAA</m2>  (matricula 2)
         #                      <bal>1234</bal>  (saldo en centimos)
         #                      <tn>1234********5678</tn> (tarjeta de credito)
         #              <td>03/12</td>          (fecha caducidad tarjeta MM/YY)
         #              </r>
         #
         #
         */


        protected void Page_Load(object sender, System.EventArgs e)
        {
            string stError = "";
            string stRdo   = "";

            Response.Clear();
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();

            Response.ContentType = "text/xml";

            try
            {
                string strTelNumber = (string)Request.QueryString["TelNumber"];
                //string strFechaOp = (string)Request.QueryString["Date"];
                //bool bSaveOp = (((string)Request.QueryString["SaveOp"])=="1");

                COPSSwitchBoardHelper.GetAccountData(strTelNumber, ref stRdo, ref stError);
                Response.Write(stRdo);
            }
            catch
            {
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string stRdo = "";

            Response.Clear();
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();

            Response.ContentType = "text/xml";

            try
            {
                int iZone = Convert.ToInt32((string)Request.QueryString["Zone"]);
                stRdo = COPSSwitchBoardHelper.GetSectorList(iZone);
                Response.Write(stRdo);
            }
            catch
            {
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            string stError = "";
            string stRdo   = "";

            Response.Clear();
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();

            Response.ContentType = "text/html";

            try
            {
                string strDateTime = "";

                COPSSwitchBoardHelper.GetDateTime(ref strDateTime);
                Response.Write(strDateTime);
            }
            catch
            {
            }
        }
        /*
         *      $this->m_baseURL."/OPSSwitchBoardOperation.aspx"."?"."TelNumber=".$this->m_callidnum."&Date=".$this->m_calldt."&SaveOp=".$SaveOp;
         *
         *      <?xml version="1.0" encoding="ISO-8859-1" ?>
         *      <r>
         *              <y>3</y>  (
         *                              -2: El saldo no es suficiente para realizar la operación  (solo si SaveOp==1)
         *                              -1: No existe usuario o no tiene matricula,
         *                              0: La operacion no es posible
         *                              1: aparcamiento,
         *                                  2: prolongacion
         *                              3: devolucion )
         *              <m>2345AAA</m>  (matricula)
         *              <oper>2</oper>  En caso de amp o dev de dónde es la operación ( 0: NO, 1: ESRO, 2: ESRE )
         *              <ds>120002190809</ds>  (fecha de inicio)
         *              <de>122900180809</de>  (fecha de fin)
         *              <dr>123000190809</dr> (en caso de devolucion fecha final tras devolucion)
         *                      <q>40</q> (cantidad en centimos consumida realmente)
         *                  <tn>1234********5678</tn> (tarjeta de credito)
         *              <td>03/12</td>          (fecha caducidad tarjeta MM/YY)
         *                      <bal>1234</bal>		(saldo después de la operación)
         *      </r>
         *
         */


        protected void Page_Load(object sender, System.EventArgs e)
        {
            string stError = "";
            string stRdo   = "";

            Response.Clear();
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();

            Response.ContentType = "text/xml";

            try
            {
                string strTelNumber = (string)Request.QueryString["TelNumber"];
                string strFechaOp   = (string)Request.QueryString["Date"];
                bool   bSaveOp      = (((string)Request.QueryString["SaveOp"]) == "1");

                string strGroup      = "";
                string strMaxTime    = "";
                string strArticleDef = "";
                string strPlate      = "";

                try
                {
                    strPlate = (string)Request.QueryString["Plate"];
                    if (strPlate == null)
                    {
                        strPlate = "";
                    }
                }
                catch
                {
                    strPlate = "";
                }

                try
                {
                    strGroup = (string)Request.QueryString["Group"];
                    if (strGroup == null)
                    {
                        strGroup = "";
                    }
                }
                catch
                {
                    strGroup = "";
                }

                try
                {
                    strMaxTime = (string)Request.QueryString["MaxTime"];
                    if (strMaxTime == null)
                    {
                        strMaxTime = "-1";
                    }
                }
                catch
                {
                    strMaxTime = "-1";
                }

                try
                {
                    strArticleDef = (string)Request.QueryString["ArticleDef"];
                    if (strArticleDef == null)
                    {
                        strArticleDef = "-1";
                    }
                }
                catch
                {
                    strArticleDef = "-1";
                }


                COPSSwitchBoardHelper.ManageCall(strTelNumber, strPlate, strFechaOp, bSaveOp, strGroup, strArticleDef, strMaxTime, ref stRdo, ref stError);
                Response.Write(stRdo);
            }
            catch
            {
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string stError = "";
            string stRdo   = "";

            Response.Clear();
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();

            Response.ContentType = "text/xml";

            try
            {
                string strTelNumber = (string)Request.QueryString["TelNumber"];
                string strFechaOp   = (string)Request.QueryString["Date"];
                bool   bSaveOp      = (((string)Request.QueryString["SaveOp"]) == "1");
                int    iZone;
                int    iSector;
                int    iSectorId = -1;
                string strPlate  = "";

                try
                {
                    iZone = Convert.ToInt32((string)Request.QueryString["Zone"]);
                }
                catch
                {
                    iZone = -1;
                }

                try
                {
                    iSector = Convert.ToInt32((string)Request.QueryString["Sector"]);
                }
                catch
                {
                    iSector = -1;
                }

                if ((iZone == 0) || (iSector == 0))
                {
                    iZone   = -1;
                    iSector = -1;
                }



                bool bError = false;
                if ((iZone == -1) || (iSector == -1))
                {
                    COPSSwitchBoardHelper.GetLastSector(strTelNumber, strFechaOp, ref strPlate, ref iSectorId);

                    if (strPlate == "")
                    {
                        stRdo  = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
                        stRdo += "<r>";
                        stRdo += "<y>0</y>";
                        stRdo += "</r>";
                        bError = true;
                    }
                    else
                    {
                        if (iSectorId == -1)
                        {
                            stRdo  = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
                            stRdo += "<r>";
                            stRdo += "<y>1</y>";
                            stRdo += "<m>" + strPlate + "</m>";
                            stRdo += "</r>";
                            bError = true;
                        }
                    }
                }
                else
                {
                    iSectorId = COPSSwitchBoardHelper.GetSectorId(iZone, iSector);
                }

                if (!bError)
                {
                    COPSSwitchBoardHelper.ManageCall(strTelNumber, "", strFechaOp, bSaveOp, iSectorId, -1, -1, ref stRdo, ref stError);

                    if ((iZone == -1) || (iSector == -1))
                    {
                        COPSSwitchBoardHelper.GetZoneSector(iSectorId, ref iZone, ref iSector);

                        //añadir la zona y sector a la respuesta
                        //acordarse de añadir el error de retorno del m1 en el xml
                        stRdo = stRdo.Replace("</r>", string.Format("<z>{0}</z><s>{1}</s></r>", iZone, iSector));
                    }
                }
                Response.Write(stRdo);
            }
            catch
            {
            }
        }