コード例 #1
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <PingRQResponse> OTA_PingRQ(string usernameAuthenticate, string passwordAuthenticate)
        {
            PingRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_PingRQ body = new OTA_PingRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, EchoData = "good echo"
                };

                //
                // Send an asynchronous ping request.
                //

                response = await service.PingRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                //
                // Add a single error block to the response with a processing exception in case of an unusual error condition.
                //

                response                  = new PingRQResponse();
                response.OTA_PingRS       = new OTA_PingRS();
                response.OTA_PingRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }
コード例 #2
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <ReadRQResponse> OTA_ReadRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, string hotelCode, ResStatus resStatus)
        {
            ReadRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_ReadRQ body = new OTA_ReadRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.            */, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID)
                };

                OTA_ReadRQReadRequests readRequests = new OTA_ReadRQReadRequests();
                OTA_ReadRQReadRequestsHotelReadRequest hotelReadRequest = new OTA_ReadRQReadRequestsHotelReadRequest()
                {
                    HotelCode = hotelCode
                };
                readRequests.Items = new object[] { hotelReadRequest };

                OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria selectionCriteria = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria()
                {
                    SelectionType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered, SelectionTypeSpecified = true                                                                                                                                         /* Must be set to true, or ReadRQ returns an error.*/
                };

                if (resStatus != ResStatus.All)
                {
                    selectionCriteria.ResStatus = resStatus.ToString();
                }

                hotelReadRequest.SelectionCriteria = selectionCriteria;
                body.ReadRequests = readRequests;

                //
                // Send a retrieve reservations request.
                //

                response = await service.ReadRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_NotifReportRQ arguments were not set up properly causing a null reference exception.");
                response = new ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }
コード例 #3
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <HotelRateAmountNotifRQResponse> OTA_HotelRateAmountNotifRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, RateAmountMessages rateAmountMessages)
        {
            HotelRateAmountNotifRQResponse response = null;

            try
            {
                PmsXchangeServiceClient    service = new AsyncServiceConnection().service;
                OTA_HotelRateAmountNotifRQ body    = new OTA_HotelRateAmountNotifRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID), RateAmountMessages = new OTA_HotelRateAmountNotifRQRateAmountMessages()
                };
                body.RateAmountMessages.HotelCode         = rateAmountMessages.HotelCode;
                body.RateAmountMessages.RateAmountMessage = new RateAmountMessageType[rateAmountMessages.RateAmountMessageNodeList.Count];

                //
                // IMPORTANT NOTE:
                //  There was a slight error made in filling out the body elements for this request.  I delegted the bad code
                //  and left this framework.  Use thde codel in the OTA_HotelAvailNotifR API as a model to complete it.

                /*
                 * int index = 0;
                 *
                 * foreach (RateAmountMessages.RateAmountMessage rAM in rateAmountMessages.RateAmountMessageNodeList)
                 * {
                 * }
                 */

                //
                // Send rates update.
                //

                response = await service.HotelRateAmountNotifRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_HotelRateAmountNotifRQ arguments were not set up properly causing a null reference exception.");
                response = new HotelRateAmountNotifRQResponse();
                response.OTA_HotelRateAmountNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelRateAmountNotifRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new HotelRateAmountNotifRQResponse();
                response.OTA_HotelRateAmountNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelRateAmountNotifRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }
コード例 #4
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <HotelAvailNotifRQResponse> OTA_HotelAvailNotifRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, AvailStatusMessages availStatusMessages)
        {
            HotelAvailNotifRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_HotelAvailNotifRQ body = new OTA_HotelAvailNotifRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID), AvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages()
                };
                body.AvailStatusMessages.HotelCode          = availStatusMessages.HotelCode;
                body.AvailStatusMessages.AvailStatusMessage = new AvailStatusMessageType[availStatusMessages.AvailStatusMessageNodeList.Count];

                int index = 0;

                foreach (AvailStatusMessages.AvailStatusMessage aSM in availStatusMessages.AvailStatusMessageNodeList)
                {
                    AvailStatusMessageType bSM = new AvailStatusMessageType()
                    {
                        StatusApplicationControl = new StatusApplicationControlType()
                    };
                    bSM.StatusApplicationControl.Start         = aSM.StatusApplicationControlNode.Start;
                    bSM.StatusApplicationControl.End           = aSM.StatusApplicationControlNode.End;
                    bSM.StatusApplicationControl.RatePlanCode  = aSM.StatusApplicationControlNode.RatePlanCode;
                    bSM.StatusApplicationControl.InvTypeCode   = aSM.StatusApplicationControlNode.InvTypeCode;
                    bSM.StatusApplicationControl.Mon           = aSM.StatusApplicationControlNode.Mon;
                    bSM.StatusApplicationControl.Tue           = aSM.StatusApplicationControlNode.Tue;
                    bSM.StatusApplicationControl.Weds          = aSM.StatusApplicationControlNode.Weds;
                    bSM.StatusApplicationControl.Thur          = aSM.StatusApplicationControlNode.Thur;
                    bSM.StatusApplicationControl.Fri           = aSM.StatusApplicationControlNode.Fri;
                    bSM.StatusApplicationControl.Sat           = aSM.StatusApplicationControlNode.Sat;
                    bSM.StatusApplicationControl.Sun           = aSM.StatusApplicationControlNode.Sun;
                    bSM.StatusApplicationControl.MonSpecified  = true;
                    bSM.StatusApplicationControl.TueSpecified  = true;
                    bSM.StatusApplicationControl.WedsSpecified = true;
                    bSM.StatusApplicationControl.ThurSpecified = true;
                    bSM.StatusApplicationControl.FriSpecified  = true;
                    bSM.StatusApplicationControl.SatSpecified  = true;
                    bSM.StatusApplicationControl.SunSpecified  = true;

                    bSM.BookingLimit = aSM.BookingLimit;

                    if (aSM.LengthsOfStayNode != null)
                    {
                        bSM.LengthsOfStay = new LengthsOfStayType();
                        bSM.LengthsOfStay.LengthOfStay = new LengthsOfStayTypeLengthOfStay[aSM.LengthsOfStayNode.LengthOfStayNodeList.Count];

                        int indexLS = 0;

                        foreach (var lOS in aSM.LengthsOfStayNode.LengthOfStayNodeList)
                        {
                            bSM.LengthsOfStay.LengthOfStay[indexLS] = new LengthsOfStayTypeLengthOfStay();
                            bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageTypeSpecified = true;
                            if (lOS.MinMaxMessageType == "SetMinLOS")
                            {
                                bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageType = LengthsOfStayTypeLengthOfStayMinMaxMessageType.SetMinLOS;
                            }
                            else
                            {
                                bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageType = LengthsOfStayTypeLengthOfStayMinMaxMessageType.SetMaxLOS;
                            }
                            bSM.LengthsOfStay.LengthOfStay[indexLS++].Time = lOS.Time;
                        }
                    }

                    if (aSM.StatusApplicationControlNode.DestinationSystemCodesNode != null)
                    {
                        bSM.StatusApplicationControl.DestinationSystemCodes = new DestinationSystemCodesTypeDestinationSystemCode[aSM.StatusApplicationControlNode.DestinationSystemCodesNode.DestinationSystemCodeNodeList.Count];

                        int indexDC = 0;

                        foreach (var dC in aSM.StatusApplicationControlNode.DestinationSystemCodesNode.DestinationSystemCodeNodeList)
                        {
                            bSM.StatusApplicationControl.DestinationSystemCodes[indexDC]         = new DestinationSystemCodesTypeDestinationSystemCode();
                            bSM.StatusApplicationControl.DestinationSystemCodes[indexDC++].Value = dC.InnerText;
                        }
                    }

                    if (aSM.RestricitionStatusNode != null)
                    {
                        bSM.RestrictionStatus = new AvailStatusMessageTypeRestrictionStatus();

                        if (aSM.RestricitionStatusNode.Status == "Open")
                        {
                            bSM.RestrictionStatus.Status          = AvailabilityStatusType.Open;
                            bSM.RestrictionStatus.StatusSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Status == "Close")
                        {
                            bSM.RestrictionStatus.Status          = AvailabilityStatusType.Close;
                            bSM.RestrictionStatus.StatusSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Restriction == "Arrival")
                        {
                            bSM.RestrictionStatus.Restriction          = RatePlanTypeRestrictionStatusRestriction.Arrival;
                            bSM.RestrictionStatus.RestrictionSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Restriction == "Departure")
                        {
                            bSM.RestrictionStatus.Restriction          = RatePlanTypeRestrictionStatusRestriction.Departure;
                            bSM.RestrictionStatus.RestrictionSpecified = true;
                        }
                    }

                    body.AvailStatusMessages.AvailStatusMessage[index++] = bSM;
                }

                //
                // Send availability update.
                //

                response = await service.HotelAvailNotifRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_HotelAvailNotifRQ arguments were not set up properly causing a null reference exception.");
                response = new HotelAvailNotifRQResponse();
                response.OTA_HotelAvailNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelAvailNotifRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new HotelAvailNotifRQResponse();
                response.OTA_HotelAvailNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelAvailNotifRS.Items = new object[] { ProcessingException(ex) };
            }


            return(response);
        }
コード例 #5
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <NotifReportRQResponse> OTA_NotifReportRQ(string usernameAuthenticate, string passwordAuthenticate, ReservationError resError, string resStatus, DateTime dateTimeStamp, string msgID, string resIDPMS)
        {
            NotifReportRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_NotifReportRQ body = new OTA_NotifReportRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.            */, TimeStamp = DateTime.Now, TimeStampSpecified = true
                };
                if (resError == null)
                {
                    body.Items = new object[] { new SuccessType() };
                }
                else
                {
                    ErrorType errorType = API.CreateErrorType(resError.err, resError.ewt, resError.errorText);

                    ErrorsType  errors = new ErrorsType();
                    ErrorType[] error  = { errorType };
                    errors.Error = error;

                    body.Items = new object[] { errors };
                }

                body.NotifDetails = new OTA_NotifReportRQNotifDetails();
                body.NotifDetails.HotelNotifReport = new OTA_NotifReportRQNotifDetailsHotelNotifReport();
                OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservations hotelReservations = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservations();
                body.NotifDetails.HotelNotifReport.Item = hotelReservations;

                OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation[] hotelReservationList = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation[1];
                hotelReservationList[0] = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation();

                hotelReservations.HotelReservation = hotelReservationList;

                hotelReservations.HotelReservation[0].ResStatus = resStatus;
                if (resStatus == "Book")
                {
                    hotelReservations.HotelReservation[0].CreateDateTime = dateTimeStamp;
                }
                else
                {
                    hotelReservations.HotelReservation[0].LastModifyDateTime = dateTimeStamp;
                }
                hotelReservations.HotelReservation[0].UniqueID         = new UniqueID_Type[1];
                hotelReservations.HotelReservation[0].UniqueID[0]      = new UniqueID_Type();
                hotelReservations.HotelReservation[0].UniqueID[0].Type = OTA_ID_Type.Reference.ToString("d");
                hotelReservations.HotelReservation[0].UniqueID[0].ID   = msgID;

                //
                // Only include the reservation ID info if there was no error processin this reservation.
                //

                if (resError == null)
                {
                    hotelReservations.HotelReservation[0].ResGlobalInfo = new ResGlobalInfoType();
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs                = new HotelReservationIDsTypeHotelReservationID[1];
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0]             = new HotelReservationIDsTypeHotelReservationID();
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0].ResID_Type  = OTA_ID_Type.Reservation.ToString("d");
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0].ResID_Value = resIDPMS;
                }

                body.NotifDetails.HotelNotifReport.Item = hotelReservations;
                response = await service.NotifReportRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_NotifReportRQ arguments were not set up properly causing a null reference exception.");
                response = new NotifReportRQResponse();
                response.OTA_NotifReportRS       = new MessageAcknowledgementType();
                response.OTA_NotifReportRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new NotifReportRQResponse();
                response.OTA_NotifReportRS       = new MessageAcknowledgementType();
                response.OTA_NotifReportRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }