public static Dictionary <CellType, Boolean> GetAvaliableCells(ExportConfigurationSetting settings, IList <dtoPathUsers> statistics) { Boolean hasFields = (settings != null && settings.Fields.Any()); List <CellType> availableCells = GetDefaultCells(settings, statistics); Dictionary <CellType, Boolean> cells = new Dictionary <CellType, Boolean>(); List <CellType> cTypes = Enum.GetValues(typeof(CellType)).Cast <CellType>().ToList(); foreach (CellType t in cTypes) { cells.Add(t, availableCells.Contains(t)); } cells[CellType.PathName] = true; cells[CellType.Auto] = statistics.Where(s => CheckEpType(s.PathType, EPType.Auto)).Any(); cells[CellType.Time] = statistics.Where(s => CheckEpType(s.PathType, EPType.Time)).Any(); cells[CellType.Mark] = statistics.Where(s => CheckEpType(s.PathType, EPType.Mark)).Any(); cells[CellType.Deadline] = true; cells[CellType.EndDate] = true; return(cells); }
private static List <CellType> GetDefaultCells(ExportConfigurationSetting settings, IList <dtoPathUsers> statistics) { Boolean eActive = (statistics != null) && statistics.Where(s => s.HasQuestionnaires(true)).Any(); Boolean eNotActive = (statistics != null) && statistics.Where(s => s.HasQuestionnaires(false)).Any(); List <CellType> cells = new List <CellType>(); if (settings.Fields != null && settings.Fields.Where(f => f.Deleted == BaseStatusDeleted.None).Count() > 0) { cells.Add(CellType.PathName); foreach (ExportFieldType type in settings.Fields.Where(f => f.Deleted == BaseStatusDeleted.None).Select(f => f.Type).ToList()) { switch (type) { case ExportFieldType.IdUser: cells.Add(CellType.IdUser); break; case ExportFieldType.IdCommunity: cells.Add(CellType.IdCommunity); break; case ExportFieldType.IdRole: cells.Add(CellType.IdRole); break; case ExportFieldType.IdAgency: cells.Add(CellType.IdAgency); break; case ExportFieldType.IdPath: cells.Add(CellType.IdPath); break; case ExportFieldType.IdUnit: cells.Add(CellType.IdUnit); break; case ExportFieldType.IdActivity: cells.Add(CellType.IdActivity); break; case ExportFieldType.IdSubActivity: cells.Add(CellType.IdSubActivity); break; case ExportFieldType.IdQuestionnaire: cells.Add(CellType.IdQuestionnaire); break; case ExportFieldType.TaxCodeInfo: cells.Add(CellType.UserTaxCode); break; case ExportFieldType.AgencyInfo: cells.Add(CellType.AgencyCurrent); cells.Add(CellType.AgencyEnd); cells.Add(CellType.AgencyStart); break; case ExportFieldType.QuestionnaireAdvancedInfo: cells.Add(CellType.QuizCompleted); cells.Add(CellType.SemiCorrectAnswers); cells.Add(CellType.UngradedAnswers); cells.Add(CellType.QuestionsSkipped); if (eNotActive) { cells.Add(CellType.NoEvaluations); } if (eActive) { cells.Add(CellType.WithEvaluations); } cells.Add(CellType.QuestionsCount); cells.Add(CellType.WrongAnswers); cells.Add(CellType.CorrectAnswers); cells.Add(CellType.QuizCells); break; case ExportFieldType.QuestionnaireCertificationInfo: cells.Add(CellType.QuizCompleted); if (eNotActive) { cells.Add(CellType.NoEvaluations); } if (eActive) { cells.Add(CellType.WithEvaluations); } //cells.Add(CellType.QuestionsCount); //cells.Add(CellType.WrongAnswers); //cells.Add(CellType.CorrectAnswers); cells.Add(CellType.QuizCells); break; case ExportFieldType.RoleInfo: cells.Add(CellType.RoleName); break; case ExportFieldType.QuestionnaireAttempts: cells.Add(CellType.QuizAttempts); break; case ExportFieldType.IdOrganization: cells.Add(CellType.IdOrganization); break; case ExportFieldType.OrganizationName: cells.Add(CellType.OrganizationName); break; case ExportFieldType.CommunityName: cells.Add(CellType.CommunityName); break; case ExportFieldType.FirstAccessOn: cells.Add(CellType.ViewedOn); break; case ExportFieldType.FirstActionOn: cells.Add(CellType.FirstActivityOn); cells.Add(CellType.StartDate); break; } } } return(cells.Distinct().ToList()); }