// // HERE IS THE SIMPLEST EXAMPLE OF A CALL TO SITEMINDER PMSXCHANGE. THIS CLICK HANDLER FOR THE "PING" BUTTON // WILL SEND A PING WITH AUTHENTICATION INFO AND CHECK IF THE SERVER IS ALIVE. // private async void button_Ping_Click(object sender, RoutedEventArgs e) { WriteResponseLine(string.Format("Sending OTA_PingRQ...")); textBlock_Ping.Text = "Sending..."; PingRQResponse pingResponse = await OTA_PingRQ(username, password); if (pingResponse.OTA_PingRS.Items[0].GetType() == typeof(SuccessType)) { textBlock_Ping.Text = pingResponse.OTA_PingRS.Items[1].ToString(); WriteResponseLine(string.Format("OTA_PingRS success!")); } else { string timestamp = pingResponse.OTA_PingRS.TimeStamp.ToString(); ErrorsType errors = (ErrorsType)pingResponse.OTA_PingRS.Items[0]; foreach (var error in errors.Error) { textBlock_Ping.Text = "Error"; WriteResponseLine(string.Format("OTA_PingRS error - Timestamp: {2}, Type: {0}, Value: {1}", error.Type, error.Value, timestamp)); } } WriteResponseLine(string.Format("")); }
/// <summary> /// Asynchronously tries to perform the refresh request. /// </summary> /// <param name="security">The security.</param> /// <param name="conversationId">The conversation identifier.</param> /// <returns>The SOAP result of the Ping response.</returns> public async Task <SoapResult <OTA_PingRS> > TryRefreshAsync(Security security, string conversationId) { OTA_PingRQ request = this.soapServiceFactory.CreatePingRequest(); SWSService service = this.soapServiceFactory.CreatePingService(conversationId, security); var source = new TaskCompletionSource <SoapResult <OTA_PingRS> >(); service.OTA_PingRQCompleted += (s, e) => { if (SoapHelper.HandleErrors(e, source)) { if (e.Result.Items.Any()) { ErrorsType error = e.Result.Items[0] as ErrorsType; if (error != null && error.Error != null && error.Error.Length > 0) { source.TrySetResult(SoapResult <OTA_PingRS> .Error(error.Error.First())); return; } } source.TrySetResult(SoapResult <OTA_PingRS> .Success(e.Result)); } }; service.OTA_PingRQAsync(request); return(await source.Task); }
// // Create an error block with a single undefined processing exception. // private static ErrorsType ProcessingException(Exception ex) { ErrorsType errors = new ErrorsType(); ErrorType[] error = { CreateErrorType(OTA_ERR.System_error, OTA_EWT.Processing_exception, ex.Message) }; errors.Error = error; return(errors); }
private async void button_HotelAvailNotif_Click(object sender, RoutedEventArgs e) { WriteResponseLine(string.Format("Sending OTA_HotelAvailNotifRQ...")); #region AvailStatusMessages setup List <AvailStatusMessage> availStatusMessageList = new List <AvailStatusMessage>(); // // Set up one or more AvailStatusMessage. Just using some random data. // DateTime start = new DateTime(2016, 8, 15); DateTime end = new DateTime(2016, 8, 18); AvailStatusMessage.StatusApplicationControl statusApplicationControl = new AvailStatusMessage.StatusApplicationControl(start, end, "S2S", "TR", GetAvailDestList("NYU", "ATL")); AvailStatusMessage availStatusMessage = new AvailStatusMessage(statusApplicationControl, Restrictions.Stop_Sold, 1, 30, null); availStatusMessageList.Add(availStatusMessage); // Add an AvailStatusMessage to AvailStatusMessages. AvailStatusMessages availStatusMessages = new AvailStatusMessages(hotelCode, availStatusMessageList); #endregion HotelAvailNotifRQResponse availResponse = await OTA_HotelAvailNotifRQ(pmsID, username, password, availStatusMessages); if (availResponse.OTA_HotelAvailNotifRS.Items[0].GetType() == typeof(SuccessType)) { WriteResponseLine(string.Format("OTA_HotelAvailNotifRS success!")); } else { string timestamp = availResponse.OTA_HotelAvailNotifRS.TimeStamp.ToString(); ErrorsType errors = (ErrorsType)availResponse.OTA_HotelAvailNotifRS.Items[0]; foreach (var error in errors.Error) { WriteResponseLine(string.Format("OTA_HotelAvailNotifRS error - Timestamp: {2}, Type: {0}, Value: {1}", error.Type, error.Value, timestamp)); } } WriteResponseLine(string.Format("")); }
private void Authenticate(ErrorsType type, LoginRequestDataPacket request) { if (type == ErrorsType.NoError) { Id = request.Identifier; LoginResponsePacket packet = new LoginResponsePacket(); SendPacket(packet); LogFactory.GetLog(server.Name).LogInfo($"[SESSION] [AUTHENTICATE STATUS: {type.ToString()}]."); } else { LoginErrorResponsePacket packet = new LoginErrorResponsePacket { Identifier = 0, Error = type }; SendPacket(packet); LogFactory.GetLog(server.Name).LogInfo($"[SESSION] [AUTHENTICATE STATUS: {type.ToString()}]."); } }
private async void Button_Ping_Click(object sender, RoutedEventArgs e) { //OTA_ResRetrieveRS reservationsResponse = API.OTA_ReadRQ(pmsID, username, password, hotelCode, ResStatus.All); PingRQResponse pingResponse = await API.OTA_PingRS(username, password); if (pingResponse.OTA_PingRS.Items[0].GetType() == typeof(SuccessType)) { string echo = pingResponse.OTA_PingRS.Items[1].ToString(); } else { ErrorsType errors = (ErrorsType)pingResponse.OTA_PingRS.Items[0]; foreach (var error in errors.Error) { } } //ReservationError resErr = new ReservationError(ERR.Hotel_not_active, EWT.Processing_exception, "hello"); }
static public async Task <PingRQResponse> OTA_PingRS(string usernameAuthenticate, string passwordAuthenticate) { PingRQResponse response = null; try { PmsXchangeServiceClient service = ServiceConnection.Instance.service; pmsXchangeService.OTA_PingRQ pingRequestBody = new pmsXchangeService.OTA_PingRQ(); pingRequestBody.Version = 1.0M; pingRequestBody.EchoToken = Guid.NewGuid().ToString(); // Echo token must be unique. pingRequestBody.TimeStamp = DateTime.Now; pingRequestBody.TimeStampSpecified = true; pingRequestBody.EchoData = "good echo"; int q = 0; int h = 7 / q; // // Send an asynchronous ping request. // response = await service.PingRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), pingRequestBody); } catch (Exception ex) { response = new PingRQResponse(); ErrorsType errors = new ErrorsType(); ErrorType [] err1 = new ErrorType[1]; err1[0] = new ErrorType(); err1[0].Type = EWT.Processing_exception.ToString(); err1[0].Value = ex.Message; response.OTA_PingRS = new OTA_PingRS(); response.OTA_PingRS.Items = new object[] { errors }; } return(response); }
public IActionResult GetMetricsErrorsCount([FromRoute] TimeSpan fromTime, [FromRoute] TimeSpan toTime, [FromRoute] ErrorsType errorsType) { return(Ok()); }
public ErrorsReturnType Invoke(int argpos, TwitchClient cl, OnMessageReceivedArgs e) { var CommantAttribute = typeof(TwitchCoreAPI.Core.Attribute.Command); var AliasAttribute = typeof(TwitchCoreAPI.Core.Attribute.AliasAttribute); var PrecondAttribute = typeof(TwitchCoreAPI.Core.Attribute.PreconditionAttribute); int poz = e.ChatMessage.Message.IndexOf(' '); poz = poz < 0 ? e.ChatMessage.Message.Length - 1 : poz - 1; string NameMethods = e.ChatMessage.Message.Substring(1, poz).ToLower(); List <object> _params; foreach (var method in ClassType.GetMethods()) { bool CommandName = false; bool AliasName = false; bool PreconditionCon = true; PreconditionResult Presult = new PreconditionResult(); foreach (var attrib in method.GetCustomAttributes()) { var type = attrib.GetType(); if (type == CommantAttribute) { var at = attrib as TwitchCoreAPI.Core.Attribute.Command; if (at.NameCommand == NameMethods) { CommandName |= true; } else { CommandName &= false; } } else if (type == AliasAttribute) { var at = attrib as TwitchCoreAPI.Core.Attribute.AliasAttribute; if (at.NameAlias == NameMethods) { AliasName = true; } } else if (type.BaseType == PrecondAttribute) { PreconditionCon = false; var at = attrib as TwitchCoreAPI.Core.Attribute.PreconditionAttribute; Presult = at.CheckPermissions(e); if (Presult.res == PreconditionResult.Result.Successfully) { PreconditionCon = true; } } } if ((CommandName || AliasName) && PreconditionCon) { ErrorsType result = GetParam(argpos, e.ChatMessage.Message, out _params, method.GetParameters()); if (result != ErrorsType.Successful && result != ErrorsType.ObjectNotFound) { return(new ErrorsReturnType(ErrorsType.ParseFailed, $"Не соответствие параметров при передаче в функцию. Строка: \"{e.ChatMessage.Message}\"")); } if (_params.Count == method.GetParameters().Count()) { ((ICommandContext)MyClassObject).SetContext(e, cl); method.Invoke(MyClassObject, _params.ToArray()); return(new ErrorsReturnType(ErrorsType.Successful, "")); } else { return(new ErrorsReturnType(ErrorsType.BadArgCount, $"Не соответсвие кол-ва аргументов функции [{_params.Count}]:[{method.GetParameters().Count()}], сообщение : \"{e.ChatMessage.Message}\"")); } } if (!PreconditionCon && (CommandName || AliasName)) { return(new ErrorsReturnType(ErrorsType.UnmetPrecondition, $"{Presult.ErrorResult}'")); } } return(new ErrorsReturnType(ErrorsType.ObjectNotFound, $"Не найдена функция \"{NameMethods}\"")); }
public ErrorsReturnType(ErrorsType result, string errors) { ErrorsMessage = errors; Result = result; }
private async void button_NotifReport_Click(object sender, RoutedEventArgs e) { WriteResponseLine(string.Format("Sending OTA_NotifReportRQ...")); foreach (HotelReservationType hotelReservation in reservationList.Items) { // // Get the pmsXchange reservation reference. // UniqueID_Type[] uniqueIDs = hotelReservation.UniqueID; string resType = uniqueIDs[0].Type; string resIDPMS = uniqueIDs[0].ID; string msgType = uniqueIDs[1].Type; string msgID = uniqueIDs[1].ID; string resStatusText = hotelReservation.ResStatus; DateTime dateTimeStamp = resStatusText == "Book" ? hotelReservation.CreateDateTime : hotelReservation.LastModifyDateTime; // // Send a reservation confirmation. // NotifReportRQResponse confirmResponse = null; if (checkBox_Conf_Errror.IsChecked == false) { confirmResponse = await OTA_NotifReportRQ(username, password, null, resStatusText, dateTimeStamp, msgID, resIDPMS); } else { ReservationError resError = new ReservationError((OTA_EWT)comboBox_OTA_EWT.SelectedValue, (OTA_ERR)comboBox_OTA_ERR.SelectedValue, null); confirmResponse = await OTA_NotifReportRQ(username, password, null, resStatusText, dateTimeStamp, msgID, resIDPMS); } // // Make sure that no errors were generated during confirmation! // if (confirmResponse.OTA_NotifReportRS.Items[0].GetType() == typeof(SuccessType)) { // // Confirmation was processed correctly. // WriteResponseLine(string.Format("Reservation resID: {0} confirmed successfully.", resIDPMS)); button_NotifReport.IsEnabled = false; } else { // // Confirmation error. // string timestamp = confirmResponse.OTA_NotifReportRS.TimeStamp.ToString(); ErrorsType errors = (ErrorsType)confirmResponse.OTA_NotifReportRS.Items[0]; foreach (var error in errors.Error) { WriteResponseLine(string.Format("OTA_NotifReportRS error - Timestamp: {2}, Type: {0}, Value: {1}", error.Type, error.Value, timestamp)); } } } WriteResponseLine(string.Format("")); }
private async void button_Read_Click(object sender, RoutedEventArgs e) { WriteResponseLine(string.Format("Sending OTA_ResRetrieveRQ...")); button_NotifReport.IsEnabled = false; ResStatus resStatus = ResStatus.All; if (radioButton_Modify.IsChecked == true) { resStatus = ResStatus.Modify; } if (radioButton_Cancel.IsChecked == true) { resStatus = ResStatus.Cancel; } if (radioButton_Book.IsChecked == true) { resStatus = ResStatus.Book; } ReadRQResponse reservationsResponse = await OTA_ReadRQ(pmsID, username, password, hotelCode, resStatus); if (reservationsResponse.OTA_ResRetrieveRS.Items[0].GetType() == typeof(SuccessType)) { WriteResponseLine(string.Format("OTA_ResRetrieveRS success!")); if (reservationsResponse.OTA_ResRetrieveRS.Items.Length > 1) { reservationList = (OTA_ResRetrieveRSReservationsList)reservationsResponse.OTA_ResRetrieveRS.Items[1]; WriteResponseLine(string.Format("# of reservations: {0} ", reservationList.Items.Length)); // // Got the reservation list, so now process it.... // foreach (HotelReservationType hotelReservation in reservationList.Items) { // // Get the pmsXchange reservation reference. // UniqueID_Type[] uniqueIDs = hotelReservation.UniqueID; string resType = uniqueIDs[0].Type; string resIDPMS = uniqueIDs[0].ID; string msgType = uniqueIDs[1].Type; string msgID = uniqueIDs[1].ID; string resStatusText = hotelReservation.ResStatus; DateTime dateTimeStamp = resStatusText == "Book" ? hotelReservation.CreateDateTime : hotelReservation.LastModifyDateTime; WriteResponseLine(string.Format("Reservation - resID: {0}, msgID: {1}, Status: {2}, TimeStamp: {3}", resIDPMS, msgID, resStatusText, dateTimeStamp.ToString())); button_NotifReport.IsEnabled = true; } } else { WriteResponseLine("No reservation list available."); } } else { string timestamp = reservationsResponse.OTA_ResRetrieveRS.TimeStamp.ToString(); ErrorsType errors = (ErrorsType)reservationsResponse.OTA_ResRetrieveRS.Items[0]; foreach (var error in errors.Error) { WriteResponseLine(string.Format("OTA_ResRetrieveRS error - Timestamp: {2}, Type: {0}, Value: {1}", error.Type, error.Value, timestamp)); } } WriteResponseLine(string.Format("")); }
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); }