/// <summary> /// Gets the inspections. /// Gets the inspections from. /// </summary> /// <returns>The service inspections.</returns> /// <param name="IsNetorkConnected">If set to <c>true</c> is netork connected.</param> /// <param name="Token">Token.</param> /// <param name="IsFirstLogin">If set to <c>true</c> is first login.</param> public List <Model.Inspection> GetServiceInspections(bool IsNetorkConnected, string Token, bool IsFirstLogin) { List <Inspection> inspections = new List <Inspection> (); try { if (IsFirstLogin && IsNetorkConnected) { InspectionService(Token); } inspections = GetInspectionTransactions().Where(i => i.IsFinalise <= 0).ToList(); foreach (var ins in inspections) { var inspection = inspectionService.GetInspections().Where(i => i.inspectionID == ins.inspectionID).FirstOrDefault(); ins.InspectionType = inspection != null ? inspection.InspectionType : ""; if (inspection != null) { ins.InspectionStarted = inspections.Where(x => x.inspectionID == inspection.inspectionID).FirstOrDefault().InspectionStarted; } } } catch (Exception ex) { Debug.WriteLine("Exception Occured in GetServiceInspections method due to " + ex.Message); } return(inspections); }
/// <summary> /// Gets the inspection detail. /// </summary> /// <returns>The inspection detail.</returns> /// <param name="inspection">Inspection.</param> /// <param name="IsImageNeeded">If set to <c>true</c> is image needed.</param> public Inspection GetInspectionDetail(Inspection inspection, bool IsImageNeeded) { using (Inspection ins = inspection) { try { this.IsImageNeeded = IsImageNeeded; var inspectionDesc = inspectionService.GetInspections().Where(i => i.inspectionID == inspection.inspectionID).FirstOrDefault(); if (inspectionDesc != null) { var inspectionTraansaction = inspectionTransactionService.GetInspectionTransactions().Where(i => i.inspectionID == inspection.inspectionID && i.projectID == inspection.projectID && i.appID == inspection.appID); if (inspectionTraansaction != null && inspectionTraansaction.Count() > 0) { ins.ID = inspectionTraansaction.FirstOrDefault().ID; //ins.InspectionStarted = inspectionTraansaction.FirstOrDefault().InspectionStarted; } inspectionTransactionID = ins.ID; GetInspectionDetails(int.Parse(inspection.inspectionID), ins); inspection.InspectionType = ins.InspectionType; var punchsequenceID = ins.sequences.Where(i => i.id == BALConstant.PUNCH_SEQUENCEID); if (punchsequenceID == null || punchsequenceID.Count() <= 0) { if (inspection.inspectionID == BALConstant.FINAL_INSPECTIONID) { Sequence punchsequence = new Sequence(); SequencesDO seq = SequencesDO.getPunchListSequenceForInspection(conn, BALConstant.PUNCH_SEQUENCEID).FirstOrDefault(); if (seq != null) { punchsequence.id = seq.ID; punchsequence.name = seq.SequenceDesc; punchsequence.Options = getPunchListForSeq(BALConstant.FINAL_INSPECTIONID, inspection.projectID, ins.ID); } if (punchsequence != null && punchsequence.Options != null && punchsequence.Options.Count > 0) { if (punchsequence.Options[0].checkListItems != null && punchsequence.Options[0].checkListItems.Count > 0) { ins.sequences.Insert(0, punchsequence); } } } } } if (ins != null) { ins.locationIDImages = new List <byte[]> (); var images = LocationImageDo.getImageForLocationIdentification(conn, ins.ID); if (images != null && images.Count > 0) { foreach (var img in images) { ins.locationIDImages.Add(img.Image); } } } } catch (Exception ex) { Debug.WriteLine("Exception Occured in GetInspectionDetail method due to " + ex.Message); } return(ins); } }