public IEnumerable <DataTransfer.Solution> GetSolutions(long problemId)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId);
                if (problem == null)
                {
                    throw new FaultException <MissingProblem>(new MissingProblem(problemId));
                }
                // TODO: In case of multi-objective problems one has to check whether it contains single- or multi-objective problems
                var result = problem.SingleObjectiveSolutions.Select(x => Convert.ToDto(x)).ToList();
                if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
                {
                    return(result);
                }
                else
                {
                    var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == problemId).ToList();
                    if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList()))
                    {
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
        public DataTransfer.Solution GetSolution(long solutionId)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                // TODO: In case of multi-objective problems one has to check whether it contains single- or multi-objective problems
                var result = Convert.ToDto(okb.SingleObjectiveSolutions.SingleOrDefault(x => x.Id == solutionId));
                if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
                {
                    return(result);
                }
                else
                {
                    var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == result.ProblemId).ToList();
                    if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList()))
                    {
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
        public IEnumerable <DataTransfer.Problem> GetProblems(string platformName)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                DataLoadOptions dlo = new DataLoadOptions();
                dlo.LoadWith <Problem>(x => x.ProblemClass);
                dlo.LoadWith <Problem>(x => x.DataType);
                dlo.LoadWith <Problem>(x => x.ProblemUsers);
                okb.LoadOptions = dlo;

                var            query   = okb.Problems.Where(x => x.Platform.Name == platformName);
                List <Problem> results = new List <Problem>();

                if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
                {
                    results.AddRange(query);
                }
                else
                {
                    foreach (var problem in query)
                    {
                        if (problem.ProblemUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, problem.ProblemUsers.Select(y => y.UserGroupId).ToList()))
                        {
                            results.Add(problem);
                        }
                    }
                }
                return(results.Select(x => Convert.ToDto(x)).ToArray());
            }
        }
        public byte[] GetAlgorithmData(long algorithmId)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var result = okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault();

                if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
                {
                    return(result);
                }
                else
                {
                    var algUsers = okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId);
                    if (algUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, algUsers.Select(y => y.UserGroupId).ToList()))
                    {
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
        public byte[] GetSolutionData(long solutionId)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var solution = okb.SingleObjectiveSolutions.SingleOrDefault(x => x.Id == solutionId);
                if (solution == null)
                {
                    throw new FaultException <MissingSolution>(new MissingSolution(solutionId));
                }

                var result = solution.BinaryData.Data.ToArray();
                if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
                {
                    return(result);
                }
                else
                {
                    var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == solution.ProblemId).ToList();
                    if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList()))
                    {
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
        public IEnumerable <Guid> GetProblemUsers(long problemId)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                return(okb.ProblemUsers.Where(x => x.ProblemId == problemId).Select(x => x.UserGroupId).ToArray());
            }
        }
        public IEnumerable <DataTransfer.Platform> GetPlatforms()
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                return(okb.Platforms.Select(x => Convert.ToDto(x)).ToArray());
            }
        }
        public DataTransfer.AlgorithmClass GetAlgorithmClass(long id)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                return(Convert.ToDto(okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id)));
            }
        }
Пример #9
0
        private bool IsAuthorizedForProblem(long problemId, OKBDataContext okb)
        {
            var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == problemId).Select(x => x.UserGroupId).ToList();

            if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers))
            {
                return(true);
            }
            return(false);
        }
Пример #10
0
        private bool IsAuthorizedForAlgorithm(long algorithmId, OKBDataContext okb)
        {
            var algUsers = okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId).Select(x => x.UserGroupId).ToList();

            if (algUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, algUsers))
            {
                return(true);
            }
            return(false);
        }
Пример #11
0
        public IEnumerable <DataTransfer.Run> GetRunsWithValues(IEnumerable <long> ids, bool includeBinaryValues, IEnumerable <DataTransfer.ValueName> valueNames)
        {
            using (OKBDataContext okb = new OKBDataContext()) {
                DataLoadOptions dlo = new DataLoadOptions();
                // TODO: specify LoadWiths
                okb.LoadOptions = dlo;

                return(FilterUnauthorizedRuns(okb.Runs.Where(x => ids.Contains(x.Id)).ToList(), okb).Select(x => Convert.ToDto(x, includeBinaryValues, valueNames)).ToArray());
            }
        }
        public void AddRun(DataTransfer.Run run)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                DataAccess.Run entity = Convert.ToEntity(run, okb);
                okb.Runs.InsertOnSubmit(entity);
                okb.SubmitChanges();
            }
        }
        public void UpdatePlatform(DataTransfer.Platform dto)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == dto.Id);
                Convert.ToEntity(dto, entity);
                okb.SubmitChanges();
            }
        }
        public long AddPlatform(DataTransfer.Platform dto)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                DataAccess.Platform entity = Convert.ToEntity(dto); entity.Id = 0;
                okb.Platforms.InsertOnSubmit(entity);
                okb.SubmitChanges();
                return(entity.Id);
            }
        }
 public IEnumerable <DataTransfer.Value> GetCharacteristicValues(long problemId)
 {
     using (OKBDataContext okb = new OKBDataContext()) {
         var prob = okb.Problems.SingleOrDefault(x => x.Id == problemId);
         if (prob == null)
         {
             return(Enumerable.Empty <DataTransfer.Value>());
         }
         return(prob.CharacteristicValues.Select(Convert.ToDto).ToArray());
     }
 }
        public void UpdateProblemUsers(long problemId, IEnumerable <Guid> users)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                okb.ProblemUsers.DeleteAllOnSubmit(okb.ProblemUsers.Where(x => x.ProblemId == problemId));
                okb.ProblemUsers.InsertAllOnSubmit(users.Select(x => new DataAccess.ProblemUser {
                    ProblemId = problemId, UserGroupId = x
                }));
                okb.SubmitChanges();
            }
        }
        public void UpdateProblemData(long problemId, byte[] data)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                var entity = okb.Problems.Where(x => x.Id == problemId).FirstOrDefault();
                if (entity != null)
                {
                    entity.BinaryData = Convert.ToEntity(data, okb);
                }
                okb.SubmitChanges();
            }
        }
        public void DeleteSolution(DataTransfer.Solution solution)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var soSolution = solution as DataTransfer.SingleObjectiveSolution;
                if (soSolution != null)
                {
                    okb.SingleObjectiveSolutions.DeleteOnSubmit(okb.SingleObjectiveSolutions.Single(x => x.Id == soSolution.Id));
                    okb.SubmitChanges();
                }
            }
        }
        public void DeletePlatform(long id)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == id);
                if (entity != null)
                {
                    okb.Platforms.DeleteOnSubmit(entity);
                }
                okb.SubmitChanges();
            }
        }
        public void SetCharacteristicValue(long problemId, DataTransfer.Value value)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId);
                if (problem == null)
                {
                    throw new FaultException <MissingProblem>(new MissingProblem(problemId));
                }

                DoSetCharacteristicValue(okb, problem, value);
                okb.SubmitChanges();
            }
        }
        public byte[] GetProblemData(long problemId)
        {
            roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);

            using (OKBDataContext okb = new OKBDataContext()) {
                var data = okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData).FirstOrDefault();
                if (data != null)
                {
                    return(data.Data.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
        public long AddSolution(DataTransfer.Solution solution, byte[] data)
        {
            roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);

            using (OKBDataContext okb = new OKBDataContext()) {
                var soSolution = solution as DataTransfer.SingleObjectiveSolution;
                if (soSolution != null)
                {
                    DataAccess.SingleObjectiveSolution entity = Convert.ToEntity(soSolution, data, okb);
                    okb.SingleObjectiveSolutions.InsertOnSubmit(entity);
                    okb.SubmitChanges();
                    return(entity.Id);
                }
            }
            throw new FaultException(new FaultReason("The solution could not be added."));
        }
        private void DoSetCharacteristicValue(OKBDataContext okb, Problem problem, DataTransfer.Value value)
        {
            CharacteristicType characteristicType;

            try {
                characteristicType = GetCharacteristicType(value);
            } catch (ArgumentException ex) {
                throw new FaultException <UnknownCharacteristicType>(new UnknownCharacteristicType(ex.Message));
            }

            var entity = problem.CharacteristicValues.SingleOrDefault(x => x.Characteristic.Name == value.Name && x.Characteristic.Type == characteristicType);

            if (entity != null)
            {
                // Update
                switch (characteristicType)
                {
                case CharacteristicType.Bool: entity.BoolValue = ((DataTransfer.BoolValue)value).Value; break;

                case CharacteristicType.Int: entity.IntValue = ((DataTransfer.IntValue)value).Value; break;

                case CharacteristicType.Long: entity.LongValue = ((DataTransfer.LongValue)value).Value; break;

                case CharacteristicType.Float: entity.FloatValue = ((DataTransfer.FloatValue)value).Value; break;

                case CharacteristicType.Double: entity.DoubleValue = ((DataTransfer.DoubleValue)value).Value; break;

                case CharacteristicType.Percent: entity.DoubleValue = ((DataTransfer.PercentValue)value).Value; break;

                case CharacteristicType.String: entity.StringValue = ((DataTransfer.StringValue)value).Value; break;

                case CharacteristicType.TimeSpan: entity.LongValue = ((DataTransfer.TimeSpanValue)value).Value; break;
                }
            }
            else
            {
                // Insert
                entity = Convert.ToEntity(value, okb, problem, characteristicType);
                okb.CharacteristicValues.InsertOnSubmit(entity);
            }
        }
Пример #24
0
 public IEnumerable <DataTransfer.ValueName> GetValueNames()
 {
     using (OKBDataContext okb = new OKBDataContext()) {
         return(okb.ValueNames.Select(x => Convert.ToDto(x)).ToArray());
     }
 }
Пример #25
0
        private List <DataAccess.Run> FilterUnauthorizedRuns(List <DataAccess.Run> runs, OKBDataContext okb)
        {
            List <DataAccess.Run> results = new List <DataAccess.Run>();

            if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
            {
                results.AddRange(runs);
            }
            else
            {
                foreach (DataAccess.Run r in runs)
                {
                    if (IsAuthorizedForAlgorithm(r.AlgorithmId, okb) && IsAuthorizedForProblem(r.ProblemId, okb))
                    {
                        results.Add(r);
                    }
                }
            }
            return(results);
        }
Пример #26
0
        public IEnumerable <Filter> GetFilters()
        {
            List <Filter> filters = new List <Filter>();

            using (OKBDataContext okb = new OKBDataContext()) {
                #region Run Filters
                filters.Add(new OrdinalComparisonDateTimeFilter(typeof(RunCreatedDateFilter).AssemblyQualifiedName, "Run Created Date"));
                filters.Add(new StringComparisonFilter(typeof(RunUserNameFilter).AssemblyQualifiedName, "Run User Name"));
                filters.Add(new StringComparisonFilter(typeof(RunClientNameFilter).AssemblyQualifiedName, "Run Client Name"));
                #endregion

                #region Parameter Filters
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ValueNameFilter).AssemblyQualifiedName,
                                "Parameter Name",
                                okb.ValueNames.Where(x => x.Category == ValueNameCategory.Parameter).Select(x => x.Name).Distinct().ToArray()
                                ));
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Binary)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameStringComparisonAvailableValuesFilter(
                                    typeof(ValueDataTypeNameFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value Data Type Name",
                                    name,
                                    okb.Values.Where(x => (x.ValueName.Name == name) && (x.ValueName.Category == ValueNameCategory.Parameter) && (x.ValueName.Type == ValueNameType.Binary)).Select(x => x.DataType.Name).Distinct().ToArray()
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Bool)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameEqualityComparisonBoolFilter(
                                    typeof(BoolValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Int)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonIntFilter(
                                    typeof(IntValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Long)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonLongFilter(
                                    typeof(LongValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.TimeSpan)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonTimeSpanFilter(
                                    typeof(TimeSpanValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Float)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonFloatFilter(
                                    typeof(FloatValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Double)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonDoubleFilter(
                                    typeof(DoubleValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Percent)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonPercentFilter(
                                    typeof(PercentValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.String)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameStringComparisonFilter(
                                    typeof(StringValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Parameter) && (x.Type == ValueNameType.Binary)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameEqualityComparisonByteArrayFilter(
                                    typeof(BinaryValueFilter).AssemblyQualifiedName,
                                    "Parameter " + name + " Value",
                                    name
                                    ));
                }
                #endregion

                #region Result Filters
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ValueNameFilter).AssemblyQualifiedName,
                                "Result Name",
                                okb.ValueNames.Where(x => x.Category == ValueNameCategory.Result).Select(x => x.Name).Distinct().ToArray()
                                ));
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Binary)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameStringComparisonAvailableValuesFilter(
                                    typeof(ValueDataTypeNameFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value Data Type Name",
                                    name,
                                    okb.Values.Where(x => (x.ValueName.Name == name) && (x.ValueName.Category == ValueNameCategory.Result) && (x.ValueName.Type == ValueNameType.Binary)).Select(x => x.DataType.Name).Distinct().ToArray()
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Bool)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameEqualityComparisonBoolFilter(
                                    typeof(BoolValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Int)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonIntFilter(
                                    typeof(IntValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Long)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonLongFilter(
                                    typeof(LongValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.TimeSpan)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonTimeSpanFilter(
                                    typeof(TimeSpanValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Float)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonFloatFilter(
                                    typeof(FloatValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Double)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonDoubleFilter(
                                    typeof(DoubleValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Percent)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameOrdinalComparisonPercentFilter(
                                    typeof(PercentValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.String)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameStringComparisonFilter(
                                    typeof(StringValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                foreach (string name in okb.ValueNames.Where(x => (x.Category == ValueNameCategory.Result) && (x.Type == ValueNameType.Binary)).Select(x => x.Name).Distinct())
                {
                    filters.Add(new NameEqualityComparisonByteArrayFilter(
                                    typeof(BinaryValueFilter).AssemblyQualifiedName,
                                    "Result " + name + " Value",
                                    name
                                    ));
                }
                #endregion

                #region Algorithm Filters
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(AlgorithmNameFilter).AssemblyQualifiedName,
                                "Algorithm Name",
                                okb.Algorithms.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(AlgorithmClassNameFilter).AssemblyQualifiedName,
                                "Algorithm Class Name",
                                okb.AlgorithmClasses.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(AlgorithmPlatformNameFilter).AssemblyQualifiedName,
                                "Algorithm Platform Name",
                                okb.Platforms.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(AlgorithmDataTypeNameFilter).AssemblyQualifiedName,
                                "Algorithm Data Type Name",
                                okb.Algorithms.Select(x => x.DataType.Name).Distinct().ToArray()
                                ));
                #endregion

                #region Problem Filters
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ProblemNameFilter).AssemblyQualifiedName,
                                "Problem Name",
                                okb.Problems.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ProblemClassNameFilter).AssemblyQualifiedName,
                                "Problem Class Name",
                                okb.ProblemClasses.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ProblemPlatformNameFilter).AssemblyQualifiedName,
                                "Problem Platform Name",
                                okb.Platforms.Select(x => x.Name).Distinct().ToArray()
                                ));
                filters.Add(new StringComparisonAvailableValuesFilter(
                                typeof(ProblemDataTypeNameFilter).AssemblyQualifiedName,
                                "Problem Data Type Name",
                                okb.Problems.Select(x => x.DataType.Name).Distinct().ToArray()
                                ));
                #endregion

                #region Combined Filters
                filters.Add(new CombinedFilter(typeof(AndFilter).AssemblyQualifiedName, "AND", BooleanOperation.And));
                filters.Add(new CombinedFilter(typeof(OrFilter).AssemblyQualifiedName, "OR", BooleanOperation.Or));
                #endregion
            }
            return(filters.OrderBy(x => x.Label));
        }
Пример #27
0
 public IEnumerable <long> GetRunIds(Filter filter)
 {
     using (OKBDataContext okb = new OKBDataContext()) {
         return(FilterRuns(okb.Runs, filter, okb).Select(x => x.Id).ToArray());
     }
 }
Пример #28
0
 public long GetNumberOfRuns(Filter filter)
 {
     using (OKBDataContext okb = new OKBDataContext()) {
         return(FilterRuns(okb.Runs, filter, okb).LongCount());
     }
 }
Пример #29
0
        private List <DataAccess.Run> FilterRuns(IQueryable <DataAccess.Run> runs, Filter filter, OKBDataContext okb)
        {
            IFilter f = (IFilter)Activator.CreateInstance(Type.GetType(filter.FilterTypeName), filter);

            var query = runs.Where(f.Expression);
            List <DataAccess.Run> results = new List <DataAccess.Run>();

            if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator))
            {
                results.AddRange(query);
            }
            else
            {
                foreach (DataAccess.Run r in query)
                {
                    if (IsAuthorizedForAlgorithm(r.AlgorithmId, okb) && IsAuthorizedForProblem(r.ProblemId, okb))
                    {
                        results.Add(r);
                    }
                }
            }
            return(results);
        }