public PdfPTable PhotoLogView(Inspection inspectionObject)
        {
            PdfPTable ParentTable = new PdfPTable(4);

            ParentTable.TotalWidth  = PageSize.A4.Width - 20;
            ParentTable.LockedWidth = true;
            //Header of Report
            PdfPCell PhotoReportHeader = new PdfPCell(new Phrase("Location Identification", headerFont));

            PhotoReportHeader.BackgroundColor     = Color.RED;
            PhotoReportHeader.FixedHeight         = 30;
            PhotoReportHeader.BorderWidth         = 1;
            PhotoReportHeader.HorizontalAlignment = PdfCell.ALIGN_CENTER;
            PhotoReportHeader.BorderColor         = Color.GRAY;
            PhotoReportHeader.Colspan             = 4;
            ParentTable.AddCell(PhotoReportHeader);
            foreach (var LocationImage in inspectionObject.locationIDImages)
            {
                if (LocationImage != null)
                {
                    iTextSharp.text.Image image = Image.GetInstance(LocationImage);
                    if (null != image)
                    {
                        image.ScaleAbsolute(574.5f, 300f);
                        PdfPCell cellPhotoAdd1;
                        cellPhotoAdd1                 = new PdfPCell(image);
                        cellPhotoAdd1.Colspan         = 4;
                        cellPhotoAdd1.BorderWidthLeft = 0;
                        cellPhotoAdd1.FixedHeight     = 300;
                        cellPhotoAdd1.BorderColor     = Color.GRAY;
                        ParentTable.AddCell(cellPhotoAdd1);
                    }
                }
                PdfPCell Blankcell1 = new PdfPCell(new Phrase(" ", headerFont));
                Blankcell1.FixedHeight = 10;
                Blankcell1.BorderWidth = 0;
                Blankcell1.Colspan     = 4;
                ParentTable.AddCell(Blankcell1);

                if (ParentTable.Rows.Count > RowLimit)
                {
                    break;
                }
            }
            PdfPCell Blankcell = new PdfPCell(new Phrase("Inspection Photos", headerFont));

            Blankcell.FixedHeight = 30;
            Blankcell.BorderWidth = 0;
            Blankcell.Colspan     = 4;
            ParentTable.AddCell(Blankcell);

            foreach (var seq in inspectionObject.sequences)
            {
                if (ParentTable.Rows.Count > RowLimit)
                {
                    break;
                }

                if (seq.Levels != null)
                {
                    foreach (var lvl in seq.Levels)
                    {
                        if (ParentTable.Rows.Count > RowLimit)
                        {
                            break;
                        }

                        if (lvl.Spaces != null && lvl.Spaces.Count > 0)
                        {
                            foreach (var spc in lvl.Spaces)
                            {
                                if (ParentTable.Rows.Count > RowLimit)
                                {
                                    break;
                                }
                                if (spc.Options != null && spc.isSelected)
                                {
                                    foreach (var opt in spc.Options)
                                    {
                                        if (opt.ID == Constants.GUIDED_OPTIONID)
                                        {
                                            if (opt.checkListItems != null && opt.checkListItems.Count > 0)
                                            {
                                                bool RepeatHeading = false;
                                                foreach (var checkList in opt.checkListItems)
                                                {
                                                    if (ParentTable.Rows.Count > RowLimit)
                                                    {
                                                        break;
                                                    }
                                                    if (checkList.photos != null && checkList.photos.Count > 0)
                                                    {
                                                        if (!RepeatHeading)
                                                        {
                                                            PdfPCell cellSequence = new PdfPCell(
                                                                new Phrase("" + seq.name + " - " + lvl.name + " - " + spc.name + " - " + opt.name, headerFont));
                                                            cellSequence.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                                                            cellSequence.BorderWidthTop      = 1;
                                                            cellSequence.BorderWidthRight    = 1;
                                                            cellSequence.BorderWidthBottom   = 0;
                                                            cellSequence.BorderWidthLeft     = 0;
                                                            cellSequence.BackgroundColor     = Color.RED;
                                                            cellSequence.Colspan             = 4;
                                                            ParentTable.AddCell(cellSequence);
                                                            RepeatHeading = true;
                                                        }

                                                        //PdfPTable guidedDetails = new PdfPTable (1);
                                                        PdfPCell guidedItem = new PdfPCell(
                                                            new Phrase("" + checkList.description, headerFont));
                                                        //guidedItem.BorderWidth = 0;
                                                        guidedItem.BorderWidthTop    = 1;
                                                        guidedItem.BorderWidthRight  = 0;
                                                        guidedItem.BorderWidthBottom = 1;
                                                        guidedItem.BorderWidthLeft   = 1;

                                                        guidedItem.Colspan = 1;
                                                        //guidedDetails.AddCell (guidedItem);
                                                        PdfPCell cellPhotoAdd;
                                                        foreach (var photo in checkList.photos)
                                                        {
                                                            if (ParentTable.Rows.Count > RowLimit)
                                                            {
                                                                break;
                                                            }
                                                            iTextSharp.text.Image image = Image.GetInstance(photo);
                                                            if (null != image)
                                                            {
                                                                image.ScaleAbsolute(430f, 370f);
                                                                cellPhotoAdd                   = new PdfPCell(image);
                                                                cellPhotoAdd.PaddingLeft       = 1;
                                                                cellPhotoAdd.PaddingTop        = 1;
                                                                cellPhotoAdd.Colspan           = 3;
                                                                cellPhotoAdd.PaddingBottom     = 1;
                                                                cellPhotoAdd.BorderWidthTop    = 1;
                                                                cellPhotoAdd.BorderWidthRight  = 1;
                                                                cellPhotoAdd.BorderWidthBottom = 1;
                                                                cellPhotoAdd.BorderWidthLeft   = 1;
                                                                cellPhotoAdd.BorderColor       = Color.GRAY;
                                                                ParentTable.AddCell(guidedItem);
                                                                ParentTable.AddCell(cellPhotoAdd);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        if (opt.photos != null && opt.photos.Count > 0)
                                        {
                                            bool RepeatHeader = false;
                                            foreach (var photo in opt.photos)
                                            {
                                                if (ParentTable.Rows.Count > RowLimit)
                                                {
                                                    break;
                                                }
                                                iTextSharp.text.Image image = Image.GetInstance(photo.Image);
                                                if (null != image)
                                                {
                                                    if (!RepeatHeader)
                                                    {
                                                        PdfPCell cellSequence = new PdfPCell(
                                                            new Phrase("" + seq.name + " - " + lvl.name + " - " + spc.name + " - " + opt.name, headerFont));
                                                        cellSequence.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                                                        cellSequence.BorderWidth         = 0;
                                                        cellSequence.BackgroundColor     = Color.RED;
                                                        cellSequence.Colspan             = 4;
                                                        ParentTable.AddCell(cellSequence);
                                                        RepeatHeader = true;
                                                    }

                                                    PdfPCell cellPhotoAdd;
                                                    image.ScaleAbsolute(574.5f, 300f);
                                                    cellPhotoAdd = new PdfPCell(image);
                                                    cellPhotoAdd.BorderWidthLeft = 0;
                                                    cellPhotoAdd.Colspan         = 4;
                                                    cellPhotoAdd.BorderColor     = Color.GRAY;
                                                    cellPhotoAdd.FixedHeight     = 300;
                                                    ParentTable.AddCell(cellPhotoAdd);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (lvl.Options != null)
                        {
                            if (ParentTable.Rows.Count > RowLimit)
                            {
                                break;
                            }
                            foreach (var opt in lvl.Options)
                            {
                                if (ParentTable.Rows.Count > RowLimit)
                                {
                                    break;
                                }
                                if (opt.photos != null && opt.photos.Count > 0)
                                {
                                    bool RepeatHeader = false;
                                    if (opt.photos != null)
                                    {
                                        foreach (var photo in opt.photos)
                                        {
                                            if (ParentTable.Rows.Count > RowLimit)
                                            {
                                                break;
                                            }
                                            iTextSharp.text.Image image = Image.GetInstance(photo.Image);
                                            if (null != image)
                                            {
                                                if (!RepeatHeader)
                                                {
                                                    PdfPCell cellSequence = new PdfPCell(
                                                        new Phrase("" + seq.name + " - " + "" + lvl.name + " - " + opt.name, headerFont));
                                                    cellSequence.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                                                    cellSequence.BorderWidth         = 0;
                                                    cellSequence.BackgroundColor     = Color.RED;
                                                    cellSequence.Colspan             = 4;
                                                    ParentTable.AddCell(cellSequence);
                                                    RepeatHeader = true;
                                                }
                                                PdfPCell cellPhotoAdd;

                                                image.ScaleAbsolute(574.5f, 300f);
                                                cellPhotoAdd = new PdfPCell(image);
                                                cellPhotoAdd.BorderWidthLeft = 0;
                                                cellPhotoAdd.Colspan         = 4;
                                                cellPhotoAdd.BorderColor     = Color.GRAY;
                                                cellPhotoAdd.FixedHeight     = 300;
                                                ParentTable.AddCell(cellPhotoAdd);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (seq.Options != null)
                {
                    if (ParentTable.Rows.Count > RowLimit)
                    {
                        break;
                    }
                    foreach (var opt in seq.Options)
                    {
                        if (ParentTable.Rows.Count > 10)
                        {
                            break;
                        }
                        if (opt.photos != null && opt.photos.Count > RowLimit)
                        {
                            bool RepeatHeader = false;
                            if (opt.photos != null)
                            {
                                foreach (var photo in opt.photos)
                                {
                                    if (ParentTable.Rows.Count > RowLimit)
                                    {
                                        break;
                                    }
                                    iTextSharp.text.Image image = Image.GetInstance(photo.Image);
                                    if (null != image)
                                    {
                                        if (!RepeatHeader)
                                        {
                                            PdfPCell cellSequence = new PdfPCell(
                                                new Phrase("" + seq.name + " - " + opt.name, headerFont));
                                            cellSequence.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                                            cellSequence.BorderWidth         = 0;
                                            cellSequence.BackgroundColor     = Color.RED;
                                            cellSequence.Colspan             = 4;
                                            ParentTable.AddCell(cellSequence);
                                            RepeatHeader = true;
                                        }
                                        PdfPCell cellPhotoAdd;
                                        image.ScaleAbsolute(574.5f, 300f);
                                        cellPhotoAdd = new PdfPCell(image);
                                        cellPhotoAdd.BorderWidthLeft = 0;
                                        cellPhotoAdd.Colspan         = 4;
                                        cellPhotoAdd.BorderColor     = Color.GRAY;
                                        cellPhotoAdd.FixedHeight     = 300;
                                        ParentTable.AddCell(cellPhotoAdd);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            PdfPCell Blankcel1 = new PdfPCell(new Phrase(" ", headerFont));

            Blankcel1.FixedHeight = 30;
            Blankcel1.BorderWidth = 0;
            Blankcel1.Colspan     = 4;
            ParentTable.AddCell(Blankcel1);

            PunchService PunchTab   = new PunchService(AppDelegate.DatabaseContext);
            var          punchItems = PunchTab.GetPunchList(AppDelegate.DatabaseContext, inspectionObject.inspectionID, inspectionObject.projectID);

            if (punchItems != null)
            {
                int count = 0;
                if (punchItems != null && punchItems.Count > 0)
                {
                    bool RepeatHeader = false;
                    foreach (var Punchpic in punchItems)
                    {
                        if (ParentTable.Rows.Count > RowLimit)
                        {
                            break;
                        }
                        count++;
                        var PunchImage = DAL.DO.PunchListImageDO.getPunchImageList(AppDelegate.DatabaseContext, Punchpic.PunchID);
                        if (PunchImage != null && PunchImage.Count > 0)
                        {
                            foreach (var imagecollection in PunchImage)
                            {
                                if (ParentTable.Rows.Count > RowLimit)
                                {
                                    break;
                                }
                                PdfPCell PunchItem = new PdfPCell();

                                PunchItem.AddElement(new Phrase("Item " + count, headerFont));
                                PunchItem.AddElement(new Phrase(Punchpic.punchDescription, cellContentFont));
                                //PunchItem.BorderWidth = 0;
                                PunchItem.BorderWidthTop    = 1;
                                PunchItem.BorderWidthRight  = 0;
                                PunchItem.BorderWidthBottom = 1;
                                PunchItem.BorderWidthLeft   = 1;
                                PdfPCell punchHeading = new PdfPCell(
                                    new Phrase(Punchpic.punchDescription, cellContentFont));
                                punchHeading.FixedHeight = 80;
                                punchHeading.BorderWidth = 0;
                                PunchItem.Colspan        = 1;
                                punchHeading.BorderColor = Color.GRAY;

                                //adding the cell for adding photo
                                PdfPCell cellPhotoAdd;
                                if (imagecollection != null)
                                {
                                    if (imagecollection.PunchListImage != null)
                                    {
                                        if (!RepeatHeader)
                                        {
                                            RepeatHeader = true;
                                            string punchListHeading = "Non Conformance Items";
                                            if (inspectionObject.inspectionID == Constants.FINAL_INSPECTIONID)
                                            {
                                                punchListHeading = "Punch List Items";
                                            }

                                            PdfPCell HeadingPunch = new PdfPCell(new Phrase(punchListHeading, headerFont));
                                            HeadingPunch.BackgroundColor     = Color.RED;
                                            HeadingPunch.FixedHeight         = 30;
                                            HeadingPunch.BorderWidth         = 0;
                                            HeadingPunch.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                                            HeadingPunch.Colspan             = 4;
                                            ParentTable.AddCell(HeadingPunch);
                                        }
                                        ParentTable.AddCell(PunchItem);


                                        iTextSharp.text.Image image1 = Image.GetInstance(imagecollection.PunchListImage);
                                        if (null != imagecollection)
                                        {
                                            image1.ScaleAbsolute(430f, 370f);

                                            cellPhotoAdd = new PdfPCell(image1);
                                            cellPhotoAdd.BorderWidthLeft = 0;


                                            cellPhotoAdd.PaddingLeft = 1;
                                            cellPhotoAdd.PaddingTop  = 1;
                                            cellPhotoAdd.Colspan     = 3;
                                            //cellPhotoAdd.Rowspan = 2;
                                            cellPhotoAdd.PaddingBottom = 1;

                                            cellPhotoAdd.BorderColor = Color.GRAY;
                                            ParentTable.AddCell(cellPhotoAdd);
                                        }
                                    }
                                }

                                //ParentTable.AddCell (photoLogTable);
                            }
                        }
                    }
                }
            }
            return(ParentTable);
        }
Exemple #2
0
        /// <summary>
        /// Gets the punch list for seq.
        /// </summary>
        /// <returns>The punch list for seq.</returns>
        /// <param name="inspectionID">Inspection I.</param>
        /// <param name="projectID">Project I.</param>
        /// <param name="inspectionTransactionID">Inspection transaction I.</param>
        public List <Option> getPunchListForSeq(string inspectionID, string projectID, int inspectionTransactionID)
        {
            List <Option> options = new List <Option> ();

            try
            {
                PunchService           punchservice = new PunchService(conn);
                List <Punch>           punchs       = punchservice.GetPunchList(conn, inspectionID, projectID);
                OptionsDO              optPunch     = OptionsDO.GetPunchOptions(conn, BALConstant.PUNCH_OPTIONID).FirstOrDefault();
                List <byte[]>          imagesList   = null;
                List <Model.CheckList> checkList    = new List <Model.CheckList>();
                if (punchs != null && punchs.Count > 0)
                {
                    List <PunchListImage> images = new List <PunchListImage>();
                    foreach (var punchItem in punchs)
                    {
                        string     comments = "";
                        ResultType results  = ResultType.NA;
                        int        checkListTransactionID = -1;
                        imagesList = new List <byte[]>();
                        var finalPunchTransaction = GetFinalPunchTransactionData(inspectionTransactionID, BALConstant.PUNCH_OPTIONID, punchItem.PunchID);
                        if (finalPunchTransaction != null && finalPunchTransaction.Count > 0)
                        {
                            var finalPunch = finalPunchTransaction.FirstOrDefault();
                            checkListTransactionID = finalPunch.CheckListTransactionID;
                            results  = (ResultType)finalPunch.CheckListResultTypeID;
                            comments = finalPunch.CheckLIstComment;
                            foreach (var item in finalPunchTransaction)
                            {
                                images.Add(new PunchListImage()
                                {
                                    Image             = item.Images,
                                    inspectionTransID = item.IspectionTransactionID,
                                    PunchID           = item.PunchID
                                });
                                imagesList.Add(item.Images);
                            }
                        }
                        checkList.Add(new Model.CheckList()
                        {
                            description      = punchItem.punchDescription,
                            itemType         = ItemType.PunchList,
                            ID               = punchItem.PunchID,
                            CheckListTransID = checkListTransactionID,
                            comments         = comments,
                            Result           = results,
                            PunchID          = punchItem.PunchID,
                            photos           = imagesList
                        });
                    }
                    options.Add(new Option()
                    {
                        ID              = optPunch.ID,
                        name            = optPunch.OptionsDesc,
                        checkListItems  = checkList,
                        InspectionID    = inspectionID,
                        isGuidedPicture = false,

                        SequenceID = BALConstant.PUNCH_SEQUENCEID
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in getPunchListForSeq method due to " + ex.Message);
            }
            return(options);
        }