Ejemplo n.º 1
0
        public static Punch GetPunchList(PunchListDO punchListDO)
        {
            Punch punch = new Punch()
            {
                PunchID          = punchListDO.ID,
                InspectionID     = punchListDO.InspectionID,
                ProjectID        = punchListDO.ProjectID,
                punchDescription = punchListDO.PunchDesc
            };

            return(punch);
        }
Ejemplo n.º 2
0
        //PunchList converter
        public static PunchListDO GetPunchListDO(Punch punch)
        {
            PunchListDO punchListDO = new PunchListDO()
            {
                ID           = punch.PunchID,
                InspectionID = punch.InspectionID,
                ProjectID    = punch.ProjectID,
                PunchDesc    = punch.punchDescription
            };

            return(punchListDO);
        }
Ejemplo n.º 3
0
        public int DeleteAllPunchItem(string inspectionID, string projectID)
        {
            int result = 0;

            try{
                result = PunchListDO.DeletePunchList(conn, inspectionID, projectID);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in DeletePunchItem method due to " + ex.Message);
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Saves the punch item.
        /// </summary>
        /// <returns>The punch item.</returns>
        /// <param name="punchItem">Punch item.</param>
        public int SavePunchItem(Punch punchItem)
        {
            int result = 0;

            try
            {
                PunchListDO punchItemDO = Converter.GetPunchListDO(punchItem);
                result = punchRepository.SaveEntity(punchItemDO);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in SavePunchItem method due to " + ex.Message);
            }
            return(result);
        }
Ejemplo n.º 5
0
        public Punch GetPunch(int PunchID)
        {
            Punch punch = new Punch();

            try
            {
                PunchListDO punchDo = punchRepository.GetEntity(PunchID);
                if (punchDo != null)
                {
                    punch = Converter.GetPunchList(punchDo);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in GetPunch method due to " + ex.Message);
            }
            return(punch);
        }
        public int DeleteInspectionTransactionNotSync(Inspection inspection)
        {
            int inspectionTransactionResult = 0;

            try
            {
                IEnumerable <InspectionTransactionDO> inspections = inspectionTransactionRepository.GetEntities();

                InspectionTransactionDO inspectionTransactionDO = inspections.FirstOrDefault(ins => ins.InspectionID == inspection.inspectionID && ins.ProjectID == inspection.projectID);
                inspectionTransactionResult = inspectionTransactionRepository.DeleteEntity(inspectionTransactionDO.ID);
                LocationImageDo.DeleteImage(conn, inspectionTransactionDO.ID);
                DocumentDO.DeleteDocument(conn, inspection.inspectionID, inspection.projectID);
                PunchListDO.DeletePunchList(conn, inspection.inspectionID, inspection.projectID);
                PunchListImageDO.DeletePunchListImageList(conn, inspection.ID);
                ReportDO.DeleteReports(conn, inspection.ID);
                using (var optService = new OptionTransactionService(conn))
                {
                    var optIds = optService.GetOptionTransactionsForInspection(inspection.ID).Select(s => s.ID);
                    OptionTransactionDO.DeleteInspectionOptions(conn, inspection.ID);
                    if (optIds != null && optIds.Count() > 0)
                    {
                        foreach (var optID in optIds)
                        {
                            var chkTransIDs = CheckListTransactionDO.GetCheckListTransaction(conn, optID).Select(s => s.ID);
                            CheckListTransactionDO.DeletecheckList(conn, optID);
                            OptionTransactionImageDO.DeleteOptionImagesSync(conn, optID);
                            if (chkTransIDs != null && chkTransIDs.Count() > 0)
                            {
                                foreach (var chkId in chkTransIDs)
                                {
                                    GuildedPhotoDO.DeleteGuidedImageList(conn, chkId);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in DeleteInspectionTransaction method due to " + ex.Message);
            }
            return(inspectionTransactionResult);
        }
Ejemplo n.º 7
0
 public List <Punch> getPunchList(string inspectionID, string projectID)
 {
     return(PunchListDO.getPunchList(conn, inspectionID, projectID));
 }
Ejemplo n.º 8
0
 public List <Punch> GetPunchList(SQLiteConnection conn, string InspectionID, string ProjectID)
 {
     return(PunchListDO.getPunchList(conn, InspectionID, ProjectID));
 }
        /// <summary>
        /// Get Inspections from service and Save to Database.
        /// </summary>
        /// <returns>The service.</returns>
        /// <param name="Token">Token.</param>
        public List <Inspection> InspectionService(string Token)
        {
            List <Inspection> inspections = new List <Inspection> ();

            try
            {
                // Get New assigned Inspections to the User
                ServiceResonse = new Model.ServiceModel.InspectionsRes();
                IServices service = new Services();
                ServiceResonse = service.FetchInspections(new Model.ServiceModel.InspectionsReq()
                {
                    token = Token
                });

                List <string> projectIDs = new List <string>();

                if (ServiceResonse != null && ServiceResonse.inspections != null && (ServiceResonse.result.code == 0 || ServiceResonse.result.code == 1))
                {
                    var inspectionLst = ServiceResonse.inspections.Where(id => id.inspectionTypeID == BALConstant.FINAL_INSPECTIONID);
                    if (inspectionLst != null && inspectionLst.Count() > 0)
                    {
                        List <string> Ids = new List <string>();
                        Ids = PunchListDO.getPunchProjectIds(conn, BALConstant.FINAL_INSPECTIONID);

                        foreach (var ins in inspectionLst)
                        {
                            if (Ids != null && Ids.Count > 0)
                            {
                                foreach (var id in Ids)
                                {
                                    if (ins.appID != id)
                                    {
                                        if (!projectIDs.Contains(ins.appID))
                                        {
                                            projectIDs.Add(ins.appID);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                projectIDs.Add(ins.appID);
                            }
                        }

                        if (projectIDs != null && projectIDs.Count > 0)
                        {
                            PunchLstResponse = service.FetchPuchList(new Model.ServiceModel.PunchListReq()
                            {
                                token = Token, appIDs = projectIDs
                            });
                        }
                        else
                        {
                            PunchLstResponse = null;
                        }
                    }
                    else
                    {
                        PunchLstResponse = null;
                    }
                }

                var ExistingInspection = GetInspectionTransactions();
                foreach (var insTrans in ExistingInspection)
                {
                    if (ServiceResonse.result != null && (ServiceResonse.result.code == 0 || ServiceResonse.result.code == 1))
                    {
                        var existingInspection = ServiceResonse.inspections.Find(si => si.inspectionTypeID == insTrans.inspectionID && si.appID == insTrans.projectID && si.pathway == insTrans.Pathway);
                        if (existingInspection == null)
                        {
                            if (insTrans.IsFinalise <= 0)
                            {
                                DeleteInspectionTransactionNotSync(insTrans);
                            }
                        }
                    }
                }
                int count = 0;

                foreach (var servInspect in ServiceResonse.inspections)
                {
                    if (PunchLstResponse != null && PunchLstResponse.result != null && (PunchLstResponse.result.code == 0 || PunchLstResponse.result.code == 1))
                    {
                        if (PunchLstResponse.projectPunchLists != null && PunchLstResponse.projectPunchLists.Count > 0)
                        {
                            foreach (var punchItems in PunchLstResponse.projectPunchLists)
                            {
                                string projectId = punchItems.appID;
                                if (servInspect.inspectionTypeID == BALConstant.FINAL_INSPECTIONID && projectId == servInspect.appID)
                                {
                                    if (punchItems.punchListItems != null && punchItems.punchListItems.Count > 0)
                                    {
                                        PunchListDO.DeletePunchList(conn, BALConstant.FINAL_INSPECTIONID, projectId);
                                        foreach (var punchcomments in punchItems.punchListItems)
                                        {
                                            List <Punch> punchList = new List <Punch>();

                                            foreach (var comment in punchcomments.comments)
                                            {
                                                punchList.Add(new Punch()
                                                {
                                                    punchDescription = comment,
                                                    ProjectID        = projectId,
                                                    InspectionID     = BALConstant.FINAL_INSPECTIONID
                                                });
                                            }
                                            PunchListDO.InsertPunchLists(conn, punchList);
                                            var PunchListID = PunchListDO.getPunchList(conn, BALConstant.FINAL_INSPECTIONID, projectId);
                                            foreach (var punchItem in PunchListID)
                                            {
                                                if (punchItem.PunchID != -1)
                                                {
                                                    OptionPunchDO.DeleteOptionPunchID(conn, punchItem.PunchID);
                                                    OptionPunchDO.InsertOptionPunch(conn, BALConstant.PUNCH_OPTIONID, punchItem.PunchID);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    var existingIns = GetInspectionTransactions().Find(i => i.inspectionID == servInspect.inspectionTypeID && i.projectID == servInspect.appID && i.Pathway == servInspect.pathway);
                    ///Punch Lists review in final Inspections of 25,50,75 and 90% created Punch Lists
                    if (existingIns == null)
                    {
                        var inspection = inspectionService.GetInspections().Where(i => i.inspectionID == servInspect.inspectionTypeID).FirstOrDefault();
                        if (!string.IsNullOrEmpty(servInspect.phoneNo))
                        {
                            servInspect.phoneNo = Regex.Replace(servInspect.phoneNo, @"(\d{3})(\d{3})(\d{4})", "$1-$2-$3");
                        }
                        string homeOwnerName = "";
                        if (!string.IsNullOrEmpty(servInspect.houseOwnerName))
                        {
                            var Name = servInspect.houseOwnerName.Split(',');
                            for (int i = Name.Length; i > 0; i--)
                            {
                                homeOwnerName += Name[i - 1];
                                homeOwnerName += " ";
                            }
                        }
                        List <Document> docList = new List <Document>();
                        if (servInspect.inspectionDocuments != null && servInspect.inspectionDocuments.Count > 0)
                        {
                            List <Model.ServiceModel.InspectionDocument> insDocumnents = new List <Model.ServiceModel.InspectionDocument>();
                            insDocumnents = servInspect.inspectionDocuments;

                            foreach (var insDoc in insDocumnents)
                            {
                                Model.Document doc = new Document();
                                doc.documentDisplayName    = insDoc.documentDisplayName;
                                doc.inspectionDocumentType = insDoc.inspectionDocumentType;
                                doc.documentID             = insDoc.documentID;
                                doc.inspectionID           = servInspect.inspectionTypeID;
                                doc.projectID = servInspect.appID;

                                using (DocViewService docServ = new DocViewService(conn))
                                {
                                    var existingDoc = docServ.GetDocumentItems(servInspect.inspectionTypeID, servInspect.appID).Where(d => d.documentID == doc.documentID);
                                    if (existingDoc != null && existingDoc.Count() > 0)
                                    {
                                        foreach (var docs in existingDoc)
                                        {
                                            docServ.DeleteDocumentItems(docs);
                                        }
                                    }
                                    docServ.SaveDocumentItems(doc);
                                }
                                docList.Add(doc);
                            }
                        }

                        inspections.Add(new Inspection()
                        {
                            inspectionID       = servInspect.inspectionTypeID,
                            inspectionDateTime = servInspect.inspectionDate,
                            ProjectName        = servInspect.projectName,
                            projectID          = servInspect.appID,
                            Pathway            = servInspect.pathway,
                            InspectionAddress1 = servInspect.activityAdress.addrline1,
                            InspectionAddress2 = servInspect.activityAdress.addrline2,
                            City                   = servInspect.activityAdress.city,
                            HouseOwnerName         = homeOwnerName.Trim(),
                            PhoneNo                = servInspect.phoneNo,
                            Pincode                = servInspect.activityAdress.postalCode,
                            InspectionType         = inspection != null ? inspection.InspectionType : "",
                            IsFinalise             = 0,
                            InspectionAttemptCount = (servInspect.info != null) ? servInspect.info.inspectionAttempt.ToString() : "",
                            ContractorName         = (servInspect.info != null) ? servInspect.info.contractorName : "",
                            HouseOwnerID           = (servInspect.info != null) ? servInspect.info.homeOwnerID.ToString() : "",
                            inspectionDocuments    = docList
                        });

                        SaveInspectionTransaction(inspections.LastOrDefault());
                        count++;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in InspectionService method due to " + ex.Message);
            }
            return(inspections);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Syncs the data.
        /// </summary>
        public void syncData()
        {
            lock (syncLock)
            {
                try
                {
                    if (!IsSyncProgress)
                    {
                        IsSyncProgress = true;

                        if (syncProgress != null)
                        {
                            syncProgress(true);
                        }
                        //Check if there are finished inspections
                        InspectionTransactionService transSer = new InspectionTransactionService(conn);
                        OptionTransactionService     OTS      = new OptionTransactionService(conn);
                        //int count = 0;
                        var                     finishedInspectionsQry = transSer.GetInspectionTransactions().Where(i => i.IsFinalise > 0);    // && (i.pass.ToLower () == "pass" || i.pass.ToLower () == "fail"));
                        UserService             userService            = new UserService(conn);
                        User                    user            = userService.GetUser();
                        IServices               service         = new Services();
                        InspectionDetailService ids             = new InspectionDetailService(conn);
                        OptionImageService      optImageservice = new OptionImageService(conn);
                        PunchService            pushservice     = new PunchService(conn);
                        DocViewService          docService      = new DocViewService(conn);
                        NotificationRepository  notificationRep = new NotificationRepository(conn);

                        if (finishedInspectionsQry.Any())
                        {
                            List <Inspection> finishedInspections = finishedInspectionsQry.Where(i => i.IsFinalise > 0).ToList();
                            if (finishedInspections.Count > 0)
                            {
                                int reportCount    = 0;
                                int punchListCount = 0;

                                Debug.WriteLine("sync thread started");

                                foreach (var inspection in finishedInspections)
                                {
                                    if (inspection == null)
                                    {
                                        Debug.WriteLine(string.Format("inspection is null"));
                                    }

                                    if (!inspection.isInspectionSynced)
                                    {
                                        if (notifiy != null)
                                        {
                                            notifiy(new notificationEventArgs
                                            {
                                                current = new Notifications
                                                {
                                                    notificationTypeID = inspection.projectID,
                                                    notificationType   = "Inspection",
                                                },
                                                isSyncCompleted = false,
                                            });
                                        }

                                        Model.ServiceModel.InspectionResults req = new Model.ServiceModel.InspectionResults();
                                        req.token       = user.Token;
                                        req.inspections = new List <Model.ServiceModel.InspectionResult>();
                                        Model.Inspection inspectionSer = ids.GetInspectionDetail(inspection, true);


                                        if (inspectionSer != null)
                                        {
                                            var insp = inspectionSer.getServiceModel();



                                            req.inspections.Add(insp);

                                            Model.ServiceModel.InspectionResultsAck inspectinPushRes = service.PushInspections(req);


                                            if (inspectinPushRes.result != null && inspectinPushRes.result.code == 0)
                                            {
                                                int inspectionTransactionID = 0;
                                                InspectionTransactionService insTransService = new InspectionTransactionService(conn);
                                                inspectionTransactionID = insTransService.GetInspectionTransactionID(inspection.projectID, inspection.inspectionID);

                                                //Loaction Image Delete after sync
                                                DAL.LocationImageDo.DeleteImage(conn, inspectionTransactionID);

                                                //Inspection Document Delete after sync
                                                var documents = docService.GetDocumentsForSync(inspection.inspectionID, inspection.projectID);
                                                if (documents != null && documents.Count > 0)
                                                {
                                                    if (DocumentDeleted != null)
                                                    {
                                                        DocumentDeleted(this, new DocumentDeletionEventArgs()
                                                        {
                                                            documentList = documents
                                                        });
                                                    }
                                                    docService.DeleteDocumentItemsForSync(inspection.inspectionID, inspection.projectID);
                                                }

                                                /// Punch List Delete for only final Inspection
                                                if (inspection.inspectionID == BALConstant.FINAL_INSPECTIONID)
                                                {
                                                    List <Punch> punchList = pushservice.getPunchList(inspection.inspectionID, inspection.projectID);
                                                    foreach (var punch in punchList)
                                                    {
                                                        PunchListImageDO.DeletePunchImageList(conn, punch.PunchID);
                                                        OptionPunchDO.DeleteOptionPunchID(conn, punch.PunchID);
                                                    }
                                                    PunchListDO.DeletePunchList(conn, BALConstant.FINAL_INSPECTIONID, inspection.projectID);
                                                }

                                                using (LevelTransactionService levelTransactionService = new LevelTransactionService(conn))
                                                {
                                                    var levelTransactions = levelTransactionService.GetLevelTransactions();

                                                    if (levelTransactions != null)
                                                    {
                                                        foreach (var levelTrans in levelTransactions)
                                                        {
                                                            levelTransactionService.DeleteLevelTransactions(levelTrans);
                                                        }
                                                    }
                                                }


                                                using (SpaceTransactionService spaceTransactionService = new SpaceTransactionService(conn))
                                                {
                                                    var spaceTransactions = spaceTransactionService.GetSpaceTransactions();

                                                    if (spaceTransactions != null)
                                                    {
                                                        foreach (var spaceTrans in spaceTransactions
                                                                 )
                                                        {
                                                            spaceTransactionService.DeleteSpaceTransactions(spaceTrans);
                                                        }
                                                    }
                                                }


                                                //Get Option transactions for inspection(Not including punch list)
                                                List <OptionTransaction> optiontransactionLst = null;
                                                optiontransactionLst = OTS.GetOptionTransactionsForInspection(inspectionTransactionID);

                                                //Delete Item Transaction
                                                if (optiontransactionLst != null && optiontransactionLst.Count > 0)
                                                {
                                                    foreach (var optiontransaction in optiontransactionLst)
                                                    {
                                                        //Option Image Deletion
                                                        optImageservice.DeleteOptionImagesForSync(conn, optiontransaction.ID);

                                                        //Guided picture deletion
                                                        if (optiontransaction.OptionId == BALConstant.GUIDEDPICTURE_OPTIONID)
                                                        {
                                                            var chkTransIDs = CheckListTransactionDO.GetCheckListTransaction(conn, optiontransaction.ID).Select(s => s.ID);
                                                            if (chkTransIDs != null && chkTransIDs.Count() > 0)
                                                            {
                                                                foreach (var chkId in chkTransIDs)
                                                                {
                                                                    GuildedPhotoDO.DeleteGuidedImageList(conn, chkId);
                                                                }
                                                            }
                                                        }
                                                        // Checklist transaction Deletion
                                                        CheckListTransactionDO.DeletecheckList(conn, optiontransaction.ID);

                                                        //Option Transaction Row deletion
                                                        OTS.DeleteOptionTransactions(optiontransaction);
                                                    }
                                                }

                                                inspection.isInspectionSynced = true;
                                                inspection.InspectionStarted  = 0;

                                                transSer.UpdateInspectionTransaction(inspection);
                                                //update notification table with successfully uploaded insÏpection
                                                notificationRep.Save("Inspection", inspection.projectID, "Inspection Results for App ID  : " + inspection.projectID + "  successfully synced");
                                            }
                                            else
                                            {
                                                //update notification table with retry count for inspection
                                                notificationRep.Save("Inspection", inspection.projectID, "Inspection Results for App ID : " + inspection.projectID + " not synced");
                                            }
                                        }
                                    }

                                    if (inspection.isInspectionSynced)
                                    {                                     ///If inspection sync is success
                                        ReportService        repservice = new ReportService(conn);
                                        IEnumerable <Report> reports    = repservice.GetReports().Where(r => r.InspectionTransID == inspection.ID);
                                        if (reports != null)
                                        {
                                            foreach (var report in reports)
                                            {
                                                if (notifiy != null)
                                                {
                                                    notifiy(new notificationEventArgs
                                                    {
                                                        current = new Notifications
                                                        {
                                                            notificationTypeID = report.ReportID + "-" + inspection.projectID,
                                                            notificationType   = "Report",
                                                        },
                                                        isSyncCompleted = false,
                                                    });
                                                }

                                                Model.ServiceModel.InspectionReportAck inspectionReoprtRes = service.PushReport(new Model.ServiceModel.InspectionReport()
                                                {
                                                    inspectionTypeID = inspection.inspectionID,
                                                    appID            = inspection.projectID,
                                                    report           = report.ReportDesc,
                                                    reportName       = report.ReportType,
                                                    token            = user.Token,
                                                });
                                                if (inspectionReoprtRes.result != null && inspectionReoprtRes.result.code == 0)
                                                {
                                                    notificationRep.Save(report.ReportType.ToUpper(), inspection.projectID, report.ReportType.ToUpper() + " Report for App ID : " + inspection.projectID + " successfully synced");
                                                    repservice.DeleteReport(report);
                                                }
                                                else
                                                {
                                                    notificationRep.Save(report.ReportType.ToUpper(), inspection.projectID, report.ReportType.ToUpper() + " Report for App ID  : " + inspection.projectID + " not synced");
                                                }
                                            }
                                        }


                                        List <Model.ServiceModel.PunchListItem> PunchItemList = new List <Model.ServiceModel.PunchListItem>();
                                        if (inspection.inspectionID != BALConstant.FINAL_INSPECTIONID)
                                        {
                                            if (notifiy != null)
                                            {
                                                notifiy(new notificationEventArgs
                                                {
                                                    current = new Notifications
                                                    {
                                                        notificationTypeID = inspection.projectID,
                                                        notificationType   = "Punchlist",
                                                    },
                                                    isSyncCompleted = false,
                                                });
                                            }

                                            List <Punch> punchList = pushservice.getPunchList(inspection.inspectionID, inspection.projectID);
                                            if (punchList != null && punchList.Count > 0)
                                            {
                                                foreach (var punch in punchList)
                                                {
                                                    List <PunchListImageDO> ImageTransLst = PunchListImageDO.getPunchImageList(conn, punch.PunchID);
                                                    List <byte[]>           images        = new List <byte[]>();

                                                    if (ImageTransLst != null)
                                                    {
                                                        foreach (var ImageTrans in ImageTransLst)
                                                        {
                                                            images.Add(ImageTrans.PunchListImage);
                                                        }
                                                    }

                                                    PunchItemList.Add(new Model.ServiceModel.PunchListItem()
                                                    {
                                                        photos   = images,
                                                        comment  = punch.punchDescription,
                                                        sequence = -1
                                                    });
                                                }

                                                Model.ServiceModel.PunchListAck inspectionPunchListRes = service.PushPunchList(new Model.ServiceModel.PunchListResult()
                                                {
                                                    inspectionTypeID = inspection.inspectionID,
                                                    appID            = inspection.projectID,
                                                    punchList        = PunchItemList,
                                                    token            = user.Token
                                                });
                                                if (inspectionPunchListRes.result != null && inspectionPunchListRes.result.code == 0)
                                                {
                                                    //update notification table with successfully uploaded punch list
                                                    notificationRep.Save("Punchlist", inspection.projectID, "Punch List for App ID : " + inspection.projectID + " successfully synced");
                                                    foreach (Punch item in punchList)
                                                    {
                                                        pushservice.DeletePunchItem(item);
                                                        PunchListImageDO.DeletePunchImageList(conn, item.PunchID);
                                                    }
                                                    OptionTransactionDO.DeleteInspectionOptions(conn, inspection.ID);
                                                }
                                                else
                                                {
                                                    //update notification table with retry count for punch list
                                                    notificationRep.Save("Punchlist", inspection.projectID, "Punch List for App ID : " + inspection.projectID + " not synced");
                                                }
                                            }
                                        }
                                    }

                                    if (inspection.isInspectionSynced)
                                    {
                                        using (ReportService repservice = new ReportService(conn))
                                        {
                                            IEnumerable <Report> reports = repservice.GetReports().Where(r => r.InspectionTransID == inspection.ID);
                                            if (reports != null && reports.Count() > 0)
                                            {
                                                reportCount = reports.Count();
                                            }
                                        }
                                        if (inspection.inspectionID != BALConstant.FINAL_INSPECTIONID)
                                        {
                                            List <Punch> punchList = pushservice.getPunchList(inspection.inspectionID, inspection.projectID);
                                            if (punchList != null && punchList.Count > 0)
                                            {
                                                punchListCount = punchList.Count;
                                            }
                                        }
                                        if (reportCount == 0 && punchListCount == 0)
                                        {
                                            transSer.DeleteInspectionTransaction(inspection);
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Exception Occured in Syncdata method due to " + ex.Message);
                }
                finally
                {
                    if (notifiy != null)
                    {
                        notifiy(new notificationEventArgs
                        {
                            current         = new Notifications(),
                            isSyncCompleted = true,
                        });
                    }
                    if (syncProgress != null)
                    {
                        syncProgress(false);
                    }
                    IsSyncProgress = false;
                    UIApplication.SharedApplication.InvokeOnMainThread(delegate
                    {
                        UIApplication.SharedApplication.IdleTimerDisabled = false;
                        Debug.WriteLine("sync thread finished");
                    });
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Preparing the inspection Pass report table.
        /// </summary>
        /// <returns>The inspection report table.</returns>
        /// <param name="inspectionObject">Inspection object.</param>
        private PdfPTable PassInspectionReportTable(Inspection inspectionObject)
        {
            PdfPCell cellPunchListHeader = null;
            // Header Font
            Font headerFont = new Font();

            headerFont.SetFamily(BaseFont.HELVETICA);
            headerFont.Color = Color.WHITE;
            headerFont.SetStyle(1);
            headerFont.Size = 15;

            //Declaration from contractor
            Font DecFont = new Font();

            DecFont.SetFamily(BaseFont.HELVETICA);
            DecFont.Color = Color.BLACK;
            DecFont.SetStyle(0);
            DecFont.Size = 15;

            // cell Content Font
            Font cellContentFont = new Font();

            cellContentFont.SetFamily(BaseFont.HELVETICA);
            cellContentFont.Color = Color.BLACK;
            cellContentFont.Size  = 15;
            cellContentFont.SetStyle(1);

            // cell Content Value Font
            Font cellContentValueFont = new Font();

            cellContentFont.SetFamily(BaseFont.HELVETICA);
            cellContentFont.Color = Color.BLACK;
            cellContentFont.Size  = 13;

            //cell Content Comment Value Font

            Font cellContentCommentValueFont = new Font();

            cellContentCommentValueFont.SetFamily(BaseFont.HELVETICA);
            cellContentCommentValueFont.SetStyle(Font.ITALIC);
            cellContentCommentValueFont.Color = Color.BLACK;
            cellContentCommentValueFont.Size  = 13;


            // Main Table
            PdfPTable MainTable = new PdfPTable(1);

            try
            {
                MainTable.TotalWidth  = PageSize.A4.Width - 20;
                MainTable.LockedWidth = true;

                // General Info Table
                PdfPTable GeneralInfotable = new PdfPTable(6);

                // GeneralInfo Header
                PdfPCell GeneralInfoHeader = new PdfPCell(new Phrase("General Information", headerFont));
                GeneralInfoHeader.BackgroundColor = Color.RED;
                GeneralInfoHeader.FixedHeight     = 30;
                GeneralInfoHeader.BorderWidthTop  = 1;

                GeneralInfoHeader.BorderColorTop      = Color.GRAY;
                GeneralInfoHeader.Colspan             = 6;
                GeneralInfoHeader.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                GeneralInfoHeader.BorderWidthLeft     = 0;
                GeneralInfoHeader.BorderWidthRight    = 0;
                GeneralInfotable.AddCell(GeneralInfoHeader);

                // GeneralInfo Cells Contractor
                PdfPCell cellContractor = new PdfPCell(new Phrase("Contractor", cellContentFont));
                cellContractor.FixedHeight         = 25;
                cellContractor.BorderWidthTop      = 1;
                cellContractor.BorderColorTop      = Color.GRAY;
                cellContractor.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellContractor.BorderWidthLeft     = 0;
                cellContractor.Colspan             = 6;
                cellContractor.BorderWidthRight    = 1;
                cellContractor.BorderColorRight    = Color.GRAY;
                GeneralInfotable.AddCell(cellContractor);

                // GeneralInfo Cells Contractor Value
                string ContractorName = "";
                if (inspectionObject.ContractorName != null)
                {
                    ContractorName = inspectionObject.ContractorName;
                }

                PdfPCell cellContractorValue = new PdfPCell(new Phrase(ContractorName, cellContentValueFont));
                cellContractorValue.FixedHeight         = 25;
                cellContractorValue.BorderWidthTop      = 1;
                cellContractorValue.BorderColorTop      = Color.GRAY;
                cellContractorValue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellContractorValue.BorderWidthLeft     = 0;
                cellContractorValue.Colspan             = 6;
                cellContractorValue.BorderWidthRight    = 1;
                cellContractorValue.BorderWidthBottom   = 0;
                cellContractorValue.BorderColorRight    = Color.GRAY;
                GeneralInfotable.AddCell(cellContractorValue);

                // Generate Home owner name Heading
                PdfPCell cellHomeownerName = new PdfPCell(new Phrase("Homeowner Name", cellContentFont));
                cellHomeownerName.FixedHeight = 25;
                //cellHomeownerName.BorderWidth = 0;
                cellHomeownerName.Colspan             = 2;
                cellHomeownerName.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellHomeownerName.BorderWidthTop      = 1;
                cellHomeownerName.BorderColorRight    = Color.GRAY;
                cellHomeownerName.BorderColorTop      = Color.GRAY;
                cellHomeownerName.BorderWidthLeft     = 0;
                cellHomeownerName.BorderWidthBottom   = 0;
                cellHomeownerName.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellHomeownerName);

                // Generate Home owner ID Heading
                PdfPCell cellHomeownerId = new PdfPCell(new Phrase("App ID ", cellContentFont));
                cellHomeownerId.BorderWidthRight    = 1;
                cellHomeownerId.BorderWidthLeft     = 0;
                cellHomeownerId.BorderWidthTop      = 1;
                cellHomeownerId.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellHomeownerId.Colspan             = 2;
                cellHomeownerId.BorderWidthBottom   = 0;
                cellHomeownerId.BorderColorRight    = Color.GRAY;
                cellHomeownerId.BorderColorTop      = Color.GRAY;
                int add2 = 0, add1 = 0;
                if (inspectionObject.InspectionAddress1 != null)
                {
                    add1 = inspectionObject.InspectionAddress1.Length;
                }
                if (inspectionObject.InspectionAddress2 != null)
                {
                    add2 = inspectionObject.InspectionAddress2.Length;
                }
                int add = add1 + add2;

                // Generate Activity Address Heading
                GeneralInfotable.AddCell(cellHomeownerId);
                PdfPCell activityAddress = new PdfPCell(new Phrase("Activity Address", cellContentFont));
                activityAddress.FixedHeight         = add;
                activityAddress.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                activityAddress.BorderWidthRight    = 0;
                activityAddress.BorderWidthLeft     = 0;
                activityAddress.BorderWidthTop      = 1;
                activityAddress.BorderWidthBottom   = 0;
                activityAddress.BorderColorTop      = Color.GRAY;

                activityAddress.Colspan = 2;
                GeneralInfotable.AddCell(activityAddress);

                string HouseOwnerName = "";
                if (!string.IsNullOrEmpty(inspectionObject.HouseOwnerName))
                {
                    HouseOwnerName = inspectionObject.HouseOwnerName;
                }
                // Generate Home owner name  value
                PdfPCell cellHomeownerNamevalue = new PdfPCell(new Phrase(HouseOwnerName, cellContentValueFont));
                cellHomeownerNamevalue.FixedHeight         = 25;
                cellHomeownerNamevalue.BorderWidthLeft     = 0;
                cellHomeownerNamevalue.BorderWidthRight    = 1;
                cellHomeownerNamevalue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellHomeownerNamevalue.BorderWidthTop      = 1;
                cellHomeownerNamevalue.Colspan             = 2;
                cellHomeownerNamevalue.BorderColorTop      = Color.GRAY;
                cellHomeownerNamevalue.BorderWidthBottom   = 1;
                cellHomeownerNamevalue.BorderColorBottom   = Color.GRAY;
                cellHomeownerNamevalue.BorderColorRight    = Color.GRAY;

                GeneralInfotable.AddCell(cellHomeownerNamevalue);
                string AppID = "";
                if (!string.IsNullOrEmpty(inspectionObject.projectID))
                {
                    AppID = inspectionObject.projectID.ToString();
                }
                // Generate Home owner ID value
                PdfPCell cellHomeownerIDvalue = new PdfPCell(new Phrase(AppID, cellContentValueFont));
                cellHomeownerIDvalue.FixedHeight         = 35;
                cellHomeownerIDvalue.BorderWidthLeft     = 0;
                cellHomeownerIDvalue.BorderWidthRight    = 1;
                cellHomeownerIDvalue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellHomeownerIDvalue.BorderWidthTop      = 1;
                cellHomeownerIDvalue.BorderColorTop      = Color.GRAY;
                cellHomeownerIDvalue.BorderColorRight    = Color.GRAY;
                cellHomeownerIDvalue.BorderWidthBottom   = 1;
                cellHomeownerIDvalue.BorderColorBottom   = Color.GRAY;
                cellHomeownerIDvalue.Colspan             = 2;
                GeneralInfotable.AddCell(cellHomeownerIDvalue);

                string address = inspectionObject.InspectionAddress1 + " " + inspectionObject.InspectionAddress2 + " " + inspectionObject.City + " " + inspectionObject.Pincode;

                // Generate Home owner address value
                PdfPCell activityAddressValue = new PdfPCell(new Phrase(address, cellContentValueFont));
                activityAddressValue.FixedHeight         = 35;
                activityAddressValue.BorderWidthTop      = 1;
                activityAddressValue.Colspan             = 2;
                activityAddressValue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                activityAddressValue.BorderColorTop      = Color.GRAY;
                activityAddressValue.BorderWidthLeft     = 0;
                activityAddressValue.BorderWidthRight    = 0;
                activityAddressValue.BorderWidthBottom   = 1;
                activityAddressValue.BorderColorBottom   = Color.GRAY;
                GeneralInfotable.AddCell(activityAddressValue);

                // Inspection Information  Table

                // Inspection Information Header
                PdfPCell inspectionInfoHeader = new PdfPCell(new Phrase("Inspection Information", headerFont));
                inspectionInfoHeader.BackgroundColor     = Color.RED;
                inspectionInfoHeader.FixedHeight         = 30;
                inspectionInfoHeader.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                inspectionInfoHeader.BorderWidthTop      = 1;
                inspectionInfoHeader.BorderColorTop      = Color.GRAY;
                inspectionInfoHeader.BorderWidthLeft     = 0;
                inspectionInfoHeader.BorderWidthRight    = 0;
                inspectionInfoHeader.Colspan             = 6;
                GeneralInfotable.AddCell(inspectionInfoHeader);

                // Generate Type of Inspection Header
                PdfPCell cellInspectionType = new PdfPCell(new Phrase("Type of Inspection ", cellContentFont));
                cellInspectionType.FixedHeight         = 25;
                cellInspectionType.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectionType.Colspan             = 2;
                cellInspectionType.BorderWidthTop      = 1;
                cellInspectionType.BorderColorTop      = Color.GRAY;
                cellInspectionType.BorderWidthLeft     = 0;
                cellInspectionType.BorderWidthRight    = 0;

                // Generate Inspector Name Header
                PdfPCell cellInspectorName = new PdfPCell(new Phrase("Inspector Name", cellContentFont));
                cellInspectorName.Colspan             = 2;
                cellInspectorName.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectorName.FixedHeight         = 25;
                cellInspectorName.BorderColorTop      = Color.GRAY;
                cellInspectorName.BorderColorRight    = Color.GRAY;
                cellInspectorName.BorderWidthLeft     = 0;
                cellInspectorName.BorderWidthTop      = 1;
                cellInspectorName.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellInspectorName);

                // Generate Inspector Name Header
                PdfPCell cellIPathwayName = new PdfPCell(new Phrase("Pathway Type ", cellContentFont));
                cellIPathwayName.Colspan             = 2;
                cellIPathwayName.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellIPathwayName.FixedHeight         = 25;
                cellIPathwayName.BorderColorTop      = Color.GRAY;
                cellIPathwayName.BorderColorRight    = Color.GRAY;
                cellIPathwayName.BorderWidthLeft     = 0;
                cellIPathwayName.BorderWidthTop      = 1;
                cellIPathwayName.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellIPathwayName);
                GeneralInfotable.AddCell(cellInspectionType);
                String inspectionType = "";
                if (inspectionObject.InspectionType != null)
                {
                    inspectionType = inspectionObject.InspectionType;
                }
                PdfPCell cellInspectionTypeValue = new PdfPCell(new Phrase(inspectionType, cellContentValueFont));
                cellInspectionTypeValue.FixedHeight         = 25;
                cellInspectionTypeValue.Colspan             = 2;
                cellInspectionTypeValue.BorderWidthTop      = 1;
                cellInspectionTypeValue.BorderColorTop      = Color.GRAY;
                cellInspectionTypeValue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectionTypeValue.BorderWidthLeft     = 0;
                cellInspectionTypeValue.BorderWidthRight    = 0;
                string representativeName = "";
                if (!string.IsNullOrEmpty(inspectionObject.RepresentativeName))
                {
                    representativeName = inspectionObject.RepresentativeName;
                }

                PdfPCell cellInspectorNameVAlue = new PdfPCell(new Phrase(representativeName, cellContentValueFont));
                cellInspectorNameVAlue.FixedHeight         = 25;
                cellInspectorNameVAlue.Colspan             = 2;
                cellInspectorNameVAlue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectorNameVAlue.BorderColorTop      = Color.GRAY;
                cellInspectorNameVAlue.BorderColorRight    = Color.GRAY;
                cellInspectorNameVAlue.BorderWidthLeft     = 0;
                cellInspectorNameVAlue.BorderWidthTop      = 1;
                cellInspectorNameVAlue.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellInspectorNameVAlue);

                //Pathway  Tyype
                string InspectionPathway = "";
                if (!string.IsNullOrEmpty(inspectionObject.Pathway.ToString()))
                {
                    InspectionPathway = inspectionObject.Pathway.ToString();
                }
                PdfPCell cellIPathwayNameVAlue = new PdfPCell(new Phrase(InspectionPathway, cellContentValueFont));
                cellIPathwayNameVAlue.Colspan             = 2;
                cellIPathwayNameVAlue.FixedHeight         = 25;
                cellIPathwayNameVAlue.BorderColorTop      = Color.GRAY;
                cellIPathwayNameVAlue.BorderColorRight    = Color.GRAY;
                cellIPathwayNameVAlue.BorderWidthLeft     = 0;
                cellIPathwayNameVAlue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellIPathwayNameVAlue.BorderWidthTop      = 1;
                cellIPathwayNameVAlue.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellIPathwayNameVAlue);
                GeneralInfotable.AddCell(cellInspectionTypeValue);
                //DAte and Time Values
                // Inspection Information two
                PdfPCell cellInspectionAttempt = new PdfPCell(new Phrase("Inspection Attempt ", cellContentFont));
                // Values Added
                cellInspectionAttempt.FixedHeight         = 25;
                cellInspectionAttempt.Colspan             = 2;
                cellInspectionAttempt.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectionAttempt.BorderWidthTop      = 1;
                cellInspectionAttempt.BorderColorTop      = Color.GRAY;
                cellInspectionAttempt.BorderWidthLeft     = 0;
                cellInspectionAttempt.BorderWidthRight    = 0;
                PdfPCell cellInspectorDAte = new PdfPCell(new Phrase("Inspection Date ", cellContentFont));
                cellInspectorDAte.Colspan             = 2;
                cellInspectorDAte.FixedHeight         = 25;
                cellInspectorDAte.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectorDAte.BorderColorTop      = Color.GRAY;
                cellInspectorDAte.BorderColorRight    = Color.GRAY;
                cellInspectorDAte.BorderWidthLeft     = 0;
                cellInspectorDAte.BorderWidthTop      = 1;
                cellInspectorDAte.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellInspectorDAte);

                //Pathway  Tyype
                PdfPCell cellInsTime = new PdfPCell(new Phrase("Inspection Time", cellContentFont));
                cellInsTime.Colspan             = 2;
                cellInsTime.FixedHeight         = 25;
                cellInsTime.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInsTime.BorderColorTop      = Color.GRAY;
                cellInsTime.BorderColorRight    = Color.GRAY;
                cellInsTime.BorderWidthLeft     = 0;
                cellInsTime.BorderWidthTop      = 1;
                cellInsTime.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellInsTime);
                GeneralInfotable.AddCell(cellInspectionAttempt);

                string InspectionAttemptCount = "";
                if (!string.IsNullOrEmpty(inspectionObject.InspectionAttemptCount))
                {
                    InspectionAttemptCount = inspectionObject.InspectionAttemptCount;
                }

                PdfPCell cellInspectionAttValue = new PdfPCell(new Phrase(InspectionAttemptCount, cellContentValueFont));
                cellInspectionAttValue.FixedHeight         = 25;
                cellInspectionAttValue.Colspan             = 2;
                cellInspectionAttValue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectionAttValue.BorderWidthTop      = 1;
                cellInspectionAttValue.BorderColorTop      = Color.GRAY;
                cellInspectionAttValue.BorderWidthLeft     = 0;
                cellInspectionAttValue.BorderWidthRight    = 0;
                string cellDateString = "";


                if (!string.IsNullOrEmpty(inspectionObject.inspectionDateTime.ToString()))
                {
                    NSDate          InspectionDate = (NSDate)DateTime.SpecifyKind(inspectionObject.inspectionDateTime, DateTimeKind.Utc);
                    NSDateFormatter dateformatter  = new NSDateFormatter();
                    dateformatter.DateFormat = @"MM/dd/yyyy";
                    cellDateString           = dateformatter.StringFor(InspectionDate);
                }
                //cellInspectorDAte =
                PdfPCell cellInspectorDateVAlue = new PdfPCell(new Phrase(cellDateString, cellContentValueFont));
                cellInspectorDateVAlue.FixedHeight         = 25;
                cellInspectorDateVAlue.Colspan             = 2;
                cellInspectorDateVAlue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellInspectorDateVAlue.BorderColorTop      = Color.GRAY;
                cellInspectorDateVAlue.BorderColorRight    = Color.GRAY;
                cellInspectorDateVAlue.BorderWidthLeft     = 0;
                cellInspectorDateVAlue.BorderWidthTop      = 1;
                cellInspectorDateVAlue.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellInspectorDateVAlue);

                string InspectionTime = "";
                if (!string.IsNullOrEmpty(inspectionObject.inspectionDateTime.ToString()))
                {
                    InspectionTime = inspectionObject.inspectionDateTime.ToString("hh:mm tt");
                }
                PdfPCell cellITimeVAlue = new PdfPCell(new Phrase(InspectionTime, cellContentValueFont));

                cellITimeVAlue.Colspan             = 2;
                cellITimeVAlue.FixedHeight         = 25;
                cellITimeVAlue.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellITimeVAlue.BorderColorTop      = Color.GRAY;
                cellITimeVAlue.BorderColorRight    = Color.GRAY;
                cellITimeVAlue.BorderWidthLeft     = 0;
                cellITimeVAlue.BorderWidthTop      = 1;
                cellITimeVAlue.BorderWidthRight    = 1;
                GeneralInfotable.AddCell(cellITimeVAlue);
                GeneralInfotable.AddCell(cellInspectionAttValue);
                //Items to be Observed

                PdfPCell cellItemsObserved = new PdfPCell(new Phrase("Observed Items ", headerFont));
                cellItemsObserved.FixedHeight         = 25;
                cellItemsObserved.BorderWidthTop      = 1;
                cellItemsObserved.BorderColorTop      = Color.GRAY;
                cellItemsObserved.Colspan             = 6;
                cellItemsObserved.BackgroundColor     = Color.RED;
                cellItemsObserved.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                cellItemsObserved.BorderWidthLeft     = 0;
                cellItemsObserved.BorderWidthRight    = 0;
                GeneralInfotable.AddCell(cellItemsObserved);

                //ITEMS TO BE ADDED HERE FROM THE INSPECTION TYPE IN APP
                List <NACheckList> naCheckList = new List <NACheckList>();
                foreach (var seqLst in inspectionObject.sequences)
                {
                    if (seqLst.Levels != null)
                    {
                        foreach (var lvl in seqLst.Levels)
                        {
                            if (lvl.Spaces != null)
                            {
                                foreach (var spc in lvl.Spaces)
                                {
                                    if (spc.Options != null && spc.isSelected)
                                    {
                                        foreach (var opt in spc.Options)
                                        {
                                            if (opt.checkListItems != null && opt.checkListItems.Count > 0)
                                            {
                                                var checkList = opt.checkListItems.Find(c => c.Result == ResultType.PASS);

                                                var NACheckList = opt.checkListItems.FindAll(c => c.Result == ResultType.NA);
                                                if (NACheckList != null && NACheckList.Count > 0)
                                                {
                                                    naCheckList.Add(new NACheckList()
                                                    {
                                                        SeqName    = seqLst.name,
                                                        LevelName  = lvl.name,
                                                        SpaceName  = spc.name,
                                                        OptionName = opt.name,
                                                        checkList  = NACheckList
                                                    });
                                                }

                                                if (checkList != null)
                                                {
                                                    PdfPCell cellSeqlName = new PdfPCell(new Phrase(seqLst.name, cellContentFont));
                                                    cellSeqlName.Colspan     = 6;
                                                    cellSeqlName.BorderWidth = 0;
                                                    GeneralInfotable.AddCell(cellSeqlName);

                                                    PdfPCell cellLavelName = new PdfPCell(new Phrase(lvl.name + " - " + spc.name, cellContentFont));
                                                    cellLavelName.PaddingLeft = 15;
                                                    cellLavelName.Colspan     = 6;
                                                    cellLavelName.BorderWidth = 0;
                                                    GeneralInfotable.AddCell(cellLavelName);

                                                    PdfPCell cellOptionName = new PdfPCell(new Phrase(opt.name, cellContentFont));
                                                    cellOptionName.PaddingLeft = 25;
                                                    cellOptionName.Colspan     = 6;
                                                    cellOptionName.BorderWidth = 0;
                                                    GeneralInfotable.AddCell(cellOptionName);

                                                    foreach (var chk in opt.checkListItems)
                                                    {
                                                        if (chk.Result == ResultType.PASS)
                                                        {
                                                            PdfPCell cellCheckListName = new PdfPCell(new Phrase(chk.description, cellContentValueFont));
                                                            cellCheckListName.PaddingLeft = 35;
                                                            cellCheckListName.Colspan     = 6;
                                                            cellCheckListName.BorderWidth = 0;
                                                            GeneralInfotable.AddCell(cellCheckListName);

                                                            PdfPCell cellCheckListComments = new PdfPCell(new Phrase(chk.comments, cellContentCommentValueFont));
                                                            cellCheckListComments.PaddingLeft = 45;
                                                            cellCheckListComments.Colspan     = 6;
                                                            cellCheckListComments.BorderWidth = 0;
                                                            GeneralInfotable.AddCell(cellCheckListComments);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (lvl.Options != null)
                            {
                                foreach (var opt in lvl.Options)
                                {
                                    if (opt.checkListItems != null && opt.checkListItems.Count > 0)
                                    {
                                        var checkList = opt.checkListItems.Find(c => c.Result == ResultType.PASS);

                                        var NACheckList = opt.checkListItems.FindAll(c => c.Result == ResultType.NA);
                                        if (NACheckList != null && NACheckList.Count > 0)
                                        {
                                            naCheckList.Add(new NACheckList()
                                            {
                                                SeqName    = seqLst.name,
                                                LevelName  = lvl.name,
                                                SpaceName  = null,
                                                OptionName = opt.name,
                                                checkList  = NACheckList
                                            });
                                        }

                                        if (checkList != null)
                                        {
                                            PdfPCell cellSeqlName = new PdfPCell(new Phrase(seqLst.name, cellContentFont));
                                            cellSeqlName.Colspan     = 6;
                                            cellSeqlName.BorderWidth = 0;
                                            GeneralInfotable.AddCell(cellSeqlName);

                                            PdfPCell cellLavelName = new PdfPCell(new Phrase(lvl.name, cellContentFont));
                                            cellLavelName.PaddingLeft = 15;
                                            cellLavelName.Colspan     = 6;
                                            cellLavelName.BorderWidth = 0;
                                            GeneralInfotable.AddCell(cellLavelName);

                                            PdfPCell cellOptionName = new PdfPCell(new Phrase(opt.name, cellContentFont));
                                            cellOptionName.PaddingLeft = 25;
                                            cellOptionName.Colspan     = 6;
                                            cellOptionName.BorderWidth = 0;
                                            GeneralInfotable.AddCell(cellOptionName);
                                            foreach (var chk in opt.checkListItems)
                                            {
                                                if (chk.Result == ResultType.PASS)
                                                {
                                                    PdfPCell cellCheckListName = new PdfPCell(new Phrase(chk.description, cellContentValueFont));
                                                    cellCheckListName.PaddingLeft = 35;
                                                    cellCheckListName.Colspan     = 6;
                                                    cellCheckListName.BorderWidth = 0;
                                                    GeneralInfotable.AddCell(cellCheckListName);

                                                    PdfPCell cellCheckListComments = new PdfPCell(new Phrase(chk.comments, cellContentCommentValueFont));
                                                    cellCheckListComments.PaddingLeft = 45;
                                                    cellCheckListComments.Colspan     = 6;
                                                    cellCheckListComments.BorderWidth = 0;
                                                    GeneralInfotable.AddCell(cellCheckListComments);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (seqLst.Options != null && (inspectionObject.inspectionID == Constants.FINAL_INSPECTIONID || seqLst.id != Constants.FINALPUNCH_SEQUENCEID))
                    {
                        foreach (var opt in seqLst.Options)
                        {
                            if (opt.checkListItems != null && opt.checkListItems.Count > 0)
                            {
                                var checkList = opt.checkListItems.Find(c => c.Result == ResultType.PASS);

                                var NACheckList = opt.checkListItems.FindAll(c => c.Result == ResultType.NA);
                                if (NACheckList != null && NACheckList.Count > 0)
                                {
                                    naCheckList.Add(new NACheckList()
                                    {
                                        SeqName    = seqLst.name,
                                        LevelName  = null,
                                        SpaceName  = null,
                                        OptionName = opt.name,
                                        checkList  = NACheckList
                                    });
                                }

                                if (checkList != null)
                                {
                                    PdfPCell cellSeqlName = new PdfPCell(new Phrase(seqLst.name, cellContentFont));
                                    cellSeqlName.Colspan     = 6;
                                    cellSeqlName.BorderWidth = 0;
                                    GeneralInfotable.AddCell(cellSeqlName);

                                    PdfPCell cellOptionName = new PdfPCell(new Phrase(opt.name, cellContentFont));
                                    cellOptionName.PaddingLeft = 15;
                                    cellOptionName.Colspan     = 6;
                                    cellOptionName.BorderWidth = 0;
                                    GeneralInfotable.AddCell(cellOptionName);

                                    foreach (var chkList in opt.checkListItems)
                                    {
                                        if (chkList.Result == ResultType.PASS)
                                        {
                                            PdfPCell cellItemValuessadded2 = new PdfPCell(new Phrase(chkList.description, cellContentValueFont));
                                            cellItemValuessadded2.PaddingLeft = 25;
                                            cellItemValuessadded2.Colspan     = 6;
                                            cellItemValuessadded2.BorderWidth = 0;
                                            GeneralInfotable.AddCell(cellItemValuessadded2);

                                            PdfPCell cellItemValuessadded3 = new PdfPCell(new Phrase(chkList.comments, cellContentCommentValueFont));
                                            cellItemValuessadded3.PaddingLeft = 30;
                                            cellItemValuessadded3.Colspan     = 6;
                                            cellItemValuessadded3.BorderWidth = 0;
                                            GeneralInfotable.AddCell(cellItemValuessadded3);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }


                if (inspectionObject.inspectionID != Constants.FINAL_INSPECTIONID)
                {
                    var PunchList = PunchListDO.getPunchList(AppDelegate.DatabaseContext,
                                                             inspectionObject.inspectionID, inspectionObject.projectID);

                    if (PunchList != null && PunchList.Count > 0 && (inspectionObject.inspectionID != Constants.NINTY_PERCENT_INSPECTIONID))
                    {
                        cellPunchListHeader = new PdfPCell(new Phrase("Non Conformance Items", headerFont));
                    }
                    if (PunchList != null && PunchList.Count > 0 && (inspectionObject.inspectionID == Constants.NINTY_PERCENT_INSPECTIONID))
                    {
                        cellPunchListHeader = new PdfPCell(new Phrase("Punch List Items", headerFont));
                    }

                    if (PunchList != null && PunchList.Count > 0)
                    {
                        cellPunchListHeader.FollowingIndent     = 10;
                        cellPunchListHeader.FixedHeight         = 25;
                        cellPunchListHeader.BorderWidthTop      = 1;
                        cellPunchListHeader.BorderColorTop      = Color.GRAY;
                        cellPunchListHeader.Colspan             = 6;
                        cellPunchListHeader.BackgroundColor     = Color.RED;
                        cellPunchListHeader.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                        cellPunchListHeader.BorderWidthLeft     = 0;
                        cellPunchListHeader.BorderWidthRight    = 0;
                        GeneralInfotable.AddCell(cellPunchListHeader);
                    }

                    if (PunchList != null && PunchList.Count > 0)
                    {
                        foreach (var punch in PunchList)
                        {
                            PdfPCell cellPunch = new PdfPCell(new Phrase(punch.punchDescription, cellContentFont));
                            cellPunch.PaddingLeft   = 10;
                            cellPunch.Colspan       = 6;
                            cellPunch.BorderWidth   = 0;
                            cellPunch.PaddingBottom = 10;
                            GeneralInfotable.AddCell(cellPunch);
                        }
                    }
                }
                if (naCheckList != null && naCheckList.Count > 0)
                {
                    PdfPCell cellNACheckListHeader = new PdfPCell(new Phrase("Not Applicable Items", headerFont));
                    cellNACheckListHeader.FollowingIndent     = 10;
                    cellNACheckListHeader.FixedHeight         = 25;
                    cellNACheckListHeader.BorderWidthTop      = 1;
                    cellNACheckListHeader.BorderColorTop      = Color.GRAY;
                    cellNACheckListHeader.Colspan             = 6;
                    cellNACheckListHeader.BackgroundColor     = Color.RED;
                    cellNACheckListHeader.HorizontalAlignment = PdfCell.ALIGN_CENTER;
                    cellNACheckListHeader.BorderWidthLeft     = 0;
                    cellNACheckListHeader.BorderWidthRight    = 0;
                    GeneralInfotable.AddCell(cellNACheckListHeader);

                    foreach (var chkList in naCheckList)
                    {
                        PdfPCell cellSeqlName = new PdfPCell(new Phrase(chkList.SeqName, cellContentFont));
                        cellSeqlName.Colspan     = 6;
                        cellSeqlName.BorderWidth = 0;
                        GeneralInfotable.AddCell(cellSeqlName);

                        if (string.IsNullOrEmpty(chkList.SpaceName) && !string.IsNullOrEmpty(chkList.LevelName))
                        {
                            PdfPCell cellLavelName = new PdfPCell(new Phrase(chkList.LevelName, cellContentFont));
                            cellLavelName.PaddingLeft = 15;
                            cellLavelName.Colspan     = 6;
                            cellLavelName.BorderWidth = 0;
                            GeneralInfotable.AddCell(cellLavelName);
                        }
                        else if (!string.IsNullOrEmpty(chkList.SpaceName) && !string.IsNullOrEmpty(chkList.LevelName))
                        {
                            PdfPCell cellLavelName = new PdfPCell(new Phrase(chkList.LevelName + " - " + chkList.SpaceName, cellContentFont));
                            cellLavelName.PaddingLeft = 15;
                            cellLavelName.Colspan     = 6;
                            cellLavelName.BorderWidth = 0;
                            GeneralInfotable.AddCell(cellLavelName);
                        }

                        PdfPCell cellOptionName = new PdfPCell(new Phrase(chkList.OptionName, cellContentFont));
                        cellOptionName.PaddingLeft = 25;
                        cellOptionName.Colspan     = 6;
                        cellOptionName.BorderWidth = 0;
                        GeneralInfotable.AddCell(cellOptionName);

                        foreach (var chk in chkList.checkList)
                        {
                            if (chk.Result == ResultType.NA)
                            {
                                PdfPCell cellCheckListName = new PdfPCell(new Phrase(chk.description, cellContentValueFont));
                                cellCheckListName.PaddingLeft = 35;
                                cellCheckListName.Colspan     = 6;
                                cellCheckListName.BorderWidth = 0;
                                GeneralInfotable.AddCell(cellCheckListName);

                                PdfPCell cellCheckListComments = new PdfPCell(new Phrase(chk.comments, cellContentCommentValueFont));
                                cellCheckListComments.PaddingLeft = 45;
                                cellCheckListComments.Colspan     = 6;
                                cellCheckListComments.BorderWidth = 0;
                                GeneralInfotable.AddCell(cellCheckListComments);
                            }
                        }
                    }
                }
                PdfPCell cellBlank = new PdfPCell(new Phrase("", cellContentFont));
                cellBlank.FixedHeight       = 30;
                cellBlank.BorderColor       = Color.GRAY;
                cellBlank.BorderWidthLeft   = 0;
                cellBlank.BorderWidthRight  = 0;
                cellBlank.BorderWidthTop    = 0;
                cellBlank.BorderWidthBottom = 0;
                cellBlank.Colspan           = 6;
                GeneralInfotable.AddCell(cellBlank);

                MainTable.AddCell(GeneralInfotable);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception occured in Pass Report" + ex.Message);
            }
            return(MainTable);
        }