Exemplo n.º 1
0
        public async Task<string> GetScheduleTheoryReportAsync(int month, int year)
        {
            int maxDaysInMonth = DateTime.DaysInMonth(year, month);
            DateTime date = new DateTime(year, month, maxDaysInMonth);

            var schedule = await _context.ScheduleTheories.FindAsync(s =>
                s.Group.TheoryStartDate <= date);

            string path = string.Format("{0}Reports/{1}{2}{3}.pdf", _serverPath, "РасписаниеТеоритическихЗанятий", month, year);
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            ScheduleTheoryReport report = new ScheduleTheoryReport(path)
            {
                Month = month,
                Year = year,
            };

            List<ScheduleTheoryEntity> lessons = new List<ScheduleTheoryEntity>();

            foreach (var less in schedule.Select(s => s.DayOfWeek).Distinct())
            {
                ScheduleTheoryEntity entity = new ScheduleTheoryEntity();
                entity.DayOfWeek = less;
                entity.Dates = DaysOfMonth(month, year).Where(d => DayOfWeekRus(d) == less);
                List<LessonTheoryEntity> list = new List<LessonTheoryEntity>();
                foreach (var item in schedule.Where(s => s.DayOfWeek == less))
                {
                    LessonTheoryEntity l = new LessonTheoryEntity
                    {
                        StartTime = item.StartTime,
                        EndTime = item.EndTime,
                        Group = item.Group.GroupName,
                        Instructor = item.Instructor.Initials,
                    };
                    list.Add(l);
                }
                entity.Lessons = list;
                lessons.Add(entity);
            }
            report.Lessons = lessons;
            return report.GetReport();
        }
Exemplo n.º 2
0
        public static void ReportThree()
        {
            ScheduleTheoryReport obj = new ScheduleTheoryReport("D:\\new3.pdf");
            List<ScheduleTheoryEntity> list = new List<ScheduleTheoryEntity>
            {
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Четверг",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 1),
                        new DateTime(2015, 10, 8),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(14, 0, 0),
                            EndTime = new TimeSpan(14, 45, 0),
                            Instructor = "Иванов И. И.",
                            Group = "В - 122",
                        },
                    },
                },
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Пятница",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 2),
                        new DateTime(2015, 10, 9),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(18, 0, 0),
                            EndTime = new TimeSpan(18, 45, 0),
                            Instructor = "Иванов И. И.",
                            Group = "В - 122",
                        },
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(14, 0, 0),
                            EndTime = new TimeSpan(14, 45, 0),
                            Instructor = "Пупкин В. В.",
                            Group = "C - 140",
                        },
                    },

                },
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Понедельник",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 12),
                        new DateTime(2015, 10, 5),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(17, 0, 0),
                            EndTime = new TimeSpan(17, 45, 0),
                            Instructor = "Иванов И. И.",
                            Group = "В - 122",
                        },
                    },
                },
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Вторник",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 6),
                        new DateTime(2015, 10, 13),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(16, 0, 0),
                            EndTime = new TimeSpan(16, 45, 0),
                            Instructor = "Пупкин В. В.",
                            Group = "C - 140",
                        },
                            new LessonTheoryEntity
                            {
                                StartTime = new TimeSpan(18, 0, 0),
                                EndTime = new TimeSpan(18, 45, 0),
                                Instructor = "Иванов И. И.",
                                Group = "B - 122",
                        },
                    },
                },
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Среда",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 7),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(16, 0, 0),
                            EndTime = new TimeSpan(16, 45, 0),
                            Instructor = "Пупкин В. В.",
                            Group = "C - 140",
                        },
                    },
                },
                new ScheduleTheoryEntity
                {
                    DayOfWeek = "Суббота",
                    Dates = new List<DateTime>
                    {
                        new DateTime(2015, 10, 10),
                        new DateTime(2015, 10, 3),
                    },
                    Lessons = new List<LessonTheoryEntity>
                    {
                        new LessonTheoryEntity
                        {
                            StartTime = new TimeSpan(15, 0, 0),
                            EndTime = new TimeSpan(15, 45, 0),
                            Instructor = "Пупкин В. В.",
                            Group = "C - 140",
                        },
                    },
                },
            };
            obj.Lessons = list;
            obj.Month = 10;
            obj.Year = 2015;
            Console.WriteLine(obj.GetReport());
        }