public async Task<ActionResult> GuestReconciliationReport(ReportPresenter reportPresenter, string pageNumber) { reportPresenter.GuestReconciliationSearchParameters = SessionData.Instance.GuestReconciliationSearchParameters != null && !string.IsNullOrEmpty(pageNumber) ? SessionData.Instance.GuestReconciliationSearchParameters : reportPresenter.GuestReconciliationSearchParameters; if (reportPresenter != null && reportPresenter.GuestReconciliationSearchParameters != null) { reportPresenter.GuestReconciliationSearchParameters.PageNumber = (!string.IsNullOrEmpty(pageNumber) && !pageNumber.Equals(UndefinedConstant)) ? (Convert.ToInt32(pageNumber) > 0 ? Convert.ToInt32(pageNumber) / ApplicationSettings.MaxPageSize : 1) : 1; if (string.IsNullOrEmpty(reportPresenter.GuestReconciliationSearchParameters.VoyageId)) { var voyage = reportPresenter.ActiveVoyages.OrderByDescending(d => d.EmbarkDate).FirstOrDefault(item => item.IsActive); reportPresenter.GuestReconciliationSearchParameters.VoyageName = voyage != null ? voyage.Name : string.Empty; reportPresenter.GuestReconciliationSearchParameters.VoyageId = voyage != null ? voyage.VoyageId : string.Empty; } else { var voyage = reportPresenter.ActiveVoyages.FirstOrDefault(item => item.VoyageId.Equals(reportPresenter.GuestReconciliationSearchParameters.VoyageId)); reportPresenter.GuestReconciliationSearchParameters.VoyageName = voyage != null ? voyage.Name : string.Empty; } reportPresenter.GuestReconciliationSearchParameters.ShipId = SessionData.Instance.MasterData.Ship.ShipId; reportPresenter.GuestReconciliationSearchParameters.ItineraryDate = BaseController.GenerateLocalDateTime(DateTime.UtcNow).ToString(this.ApplicationSettings.ShipDateTimeFormat); reportPresenter.GuestReconciliationSearchParameters.PageSize = SessionData.Instance.PagingNumberOfRecords; reportPresenter.GuestReconciliationSearchParameters.ExceptionStartDate = !string.IsNullOrEmpty(reportPresenter.GuestReconciliationSearchParameters.ExceptionStartDate) ? Convert.ToDateTime(reportPresenter.GuestReconciliationSearchParameters.ExceptionStartDate).ToString(this.ApplicationSettings.ShipDateTimeFormat, CultureInfo.InvariantCulture) : null; reportPresenter.GuestReconciliationSearchParameters.ExceptionEndDate = !string.IsNullOrEmpty(reportPresenter.GuestReconciliationSearchParameters.ExceptionEndDate) ? Convert.ToDateTime(reportPresenter.GuestReconciliationSearchParameters.ExceptionEndDate).ToString(this.ApplicationSettings.ShipDateTimeFormat, CultureInfo.InvariantCulture) : null; if (!string.IsNullOrEmpty(reportPresenter.GuestReconciliationSearchParameters.SearchName)) { if (reportPresenter.GuestReconciliationSearchParameters.SearchName.Contains(Comma)) { var name = reportPresenter.GuestReconciliationSearchParameters.SearchName.Split(Comma); reportPresenter.GuestReconciliationSearchParameters.LastName = name[0].Trim(); reportPresenter.GuestReconciliationSearchParameters.FirstName = name[1].Trim(); } else { reportPresenter.GuestReconciliationSearchParameters.LastName = reportPresenter.GuestReconciliationSearchParameters.SearchName.Trim(); } } var guestReconciliation = await this.reportManager.RetrieveGuestReconciliationReportAsync(reportPresenter.GuestReconciliationSearchParameters); if (guestReconciliation != null) { reportPresenter.MapGuestReconciliationSearchResult(guestReconciliation); if (reportPresenter.CheckedInGuestsItems.Count > 0) { reportPresenter.CheckedInGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; }); } if (reportPresenter.OnboardGuestsItems.Count > 0) { reportPresenter.OnboardGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; }); } reportPresenter.TotalRecordCount = guestReconciliation.GuestReconciliationReport.TotalResult; reportPresenter.TotalOnboardGuest = guestReconciliation.GuestReconciliationReport.TotalOnboardGuest; reportPresenter.TotalCheckedInGuest = guestReconciliation.GuestReconciliationReport.TotalCheckedInGuest; } reportPresenter.NoRecordFound = reportPresenter.ShipSummaryItems.Count <= 0 && reportPresenter.CheckedInGuestsItems.Count <= 0 && reportPresenter.OnboardGuestsItems.Count <= 0; SessionData.Instance.AssignGuestReconciliationData(reportPresenter.GuestReconciliationSearchParameters); } return this.PartialView(GuestReconciliationPartialView, reportPresenter); }
/// <summary> /// Retrieves the guest reconciliation. /// </summary> /// <param name="type">The type.</param> /// <returns> /// The Task /// </returns> private async Task RetrieveGuestReconciliation(string type) { string reportName = "GuestReconciliation", reportTitle = "Guest Reconciliation Report", voyageIds = string.Empty; var searchFilter = SessionData.Instance.GuestReconciliationSearchParameters; searchFilter.PageSize = 0; searchFilter.PageNumber = 1; var reportPresenter = new ReportPresenter(); var guestReconciliation = await this.reportManager.RetrieveGuestReconciliationReportAsync(searchFilter); if (guestReconciliation != null) { reportPresenter.MapGuestReconciliationSearchResult(guestReconciliation); if (reportPresenter.CheckedInGuestsItems.Count > 0) { reportPresenter.CheckedInGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) && CheckValidImagePath(item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst) ? new Uri(item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst).AbsoluteUri : GetImagePath(); }); } if (reportPresenter.OnboardGuestsItems.Count > 0) { reportPresenter.OnboardGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) && CheckValidImagePath(item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst) ? new Uri(item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst).AbsoluteUri : GetImagePath(); }); } } if (string.IsNullOrEmpty(searchFilter.VoyageId)) { if (SessionData.Instance.MasterData.Voyages.Count > 0) { voyageIds = string.Join(CommaSeparator, SessionData.Instance.MasterData.Voyages.Select(id => id.VoyageId)); } } else { if (searchFilter.VoyageId.IndexOf(",", StringComparison.InvariantCultureIgnoreCase) > 0) { var voyageList = searchFilter.VoyageId.Split(','); foreach (var item in voyageList) { var voyageItem = SessionData.Instance.MasterData.Voyages.FirstOrDefault(voyage => voyage.VoyageId.Equals(item.ToString(CultureInfo.InvariantCulture))); voyageIds += string.Format(CultureInfo.InvariantCulture, "{0}{1}", voyageItem != null ? voyageItem.Name : string.Empty, CommaSeparator); } voyageIds = voyageIds.TrimEnd(','); } else { var voyageItem = SessionData.Instance.MasterData.Voyages.FirstOrDefault(voyage => voyage.VoyageId.Equals(searchFilter.VoyageId)); voyageIds = voyageItem != null ? voyageItem.Name : string.Empty; } } var dt = new DataTable(); dt.Clear(); dt.Columns.Add("System"); dt.Columns.Add("Total"); dt.Columns.Add("Onboard"); dt.Columns.Add("No Show"); foreach (var summary in reportPresenter.ShipSummaryItems) { DataRow dataRow = dt.NewRow(); dataRow["System"] = summary.SystemType; dataRow["Total"] = summary.TotalOccupancy; dataRow["Onboard"] = summary.StatusCount; dataRow["No Show"] = summary.NoShowCount; dt.Rows.Add(dataRow); } var dataOG = new DataTable(); dataOG.Clear(); dataOG.Columns.Add("Stateroom"); dataOG.Columns.Add("Name"); dataOG.Columns.Add("Booking No"); dataOG.Columns.Add("Sequence No"); dataOG.Columns.Add("Apass Swipe Time"); dataOG.Columns.Add("Photo"); dataOG.Columns.Add("Cancellation"); dataOG.Columns.Add("GuestStatus"); foreach (var guest in reportPresenter.OnboardGuestsItems) { DataRow dataOGRow = dataOG.NewRow(); dataOGRow["Stateroom"] = guest.Stateroom; dataOGRow["Name"] = guest.LastName + " " + guest.FirstName; dataOGRow["Booking No"] = guest.BookingNo; dataOGRow["Sequence No"] = guest.SequenceNumber; dataOGRow["Apass Swipe Time"] = guest.OnboardTime; dataOGRow["Photo"] = guest.MediaItemAddress; dataOGRow["Cancellation"] = string.Empty; dataOGRow["GuestStatus"] = guest.Status; dataOG.Rows.Add(dataOGRow); } var dataCI = new DataTable(); dataCI.Clear(); dataCI.Columns.Add("Stateroom"); dataCI.Columns.Add("Name"); dataCI.Columns.Add("Booking No"); dataCI.Columns.Add("Checked-In Time"); dataCI.Columns.Add("Check-In By"); dataCI.Columns.Add("Photo"); dataCI.Columns.Add("GuestStatus"); foreach (var guest in reportPresenter.CheckedInGuestsItems) { DataRow dataCIRow = dataCI.NewRow(); dataCIRow["Stateroom"] = guest.Stateroom; dataCIRow["Name"] = guest.LastName + " " + guest.FirstName; dataCIRow["Booking No"] = guest.BookingNo; dataCIRow["Checked-In Time"] = guest.CheckedInDate; dataCIRow["Check-In By"] = guest.CheckInBy; dataCIRow["Photo"] = guest.MediaItemAddress; dataCIRow["GuestStatus"] = guest.Status; dataCI.Rows.Add(dataCIRow); } DataSet dataSet = new DataSet(); dataSet.Tables.Add(dt); dataSet.Tables.Add(dataOG); dataSet.Tables.Add(dataCI); if (type == ExcelConst) { this.excelProvider.PrepareExcel(dataSet, reportName, reportTitle, this.Response, this.Server, voyageIds); } else if (type == PDFConst) { string html = string.Empty; var pdfTable = new PdfPTable(4); pdfTable.DefaultCell.Padding = 3; pdfTable.WidthPercentage = 100; pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; pdfTable.DefaultCell.BorderWidth = 1; var header = new PdfPCell(new Phrase("\nGuest Reconciliation Report", new Font(Font.FontFamily.TIMES_ROMAN, 30))); header.VerticalAlignment = Element.ALIGN_MIDDLE; header.HorizontalAlignment = Element.ALIGN_CENTER; header.FixedHeight = 100; header.Colspan = 17; pdfTable.AddCell(header); var summaryHeader = new PdfPCell(new Phrase("\nEmbarkation Statistics For " + voyageIds)); summaryHeader.VerticalAlignment = Element.ALIGN_MIDDLE; summaryHeader.HorizontalAlignment = Element.ALIGN_CENTER; summaryHeader.FixedHeight = 50; summaryHeader.Colspan = 8; pdfTable.AddCell(summaryHeader); foreach (DataColumn column in dt.Columns) { var cell = new PdfPCell(); cell = new PdfPCell(new Phrase(column.ColumnName)); cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdfTable.AddCell(cell); } foreach (DataRow row in dt.Rows) { foreach (DataColumn column in dt.Columns) { pdfTable.AddCell(row[column.ColumnName].ToString()); } } iTextSharp.text.Image guestPhoto = null; var pdfOGTable = new PdfPTable(8); pdfOGTable.DefaultCell.Padding = 3; pdfOGTable.WidthPercentage = 100; pdfOGTable.HorizontalAlignment = Element.ALIGN_LEFT; pdfOGTable.DefaultCell.BorderWidth = 1; var onboardHeader = new PdfPCell(new Phrase("\nOnboard Not Checked In : " + reportPresenter.OnboardGuestsItems.Count)); onboardHeader.VerticalAlignment = Element.ALIGN_MIDDLE; onboardHeader.HorizontalAlignment = Element.ALIGN_CENTER; onboardHeader.FixedHeight = 50; onboardHeader.Colspan = 8; pdfOGTable.AddCell(onboardHeader); foreach (DataColumn column in dataOG.Columns) { var cell = new PdfPCell(); cell = new PdfPCell(new Phrase(column.ColumnName)); cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdfOGTable.AddCell(cell); } foreach (DataRow row in dataOG.Rows) { foreach (DataColumn column in dataOG.Columns) { if (column.ColumnName == PhotoConst) { var cell = new PdfPCell(); guestPhoto = iTextSharp.text.Image.GetInstance(row[column.ColumnName].ToString()); guestPhoto.ScaleAbsolute(40f, 60f); cell.FixedHeight = 80f; cell = new PdfPCell(guestPhoto); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.PaddingTop = 5f; cell.PaddingBottom = 5f; pdfOGTable.AddCell(cell); } else { var cell = new PdfPCell(); cell = new PdfPCell(new Phrase(row[column.ColumnName].ToString())); pdfOGTable.AddCell(cell); } } } var pdfCITable = new PdfPTable(7); pdfCITable.DefaultCell.Padding = 3; pdfCITable.WidthPercentage = 100; pdfCITable.HorizontalAlignment = Element.ALIGN_LEFT; pdfCITable.DefaultCell.BorderWidth = 1; var checkedInHeader = new PdfPCell(new Phrase("\nChecked-in But Not Onboard : " + reportPresenter.CheckedInGuestsItems.Count)); checkedInHeader.VerticalAlignment = Element.ALIGN_MIDDLE; checkedInHeader.HorizontalAlignment = Element.ALIGN_CENTER; checkedInHeader.FixedHeight = 50; checkedInHeader.Colspan = 8; pdfCITable.AddCell(checkedInHeader); foreach (DataColumn column in dataCI.Columns) { var cell = new PdfPCell(); cell = new PdfPCell(new Phrase(column.ColumnName)); cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdfCITable.AddCell(cell); } foreach (DataRow row in dataCI.Rows) { foreach (DataColumn column in dataCI.Columns) { if (column.ColumnName == PhotoConst) { var cell = new PdfPCell(); guestPhoto = iTextSharp.text.Image.GetInstance(row[column.ColumnName].ToString()); guestPhoto.ScaleAbsolute(40f, 60f); cell.FixedHeight = 80f; cell = new PdfPCell(guestPhoto); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.PaddingTop = 5f; cell.PaddingBottom = 5f; pdfCITable.AddCell(cell); } else { var cell = new PdfPCell(); cell = new PdfPCell(new Phrase(row[column.ColumnName].ToString())); pdfCITable.AddCell(cell); } } } var sr = new StringReader(html); var pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f); PdfWriter wri = PdfWriter.GetInstance(pdfDoc, this.Response.OutputStream); pdfDoc.Open(); pdfDoc.Add(pdfTable); pdfDoc.Add(pdfOGTable); pdfDoc.Add(pdfCITable); XMLWorkerHelper.GetInstance().ParseXHtml(wri, pdfDoc, sr); pdfDoc.Close(); Response.ContentType = PDFTypeConst; Response.AddHeader(ContentDisposition, "attachment;filename=GuestReconciliationReport.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); } }
/// <summary> /// Guests the reconciliation print. /// </summary> /// <returns>The Task</returns> public async Task<ActionResult> GuestReconciliationPrint() { var reportPresenter = new ReportPresenter(); var searchFilter = new GuestReconciliationSearchParameters(); searchFilter = SessionData.Instance.GuestReconciliationSearchParameters; searchFilter.PageSize = 0; searchFilter.PageNumber = 1; var guestReconciliation = await this.reportManager.RetrieveGuestReconciliationReportAsync(searchFilter); reportPresenter.GuestReconciliationSearchParameters = searchFilter; if (guestReconciliation != null) { var authenticationToken = await Client.Common.TokenManager.CreateAsync(new CancellationToken(false)); reportPresenter.MapGuestReconciliationSearchResult(guestReconciliation); reportPresenter.TotalOnboardGuest = guestReconciliation.GuestReconciliationReport.TotalOnboardGuest; reportPresenter.TotalCheckedInGuest = guestReconciliation.GuestReconciliationReport.TotalCheckedInGuest; if (reportPresenter.CheckedInGuestsItems != null && reportPresenter.CheckedInGuestsItems.Count > 0) { reportPresenter.CheckedInGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + authenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; }); } if (reportPresenter.OnboardGuestsItems != null && reportPresenter.OnboardGuestsItems.Count > 0) { reportPresenter.OnboardGuestsItems.ToList().ForEach(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + authenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; }); } } return this.View(GuestReconciliationPrintView, reportPresenter); }