public bool Subscribe(APIUtility transactionObject) { transactionObject.APIKey = ApiKey; transactionObject.APISecret = ApiSecret; //var rootObject = transactionObject.RootObject; //rootObject.Source = "CNFR151001_ChristmasGame_Sweepstake_CarteNoire_Campaign"; //rootObject.Attributes.Add(new Attribute { Name = "Salutation", Value = "1" }); //rootObject.Attributes.Add(new Attribute { Name = "Lastname", Value = "Lastname" }); //rootObject.Attributes.Add(new Attribute { Name = "Firstname", Value = "Firstname" }); //rootObject.Attributes.Add(new Attribute { Name = "Email", Value = "Email" }); //rootObject.Attributes.Add(new Attribute { Name = "Birthday", Value = "Birthday" }); //rootObject.Attributes.Add(new Attribute { Name = "Street1", Value = "Street1" }); //rootObject.Attributes.Add(new Attribute { Name = "Zipcode", Value = "Zipcode" }); //rootObject.Attributes.Add(new Attribute { Name = "City", Value = "City" }); //rootObject.Attributes.Add(new Attribute { Name = "PhonePrivate", Value = "PhonePrivate" }); //rootObject.Attributes.Add(new Attribute { Name = "list:CarteNoire_Email", Value = "" }); //transactionObject.RefreshAccessToken = APIUtility.HttpVerb.POST; //rootObject.Transactions.Add(new Transaction //{ // Name = "CNFR151001 Carte Noire Christmas Game Sweepstake (IN)", // Source = "CNFR151001_ChristmasGame_Sweepstake_CarteNoire_Campaign", // Date_Created = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"), // Parameters = new List<TransactionParameter> { new TransactionParameter { Name = "Ident_long", Value = "ADF12A67-E97D-4C5E-86FB-85FD5BF00B18" } } //}); bool isSuccess = transactionObject.MakeRequest(); return(isSuccess); }
public static string HotelMultiSingleAvailability(string hotelcode, string start, string end) { string soapResult = string.Empty; try { string StayBazarWBSOffice = BLayer.Settings.GetValue(CLayer.Settings.STAYBAZARWBSOFFICE); var _url = BLayer.Settings.GetValue(CLayer.Settings.STAYBAZARWBSURL); //"https://nodeD1.test.webservices.amadeus.com/1ASIWSTYSZRU"; var _action = BLayer.Settings.GetValue(CLayer.Settings.STAYBAZARWBSHOTELMULTISINGLEACTION); //"http://webservices.amadeus.com/Hotel_MultiSingleAvailability_10.0"; string SoapHeader = APIUtility.SetSoapHeaderPriceingdetails(_url, _action); string SoapBody = APIUtility.SetHotelMultiSingleAvailabilityBodyPriceingdetails(hotelcode, start, end); string SoapEnvelop = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; SoapEnvelop = SoapEnvelop + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:sec=\"http://xml.amadeus.com/2010/06/Security_v1\" xmlns:typ=\"http://xml.amadeus.com/2010/06/Types_v1\" xmlns:iat=\"http://www.iata.org/IATA/2007/00/IATA2010.1\" xmlns:app=\"http://xml.amadeus.com/2010/06/AppMdw_CommonTypes_v3\" xmlns:link=\"http://wsdl.amadeus.com/2010/06/ws/Link_v1\" xmlns:ses=\"http://xml.amadeus.com/2010/06/Session_v3\" xmlns:ns=\"http://www.opentravel.org/OTA/2003/05\">"; SoapEnvelop = SoapEnvelop + SoapHeader + SoapBody; SoapEnvelop = SoapEnvelop + "</soapenv:Envelope>"; XmlDocument soapEnvelopeXml = new XmlDocument(); soapEnvelopeXml.LoadXml(SoapEnvelop); HttpWebRequest webRequest = CreateWebRequest(_url, _action); webRequest.Proxy = null; webRequest = InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest); // begin async call to web request. IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); // suspend this thread until call is complete. You might want to // do something usefull here like update your UI. asyncResult.AsyncWaitHandle.WaitOne(); // get the response from the completed web request. using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) { using (StreamReader rd = new StreamReader(webResponse.GetResponseStream())) { soapResult = rd.ReadToEnd(); } // Console.Write(soapResult); Console.WriteLine("update gds rates for Hotel code: " + hotelcode); } } catch (WebException webex) { WebResponse errResp = webex.Response; using (Stream respStream = errResp.GetResponseStream()) { StreamReader reader = new StreamReader(respStream); string text = reader.ReadToEnd(); soapResult = text; } Console.WriteLine("Failed to get gds rates for Hotel code: " + hotelcode); } return(soapResult); }
public ResponseRootObject SubscribeWithRequestConsumerId(APIUtility transactionObject) { transactionObject.APIKey = ApiKey; transactionObject.APISecret = ApiSecret; transactionObject.Method = APIUtility.HttpVerb.POST; return(transactionObject.SubscribeWithRequestConsumerId()); }
public ActionResult Index(string CompanyName, string Address1, string Address2, string City, string State, string Country, string Zipcode, string Telephone) { OICleanseMatchViewModel model = new OICleanseMatchViewModel(); if (!string.IsNullOrEmpty(CompanyName) && !string.IsNullOrEmpty(Country)) { string ConnectionString = this.CurrentClient.ApplicationDBConnectionString; string[] hostParts = new System.Uri(Request.Url.AbsoluteUri).Host.Split('.'); string SubDomain = hostParts[0]; model = APIUtility.GetOICleanseMatchResult(CompanyName, Address1, Address2, City, State, Country, Zipcode, Telephone, ConnectionString, SubDomain); if (model.oICleanseMatchOutputs == null && model.Error != null) { model.oICleanseMatchOutputs = new List <OICleanseMatchOutput>(); ViewBag.ErrorMessage = model.Error.ToString(); } } else { model.oICleanseMatchOutputs = new List <OICleanseMatchOutput>(); ViewBag.ErrorMessage = DandBSettingLang.msgInvadilState; } if (Request.IsAjaxRequest()) { return(PartialView("~/Views/OI/OISearchData/_Index.cshtml", model)); } else { return(PartialView("~/Views/OI/OISearchData/Index.cshtml", model)); } }
public ActionResult OIAltSearchOrbNumber(string Parameters) { //OI - Search Data(Support Search by webdomain, orb number, email, ein)(MP - 577) string Country = string.Empty, OrbNum = string.Empty; if (!string.IsNullOrEmpty(Parameters)) { Parameters = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase); OrbNum = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1); Country = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 1, 1); } string ConnectionString = this.CurrentClient.ApplicationDBConnectionString; string[] hostParts = new System.Uri(Request.Url.AbsoluteUri).Host.Split('.'); string SubDomain = hostParts[0]; OICleanseMatchViewModel model = new OICleanseMatchViewModel(); model = APIUtility.GetOICleanseMatchResult("", "", "", "", "", Country, "", "", ConnectionString, SubDomain, null, "", OrbNum); if (model.oICleanseMatchOutputs == null && model.Error != null) { model.oICleanseMatchOutputs = new List <OICleanseMatchOutput>(); ViewBag.ErrorMessage = model.Error.ToString(); } return(PartialView("~/Views/OI/OISearchData/_Index.cshtml", model)); }
public bool BookingDecline(long BookingId, string ControlNumber = "") { try { BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Decline, BookingId); #region GDS Booking Cancel int InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(BLayer.Bookings.GetPropertyId(BookingId)); if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus) { ControlNumber = BLayer.Bookings.GetGDSBookingControlNumber(BookingId); if (string.IsNullOrEmpty(ControlNumber)) { ControlNumber = Convert.ToString(System.Web.HttpContext.Current.Session["ControlNumber"]); } int OptionCode = (ControlNumber == "") ? 0 : (int)CLayer.ObjectStatus.PNROptionCodes.OptionPNRFinalize; string resultCancel = APIUtility.ExecutePNRCancel(ControlNumber, OptionCode); } #endregion } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(false); } return(true); }
public ResponseRootObject GetProfileByConsumerId(APIUtility transactionObject, string consumerId, bool requireApiKey = false) { transactionObject.APIKey = ApiKey; transactionObject.APISecret = ApiSecret; transactionObject.Method = APIUtility.HttpVerb.GET; return(transactionObject.GetProfileByConsumerId(consumerId, requireApiKey, true)); }
public JObject CallAPIs(string apiKey) { APIUtility apiObject = new APIUtility(); JObject response = null; response = apiObject.getResponseFromPOSTAPI(apiKey); return(response); }
public ResponseRootObject UpdateProfileByConsumerId(APIUtility transactionObject, string consumerId) { transactionObject.APIKey = ApiKey; transactionObject.APISecret = ApiSecret; transactionObject.Method = APIUtility.HttpVerb.PUT; return(transactionObject.UpdateProfileByConsumerId(consumerId)); }
private void EmailAllMembers(BandViewModel band) { List <string> bandEmails = GetEmails(band); for (int i = 0; i < bandEmails.Count; i++) { string receipient = bandEmails[i]; string subject = "Join BANDdrop group!"; string body = "Join group by entering : '" + band.Name + "' at band join page!"; APIUtility.SendSimpleMessage(receipient, subject, body); } }
public bool BookingCancel(long BookingId, string ControlNumber = "") { try { BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Cancelled, BookingId); #region GDS Booking Cancel int InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(BLayer.Bookings.GetPropertyId(BookingId)); if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus) { ControlNumber = BLayer.Bookings.GetGDSBookingControlNumber(BookingId); if (string.IsNullOrEmpty(ControlNumber)) { ControlNumber = Convert.ToString(System.Web.HttpContext.Current.Session["ControlNumber"]); } int OptionCode = (ControlNumber == "") ? 0 : (int)CLayer.ObjectStatus.PNROptionCodes.OptionPNRFinalize; string resultCancel = APIUtility.ExecutePNRCancel(ControlNumber, OptionCode); #region Transaction Log string LoggedInUser = Convert.ToString(System.Web.HttpContext.Current.Session["LoggedInUser"]); string currentUrl = string.Empty; try { APIUtility.GenerateGDSTransactionLog(currentUrl, resultCancel, Convert.ToInt32(LoggedInUser), (int)CLayer.ObjectStatus.GDSType.PNRCancel, BookingId); } catch (Exception ex) { APIUtility.GenerateGDSTransactionLog(currentUrl, resultCancel, Convert.ToInt32(LoggedInUser), (int)CLayer.ObjectStatus.GDSType.PNRCancel, BookingId); } #endregion Transaction log end } #endregion } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(false); } return(true); }
public bool CancelInCompleteGDSBookings() { bool result = false; try { String hotelcode = string.Empty; List <CLayer.BookingItem> objInCompleteBookings = BLayer.BookingItem.GetIncompleteGDSBookings(); foreach (var item in objInCompleteBookings) { #region Cancel incomplete GDS bookings bool bResult = BookingDecline(item.BookingId, item.HotelConfirmNumber); // BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Cancelled, item.BookingId); #endregion } result = true; #region Transaction Log if (objInCompleteBookings.Count > 0) { APIUtility.GenerateGDSTransactionLog("", "BulkCancelIncompleteBookingsSuccess", 0, (int)CLayer.ObjectStatus.GDSType.BulkCancelIncompleteBookings, 0); } #endregion Transaction log end } catch (Exception ex) { result = false; #region Transaction Log APIUtility.GenerateGDSTransactionLog("", "BulkCancelIncompleteBookingsFailure", 0, (int)CLayer.ObjectStatus.GDSType.BulkCancelIncompleteBookings, 0); #endregion Transaction log end throw ex; } return(result); }
public bool BookingDecline(long BookingId, string ControlNumber = "") { try { BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Cancelled, BookingId); #region GDS Booking Cancel int InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(BLayer.Bookings.GetPropertyId(BookingId)); if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus) { ControlNumber = BLayer.Bookings.GetGDSBookingControlNumber(BookingId); int OptionCode = (ControlNumber == "") ? 0 : (int)CLayer.ObjectStatus.PNROptionCodes.OptionPNRFinalize; string resultCancel = APIUtility.ExecutePNRCancel(ControlNumber, OptionCode, true); } #endregion } catch (Exception ex) { LogHandler.LogError(ex); return(false); } return(true); }
public bool UpdatePropertyStarRatings() { bool result = false; long id1 = 0; string HotelID = string.Empty; try { String hotelcode = string.Empty; List <CLayer.Property> objProperties = BLayer.Property.GetAllGDSProperties().ToList(); CLayer.GDSBookingDetails.Envelope ss = new CLayer.GDSBookingDetails.Envelope(); CLayer.GDSBookingDetailsAdv.Envelope ssAdv = new CLayer.GDSBookingDetailsAdv.Envelope();// ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel); long id = 0; foreach (var pitem in objProperties) { try { // #region Update Property Description StringBuilder Description = new StringBuilder(); //Update property description start Serializer ser = new Serializer(); id = pitem.PropertyId; id1 = id; string HotelCode = pitem.HotelID; HotelID = HotelCode; string hotel = GetGDS_Hotel_Details(HotelCode); ss = ser.Deserialize <CLayer.GDSBookingDetails.Envelope>(hotel); DataTable dtHotel = BLayer.Property.GetHotelFormattedDescription(id); string FormattedDescription = string.Empty; if (dtHotel.Rows.Count > 0) { foreach (DataRow dr in dtHotel.Rows) { FormattedDescription = Convert.ToString(dr["FormattedDescription"]); } } FormattedDescription = GDSProcess.GDSFormatDescription.GetFormattedDescription(hotel); int StarRatings = GDSProcess.GDSFormatDescription.StarRatings; int LocalStarRating = APIUtility.GetStarRating(hotel); if (LocalStarRating > 0) { BLayer.Property.GDSUpdatePropertyStarRatings(id, LocalStarRating); } if ((LocalStarRating == 0) && (StarRatings == 0)) { BLayer.Property.GDSUpdatePropertyStarRatings(id, 0); } } catch (Exception ex) { // LogHandler.AddLog("Error in-"+hotelcode); WriteToLog(HotelID.ToString() + "-" + ex.Message, true); } finally { } } result = true; } catch (Exception ex) { LogHandler.AddLog(ex.Message); string a = id1.ToString(); result = false; throw ex; } return(result); }
public static List <CLayer.RoomStaysResult> GetRoomStaysAdv(CLayer.HotelAvailabilityAdvancedFirst.OTA_HotelAvailRSRoomStays RoomStaysList, string[] pRPH, string RequestedCurrencyCode = "", decimal ConversionRate = 0, string GDSCountry = "") { List <CLayer.RoomStaysResult> RoomStaysResultList = new List <CLayer.RoomStaysResult>(); for (int i = 0; i < pRPH.Length; i++) { var RoomStayItem = RoomStaysList.RoomStay.Where(s => s.RPH == Convert.ToInt32(pRPH[i])).ToList(); CLayer.RoomStaysResult objRoomStay = new CLayer.RoomStaysResult(); if (RoomStayItem[0].RoomRates != null) { objRoomStay.AmountBeforeTax = Convert.ToDecimal(RoomStayItem[0].RoomRates.RoomRate.Total.AmountBeforeTax); objRoomStay.AmountBeforeTax = (GDSCountry == "") ? objRoomStay.AmountBeforeTax : APIUtility.GetGDSConvertedAmount(objRoomStay.AmountBeforeTax, ConversionRate); objRoomStay.BookingCode = RoomStayItem[0].RoomRates.RoomRate.BookingCode; objRoomStay.AmountAfterTax = RoomStayItem[0].RoomRates.RoomRate.Total.AmountAfterTax; objRoomStay.CurrencyCode = RoomStayItem[0].RoomRates.RoomRate.Total.CurrencyCode; //if (HotelResultAdvFirst.Body.OTA_HotelAvailRS.CurrencyConversions != null) //{ // var item = HotelResultAdvFirst.Body.OTA_HotelAvailRS.CurrencyConversions; if ((RequestedCurrencyCode != objRoomStay.CurrencyCode) && (RequestedCurrencyCode != "")) { objRoomStay.AmountAfterTax = Math.Round(objRoomStay.AmountAfterTax * ConversionRate, 0); } else { objRoomStay.AmountAfterTax = (GDSCountry == "") ? objRoomStay.AmountAfterTax : APIUtility.GetGDSConvertedAmount(objRoomStay.AmountBeforeTax, ConversionRate); } //} CLayer.RoomRateDescription ObjRoomRateDescription = new CLayer.RoomRateDescription(); ObjRoomRateDescription.Name = RoomStayItem[0].RoomRates.RoomRate.RoomRateDescription.Name; ObjRoomRateDescription.Description = RoomStayItem[0].RoomRates.RoomRate.RoomRateDescription.Text; objRoomStay.RoomRateDescriptionItem = ObjRoomRateDescription; objRoomStay.RoomTypeCode = RoomStayItem[0].RoomRates.RoomRate.RoomTypeCode; objRoomStay.RatePlanCode = RoomStayItem[0].RoomRates.RoomRate.RatePlanCode; //CLayer.RoomRateTotal ObjRoomRateTotal = new CLayer.RoomRateTotal(); //List<CLayer.RoomRateTotalTaxes> ObjRoomRateTotalTaxesList = new List<CLayer.RoomRateTotalTaxes>(); //CLayer.RoomRateTotalTaxes ObjRoomRateTotalTaxes = new CLayer.RoomRateTotalTaxes(); //ObjRoomRateTotalTaxes.Type= RoomStayItem[0].RoomRates.RoomRate[- } if (RoomStayItem[0].RatePlans != null) { objRoomStay.RatePlanCode = RoomStayItem[0].RatePlans.RatePlan.RatePlanCode; } if (RoomStayItem[0].RoomTypes != null) { objRoomStay.RoomType = RoomStayItem[0].RoomTypes.RoomType.RoomType; // objRoomStay.RoomTypeDescription = APIUtility.GenerateRoomDescription(RoomStayItem[0].RoomTypes.RoomType.RoomTypeCode); // objRoomStay.RoomTypeCode= RoomStayItem[0].RoomTypes.RoomType.RoomTypeCode; } RoomStaysResultList.Add(objRoomStay); } return(RoomStaysResultList); }
public ResultDTO Process() { var source = (CountryCode == CountryKeys.IE) ? "CBIE180101_Inventor_Promotion_Cadbury_Campaign" : "CBUK180501_Inventor_Promotion_Cadbury_Campaign"; var transactionName = (CountryCode == CountryKeys.IE) ? "CBIE180101 Cadbury Inventor Promotion Participation (IN)" : "CBUK180501 Cadbury Inventor Promotion Participation (IN)"; var participantsListName = (CountryCode == CountryKeys.IE) ? "list:CBIE180101_Participants" : "list:CBUK180501_Participants"; var termsAndConditionsName = (CountryCode == CountryKeys.IE) ? "list:CBIE180101_TermsAndConditions" : "list:CBUK180501_TermsAndConditions"; APIUtility transactionObject = new APIUtility(); var rootObject = transactionObject.RootObject; rootObject.Source = source; rootObject.Attributes.Add(new TransactionAttribute { Name = "Firstname", Value = FirstName }); rootObject.Attributes.Add(new TransactionAttribute { Name = "Lastname", Value = LastName }); rootObject.Attributes.Add(new TransactionAttribute { Name = "Email", Value = Email }); rootObject.Attributes.Add(new TransactionAttribute { Name = "MobilePrivate", Value = MobilePrivate }); rootObject.Attributes.Add(new TransactionAttribute { Name = "City", Value = City }); rootObject.Attributes.Add(new TransactionAttribute { Name = "Birthday", Value = Birthday }); rootObject.Attributes.Add(new TransactionAttribute { Name = "list:Cadbury_Email", Value = (CadburyEmail) ? 1 : 0 }); rootObject.Attributes.Add(new TransactionAttribute { Name = participantsListName, Value = 1 }); rootObject.Attributes.Add(new TransactionAttribute { Name = "list:Privacy_Policy_EN", Value = 1 }); rootObject.Attributes.Add(new TransactionAttribute { Name = termsAndConditionsName, Value = 1 }); transactionObject.Method = APIUtility.HttpVerb.POST; rootObject.Transactions.Add(new Transaction { Name = transactionName, Source = source, Date_Created = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"), Parameters = new List <TransactionParameter> { new TransactionParameter { Name = "Q1", Value = Ingredient1Category }, new TransactionParameter { Name = "Q2", Value = Ingredient1Name }, new TransactionParameter { Name = "Q3", Value = Ingredient1Colour }, new TransactionParameter { Name = "Q4", Value = Ingredient2Category }, new TransactionParameter { Name = "Q5", Value = Ingredient2Name }, new TransactionParameter { Name = "Q6", Value = Ingredient2Colour }, new TransactionParameter { Name = "Q7", Value = Ingredient3Category }, new TransactionParameter { Name = "Q8", Value = Ingredient3Name }, new TransactionParameter { Name = "Q9", Value = Ingredient3Colour }, new TransactionParameter { Name = "Q10", Value = BarColour }, new TransactionParameter { Name = "Q11", Value = BarDescription }, new TransactionParameter { Name = "Q12", Value = BarName }, new TransactionParameter { Name = "Q15", Value = ParticipationId }, } }); ResponseRootObject apiResult = null; try { apiResult = ProCampaignFactory.ConfigureProCampaignService(CountryCode) .ConsumerClient .SubscribeWithRequestConsumerId(transactionObject); } catch (WebException ex) { using (var responseStream = ((HttpWebResponse)ex.Response).GetResponseStream()) { if (responseStream != null) { using (var reader = new StreamReader(responseStream)) { var responseValue = reader.ReadToEnd(); try { apiResult = JsonConvert.DeserializeObject <ResponseRootObject>(responseValue); } catch (Exception exc) { } } } } } var proCampaignStatus = new ProCampaignStatus() { Id = Guid.NewGuid(), EntryId = EntryId, IsSuccessful = (apiResult == null) ? false : apiResult.IsSuccessful, ResponseCode = (apiResult == null) ? 0 : apiResult.StatusCode, ResponseText = (apiResult == null) ? String.Empty : apiResult.StatusMessage, HttpStatusCode = (apiResult == null) ? 0 : apiResult.HttpStatusCode, HttpStatusMessage = (apiResult == null) ? String.Empty : apiResult.HttpStatusMessage, CreatedOn = DateTime.UtcNow }; ProCampaignStatusManager.Insert(proCampaignStatus); if (apiResult != null && apiResult.IsSuccessful) { Result.HttpStatusCode = HttpStatusCode.OK; Result.Meta = new { ConsumerId = apiResult.Data.ConsumerId }; } else { Result.HttpStatusCode = HttpStatusCode.InternalServerError; Result.Code = CodeKeys.SYSTEM_ERROR_02; var proCampaignTransaction = new ProCampaignTransaction() { Id = Guid.NewGuid(), ProCampaignStatusId = proCampaignStatus.Id, Status = ProCampaignTransactionStatusKeys.NEW, Database = CountryCode, TransactionObject = JsonConvert.SerializeObject( transactionObject, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }), CreatedOn = DateTime.UtcNow }; ProCampaignTransactionManager.Insert(proCampaignTransaction); } return(Result); }
public bool GDSBookingConfirm(long bookingId) { long propertyId = 0; bool returnvalue = false; int InventoryAPIType = 0; try { StayBazar.Controllers.BookingController objBookingController = new StayBazar.Controllers.BookingController(); long userId = objBookingController.GetUserId(); if (bookingId <= 0) { bookingId = BLayer.Bookings.GetCartId(userId); } string IpAdds = GetIPAddress(); propertyId = BLayer.BookingExternalInventory.GetPropertyIdByBookingId(bookingId); InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(BLayer.Bookings.GetPropertyId(bookingId)); Session["InventoryAPIType"] = InventoryAPIType; ViewBag.AmadeusRates = TempData["AmadeusRates"]; TempData.Keep("AmadeusRates"); List <CLayer.BookingItem> bookitems = new List <CLayer.BookingItem>(); if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus) { bookitems = BLayer.BookingItem.GetAllDetails(bookingId, true); } else { bookitems = BLayer.BookingItem.GetAllDetails(bookingId); } string HotelId = BLayer.Property.GetHotelId(BLayer.Bookings.GetPropertyId(bookingId)); if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus) { #region HOTEL SELL string Action = BLayer.Settings.GetValue(CLayer.Settings.STAYBAZARWBSHOTELSELLACTION);; CLayer.SearchCriteria srch = new CLayer.SearchCriteria(); srch.HotelCode = HotelId; List <CLayer.RoomStaysResult> RoomStaysResultList = APIUtility.AmedusHotelRoomStaysResultList; RoomStaysResultList = (List <CLayer.RoomStaysResult>)TempData["RoomStaysResult"]; TempData.Keep("RoomStaysResult"); string SoapHeaderStateful = string.Empty; foreach (var item in RoomStaysResultList) { string BookingCode = item.BookingCode; string HotelSellSoapBody = APIUtility.Hotel_Sell(HotelId, BookingCode); SoapHeaderStateful = APIUtility.SetStatefulSoapHeader(Action, Session["SessionId"].ToString(), Convert.ToInt32(Session["SequenceNumber"]), Session["SecurityToken"].ToString()); string result = APIUtility.GetAmedusResult(Action, SoapHeaderStateful, HotelSellSoapBody); if (!APIUtility.CheckHotelBookingErrorExists(result)) { Serializer HotelSell = new Serializer(); CLayer.HotelSell.Envelope HotelSellResult = HotelSell.Deserialize <CLayer.HotelSell.Envelope>(result); Session["HotelSellStatus"] = "success"; Session["SessionId"] = HotelSellResult.Header.Session.SessionId; Session["SequenceNumber"] = Convert.ToInt32(HotelSellResult.Header.Session.SequenceNumber); Session["SecurityToken"] = HotelSellResult.Header.Session.SecurityToken; returnvalue = true; } else { Serializer HotelSellError = new Serializer(); CLayer.HotelSell.Envelope HotelSellErrorResult = HotelSellError.Deserialize <CLayer.HotelSell.Envelope>(result); Session["HotelSellStatus"] = "error"; Session["SessionId"] = HotelSellErrorResult.Header.Session.SessionId; Session["SequenceNumber"] = Convert.ToInt32(HotelSellErrorResult.Header.Session.SequenceNumber); Session["SecurityToken"] = HotelSellErrorResult.Header.Session.SecurityToken; ViewBag.HotelSellResult = "error"; TempData["Errorcomes"] = "error"; #region PNR CANCEL string resultCancel = APIUtility.ExecutePNRCancel("", (int)CLayer.ObjectStatus.PNROptionCodes.OptionPNRGeneration); returnvalue = false; #endregion } } #endregion #region PNR MULTIELEMENTS-FINAL Action = BLayer.Settings.GetValue(CLayer.Settings.STAYBAZARWBSPNRADDACTION);; SoapHeaderStateful = APIUtility.SetStatefulSoapHeader(Action, Session["SessionId"].ToString(), Convert.ToInt32(Session["SequenceNumber"]), Session["SecurityToken"].ToString()); APIUtility.SoapHeaderStateful = SoapHeaderStateful; string BookingCodeFinal = RoomStaysResultList.OrderBy(x => x.AmountAfterTax).FirstOrDefault().BookingCode; string PNRADDSoapBody = APIUtility.PNR_AddMultielements(HotelId, BookingCodeFinal, "*****@*****.**", 11); TempData["RoomStaysResult"] = RoomStaysResultList; APIUtility.AmedusHotelRoomStaysResultList = RoomStaysResultList; string resultFinal = APIUtility.GetAmedusResult(Action, APIUtility.SoapHeaderStateful, PNRADDSoapBody); Serializer pnrser = new Serializer(); CLayer.PNRAddElementsConfirm.Envelope PNRAddResult = pnrser.Deserialize <CLayer.PNRAddElementsConfirm.Envelope>(resultFinal); Session["ControlNumber"] = PNRAddResult.Body.PNR_Reply.pnrHeader.reservationInfo.reservation.controlNumber; if (APIUtility.CheckHotelBookingErrorExists(resultFinal)) { Serializer HotelSellError = new Serializer(); CLayer.HotelSell.Envelope HotelSellErrorResult = HotelSellError.Deserialize <CLayer.HotelSell.Envelope>(resultFinal); Session["HotelSellStatus"] = "error"; Session["SessionId"] = HotelSellErrorResult.Header.Session.SessionId; Session["SequenceNumber"] = Convert.ToInt32(HotelSellErrorResult.Header.Session.SequenceNumber); Session["SecurityToken"] = HotelSellErrorResult.Header.Session.SecurityToken; #region PNR CANCEL string ControlNumber = Convert.ToString(Session["ControlNumber"]); string resultCancel = APIUtility.ExecutePNRCancel(ControlNumber, (int)CLayer.ObjectStatus.PNROptionCodes.OptionPNRFinalize); returnvalue = false; #endregion } else { returnvalue = true; } #endregion List <CLayer.BookingItem> objBookItems = BLayer.BookingItem.GetAccomodationFromBookingCode(BookingCodeFinal); foreach (var item in objBookItems) { BLayer.BookingItem.UpdateHotelConfirmNumber(item.BookingId, item.AccommodationId, Convert.ToString(Session["ControlNumber"])); } } } catch (Exception ex) { returnvalue = false; throw ex; } return(returnvalue); }
public bool UpdatePropertyDescriptionandImages() { bool result = false; long id1 = 0; string HotelID = string.Empty; try { String hotelcode = string.Empty; List <CLayer.Property> objProperties = BLayer.Property.GetAllGDSPropertiesWithOutData().ToList(); List <CLayer.Property> objDescriptions = BLayer.Property.GetAllGDSPropertyDescriptionsWithOutData(); // List<CLayer.Property> objFormattedDescriptions = BLayer.Property.GetAllGDSPropertyFormattedDescriptionsWithOutData(); List <CLayer.Property> objTitles = BLayer.Property.GetAllGDSPropertyTitlesWithOutData(); CLayer.GDSBookingDetails.Envelope ss = new CLayer.GDSBookingDetails.Envelope(); CLayer.GDSBookingDetailsAdv.Envelope ssAdv = new CLayer.GDSBookingDetailsAdv.Envelope();// ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel); long id = 0; foreach (var pitem in objProperties) { try { #region Update Property Description StringBuilder Description = new StringBuilder(); //Update property description start Serializer ser = new Serializer(); id = pitem.PropertyId; id1 = id; string HotelCode = pitem.HotelID; HotelID = HotelCode; string hotel = GetGDS_Hotel_Details(HotelCode); ss = ser.Deserialize <CLayer.GDSBookingDetails.Envelope>(hotel); DataTable dtHotel = BLayer.Property.GetHotelFormattedDescription(id); string FormattedDescription = string.Empty; if (dtHotel.Rows.Count > 0) { foreach (DataRow dr in dtHotel.Rows) { FormattedDescription = Convert.ToString(dr["FormattedDescription"]); } } if (string.IsNullOrEmpty(FormattedDescription)) { FormattedDescription = GDSProcess.GDSFormatDescription.GetFormattedDescription(hotel); BLayer.Property.GDSUpdatePropertyDescriptionFormatted(id, FormattedDescription, GDSProcess.GDSFormatDescription.StarRatings, ""); } int LocalStarRating = APIUtility.GetStarRating(hotel); if (LocalStarRating > 0) { BLayer.Property.GDSUpdatePropertyStarRatings(id, LocalStarRating); } if (ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents != null) { var TitleItem = objTitles.Where(x => x.HotelID == HotelCode).ToList(); if (TitleItem != null) { if (TitleItem.Count > 0) { string Title = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelName; BLayer.Property.GDSUpdatePropertyTitle(id, Title); } } #region Update Description Without Formatting if (string.IsNullOrEmpty(FormattedDescription)) { var DescriptionItem = objDescriptions.Where(x => x.HotelID == HotelCode).ToList(); if (DescriptionItem != null) { if (DescriptionItem.Count > 0) { if (ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo != null) { var description = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.Descriptions; if (description != null) { var descriptionList = description.MultimediaDescriptions.MultimediaDescription; var Descriptions = from order in descriptionList where order.TextItems != null select order; string HotelDescription = string.Empty; foreach (var desc in Descriptions) { if (desc.InfoCode != null) { foreach (var datas in desc.TextItems.TextItem.Description) { HotelDescription = HotelDescription + datas.__Text + "#256#"; } } // HotelDescription = HotelDescription + "<br>"; } Description.Append(HotelDescription); BLayer.Property.GDSUpdatePropertyDescription(id, Description.ToString()); } } } } } #endregion //update property description end #endregion #region Update Property Images old method // var ssw = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.Descriptions; //// var sswguest = ssAdv.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.CategoryCodes.GuestRoomInfo.Where(x => x.Code == 28); // if (ssw!=null) // { // var sswList = ssw; // List<CLayer.PropertyFiles> picturelist = new List<CLayer.PropertyFiles>(); // //var filteredOrders = from order in sswList // // where order.ImageItems != null // // select order; // int nos = 0; // BLayer.Property.DeleteGDSPropertyImages(id); // foreach (var item in sswList.MultimediaDescriptions.MultimediaDescription) // { // if (item.ImageItems != null) // { // var t = item.ImageItems.ImageItem; // if (t != null) // { // foreach (var itemimg in t) // { // CLayer.PropertyFiles picture = new CLayer.PropertyFiles(); // picture.FileName = itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL; // picture.PropertyId = id; // picturelist.Add(picture); // BLayer.Property.GDSSaveImageurl(id, picture.FileName); // nos++; // if (nos == PictureCount) break; // } // } // } // if (nos == PictureCount) break; // } // if(picturelist.Count<8) // { // ssAdv = ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel); // var sswguest = ssAdv.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.CategoryCodes.GuestRoomInfo.Where(x => x.Code == 28); // if (sswguest != null) // { // int PictureCount = 8 - picturelist.Count; // int ImgCounter = 0; // foreach (var item in sswguest) // { // foreach (var itemAdv in item.MultimediaDescriptions) // { // if (itemAdv.ImageItems != null) // { // var t = itemAdv.ImageItems; // if (t != null) // { // foreach (var itemimg in t) // { // CLayer.PropertyFiles picture = new CLayer.PropertyFiles(); // picture.FileName = itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL; // picture.PropertyId = id; // picturelist.Add(picture); // BLayer.Property.GDSSaveImageurl(id, picture.FileName); // ImgCounter++; // if (ImgCounter == PictureCount) break; // } // } // } // if (ImgCounter == PictureCount) break; // } // if (ImgCounter == PictureCount) break; // } // } // } // } #endregion #region update property contact numbers //update GDS Property contact numbers start CLayer.GDSBookingDetails.Envelope GDSBookingDetails = ss; string Phone = string.Empty; string Mobile = string.Empty; string Email = string.Empty; if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Emails != null) { Email = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Emails.Email.ToString(); } if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones != null) { if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "1").Count() > 0) { Phone = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "1").FirstOrDefault().PhoneNumber; } if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "5").Count() > 0) { Mobile = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "5").FirstOrDefault().PhoneNumber; } if ((!string.IsNullOrEmpty(Phone)) || (!string.IsNullOrEmpty(Mobile)) || (!string.IsNullOrEmpty(Email))) { BLayer.Property.GDSUpdatePropertyContactNumbers(id, Phone, Mobile, Email); } } //update GDS Property Contact numbers end //#region Transaction Log //APIUtility.GenerateGDSTransactionLog("", "BulkImageandDescriptionSuccess", 0, (int)CLayer.ObjectStatus.GDSType.BulkHotelImageDescriptionUpdation, 0); //#endregion Transaction log end #endregion } #region UPDATE PROPERTY IMAGES long ImageCount = BLayer.Property.GetGDSPropertyImagesCount(id); if (ImageCount < 1) { BLayer.Property.DeleteGDSPropertyImages(id); List <CLayer.PropertyFiles> pictlist = GetGDSImages(hotel, id); } #endregion // WriteToLog(HotelID); } catch (Exception ex) { // LogHandler.AddLog("Error in-"+hotelcode); WriteToLog(HotelID, true); } finally { } } result = true; } catch (Exception ex) { LogHandler.AddLog(ex.Message); string a = id1.ToString(); result = false; throw ex; } return(result); }
private List <CLayer.PropertyFiles> GetGDSImages(string response, long id) { List <CLayer.PropertyFiles> picturelist = new List <CLayer.PropertyFiles>(); XmlDocument xmlDoc = new XmlDocument(); string a = string.Empty; // List<CLayer.PropertyFiles> pictureslist = new List<CLayer.PropertyFiles>(); try { // xmlDoc.Load(@"F:\HotelDescriptiveIno.xml"); xmlDoc.LoadXml(response); XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable); XmlNode node = null; XmlNode nodeImages = null; XmlNode nodeguestImages = null; string nodeRoot = "/soapenv:Envelope/soapenv:Body/"; string nodevalue = "/si:OTA_HotelDescriptiveInfoRS/si:HotelDescriptiveContents/si:HotelDescriptiveContent/si:HotelInfo/si:Descriptions"; //"/si:MultimediaDescriptions/si:MultimediaDescription/si:ImageItems/si:ImageItem/si:ImageFormat/si:URL"; string nodevalueguestroom = "/si:OTA_HotelDescriptiveInfoRS/si:HotelDescriptiveContents/si:HotelDescriptiveContent/si:HotelInfo/si:CategoryCodes/si:CategoryCodes/si:GuestRoomInfo"; //si:MultimediaDescriptions/si:MultimediaDescription/si:ImageItems/si:ImageItem/si:ImageFormat/si:URL"; xmlnsManager.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); xmlnsManager.AddNamespace("awsse", "http://xml.amadeus.com/2010/06/Session_v3"); xmlnsManager.AddNamespace("wsa", "http://www.w3.org/2005/08/addressing"); xmlnsManager.AddNamespace("si", "http://www.opentravel.org/OTA/2003/05"); nodeImages = xmlDoc.SelectSingleNode(nodeRoot + nodevalue, xmlnsManager); nodeguestImages = xmlDoc.SelectSingleNode(nodeRoot + nodevalueguestroom, xmlnsManager); #region MAIN IMAGES if (nodeImages != null) { XmlNodeList list = nodeImages.SelectNodes("//si:MultimediaDescriptions/si:MultimediaDescription", xmlnsManager); int PictureCount = 0; int nodes = 0; if (list != null) { foreach (XmlNode item in list) { var subItem = item.SelectNodes("//si:ImageItems", xmlnsManager); if (subItem != null) { foreach (XmlNode sItem in subItem) { IEnumerable <XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem", xmlnsManager).Cast <XmlNode>().OrderByDescending(r => Convert.ToDateTime(r.Attributes["LastModifyDateTime"].Value)); // IEnumerable<XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager).Cast<XmlNode>().OrderByDescending(r => Convert.ToDecimal(r.Attributes["LastModifyDateTime"].Value)); if (subInnerItem != null) { foreach (XmlNode sItem1 in subInnerItem) { var subUrlItem = sItem1.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager); if (subUrlItem != null) { PictureCount = subInnerItem.Count(); foreach (XmlNode UItem in subUrlItem) { var UrlItem = UItem.ChildNodes[0].InnerText; //url bool bImageExists = true; if (!string.IsNullOrEmpty(UrlItem)) { bImageExists = APIUtility.DoesImageExistRemotely(UrlItem); } if (bImageExists) { CLayer.PropertyFiles picture = new CLayer.PropertyFiles(); picture.FileName = UrlItem;// itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL; picture.PropertyId = id; picture.IsValid = true; picturelist.Add(picture); BLayer.Property.GDSSaveImageurl(id, picture.FileName); } nodes++; if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } } #endregion #region GUESTROOMIMAGES if (nodeguestImages != null) { XmlNodeList listGuestRoomImages = nodeguestImages.SelectNodes("//si:MultimediaDescriptions/si:MultimediaDescription", xmlnsManager); if (listGuestRoomImages != null) { int PictureCount = 0; int nodes = 0; foreach (XmlNode item in listGuestRoomImages) { var subItem = item.SelectNodes("//si:ImageItems", xmlnsManager); if (subItem != null) { foreach (XmlNode sItem in subItem) { IEnumerable <XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem", xmlnsManager).Cast <XmlNode>().OrderByDescending(r => Convert.ToDateTime(r.Attributes["LastModifyDateTime"].Value)); // IEnumerable<XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager).Cast<XmlNode>().OrderByDescending(r => Convert.ToDecimal(r.Attributes["LastModifyDateTime"].Value)); if (subInnerItem != null) { foreach (XmlNode sItem1 in subInnerItem) { var subUrlItem = sItem1.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager); if (subUrlItem != null) { PictureCount = subInnerItem.Count(); foreach (XmlNode UItem in subUrlItem) { var UrlItem = UItem.ChildNodes[0].InnerText; //url bool bImageExists = true; if (!string.IsNullOrEmpty(UrlItem)) { bImageExists = APIUtility.DoesImageExistRemotely(UrlItem); } if (bImageExists) { CLayer.PropertyFiles picture = new CLayer.PropertyFiles(); picture.FileName = UrlItem;// itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL; picture.PropertyId = id; picturelist.Add(picture); BLayer.Property.GDSSaveImageurl(id, picture.FileName); } nodes++; if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } if (nodes == PictureCount) { break; } } } } #endregion } catch (Exception ex) { LogHandler.AddLog(ex.Message); } return(picturelist); }