/// ------------------------------------------------------------------------------------ /// <summary> /// What are the workflow stages which have been completed for this session/person? /// </summary> /// ------------------------------------------------------------------------------------ public virtual IEnumerable <ComponentRole> GetCompletedStages( bool modifyComputedListWithUserOverrides) { //Todo: eventually, we need to differentiate between a file sitting there that // is in progress, and one that is in fact marked as completed. For now, just // being there gets you the gold star. // Use a dictionary rather than yield so we don't emit more than // one instance of each role. var completedRoles = new Dictionary <string, ComponentRole>(); foreach (var component in GetComponentFiles()) { foreach (var role in component.GetAssignedRoles(this)) { completedRoles[role.Id] = role; } } if (ComponentRoles.Except(completedRoles.Values).Any()) { foreach (var component in GetComponentFiles()) { foreach (var role in component.GetAssignedRolesFromAnnotationFile()) { completedRoles[role.Id] = role; } } } return(modifyComputedListWithUserOverrides ? GetCompletedStagesModifedByUserOverrides(completedRoles.Values) : completedRoles.Values); }
/// ------------------------------------------------------------------------------------ protected override IEnumerable <KeyValuePair <string, string> > GetFilesToCopy(IEnumerable <string> validComponentFilesToCopy) { if (GetCompletedStages(true).Any(s => s.Id == ComponentRole.kSourceComponentRoleId)) { foreach (var kvp in base.GetFilesToCopy(validComponentFilesToCopy)) { yield return(kvp); } } else { var sourceRole = ComponentRoles.First(r => r.Id == ComponentRole.kSourceComponentRoleId); bool foundSourceFile = false; foreach (var srcFile in validComponentFilesToCopy) { var destFile = (foundSourceFile || !sourceRole.IsPotential(srcFile)) ? GetDestinationFilename(srcFile) : Path.Combine(FolderPath, sourceRole.GetCanoncialName(Path.GetFileNameWithoutExtension(srcFile), Path.GetFileName(srcFile))); if (!File.Exists(destFile)) { yield return(new KeyValuePair <string, string>(srcFile, destFile)); foundSourceFile = true; } } } }
/// ------------------------------------------------------------------------------------ public override void Load() { base.Load(); StageCompletedControlValues = ComponentRoles.ToDictionary(role => role.Id, role => (StageCompleteType)Enum.Parse(typeof(StageCompleteType), MetaDataFile.GetValue(SessionFileType.kStageFieldPrefix + role.Id, StageCompleteType.Auto.ToString()) as string)); }
/// ------------------------------------------------------------------------------------ public override IEnumerable <ComponentRole> GetCompletedStages( bool modifyComputedListWithUserOverrides) { var list = base.GetCompletedStages(modifyComputedListWithUserOverrides).ToList(); if (GetShouldReportHaveConsent()) { list.Insert(0, ComponentRoles.First(r => r.Id == ComponentRole.kConsentComponentRoleId)); } return(modifyComputedListWithUserOverrides ? GetCompletedStagesModifedByUserOverrides(list) : list); }
/// ------------------------------------------------------------------------------------ protected IEnumerable <ComponentRole> GetCompletedStagesModifedByUserOverrides( IEnumerable <ComponentRole> autoComputedCompletedRoles) { // Return the auto-computed roles for which the user has kept the auto-compute setting. foreach (var role in autoComputedCompletedRoles.Where(role => StageCompletedControlValues.Any(kvp => kvp.Key == role.Id && kvp.Value == StageCompleteType.Auto))) { yield return(role); } // Return the roles the user has forced to be complete. foreach (var role in ComponentRoles.Where(role => StageCompletedControlValues.Any(kvp => kvp.Key == role.Id && kvp.Value == StageCompleteType.Complete))) { yield return(role); } }