Untitled
csharp
a month ago
18 kB
1
Indexable
Never
[HttpGet] [Route("CreatePrint/{QuoteID}")] public clsQuote CreatePrint(string QuoteID) { OleDbDataReader objReader; double tempValue; bool hasCreditDiscount = false; double tempDiscountValue; string Template = _hostingEnvironment.ContentRootPath + "\\Templates\\Quote_Print.html"; string QuoteTxt = System.IO.File.ReadAllText(Template); //CAMBIO LOS DATOS DE LA AGENCIA Y DEL QUOTE double Discount = 0; objReader = AV_Database.DameReader("select *,dbo.[GetQuoteDiscount](QuoteID) discount from quotes where quoteid=" + QuoteID, configuration.GetConnectionString("BaseEnix")); objReader.Read(); string AgencyID = objReader["AgencyID"].ToString(); string QuoteName = objReader["Name"].ToString(); string QuoteComments = objReader["Comments"].ToString(); Discount = Convert.ToDouble(objReader["Discount"]); objReader = null; objReader = AV_Database.DameReader("select ISNULL(Name,'blank.jpg'),Company,Address,zoneid,isnull(phone,'') phone from agency where AgencyID=" + AgencyID, configuration.GetConnectionString("BaseEnix")); objReader.Read(); string AgencyLogo = configuration.GetSection("General")["BaseBackoffice"].ToString() + "/imagen/agency/" + objReader[0].ToString(); string AgencyName = objReader["Company"].ToString(); string AgencyAddress1 = objReader["Address"].ToString(); string AgencyAddress2 = objReader["zoneid"].ToString(); string AgencyPhone = objReader["phone"].ToString(); objReader.Close(); objReader = null; //GET CURRENCY SIGN string MoneySign = "$"; // usd objReader = AV_Database.DameReader("select * from agency_ext inner join currency on currency.id=agency_ext.DefaultCurrency where agencyid=" + AgencyID, configuration.GetConnectionString("BaseEnix")); if (objReader.HasRows == true) { objReader.Read(); if (objReader["code"].ToString() == "BRL") { MoneySign = "R$"; } } objReader = null; objReader = AV_Database.DameReader("SELECT City + ', ' + State + ', ' + Country FROM vw_Cities where zoneid=" + AgencyAddress2, configuration.GetConnectionString("BaseEnix")); objReader.Read(); AgencyAddress2 = objReader[0].ToString().ToTitleCase(); objReader = null; double Total = 0; double TotalDescuento = 0; string Servicios = ""; string Servicio; //CARGO SERVICIOS List<SMT_BlazorWebApp.Shared.Booking.clsQuoteItem> QuoteItems = GetAgencyQuotesDetails(QuoteID); foreach (var objItemQuote in QuoteItems) { Servicio = ""; string Line1 = ""; string Line2_Arrival = "Arrival: " + objItemQuote.SearchObject.DateFrom.ToString("dd/MMM/yyyy") + " - " + objItemQuote.SearchObject.DateTo.ToString("dd/MMM/yyyy"); string Line3 = ""; Line1 = objItemQuote.ObjectBooking.SelectedObject.Address; Line3 = objItemQuote.ObjectBooking.SelectedObject.City + " - " + objItemQuote.ObjectBooking.SelectedObject.Country; switch (objItemQuote.SearchObject.searchType) { case SearchType.Hotels: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_hotel.jpg' style='width:60px'></td>"; break; case SearchType.UniversalResort: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_hotel.jpg' style='width:60px'></td>"; break; case SearchType.DisneyResort: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_disney.jpg' style='width:60px'></td>"; break; case SearchType.DisneyTickets: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_admission.jpg' style='width:60px'></td>"; break; case SearchType.UniversalTickets: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_admission.jpg' style='width:60px'></td>"; break; case SearchType.Admissions: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_admission.jpg' style='width:60px'></td>"; break; case SearchType.Insurance: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_insurance.jpg' style='width:60px'></td>"; break; case SearchType.Cars: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_car.jpg' style='width:60px'></td>"; Line1 = "Pickup: " + objItemQuote.SearchObject.SearchObject.Nombre + " - " + objItemQuote.SearchObject.DateFrom.ToString("dd/MMMM/yyyy hh:mm:tt"); Line3 = "Dropoff: " + objItemQuote.SearchObject.SearchObject_Destination.Nombre + " - " + objItemQuote.SearchObject.DateTo.ToString("dd/MMMM/yyyy hh:mm:tt"); break; case SearchType.Transfers: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_transfer.jpg' style='width:60px'></td>"; Line1 = "Airline: " + objItemQuote.ObjectBooking.SelectedObject.Transfer_Airline + " - " + objItemQuote.ObjectBooking.SelectedObject.Transfer_Hour; Line3 = "Comment: " + objItemQuote.ObjectBooking.SelectedObject.Transfer_Comment; break; case SearchType.Excursions: Servicio = "<tr><td class='IconCell' valign='center'><img src='https://content.enix.travel/icons/icon_excursion.jpg' style='width:60px'></td>"; break; } Servicio += " <td class='voucher-numbersCell2' valign='top' style='width:100%'><table width='100%' class='voucher-productDescription'><tr>"; string Paxes = ""; Paxes = objItemQuote.SearchObject.Rooms[0].Adults.ToString() + " (AD) "; if (objItemQuote.SearchObject.Rooms[0].Childs > 0) { Paxes += "- " + objItemQuote.SearchObject.Rooms[0].Childs.ToString() + " (CD)"; } if (objItemQuote.ObjectBooking.HasCreditDiscount) { hasCreditDiscount = true; { tempValue = objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.GetPriceCurrencyFirstCurrency(); tempDiscountValue = tempValue - (tempValue * (objItemQuote.ObjectBooking.CreditDiscount)); //this.HasCreditDiscountHelper = objQuoteItem.ObjectBooking.HasCreditDiscount; //var totalCost = ((@objQuoteItem.ObjectBooking.SelectedObject_SubItem.Price_Enix.MainCurrency_MarkedUp) * ExchangeRate); //sumTotalCosts += totalCost; //TotalTest = sumTotalCosts; //TotalDiscounted += tempDiscountValue; } if (objItemQuote.SearchObject.searchType == SearchType.DisneyResort) { if (objItemQuote.SearchObject.Disney_AdmissionTypeID != 0) { double exchangeRate = objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.CurrencyPrices[0].ExchangeRate; tempValue = (((objItemQuote.Item_OriginalValue + objItemQuote.Item_MarkupFixed) / (1 - (objItemQuote.Item_MarkupPercentage / 100))) * exchangeRate); tempDiscountValue = tempValue - (tempValue * (objItemQuote.ObjectBooking.CreditDiscount)); TotalDescuento += tempDiscountValue; //Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + " - " + objItemQuote.SearchObject.Disney_AdmissionDays + " " + objItemQuote.SearchObject.Disney_AdmissionType + "</td><td style='padding-bottom:5px' rowspan='4'>" + MoneySign + " " + (((objItemQuote.Item_OriginalValue + objItemQuote.Item_MarkupFixed) * (1 + (objItemQuote.Item_MarkupPercentage / 100))) * exchangeRate).ToString("0.00") + "</td></tr>"; Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + " - " + objItemQuote.SearchObject.Disney_AdmissionDays + " " + objItemQuote.SearchObject.Disney_AdmissionType + "</td><td style='padding-bottom:5px' rowspan='4'>À vista com desconto <br><font style='color:red !important'>" + MoneySign + " " + tempDiscountValue.ToString("0.00") + "</font><br><font style='color:red !important'>" + MoneySign + " " + tempValue.ToString("0.00") + "</font> no cartão<br>Em até 10x sem juros de<br><font style='color:red !important'>" + MoneySign + " " + (tempValue / 10).ToString("0.00") + "</font></td></tr>"; } else { TotalDescuento += tempDiscountValue; //Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + "</td><td style='padding-bottom:5px' rowspan='4'>" + MoneySign + " " + objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.GetPriceCurrencyFirstCurrency().ToString("0.00") + "</td></tr>"; Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + "</td><td style='padding-bottom:5px' rowspan='4'>À vista com desconto<br><font style='color:red !important'>" + MoneySign + " " + tempDiscountValue.ToString("0.00") + "</font><br><font style='color:red !important'>" + MoneySign + " " + tempValue.ToString("0.00") + "</font> no cartão<br>Em até 10x sem juros de<br><font style='color:red !important'>" + MoneySign + " " + (tempValue / 10).ToString("0.00") + "</font></td></tr>"; } } else { TotalDescuento += tempDiscountValue; Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + "</td><td style='padding-bottom:5px' rowspan='4'>À vista com desconto<br><font style='color:red !important'>" + MoneySign + " " + tempDiscountValue.ToString("0.00") + "</font><br><font style='color:red !important'>" + MoneySign + " " + tempValue.ToString("0.00") + "</font> no cartão<br>Em até 10x sem juros de<br><font style='color:red !important'>" + MoneySign + " " + (tempValue / 10).ToString("0.00") + "</font></td></tr>"; } Servicio += "<tr ><td style='width:40%;padding-right:10px'>" + objItemQuote.ObjectBooking.SelectedObject_SubItem.Name + "</td><td style='width:40%'>" + Line1 + "</td></tr>"; Servicio += "<tr><td style='width:40%'>" + Line2_Arrival + "</td><td style='width:40%'>" + Line3 + "</td></tr>"; Servicio += "<tr><td style='width:40%'>" + Paxes + "</td><td></td></tr>"; Servicio += "</tr></table></td>"; Servicio += "</tr>"; Servicios += Servicio; } else { if (objItemQuote.SearchObject.searchType == SearchType.DisneyResort) { if (objItemQuote.SearchObject.Disney_AdmissionTypeID != 0) { double exchangeRate = objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.CurrencyPrices[0].ExchangeRate; Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + " - " + objItemQuote.SearchObject.Disney_AdmissionDays + " " + objItemQuote.SearchObject.Disney_AdmissionType + "</td><td style='padding-bottom:5px'>" + MoneySign + " " + (((objItemQuote.Item_OriginalValue + objItemQuote.Item_MarkupFixed) / (1 - (objItemQuote.Item_MarkupPercentage / 100))) * exchangeRate).ToString("0.00") + "</td></tr>"; } else { Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + "</td><td style='padding-bottom:5px'>" + MoneySign + " " + objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.GetPriceCurrencyFirstCurrency().ToString("0.00") + "</td></tr>"; } } else { Servicio += "<tr style='font-weight:bold'><td colspan=2 style='width:80%;padding-bottom:5px'>" + objItemQuote.ObjectBooking.SelectedObject.Name + "</td><td style='padding-bottom:5px'>" + MoneySign + " " + objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.GetPriceCurrencyFirstCurrency().ToString("0.00") + "</td></tr>"; } Servicio += "<tr ><td style='width:40%;padding-right:10px'>" + objItemQuote.ObjectBooking.SelectedObject_SubItem.Name + "</td><td style='width:40%'>" + Line1 + "</td><td></td></tr>"; Servicio += "<tr><td style='width:40%'>" + Line2_Arrival + "</td><td style='width:40%'>" + Line3 + "</td><td></td></tr>"; Servicio += "<tr><td style='width:40%'>" + Paxes + "</td><td></td><td></td></tr>"; Servicio += "</tr></table></td>"; Servicio += "</tr>"; Servicios += Servicio; } if (objItemQuote.SearchObject.searchType == SearchType.DisneyResort) { double exchangeRate = objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.CurrencyPrices[0].ExchangeRate; Total += (((objItemQuote.Item_OriginalValue + objItemQuote.Item_MarkupFixed) / (1 - (objItemQuote.Item_MarkupPercentage / 100))) * exchangeRate); } else { Total += objItemQuote.ObjectBooking.SelectedObject_SubItem.Price_Enix.GetPriceCurrencyFirstCurrency(); } } //REAMPLAZOS HEADER QuoteTxt = QuoteTxt.Replace("_LOGOURL_", AgencyLogo); QuoteTxt = QuoteTxt.Replace("_QUOTENAME_", QuoteName.ToTitleCase()); QuoteTxt = QuoteTxt.Replace("_QUOTEID_", QuoteID); QuoteTxt = QuoteTxt.Replace("_AGENCY_", AgencyName.ToUpper()); if (configuration.GetValue<string>("TTC_Instance") == "SUNCOAST") { QuoteTxt = QuoteTxt.Replace("_ADDRESS1_", AgencyPhone); QuoteTxt = QuoteTxt.Replace("_ADDRESS2_", ""); } else { QuoteTxt = QuoteTxt.Replace("_ADDRESS1_", AgencyAddress1); QuoteTxt = QuoteTxt.Replace("_ADDRESS2_", AgencyAddress2); } QuoteTxt = QuoteTxt.Replace("_QUOTECOMMENT_", QuoteComments); //GENERACION DE SERVICIOS QuoteTxt = QuoteTxt.Replace("_CONTENIDO_", Servicios); //REEMPLAZO FOOTER if (hasCreditDiscount) { QuoteTxt = QuoteTxt.Replace("_QUOTETOTAL_", "Total Geral à vista: " + MoneySign + " " + TotalDescuento.ToString("0.00") + "<br><br>No cartão (até 10x de " + MoneySign + " " + (Total / 10).ToString("0.00") + " sem juros) " + MoneySign + " " + Total.ToString("0.00")); } else { QuoteTxt = QuoteTxt.Replace("_QUOTETOTAL_", "Total: " + MoneySign + " " + Total.ToString("0.00")); } //ESCRIBE HTML string TemplateOut = configuration.GetValue<string>("QuotePath"); System.IO.File.WriteAllText(TemplateOut + QuoteID + ".html", QuoteTxt); //MANDAR A PROCESAR EL PDF PDF_Generator.PDF_GeneratorSoapClient objPDF = new PDF_Generator.PDF_GeneratorSoapClient(PDF_Generator.PDF_GeneratorSoapClient.EndpointConfiguration.PDF_GeneratorSoap12, configuration.GetSection("General")["BackendPDF"].ToString()); objPDF.ConvertHTML_ToPDF(TemplateOut + QuoteID + ".html", TemplateOut, "Quote_" + QuoteID); objPDF = null; clsQuote salida = new clsQuote(); salida.PDFPath = configuration.GetValue<string>("QuoteURL") + "Quote_" + QuoteID + ".pdf"; //DEVUELVO EL PATH AL QUOTE.PDF return salida; }