/// <summary> /// One level is done /// </summary> /// <param name="qualification"></param> /// <param name="others"></param> /// <returns></returns> private List <QualificationStep> GetQualificationStepAndChilds( Qualification qualification, List <PublishedAction> others) { var steps = new List <QualificationStep>(); var qualificationSteps = qualification.QualificationSteps.OrderBy(a => a.PublishedAction.WBSParts, new WBSPartsComparer()).ToList(); foreach (var step in qualificationSteps) { // Display the parent first int level = 0; foreach (var parent in WbsUtil.GetParents(step.PublishedAction, others)) { // If parent has been already added, we skip it if (!steps.Any(u => u.PublishedAction.WBS == parent.WBS)) { steps.Add(new QualificationStep { IsQualified = step.IsQualified, Level = level, PublishedAction = new PublishedAction { WBS = parent.WBS, Label = parent.Label }, IsParent = true }); } level = level + 1; } // Add the current one step.Level = level; steps.Add(step); // Check the linked publication var linkedPublication = step.PublishedAction.LinkedPublication; if (linkedPublication == null) { continue; } // Traitement des sous process foreach (var publishedAction in step.PublishedAction.LinkedPublication.PublishedActions) { var linkedQualification = step.PublishedAction.LinkedPublication.Qualifications .Where(d => d.EndDate != null && !d.IsDeleted && d.PublicationId == step.PublishedAction.LinkedPublicationId) .OrderByDescending(d => d.EndDate).FirstOrDefault(); if (linkedQualification == null) { continue; } foreach (var linkedStep in linkedQualification.QualificationSteps) { linkedStep.Level = 1; if (!steps.Any(u => u.QualificationStepId == linkedStep.QualificationStepId)) { linkedStep.PublishedAction.WBS = step.PublishedAction.WBS + "." + linkedStep.PublishedAction.WBS; steps.Add(linkedStep); } } } } return(steps); }
public static List <InspectionStep> GetInspectionStepAndChilds(Inspection inspection, List <PublishedAction> others) { var steps = new List <InspectionStep>(); foreach (var step in inspection.InspectionSteps) { // Display the parent first int level = 0; foreach (var parent in WbsUtil.GetParents(step.PublishedAction, others)) { // If parent has been already added, we skip it if (!steps.Any(u => u.PublishedAction.WBS == parent.WBS)) { steps.Add(new InspectionStep { IsOk = step.IsOk, Level = level, PublishedAction = new PublishedAction { WBS = parent.WBS, Label = parent.Label }, IsParent = true }); } level++; } step.Level = level; steps.Add(step); var linkedPublication = step.PublishedAction.LinkedPublication; if (linkedPublication == null) { continue; } // Traitement des sous process foreach (var publishedAction in step.PublishedAction.LinkedPublication.PublishedActions) { var linkedInspection = step.PublishedAction.LinkedPublication.Inspections .Where(d => d.EndDate != null && !d.IsDeleted && d.PublicationId == step.PublishedAction.LinkedPublicationId) .OrderByDescending(d => d.EndDate).FirstOrDefault(); if (linkedInspection == null) { continue; } foreach (var linkedStep in linkedInspection.InspectionSteps) { linkedStep.Level = 1; if (!steps.Any(u => u.InspectionStepId == linkedStep.InspectionStepId)) { linkedStep.PublishedAction.WBS = step.PublishedAction.WBS + "." + linkedStep.PublishedAction.WBS; steps.Add(linkedStep); } } } } return(steps); }