Exemplo n.º 1
0
        public FlightInfo GetFlightInfo(BookingInfo bookingInfo)
        {
            FlightInfo flightInfo = new FlightInfo();

            //this is dummy data. In real scenario, the data will come from database.
            if (bookingInfo.DepartureLocation == "New York" && bookingInfo.Destination == "London")
            {
                flightInfo.DepartureLocation = "New York";
                flightInfo.Destination       = "London";

                flightInfo.DepartureDateandTime   = new DateTime(2012, 4, 15, 7, 30, 0);
                flightInfo.ArrivalDateandTimeDest = new DateTime(2012, 4, 15, 11, 0, 0);
                flightInfo.FlightNumberLeave      = "NY0723";

                flightInfo.ReturnDateandTime      = new DateTime(2012, 4, 20, 10, 0, 0);
                flightInfo.ArrivalDateandTimeBack = new DateTime(2012, 4, 20, 13, 30, 0);
                flightInfo.FlightNumberReturn     = "NY0582";

                flightInfo.Status = "Available";
                flightInfo.Fare   = 575.0f;

                flightInfo.Seats = new string[] { "12B", "14C" };
            }

            return(flightInfo);
        }
Exemplo n.º 2
0
        public string BookFlight(FlightInfo flightInfo, PassengerInfo passengerInfo, BookingInfo bookingInfo)
        {
            //create barcodes for departure and arrival
            BarCode barcode           = new BarCode(path);
            string  barcodeFileLeave  = barcode.CreateBarCode(flightInfo.FlightNumberLeave + passengerInfo.SeatNumber, false);
            string  barcodeFileReturn = barcode.CreateBarCode(flightInfo.FlightNumberReturn + passengerInfo.SeatNumber, true);


            //based on flightinfo and passengerinfo create PDF ticket
            Aspose.Pdf.Generator.Pdf pdf;
            Ticket ticket = new Ticket(path);

            pdf = ticket.GetTicket(passengerInfo, flightInfo, bookingInfo);
            string fileName = "Ticket_" + flightInfo.DepartureLocation + "_" + flightInfo.Destination + ".pdf";

            pdf.Save(path + "\\" + fileName);


            //send email to passenger at his/her email address
            Email  email       = new Email(path);
            string messageBody = "Hi " + passengerInfo.Name + ",<br/>";

            messageBody += "Please find attached your ticket for " + flightInfo.DepartureLocation + " to " + flightInfo.Destination + "<br/><br/>";
            messageBody += "Thank you for traveling with FlyNow Airline.<br/>";
            email.SendEmail(passengerInfo.Name, passengerInfo.Email, "Ticket " + flightInfo.DepartureLocation + " to " + flightInfo.Destination, messageBody, path + "\\" + fileName);


            //if everything successful send a success message else sorry message and try again message.
            return("Booking successful. Ticket is sent via email");
        }
        public string BookFlight(FlightInfo flightInfo, PassengerInfo passengerInfo, BookingInfo bookingInfo)
        {

            //create barcodes for departure and arrival
            BarCode barcode = new BarCode(path);
            string barcodeFileLeave = barcode.CreateBarCode(flightInfo.FlightNumberLeave + passengerInfo.SeatNumber, false);
            string barcodeFileReturn = barcode.CreateBarCode(flightInfo.FlightNumberReturn + passengerInfo.SeatNumber, true);


            //based on flightinfo and passengerinfo create PDF ticket
            Aspose.Pdf.Generator.Pdf pdf;
            Ticket ticket = new Ticket(path);
            pdf = ticket.GetTicket(passengerInfo,flightInfo, bookingInfo);
            string fileName = "Ticket_" + flightInfo.DepartureLocation + "_" + flightInfo.Destination + ".pdf";
            pdf.Save(path + "\\" + fileName);
           
                      
            //send email to passenger at his/her email address
            Email email = new Email(path);
            string messageBody = "Hi " + passengerInfo.Name  + ",<br/>";
            messageBody += "Please find attached your ticket for " + flightInfo.DepartureLocation + " to " + flightInfo.Destination + "<br/><br/>";
            messageBody += "Thank you for traveling with FlyNow Airline.<br/>";
            email.SendEmail(passengerInfo.Name, passengerInfo.Email, "Ticket " + flightInfo.DepartureLocation + " to " + flightInfo.Destination, messageBody, path + "\\" + fileName);


            //if everything successful send a success message else sorry message and try again message. 
            return "Booking successful. Ticket is sent via email";
        }
        public FlightInfo GetFlightInfo(BookingInfo bookingInfo)
        {

            FlightInfo flightInfo = new FlightInfo();

            //this is dummy data. In real scenario, the data will come from database.
            if (bookingInfo.DepartureLocation == "New York" && bookingInfo.Destination == "London")
            {

                flightInfo.DepartureLocation = "New York";
                flightInfo.Destination = "London";

                flightInfo.DepartureDateandTime = new DateTime(2012, 4, 15, 7, 30, 0);
                flightInfo.ArrivalDateandTimeDest = new DateTime(2012, 4, 15, 11, 0, 0);
                flightInfo.FlightNumberLeave = "NY0723";

                flightInfo.ReturnDateandTime = new DateTime(2012, 4, 20, 10, 0, 0);
                flightInfo.ArrivalDateandTimeBack = new DateTime(2012, 4, 20, 13, 30, 0);
                flightInfo.FlightNumberReturn = "NY0582";

                flightInfo.Status = "Available";
                flightInfo.Fare = 575.0f;

                flightInfo.Seats = new string[] { "12B", "14C" };

            }

            return flightInfo;
        }
Exemplo n.º 5
0
        private void PutOrder(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, FlightInfo flightInfo, BookingInfo bookingInfo)
		{
            //ticket for leaving             
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, false);

            //ticket for returning
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, true);

		}
Exemplo n.º 6
0
		public Aspose.Pdf.Generator.Pdf GetTicket(PassengerInfo passengerInfo, FlightInfo flightInfo, BookingInfo bookingInfo)
		{
            
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
			pdf.IsTruetypeFontMapCached = false;
            			
            pdf.Sections.Add();
            MarginInfo marginInfo = new MarginInfo();
            marginInfo.Top = 50;
            marginInfo.Left = 50;
            marginInfo.Right = 50;

            pdf.Sections[0].PageInfo.Margin = marginInfo;

            PutOrder(pdf, passengerInfo, flightInfo, bookingInfo);

            return pdf;
		}
Exemplo n.º 7
0
        private void PutSummary(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, BookingInfo bookingInfo, FlightInfo flightInfo, bool isReturn)
		{
            //create table structure for the ticket
			Table summaryTable  = new Table();
            Aspose.Pdf.Generator.Color color = new Aspose.Pdf.Generator.Color(111, 146, 188);
			summaryTable.Margin.Top = 20;
			summaryTable.ColumnWidths = "80 80 80 80";
			summaryTable.DefaultCellTextInfo.FontSize = 10;
			summaryTable.DefaultCellPadding.Bottom = summaryTable.DefaultCellPadding.Top = 3;
            summaryTable.Border = new BorderInfo((int)BorderSide.Box, 0.5f ,color);
            summaryTable.BackgroundColor = new Color(173, 202, 225);

            //add table to the PDF page
			Section section = pdf.Sections[0];
			section.Paragraphs.Add(summaryTable);

            //declare temporary variables
            Aspose.Pdf.Generator.TextInfo textInfo = new Aspose.Pdf.Generator.TextInfo();
            Cell tempCell;

            //add logo and barcode images
            Row row1SummaryTable = summaryTable.Rows.Add();
            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            Cell cell1 = new Cell(row1SummaryTable);
            cell1.ColumnsSpan = 2;
            cell1.DefaultCellTextInfo = textInfo;

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File = path + "\\FlyNowLogoOnly.jpg";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

            img.ImageInfo.FixWidth = 90;
            img.ImageInfo.FixHeight = 30;
            
            cell1.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell1);

            Cell cell2 = new Cell(row1SummaryTable);
            cell2.ColumnsSpan = 2;
            cell2.DefaultCellTextInfo = textInfo;
            cell2.Alignment = AlignmentType.Right;

            img = new Aspose.Pdf.Generator.Image();
            if(!isReturn)
                 img.ImageInfo.File = path + "\\barcodeleave.jpg";
            else
                img.ImageInfo.File = path + "\\barcodereturn.jpg";
            
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            img.ImageInfo.FixWidth = 160;
            img.ImageInfo.FixHeight = 30;
            
            cell2.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell2);


            Row row2SummaryTable = summaryTable.Rows.Add();
            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Class:", row2SummaryTable, textInfo, true);
            row2SummaryTable.Cells.Add(tempCell);

            //cell2 = new Cell(row2SummaryTable);
            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell("Economy", row2SummaryTable, textInfo, false);
            row2SummaryTable.Cells.Add(tempCell);

            //add emptry cells
            Cell cell3 = new Cell(row2SummaryTable);
            row2SummaryTable.Cells.Add(cell3);
            Cell cell4 = new Cell(row2SummaryTable);
            row2SummaryTable.Cells.Add(cell4);


            //add flight details
            Row row3SummaryTable = summaryTable.Rows.Add();
            
            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Flight:  ", row3SummaryTable, textInfo,true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.FlightNumberLeave, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.FlightNumberReturn, row3SummaryTable, textInfo, false);

            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Seat Number:  ", row3SummaryTable, textInfo, true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell(passengerInfo.SeatNumber, row3SummaryTable, textInfo, false);
            row3SummaryTable.Cells.Add(tempCell);

            Row row4SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("From:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);

            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("To:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);

            row4SummaryTable.Cells.Add(tempCell);


            Row row5SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman",9, "Black", true);
            tempCell = AddTextToCell("Departure:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                 tempCell = AddTextToCell(flightInfo.DepartureDateandTime.ToString(), row5SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.ReturnDateandTime.ToString(), row5SummaryTable, textInfo, false);

            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Arrival:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                 tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeDest.ToString(), row5SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeBack.ToString(), row5SummaryTable, textInfo, false);

            row5SummaryTable.Cells.Add(tempCell);


            
		}
Exemplo n.º 8
0
        private void PutSummary(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, BookingInfo bookingInfo, FlightInfo flightInfo, bool isReturn)
        {
            //create table structure for the ticket
            Table summaryTable = new Table();

            Aspose.Pdf.Generator.Color color = new Aspose.Pdf.Generator.Color(111, 146, 188);
            summaryTable.Margin.Top   = 20;
            summaryTable.ColumnWidths = "80 80 80 80";
            summaryTable.DefaultCellTextInfo.FontSize = 10;
            summaryTable.DefaultCellPadding.Bottom    = summaryTable.DefaultCellPadding.Top = 3;
            summaryTable.Border          = new BorderInfo((int)BorderSide.Box, 0.5f, color);
            summaryTable.BackgroundColor = new Color(173, 202, 225);

            //add table to the PDF page
            Section section = pdf.Sections[0];

            section.Paragraphs.Add(summaryTable);

            //declare temporary variables
            Aspose.Pdf.Generator.TextInfo textInfo = new Aspose.Pdf.Generator.TextInfo();
            Cell tempCell;

            //add logo and barcode images
            Row row1SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            Cell cell1 = new Cell(row1SummaryTable);

            cell1.ColumnsSpan         = 2;
            cell1.DefaultCellTextInfo = textInfo;

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File          = path + "\\FlyNowLogoOnly.jpg";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

            img.ImageInfo.FixWidth  = 90;
            img.ImageInfo.FixHeight = 30;

            cell1.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell1);

            Cell cell2 = new Cell(row1SummaryTable);

            cell2.ColumnsSpan         = 2;
            cell2.DefaultCellTextInfo = textInfo;
            cell2.Alignment           = AlignmentType.Right;

            img = new Aspose.Pdf.Generator.Image();
            if (!isReturn)
            {
                img.ImageInfo.File = path + "\\barcodeleave.jpg";
            }
            else
            {
                img.ImageInfo.File = path + "\\barcodereturn.jpg";
            }

            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            img.ImageInfo.FixWidth      = 160;
            img.ImageInfo.FixHeight     = 30;

            cell2.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell2);


            Row row2SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Class:", row2SummaryTable, textInfo, true);
            row2SummaryTable.Cells.Add(tempCell);

            //cell2 = new Cell(row2SummaryTable);
            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell("Economy", row2SummaryTable, textInfo, false);
            row2SummaryTable.Cells.Add(tempCell);

            //add emptry cells
            Cell cell3 = new Cell(row2SummaryTable);

            row2SummaryTable.Cells.Add(cell3);
            Cell cell4 = new Cell(row2SummaryTable);

            row2SummaryTable.Cells.Add(cell4);


            //add flight details
            Row row3SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Flight:  ", row3SummaryTable, textInfo, true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);

            if (!isReturn)
            {
                tempCell = AddTextToCell(flightInfo.FlightNumberLeave, row3SummaryTable, textInfo, false);
            }
            else
            {
                tempCell = AddTextToCell(flightInfo.FlightNumberReturn, row3SummaryTable, textInfo, false);
            }

            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Seat Number:  ", row3SummaryTable, textInfo, true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell(passengerInfo.SeatNumber, row3SummaryTable, textInfo, false);
            row3SummaryTable.Cells.Add(tempCell);

            Row row4SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("From:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if (!isReturn)
            {
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);
            }
            else
            {
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);
            }

            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("To:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if (!isReturn)
            {
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);
            }
            else
            {
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);
            }

            row4SummaryTable.Cells.Add(tempCell);


            Row row5SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Departure:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if (!isReturn)
            {
                tempCell = AddTextToCell(flightInfo.DepartureDateandTime.ToString(), row5SummaryTable, textInfo, false);
            }
            else
            {
                tempCell = AddTextToCell(flightInfo.ReturnDateandTime.ToString(), row5SummaryTable, textInfo, false);
            }

            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Arrival:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if (!isReturn)
            {
                tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeDest.ToString(), row5SummaryTable, textInfo, false);
            }
            else
            {
                tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeBack.ToString(), row5SummaryTable, textInfo, false);
            }

            row5SummaryTable.Cells.Add(tempCell);
        }
Exemplo n.º 9
0
        private void PutOrder(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, FlightInfo flightInfo, BookingInfo bookingInfo)
        {
            //ticket for leaving
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, false);

            //ticket for returning
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, true);
        }
Exemplo n.º 10
0
        public Aspose.Pdf.Generator.Pdf GetTicket(PassengerInfo passengerInfo, FlightInfo flightInfo, BookingInfo bookingInfo)
        {
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            pdf.IsTruetypeFontMapCached = false;

            pdf.Sections.Add();
            MarginInfo marginInfo = new MarginInfo();

            marginInfo.Top   = 50;
            marginInfo.Left  = 50;
            marginInfo.Right = 50;

            pdf.Sections[0].PageInfo.Margin = marginInfo;

            PutOrder(pdf, passengerInfo, flightInfo, bookingInfo);

            return(pdf);
        }