示例#1
0
        private TravelItinerary.TravelItineraryReadRS getResponseService(string convid, string ipcc, string securitytoken, string RecLoc)
        {
            #region ====== Connection with web service ======

            //itineraryObject.Status = true;
            DateTime dt     = DateTime.UtcNow;
            string   tstamp = dt.ToString("s") + "Z";

            TravelItinerary.MessageHeader msgHeader = new TravelItinerary.MessageHeader();
            msgHeader.ConversationId = convid;          // Put ConversationId in req header

            TravelItinerary.From      from           = new TravelItinerary.From();
            TravelItinerary.PartyId   fromPartyId    = new TravelItinerary.PartyId();
            TravelItinerary.PartyId[] fromPartyIdArr = new TravelItinerary.PartyId[1];
            fromPartyId.Value = "99999";
            fromPartyIdArr[0] = fromPartyId;
            from.PartyId      = fromPartyIdArr;
            msgHeader.From    = from;

            TravelItinerary.To        to           = new TravelItinerary.To();
            TravelItinerary.PartyId   toPartyId    = new TravelItinerary.PartyId();
            TravelItinerary.PartyId[] toPartyIdArr = new TravelItinerary.PartyId[1];
            toPartyId.Value = "123123";
            toPartyIdArr[0] = toPartyId;
            to.PartyId      = toPartyIdArr;
            msgHeader.To    = to;

            msgHeader.CPAId  = ipcc;
            msgHeader.Action = "TravelItineraryReadLLSRQ";
            TravelItinerary.Service service = new TravelItinerary.Service();
            service.Value     = "Travel Itinerary Read";
            msgHeader.Service = service;


            TravelItinerary.MessageData msgData = new TravelItinerary.MessageData();
            msgData.MessageId     = "mid:[email protected]";
            msgData.Timestamp     = tstamp;
            msgHeader.MessageData = msgData;
            TravelItinerary.Security1 security = new TravelItinerary.Security1();
            security.BinarySecurityToken = securitytoken;       // Put BinarySecurityToken in req header

            //Create the request object req and the value for the IPCC in the payload of the request.
            string GEAServices = ConfigurationManager.AppSettings["ServiciosGEA"];

            TravelItinerary.TravelItineraryReadRQMessagingDetails messagingDetails = new TravelItinerary2.TravelItineraryReadRQMessagingDetails();

            messagingDetails.Transaction         = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction[1];
            messagingDetails.Transaction[0]      = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
            messagingDetails.Transaction[0].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.PNR;


            //for (int i = 0; i < GEAServices.Split('|').Length; i++)
            //{
            //    if (GEAServices.Split('|')[i] == "HOT")
            //    {
            //        messagingDetails.Transaction[i] = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
            //        messagingDetails.Transaction[i].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.HOT;
            //    }
            //    else if (GEAServices.Split('|')[i] == "CAR")
            //    {
            //        messagingDetails.Transaction[i] = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
            //        messagingDetails.Transaction[i].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.CAR;
            //    }
            //}

            TravelItinerary.TravelItineraryReadRQ req = new TravelItinerary.TravelItineraryReadRQ();
            //TravelItinerary.OTA_TravelItineraryReadRQPOS pos = new TravelItinerary.OTA_TravelItineraryReadRQPOS();
            //TravelItinerary.OTA_TravelItineraryReadRQPOSSource source = new TravelItinerary.OTA_TravelItineraryReadRQPOSSource();
            //source.PseudoCityCode = ipcc;
            //pos.Source = source;
            //req.POS = pos;
            req.TimeStamp          = DateTime.Now;
            req.TimeStampSpecified = true;
            req.MessagingDetails   = messagingDetails;
            req.Version            = "2.2.0"; // Specify the service version

            //TravelItinerary.OTA_TravelItineraryReadRQTPA_Extensions tpa = new TravelItinerary.OTA_TravelItineraryReadRQTPA_Extensions();
            //TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetails msj = new TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetails();
            //TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetailsMDRSubset code = new TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetailsMDRSubset();

            //code.Code = "PN43";
            //msj.MDRSubset = code;
            //tpa.MessagingDetails = msj;
            //req.TPA_Extensions = tpa;

            TravelItinerary.TravelItineraryReadRQUniqueID uniqueID = new TravelItinerary.TravelItineraryReadRQUniqueID();
            uniqueID.ID  = RecLoc;
            req.UniqueID = uniqueID;


            TravelItinerary.TravelItineraryReadService serviceObj = new TravelItinerary.TravelItineraryReadService();
            serviceObj.MessageHeaderValue = msgHeader;
            serviceObj.Security           = security;

            //System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(req.GetType());
            //System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\RESP\otatravelItineraryHotelReq " + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xml");
            //writer.Serialize(file, req);
            //file.Close();


            //Call the service and assign the response object.
            TravelItinerary.TravelItineraryReadRS resp = serviceObj.TravelItineraryReadRQ(req);         // Send the request.

            //Retrieve data from the resp object, such as flight number and airline code, and display
            //it on standard output. the client can retrieve other data from the response the same wayi.

            #endregion
            return(resp);
        }
示例#2
0
        public List <OTATravelItineraryObjectHotel> getHotelValues(string convid, string ipcc, string securitytoken, string RecLoc, string sixReceived, string agente, string mail, string RFC, List <string> lstcommission, string PNRDataHotel, string PNRDataCar)
        {
            List <OTATravelItineraryObjectHotel> myObect         = new List <OTATravelItineraryObjectHotel>();
            OTATravelItineraryObjectHotel        itineraryObject = null;
            string errorMessage = string.Empty;

            try
            {
                #region ====== Connection with web service ======

                //itineraryObject.Status = true;
                DateTime dt     = DateTime.UtcNow;
                string   tstamp = dt.ToString("s") + "Z";

                TravelItinerary.MessageHeader msgHeader = new TravelItinerary.MessageHeader();
                msgHeader.ConversationId = convid;              // Put ConversationId in req header

                TravelItinerary.From      from           = new TravelItinerary.From();
                TravelItinerary.PartyId   fromPartyId    = new TravelItinerary.PartyId();
                TravelItinerary.PartyId[] fromPartyIdArr = new TravelItinerary.PartyId[1];
                fromPartyId.Value = "99999";
                fromPartyIdArr[0] = fromPartyId;
                from.PartyId      = fromPartyIdArr;
                msgHeader.From    = from;

                TravelItinerary.To        to           = new TravelItinerary.To();
                TravelItinerary.PartyId   toPartyId    = new TravelItinerary.PartyId();
                TravelItinerary.PartyId[] toPartyIdArr = new TravelItinerary.PartyId[1];
                toPartyId.Value = "123123";
                toPartyIdArr[0] = toPartyId;
                to.PartyId      = toPartyIdArr;
                msgHeader.To    = to;

                msgHeader.CPAId  = ipcc;
                msgHeader.Action = "TravelItineraryReadLLSRQ";
                TravelItinerary.Service service = new TravelItinerary.Service();
                service.Value     = "Travel Itinerary Read";
                msgHeader.Service = service;


                TravelItinerary.MessageData msgData = new TravelItinerary.MessageData();
                msgData.MessageId     = "mid:[email protected]";
                msgData.Timestamp     = tstamp;
                msgHeader.MessageData = msgData;
                TravelItinerary.Security1 security = new TravelItinerary.Security1();
                security.BinarySecurityToken = securitytoken;   // Put BinarySecurityToken in req header

                //Create the request object req and the value for the IPCC in the payload of the request.
                string GEAServices = ConfigurationManager.AppSettings["ServiciosGEA"];

                TravelItinerary.TravelItineraryReadRQMessagingDetails messagingDetails = new TravelItinerary2.TravelItineraryReadRQMessagingDetails();

                messagingDetails.Transaction         = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction[1];
                messagingDetails.Transaction[0]      = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
                messagingDetails.Transaction[0].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.PNR;


                //for (int i = 0; i < GEAServices.Split('|').Length; i++)
                //{
                //    if (GEAServices.Split('|')[i] == "HOT")
                //    {
                //        messagingDetails.Transaction[i] = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
                //        messagingDetails.Transaction[i].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.HOT;
                //    }
                //    else if (GEAServices.Split('|')[i] == "CAR")
                //    {
                //        messagingDetails.Transaction[i] = new TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransaction();
                //        messagingDetails.Transaction[i].Code = TravelItinerary2.TravelItineraryReadRQMessagingDetailsTransactionCode.CAR;
                //    }
                //}

                TravelItinerary.TravelItineraryReadRQ req = new TravelItinerary.TravelItineraryReadRQ();
                //TravelItinerary.OTA_TravelItineraryReadRQPOS pos = new TravelItinerary.OTA_TravelItineraryReadRQPOS();
                //TravelItinerary.OTA_TravelItineraryReadRQPOSSource source = new TravelItinerary.OTA_TravelItineraryReadRQPOSSource();
                //source.PseudoCityCode = ipcc;
                //pos.Source = source;
                //req.POS = pos;
                req.TimeStamp          = DateTime.Now;
                req.TimeStampSpecified = true;
                req.MessagingDetails   = messagingDetails;
                req.Version            = "2.2.0"; // Specify the service version

                //TravelItinerary.OTA_TravelItineraryReadRQTPA_Extensions tpa = new TravelItinerary.OTA_TravelItineraryReadRQTPA_Extensions();
                //TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetails msj = new TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetails();
                //TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetailsMDRSubset code = new TravelItinerary.OTA_TravelItineraryReadRQTPA_ExtensionsMessagingDetailsMDRSubset();

                //code.Code = "PN43";
                //msj.MDRSubset = code;
                //tpa.MessagingDetails = msj;
                //req.TPA_Extensions = tpa;

                TravelItinerary.TravelItineraryReadRQUniqueID uniqueID = new TravelItinerary.TravelItineraryReadRQUniqueID();
                uniqueID.ID  = RecLoc;
                req.UniqueID = uniqueID;


                TravelItinerary.TravelItineraryReadService serviceObj = new TravelItinerary.TravelItineraryReadService();
                serviceObj.MessageHeaderValue = msgHeader;
                serviceObj.Security           = security;

                //System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(req.GetType());
                //System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\RESP\otatravelItineraryHotelReq " + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xml");
                //writer.Serialize(file, req);
                //file.Close();


                //Call the service and assign the response object.
                TravelItinerary.TravelItineraryReadRS resp = serviceObj.TravelItineraryReadRQ(req);             // Send the request.

                XmlDocument doc = Serialize(resp);
                doc = Serialize(req);

                //Retrieve data from the resp object, such as flight number and airline code, and display
                //it on standard output. the client can retrieve other data from the response the same wayi.

                #endregion

                string typeCar     = string.Empty;;
                string codeCityIti = string.Empty;
                string codeCityDB  = string.Empty;
                chainCodeCancel = string.Empty;
                TimeSpan ts = new TimeSpan();

                //////////////////////////////////////////////////////////////
                //Validacion de errores en al conexion del web service//
                //////////////////////////////////////////////////////////////
                if (resp.ApplicationResults.Error == null)
                {
                    //////////////////////////////////////////////////////////////
                    //Se obtine infomacion del PNR//
                    //////////////////////////////////////////////////////////////

                    if (resp.TravelItinerary.ItineraryInfo.ReservationItems != null)
                    {
                        for (int i = 0; i < resp.TravelItinerary.ItineraryInfo.ReservationItems.Length; i++)
                        {
                            itineraryObject = new OTATravelItineraryObjectHotel();
                            itineraryObject.CancelNumberList = new List <string>();
                            getNumCancelRecClose(resp, itineraryObject, string.IsNullOrEmpty(resp.TravelItinerary.ItineraryRef.ID) ? RecLoc : resp.TravelItinerary.ItineraryRef.ID);

                            string commision = string.Empty;

                            if (lstcommission.Count > 1)
                            {
                                commision = lstcommission[i];
                            }
                            else
                            {
                                commision = "10";
                            }

                            itineraryObject.Prov_Direct_Pay = true;

                            string dk = string.Empty;

                            dk = resp.TravelItinerary.ItineraryRef.CustomerIdentifier.ToUpper();

                            string phone = string.Empty;

                            foreach (TravelItinerary2.TravelItineraryReadRSTravelItineraryCustomerInfoContactNumber contactNumber in resp.TravelItinerary.CustomerInfo.ContactNumbers)
                            {
                                if (!string.IsNullOrEmpty(phone))
                                {
                                    phone = string.Concat(phone, ", ");
                                }
                                phone = string.Concat(phone, contactNumber.Phone);
                            }

                            string passengerType = string.Empty;
                            int    passengerNum  = 0;

                            for (int cusNum = 0; cusNum < resp.TravelItinerary.CustomerInfo.PersonName.Length; cusNum++)
                            {
                                if (!string.IsNullOrEmpty(resp.TravelItinerary.CustomerInfo.PersonName[cusNum].PassengerType))
                                {
                                    if (resp.TravelItinerary.CustomerInfo.PersonName[cusNum].PassengerType.Length > 0)
                                    {
                                        passengerType = "|" + resp.TravelItinerary.CustomerInfo.PersonName[cusNum].PassengerType;
                                        passengerNum  = cusNum + 1;
                                    }
                                    else
                                    {
                                        passengerType = string.Empty; //numero de pasajeros
                                    }
                                }
                                else
                                {
                                    passengerType = string.Empty;
                                }
                            }

                            string passengerName = string.Empty;
                            string title         = string.Empty;

                            divide = resp.TravelItinerary.CustomerInfo.PersonName[0].GivenName.Split("".ToCharArray());

                            if (divide.Length > 1)
                            {
                                passengerName = resp.TravelItinerary.CustomerInfo.PersonName[0].GivenName.Substring(0, resp.TravelItinerary.CustomerInfo.PersonName[0].GivenName.Length - 3);
                                title         = divide[divide.Length - 1];
                            }
                            else
                            {
                                passengerName = resp.TravelItinerary.CustomerInfo.PersonName[0].GivenName;
                                title         = string.Empty;
                            }

                            string passengerSurname = string.Empty;

                            passengerSurname = resp.TravelItinerary.CustomerInfo.PersonName[0].Surname;

                            if (resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel != null && string.IsNullOrEmpty(PNRDataHotel))
                            {
                                if (resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel.Status == "HK" || resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel.Status == "GK")
                                {
                                    itineraryObject = GetHotel(resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel, commision, dk, phone, RFC, agente, mail,
                                                               sixReceived, passengerType, passengerNum, passengerName, title, passengerSurname, itineraryObject.Status, itineraryObject.CancelNumberList);
                                    itineraryObject.Record = string.IsNullOrEmpty(resp.TravelItinerary.ItineraryRef.ID) ? string.Concat(RecLoc, "|HOTEL") : string.Concat(resp.TravelItinerary.ItineraryRef.ID, "|HOTEL");
                                }
                                else
                                {
                                    errorMessage = string.Concat("Error MyCTS: Segmento ", resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel.SegmentNumber, " en status ", resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel.Status);
                                }
                            }
                            else if (resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle != null && string.IsNullOrEmpty(PNRDataCar))
                            {
                                if (resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle.Status == "HK" || resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle.Status == "GK")
                                {
                                    itineraryObject = GetCars(resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle, commision, dk, phone, RFC, agente, mail,
                                                              sixReceived, passengerType, passengerNum, passengerName, title, passengerSurname, itineraryObject.Status, itineraryObject.CancelNumberList);
                                    itineraryObject.Record = string.IsNullOrEmpty(resp.TravelItinerary.ItineraryRef.ID) ? string.Concat(RecLoc, "|CAR") : string.Concat(resp.TravelItinerary.ItineraryRef.ID, "|CAR");
                                }
                                else
                                {
                                    errorMessage = string.Concat("Error MyCTS: Segmento ", resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle.SegmentNumber, " en status ", resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle.Status);
                                }
                            }
                            else
                            {
                                if (itineraryObject != null)
                                {
                                    if (itineraryObject.CancelNumberList.Count < 0)                     //cuando el records es nuevo y no tiene cancelaciones
                                    {
                                        if (!string.IsNullOrEmpty(itineraryObject.Confirmation_Number)) //valida si la clave de confirmacion del hotel no fue asignada al segmento

                                        {
                                            myObect.Add(itineraryObject);
                                        }
                                    }
                                    else
                                    if (myObect.Count == 0)    //itinerario basio solo para leera el estatus y los numeros de cancelacion
                                    {
                                        if (!string.IsNullOrEmpty(itineraryObject.Confirmation_Number))
                                        {
                                            myObect.Add(itineraryObject);
                                        }
                                    }
                                }
                            }

                            if (resp.TravelItinerary.ItineraryInfo.ReservationItems.Length > 0 &&//cuando el record tiene cancelaciones
                                resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Hotel != null)
                            {
                                if (!string.IsNullOrEmpty(itineraryObject.Confirmation_Number))
                                {
                                    myObect.Add(itineraryObject);
                                }
                            }
                            else if (resp.TravelItinerary.ItineraryInfo.ReservationItems.Length > 0 &&//cuando el record tiene cancelaciones
                                     resp.TravelItinerary.ItineraryInfo.ReservationItems[i].Vehicle != null)
                            {
                                if (!string.IsNullOrEmpty(itineraryObject.Confirmation_Number))
                                {
                                    myObect.Add(itineraryObject);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (TravelItinerary2.ProblemInformation error in resp.ApplicationResults.Error)
                    {
                        foreach (TravelItinerary2.SystemSpecificResults systemSpecificResults in error.SystemSpecificResults)
                        {
                            foreach (TravelItinerary2.MessageCondition message in systemSpecificResults.Message)
                            {
                                if (!string.IsNullOrEmpty(errorMessage))
                                {
                                    errorMessage = string.Concat(errorMessage, ", ");
                                }
                                else
                                {
                                    errorMessage = "Error MyCTS: ";
                                }
                                errorMessage = string.Concat(errorMessage, message.Value);
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(errorMessage))
                {
                    itineraryObject = new OTATravelItineraryObjectHotel();
                    itineraryObject.errorWSSabre = errorMessage;
                    myObect.Add(itineraryObject);
                }
            }
            catch (Exception e)
            {
                itineraryObject = new OTATravelItineraryObjectHotel();

                itineraryObject.errorWSSabre = string.Concat("Error MyCTS: ", e.ToString());
                myObect.Add(itineraryObject);
            }

            return(myObect);
        }