/// <summary> /// Creates the update check lists. /// </summary> /// <param name="optReference">Opt reference.</param> /// <param name="inspectionData">Inspection data.</param> /// <param name="itemTransaction">Item transaction.</param> private void CreateUpdateCheckLists(Option optReference, InspectionData inspectionData, IEnumerable <TransactionResult> itemTransaction) { CheckList checkList = null; try { if (optReference != null && optReference.checkListItems == null) { optReference.checkListItems = new List <CheckList>(); } checkList = optReference.checkListItems.Find(i => i.ID == inspectionData.CheckListID); if (checkList == null) { checkList = new CheckList() { ID = inspectionData.CheckListID, description = inspectionData.CheckListDesc }; optReference.checkListItems.Add(checkList); } if (optReference.ID == BALConstant.GUIDEDPICTURE_OPTIONID) { checkList.itemType = ItemType.GuidedPicture; } else { checkList.itemType = ItemType.CheckListItem; } if (optReference.SequenceID == BALConstant.PUNCH_SEQUENCEID) { checkList.itemType = ItemType.PunchList; } if (itemTransaction != null && itemTransaction.Count() > 0) { if (optReference.checkListItems != null && optReference.checkListItems.Count > 0) { optReference.isEnabled = true; } optReference.OptionTransactionID = itemTransaction.FirstOrDefault().OptionsTransactionID; var checkListTransaction = itemTransaction.Where(it => it.CheckListID == checkList.ID).FirstOrDefault(); if (checkListTransaction != null) { checkList.Result = (ResultType)checkListTransaction.CheckListResultTypeID; checkList.comments = checkListTransaction.CheckLIstComment; checkList.CheckListTransID = checkListTransaction.CheckListTransactionID; if (checkList.itemType == ItemType.GuidedPicture) { if (this.IsImageNeeded) { GetCheckListImages(checkListTransaction, checkList); } } } } } catch (Exception ex) { Debug.WriteLine("Exception Occured in CreateUpdateCheckLists method due to " + ex.Message); } }
/// <summary> /// Creates the update level. /// </summary> /// <param name="seq">Seq.</param> /// <param name="inspectionData">Inspection data.</param> /// <param name="itemTransaction">Item transaction.</param> public void CreateUpdateLevel(Sequence seq, InspectionData inspectionData, IEnumerable <TransactionResult> itemTransaction) { Level level = null; try { if (inspectionData.SpaceID != null && inspectionData.SpaceID > 0) { if (seq != null && seq.Levels == null) { seq.Levels = new List <Level>(); } level = seq.Levels.Find(a => a.ID == inspectionData.LevelID && a.seqID == inspectionData.SequenceID); if (level == null) { level = new Level() { ID = inspectionData.LevelID != null ? (int)inspectionData.LevelID:-1, name = inspectionData.LevelDesc, seqID = inspectionData.SequenceID, }; //level.isSelected = true; seq.Levels.Add(level); } CreateUpdateSpace(level, inspectionData, itemTransaction); } else { if (seq != null && seq.Levels == null) { seq.Levels = new List <Level>(); } level = seq.Levels.Find(a => a.ID == inspectionData.LevelID && a.seqID == inspectionData.SequenceID); if (level == null) { level = new Level() { ID = inspectionData.LevelID != null ? (int)inspectionData.LevelID:-1, name = inspectionData.LevelDesc, seqID = inspectionData.SequenceID }; seq.Levels.Add(level); } CreateUpdateOption(level, inspectionData, itemTransaction); } } catch (Exception ex) { Debug.WriteLine("Exception Occured in CreateUpdateLevel method due to " + ex.Message); } }
/// <summary> /// Creates the update sequence. /// </summary> /// <param name="ins">Ins.</param> /// <param name="inspectionData">Inspection data.</param> /// <param name="optionTransaction">Option transaction.</param> public void CreateUpdateSequence(Inspection ins, InspectionData inspectionData, IEnumerable <TransactionResult> optionTransaction) { Sequence seq = null; try{ if (inspectionData.LevelID != null && inspectionData.LevelID > 0) { seq = ins.sequences.Find(a => a.getSequenceID() == inspectionData.SequenceID); if (seq == null) { seq = new Sequence() { id = inspectionData.SequenceID, LevelID = (int)inspectionData.LevelID, name = inspectionData.SequenceDesc }; ins.sequences.Add(seq); } CreateUpdateLevel(seq, inspectionData, optionTransaction); } else { seq = ins.sequences.Find(a => a.getSequenceID() == inspectionData.SequenceID); if (seq == null) { seq = new Sequence() { id = inspectionData.SequenceID, //LevelID=null, name = inspectionData.SequenceDesc }; ins.sequences.Add(seq); } CreateUpdateOption(seq, inspectionData, optionTransaction); } }catch (Exception ex) { Debug.WriteLine("Exception Occured in CreateUpdateSequence method due to " + ex.Message); } }
/// <summary> /// Creates the update space. /// </summary> /// <param name="levelReference">Level reference.</param> /// <param name="inspectionData">Inspection data.</param> /// <param name="itemTransaction">Item transaction.</param> public void CreateUpdateSpace(Level levelReference, InspectionData inspectionData, IEnumerable <TransactionResult> itemTransaction) { Space spc = null; try{ if (levelReference != null && levelReference.Spaces == null) { levelReference.Spaces = new List <Space>(); } spc = levelReference.Spaces.Find(a => a.id == inspectionData.SpaceID); if (spc == null) { spc = new Space() { id = inspectionData.SpaceID != null ? (int)inspectionData.SpaceID:-1, name = inspectionData.SpaceDesc, SpaceID = (inspectionData.SpaceID.HasValue) ? inspectionData.SpaceID.Value : 0, seqID = inspectionData.SequenceID, levelID = (inspectionData.LevelID.HasValue) ? inspectionData.LevelID.Value : 0 }; spc.IsEnabled = true; //spc.isSelected = true; levelReference.Spaces.Add(spc); } CreateUpdateOption(spc, inspectionData, itemTransaction); } catch (Exception ex) { Debug.WriteLine("Exception Occured in CreateUpdateLevel method due to " + ex.Message); } }
/// <summary> /// Creates the update option. /// </summary> /// <param name="sequence">Sequence.</param> /// <param name="inspectionData">Inspection data.</param> /// <param name="itemTransaction">Item transaction.</param> private void CreateUpdateOption(ISequenceOption sequence, InspectionData inspectionData, IEnumerable <TransactionResult> itemTransaction) { Option opt = null; try{ if (sequence != null && sequence.Options == null) { sequence.Options = new List <Option>(); } opt = sequence.Options.Find(o => o.ID == inspectionData.OptionsID && o.SequenceID == inspectionData.SequenceID && o.LevelID == inspectionData.LevelID && o.SpaceID == inspectionData.SpaceID); if (opt == null) { opt = new Option() { ID = inspectionData.OptionsID, name = inspectionData.OptionsDesc }; opt.InspectionID = inspectionData.InspectionID; opt.SequenceID = inspectionData.SequenceID; opt.LevelID = inspectionData.LevelID; opt.SpaceID = inspectionData.SpaceID; opt.OptionId = inspectionData.OptionsID; //opt.OptionTransactionID=itemTransaction.FirstOrDefault().OptionsTransactionID; sequence.Options.Add(opt); } if (inspectionData.LevelID > 0) { if (itemTransaction != null && itemTransaction.Count() > 0) { if (inspectionData.SpaceID > 0) { itemTransaction = itemTransaction.Where(i => i.SequenceID == inspectionData.SequenceID && i.LevelID == inspectionData.LevelID && i.SpaceID == inspectionData.SpaceID && i.OptionID == inspectionData.OptionsID); } else { itemTransaction = itemTransaction.Where(i => i.SequenceID == inspectionData.SequenceID && i.LevelID == inspectionData.LevelID && i.SpaceID <= 0 && i.OptionID == inspectionData.OptionsID); } if (itemTransaction != null && itemTransaction.Count() > 0) { if (sequence is ISpace) { //(sequence as Space).isSelected=true; //UpdateOptionSelected(itemTransaction, ref opt); } //if(this.IsImageNeeded) //{ GetOptionImages(itemTransaction, opt); //} } } } else { if (itemTransaction != null && itemTransaction.Count() > 0) { itemTransaction = itemTransaction.Where(i => i.SequenceID == inspectionData.SequenceID && i.LevelID <= 0 && i.SpaceID <= 0 && i.OptionID == inspectionData.OptionsID); if (itemTransaction != null && itemTransaction.Count() > 0) { UpdateOptionSelected(itemTransaction, ref opt); //if(this.IsImageNeeded) //{ GetOptionImages(itemTransaction, opt); //} } } } CreateUpdateCheckLists(opt, inspectionData, itemTransaction); if (opt.getCheckListItems() != null && opt.getCheckListItems().Count > 0) { opt.isEnabled = true; //opt.isSelected = true; } } catch (Exception ex) { Debug.WriteLine("Exception Occured in CreateUpdateOption method due to " + ex.Message); } }