public ActionResult ETicket(string id) { try { long PNRid = Int64.Parse(id); int agentid = ticketprovider.GetAgentIdbyPNRId(PNRid); ETicketViewModel viewmodel = ticketprovider.GetAllInformationForeTicket(PNRid, agentid); viewmodel.PNRSectorList = ticketprovider.DeterminePNRSectorCount(PNRid); viewmodel.PassengerList = ticketprovider.GetPassengerListByPNRID(PNRid, agentid); viewmodel.PNRSegmentList = ticketprovider.GetPNRSegmentListByPNRSectorID(PNRid); viewmodel.ShowFareOnETicket = ticketprovider.ShowFareOnETicket(agentid); viewmodel.ShowAgentLogoOnETicket = ticketprovider.ShowAgentLogoOnETicket(agentid); viewmodel.AirlineVendorLocators = ticketprovider.GetAirlineVendorLocatorsById(PNRid); viewmodel.OperatingAirline = ticketprovider.GetAirlineCodeByMasterPnrId(PNRid); string htmlContent = RenderPartialViewToString(viewmodel); using (ImagePathFixer pathFixer = new ImagePathFixer()) { htmlContent = pathFixer.FixImagePath(htmlContent); using (TempHtmlFile file = new TempHtmlFile()) { file.Write(htmlContent); DownloadPdf(file); } } } catch (Exception ex) { } return(new EmptyResult()); }
public ActionResult ETicket(long id) { long PNRid = id; int agentid = ticketprovider.GetAgentIdbyPNRIdLcc(PNRid); var masterpnrsresult = ticketprovider.GetTicketStatusIdByMPNRId(id); ETicketViewModel viewmodel; if (masterpnrsresult.TicketStatusId == 29) { viewmodel = ticketprovider.GetB2CMasterInformationForeTicket(id, masterpnrsresult.CreatedBy); } else { viewmodel = ticketprovider.GetLccMasterInformationForeTicket(id, agentid); } viewmodel.PNRList = ticketprovider.GetLccPNRInformationForeTicket(viewmodel.MasterPNRId); viewmodel.PNRSectorList = ticketprovider.GetAllLccPNRSector(viewmodel.MasterPNRId); viewmodel.PNRSegmentList = ticketprovider.GetAllLccPNRSegment(viewmodel.MasterPNRId); viewmodel.PassengerList = ticketprovider.GetAllLccPNRPassenger(id); viewmodel.ShowFareOnETicket = ticketprovider.ShowFareOnETicket(agentid); viewmodel.ShowAgentLogoOnETicket = ticketprovider.ShowAgentLogoOnETicket(agentid); viewmodel.ShowServiceChargeOnETicket = ticketprovider.isLccServiceChargeIncludeInTax(agentid); string htmlContent = RenderPartialViewToString(viewmodel); using (ImagePathFixer pathFixer = new ImagePathFixer()) { htmlContent = pathFixer.FixImagePath(htmlContent); using (TempHtmlFile file = new TempHtmlFile()) { file.Write(htmlContent); DownloadPdf(file); } } return(new EmptyResult()); //Require No ActionExecutingContext ActionFilterAttribute }
private void buttonExport_Click(object sender, EventArgs e) { var cwd = new CancellableWorkerDialog { Information = "Производится экспорт документа, представляющего собой типовой отчет об оценке недвижимости, в Microsoft Word.\n\nРезультирующий документ будет открыт в новом окне Microsoft Word.", Cancellable = false, }; cwd.Worker = x => { x.UpdateProgress(10, "Инициализация Microsoft Word"); var w = new Word() as IWord; if (w == null) { MessageBox.Show(this, "Не удается инициализировать Microsoft Word.\nУбедитесь, что он установлен.", "Модуль Экспорта Данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Scenario.LastReportId = Guid.NewGuid(); //var infileMain = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Guid.NewGuid() + ".main.html")); //var infileAppendix = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Guid.NewGuid() + ".apendix.html")); var outfile = new FileInfo(Path.Combine( #if DEBUG && USE_TDISK @"T:\" #else Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) #endif , Scenario.LastReportId + ".doc")); x.UpdateProgress(20, "Экспорт отчета"); var infileMain = new TempHtmlFile(MainSource); x.UpdateProgress(40, "Экспорт приложений"); var infileAppendix = new TempHtmlFile(AppendixSource); //using (var writer = new StreamWriter(File.OpenWrite(infileMain.FullName), Encoding.GetEncoding(0x4e3)))writer.Write(MainSource); //using (var writer = new StreamWriter(File.OpenWrite(infileAppendix.FullName), Encoding.GetEncoding(0x4e3)))writer.Write(AppendixSource); var doc = w.Documents.Add(); doc.Range().InsertFile(infileMain.FullName); infileMain.Delete(); var s = doc.Sections.Add(); s.PageSetup.Orientation = PageOrientation.Landscape; s.Range.InsertFile(infileAppendix.FullName); infileAppendix.Delete(); x.UpdateProgress(60, "Форматирование документа"); doc.Range().Find.Execute("$$$newline$$$", false, false, false, false, false, false, false, null, "^m", 2); doc.SaveAs(outfile.FullName); x.UpdateProgress(90, "Почти все готово"); w.Visible = true; Marshal.FinalReleaseComObject(s); Marshal.FinalReleaseComObject(doc); Marshal.FinalReleaseComObject(w); GC.Collect(); GC.WaitForPendingFinalizers(); }; cwd.ShowDialog(this); }