Esempio n. 1
0
    public PNRData(string searchid, CustomerInfo ci, string rph, string ContextResult, string BookinID)
    {
        //string filePathContext = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_ContextChange-RS.xml");
        //if (File.Exists(filePathContext))
        //{
        //    ContextResult = File.ReadAllText(filePathContext);
        //}
        //else
        //{
        //    ContextResult = XMLRead.ContextChange(searchid);
        //}

        string result = "";
        int    rphl   = rph.ToString().Length;

        if (rphl == 1)
        {
            rph = "0" + rph.ToString();
        }
        string RateBodyRQ      = GetRateDescBodyRQ(rph);
        string PassengerBodyRQ = GetPassengerBodyRQ(ci);
        string HoteResBodyRQ   = GetHotelResBodyRQ(ci, rph);
        string RateRQ          = GetRateDescRQ(ContextResult, RateBodyRQ);

        result = XMLRead.SendQuery(RateRQ);
        XMLRead.SaveXMLFile(RateRQ, result, BookinID + "_RateDesec");
        string PassengerRQ = GetPassengerXMLRQ(result, PassengerBodyRQ);

        result = XMLRead.SendQuery(PassengerRQ);
        XMLRead.SaveXMLFile(RateRQ, result, BookinID + "_PassengerDet");
        string HotelResRq = GetHotelResXMLRQ(result, HoteResBodyRQ);

        result = XMLRead.SendQuery(HotelResRq);
        XMLRead.SaveXMLFile(RateRQ, result, BookinID + "_HotelResDet");
        string EndTransRQ = GetEndTransRQ(result);

        result = XMLRead.SendQuery(EndTransRQ);
        XMLRead.SaveXMLFile(RateRQ, result, BookinID + "_EndTrans");
        string EndTransXML = result;

        Hes = new HotelEndTrans(EndTransXML);

        if (result.ToString() != "")
        {
            DataSet      ds        = new DataSet();
            DataSet      dsSession = new DataSet();
            StringReader se_stream = new StringReader(result);
            dsSession.ReadXml(se_stream);
            string Rq = "";

            if (dsSession.Tables["BinarySecurityToken"] != null)
            {
                DataTable dtBinarySecurityToken = dsSession.Tables["BinarySecurityToken"];
                DataTable dtMessageData         = dsSession.Tables["MessageData"];
                DataTable dtMessageHeader       = dsSession.Tables["MessageHeader"];
                string    timestamp             = DateTime.UtcNow.ToString();
                string    cresult = XMLRead.closession(dtMessageData.Rows[0]["MessageId"].ToString(), timestamp, dtBinarySecurityToken.Rows[0]["BinarySecurityToken_Text"].ToString(), searchid + "_PNREndTrans", XMLRead.pcc, XMLRead.ipcc);
            }
        }
    }
    public PNRDataAj(string searchid, CustomerInfo ci, string rph, string BookinID, string hotelcode, string CurrencyCode, string b2c_idn, string rooms, string Guestdet)
    {
        string ratekey = string.Empty;

        string    cmdtxtrkey = "select HB_RateKey from HotelBooking where Bookingidn=" + BookinID + "";
        DataTable dtrkey     = manage_data.GetDataTable(cmdtxtrkey, manage_data.con);

        if (dtrkey.Rows.Count > 0)
        {
            ratekey = dtrkey.Rows[0]["HB_RateKey"].ToString();
        }
        //// temporarily commented
        //string filePathContext = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_ContextChange-RS.xml");
        //if (File.Exists(filePathContext))
        //{
        //    ContextResult = File.ReadAllText(filePathContext);
        //}
        //else
        //{
        //    ContextResult = XMLRead.ContextChange(searchid);
        //}

        DataTable dtpcc = manage_data.getpccdetails(b2c_idn);

        if (dtpcc.Rows.Count > 0)
        {
            cnphone  = dtpcc.Rows[0]["cust_identifier"].ToString().Substring(0, 3) + "-" + dtpcc.Rows[0]["cust_identifier"].ToString().Substring(3, 3) + "-" + dtpcc.Rows[0]["cust_identifier"].ToString().Substring(6, 4);
            cident   = dtpcc.Rows[0]["cust_identifier"].ToString();
            pcc      = dtpcc.Rows[0]["prv_pcc"].ToString();
            ipcc     = dtpcc.Rows[0]["prv_ipcc"].ToString();
            username = dtpcc.Rows[0]["prv_username"].ToString();
            password = dtpcc.Rows[0]["prv_pwd"].ToString();
        }

        XMLRead.GetPccDetails(b2c_idn);
        string result = "";

        result = XMLRead.ContextChange(searchid + "_" + hotelcode + "_PNR");

        int rphl = rph.ToString().Length;

        if (rphl == 1)
        {
            rph = "0" + rph.ToString();
        }

        //string RateBodyRQ = GetRateDescBodyRQ(rph);
        //string PassengerBodyRQ = GetPassengerBodyRQ(ci, Guestdet);
        string htlbkuri = ConfigurationManager.AppSettings["HotelPortalBookingUri"] != null ? ConfigurationManager.AppSettings["HotelPortalBookingUri"].ToString() : string.Empty;

        if (!string.IsNullOrEmpty(htlbkuri))
        {
            string HoteResBodyRQ = GetHotelResBodyRQ(searchid, ci, rph, rooms, ratekey, BookinID);


            result = XMLRead.SendQuery(HoteResBodyRQ, htlbkuri);


            XMLRead.SaveXMLTextFile(HoteResBodyRQ, result, searchid + "_" + BookinID + "_PNRHotelResDet");



            //searchid = "7430";
            //BookinID = "1918";


            string filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_" + BookinID + "_PNRHotelResDet" + "-RS.xml");
            result = File.ReadAllText(filePathRQ);


            //string RateRQ = GetRateDescRQ(result, RateBodyRQ);

            //result = XMLRead.SendQuery(RateRQ);
            //XMLRead.SaveXMLTextFile(RateRQ, result, searchid + "_" + BookinID + "_PNRRateDesec");

            //string PassengerRQ = GetPassengerXMLRQ(result, PassengerBodyRQ);
            //result = XMLRead.SendQuery(PassengerRQ);
            //XMLRead.SaveXMLTextFile(PassengerRQ, result, searchid + "_" + BookinID + "_PNRPassengerDet");

            //string HotelResRq = GetHotelResXMLRQ(result, HoteResBodyRQ);
            //result = XMLRead.SendQuery(HotelResRq);
            //XMLRead.SaveXMLTextFile(HotelResRq, result, searchid + "_" + BookinID + "_PNRHotelResDet");

            //string EndTransRQ = GetEndTransRQ(result);
            //result = XMLRead.SendQuery(EndTransRQ);
            //XMLRead.SaveXMLTextFile(EndTransRQ, result, searchid + "_" + BookinID + "_PNREndTrans");


            string EndTransXML = result;
            Hes = new HotelEndTrans(EndTransXML, BookinID, filePathRQ);

            ////closing the session

            //if (result.ToString() != "")
            //{
            //    DataSet ds = new DataSet();
            //    DataSet dsSession = new DataSet();
            //    StringReader se_stream = new StringReader(result);
            //    dsSession.ReadXml(se_stream);
            //    string Rq = "";

            //    if (dsSession.Tables["BinarySecurityToken"] != null)
            //    {
            //        DataTable dtBinarySecurityToken = dsSession.Tables["BinarySecurityToken"];
            //        DataTable dtMessageData = dsSession.Tables["MessageData"];
            //        DataTable dtMessageHeader = dsSession.Tables["MessageHeader"];
            //        string timestamp = DateTime.UtcNow.ToString();
            //        string cresult = XMLRead.closession(dtMessageData.Rows[0]["MessageId"].ToString(), timestamp, dtBinarySecurityToken.Rows[0]["BinarySecurityToken_Text"].ToString(), searchid + "_" + BookinID + "_PNR", XMLRead.pcc, XMLRead.ipcc);
            //    }
            //}
        }
    }