Ejemplo n.º 1
0
        public void Execute(IDataBase db)
        {
            var olapRound = new OlapRound("Тестовая подготовка", "2015");

            db.InsertOlapRound(olapRound);
        }
Ejemplo n.º 2
0
        public static OlapCube ExportOlapCube(this OlapCube olapCube)
        {
            var result = new List<OlapCube>();

            object conditionDefinition = null;

            var @switch = new Dictionary<string, Action>
            {
                {
                    Conditions[0], () =>
                    {
                        result.Add(new OlapCube(olapCube.OlapRounds.Where(item => item.Year == (string)conditionDefinition).ToArray()));
                    }
                },
                {
                    Conditions[1], () =>
                    {
                        result.Add(new OlapCube(olapCube.OlapRounds.Where(item => item.Name == (conditionDefinition as OlapRound).Name).ToArray()));
                    }
                },
                {
                    Conditions[2], () =>
                    {
                        var _group = conditionDefinition as Group;

                        // TODO: Такая портянка :D

                        result.Add(new OlapCube(
                            (
                                from olapRound in olapCube.OlapRounds //Выбираем циклы

                                let list = olapRound.CertifiedTests.Where //Формируем список оцененных тестов
                                (
                                    certifiedTest =>
                                    _group.Peoples.FirstOrDefault(people => people.Equals(certifiedTest.PassedTest.People)) != null //В которых есть люди, принадлежащие данной группе
                                ).ToArray()

                                where list.Length != 0 //Отсекаем пустые циклы

                                select new

                                OlapRound(olapRound.Name, olapRound.Year, list, olapRound.Id) //Создаем новый цикл

                            ).ToArray()
                        ));
                    }
                },
                {
                    Conditions[3], () =>
                    {
                        var people = conditionDefinition as People;

                        // TODO: Еще одна :D

                        result.Add(new OlapCube(
                            (
                                from olapRound in olapCube.OlapRounds

                                let listTests = olapRound.CertifiedTests.Where
                                (
                                    certifiedTest => certifiedTest.PassedTest.People.Equals(people)
                                ).ToArray()

                                where listTests.Length != 0

                                select new

                                OlapRound(olapRound.Name, olapRound.Year, listTests, olapRound.Id)

                            ).ToArray()
                        ));
                    }
                },
                {
                    Conditions[4], () =>
                    {
                        var date = (DateTime)conditionDefinition;

                        // TODO: Я все никак не успокоюсь

                        result.Add(new OlapCube(
                            (
                                from olapRound in olapCube.OlapRounds

                                let listTests = olapRound.CertifiedTests.Where
                                (
                                    certifiedTest => certifiedTest.PassedTest.PassDate.Date.ToShortDateString() == date.Date.ToShortDateString()
                                ).ToArray()

                                where listTests.Length != 0

                                select new

                                OlapRound(olapRound.Name, olapRound.Year, listTests, olapRound.Id)

                            ).ToArray()
                        ));
                    }
                },
                {
                    Conditions[5], () =>
                    {
                        var test = conditionDefinition as Test;

                        // TODO: Ну теперь пожалуй хватит

                        result.Add(new OlapCube(
                            (
                                from olapRound in olapCube.OlapRounds

                                let listTests = olapRound.CertifiedTests.Where
                                (
                                    certifiedTest => certifiedTest.PassedTest.Test.Equals(test)
                                ).ToArray()

                                where listTests.Length != 0

                                select new

                                OlapRound(olapRound.Name, olapRound.Year, listTests, olapRound.Id)

                            ).ToArray()
                        ));
                    }
                }
            };

            foreach (var definition in Definitions)
            {
                foreach (var obj in definition.Value)
                {
                    conditionDefinition = obj;

                    Action action;

                    @switch.TryGetValue(definition.Key, out action);

                    action();
                }
            }

            var listRounds = new List<OlapRound>();

            foreach (var cube in result)
            {
                foreach (var round in cube.OlapRounds)
                {
                    var contains = false;
                    var indexContains = -1;

                    for (var i = 0; i < listRounds.Count && !contains; i++)
                    {
                        contains = round.Equals(listRounds[i]);
                        indexContains = i;
                    }

                    if (!contains)
                    {
                        listRounds.Add(round);
                    }
                    else
                    {
                        foreach (var test in round.CertifiedTests)
                        {
                            var currentRound = listRounds[indexContains];

                            contains = false;

                            for (var i = 0; i < currentRound.CertifiedTests.Length && !contains; i++)
                            {
                                contains = currentRound.CertifiedTests[i].Equals(test);
                            }

                            if (!contains)
                            {
                                var newListCertifiedTests = new List<CertifiedTest>();

                                newListCertifiedTests.AddRange(currentRound.CertifiedTests);
                                newListCertifiedTests.Add(test);

                                listRounds[indexContains] = new OlapRound(currentRound.Name, currentRound.Year, newListCertifiedTests.ToArray(), currentRound.Id);
                            }
                        }
                    }
                }
            }

            return Definitions.IsEmpty() ? olapCube : new OlapCube(listRounds.ToArray());
        }
Ejemplo n.º 3
0
 public RoundReport(OlapRound olapRound)
 {
     OlapRound = olapRound;
 }