public static void UploadTimetable(Group[] OKKT) { List <TimetablesList> timetableOKKT = new List <TimetablesList>(); TimetablesList temp; for (int i = 0; i < OKKT.Length; i++) { temp = new TimetablesList(); temp.Group = OKKT[i].Name; temp.Monday0 = OKKT[i].TotalTimetable[0, 0]; temp.Monday1 = OKKT[i].TotalTimetable[0, 1]; temp.Monday2 = OKKT[i].TotalTimetable[0, 2]; temp.Monday3 = OKKT[i].TotalTimetable[0, 3]; temp.Monday4 = OKKT[i].TotalTimetable[0, 4]; temp.Monday5 = OKKT[i].TotalTimetable[0, 5]; temp.Tuesday0 = OKKT[i].TotalTimetable[1, 0]; temp.Tuesday1 = OKKT[i].TotalTimetable[1, 1]; temp.Tuesday2 = OKKT[i].TotalTimetable[1, 2]; temp.Tuesday3 = OKKT[i].TotalTimetable[1, 3]; temp.Tuesday4 = OKKT[i].TotalTimetable[1, 4]; temp.Tuesday5 = OKKT[i].TotalTimetable[1, 5]; temp.Wednesday0 = OKKT[i].TotalTimetable[2, 0]; temp.Wednesday1 = OKKT[i].TotalTimetable[2, 1]; temp.Wednesday2 = OKKT[i].TotalTimetable[2, 2]; temp.Wednesday3 = OKKT[i].TotalTimetable[2, 3]; temp.Wednesday4 = OKKT[i].TotalTimetable[2, 4]; temp.Wednesday5 = OKKT[i].TotalTimetable[2, 5]; temp.Thursday0 = OKKT[i].TotalTimetable[3, 0]; temp.Thursday1 = OKKT[i].TotalTimetable[3, 1]; temp.Thursday2 = OKKT[i].TotalTimetable[3, 2]; temp.Thursday3 = OKKT[i].TotalTimetable[3, 3]; temp.Thursday4 = OKKT[i].TotalTimetable[3, 4]; temp.Thursday5 = OKKT[i].TotalTimetable[3, 5]; temp.Friday0 = OKKT[i].TotalTimetable[4, 0]; temp.Friday1 = OKKT[i].TotalTimetable[4, 1]; temp.Friday2 = OKKT[i].TotalTimetable[4, 2]; temp.Friday3 = OKKT[i].TotalTimetable[4, 3]; temp.Friday4 = OKKT[i].TotalTimetable[4, 4]; temp.Friday5 = OKKT[i].TotalTimetable[4, 5]; timetableOKKT.Add(temp); } DBLoad a = new DBLoad(); a.GroupsTimetableList = timetableOKKT; a.ImportTimetableToFB(); }
public static void LogicRun() { DBLoad a = new DBLoad(); a.UploadFromFBBD(); string[] N_Prepods = new string[a.UploadList.Count]; string[] N_Groups = new string[a.UploadList.Count]; string[] N_Subjects = new string[a.UploadList.Count]; int[] N_PerWeek = new int[a.UploadList.Count]; int[] N_Weeks = new int[a.UploadList.Count]; int[] N_Total = new int[a.UploadList.Count]; for (int i = 0; i < a.UploadList.Count; i++) { N_Prepods[i] = a.UploadList[i].Teacher; N_Groups[i] = a.UploadList[i].Group; N_Subjects[i] = a.UploadList[i].Subject; N_PerWeek[i] = Convert.ToInt32(a.UploadList[i].HoursPerWeek); N_Weeks[i] = Convert.ToInt32(a.UploadList[i].Weeks); N_Total[i] = Convert.ToInt32(a.UploadList[i].TotalHours); } a.UploadTeachersOpp(); string[] P_Prepods = new string[a.TeachersOppList.Count]; string[] P_Opps = new string[a.TeachersOppList.Count]; for (int i = 0; i < a.TeachersOppList.Count; i++) { P_Prepods[i] = a.TeachersOppList[i].Teacher; P_Opps[i] = a.TeachersOppList[i].Monday + a.TeachersOppList[i].Tuesday + a.TeachersOppList[i].Wednesday + a.TeachersOppList[i].Thursday + a.TeachersOppList[i].Friday; } a.UploadCabinets(); string[] C_Prepods = new string[a.CabList.Count]; string[] C_cabs = new string[a.CabList.Count]; for (int i = 0; i < a.CabList.Count; i++) { C_Prepods[i] = a.CabList[i].TeacherName; C_cabs[i] = a.CabList[i].Cabinet; } int Number_of_prep = P_Prepods.Length; //Количество преподавателей для инициализации TeacherList[] Prep_okkt; //список преподов Prep_okkt = new TeacherList[Number_of_prep]; IEnumerable <String> IE_G_Group = N_Groups.Distinct(); string[] G_Groups = IE_G_Group.ToArray(); int[] G_Practice = new int[G_Groups.Count()]; for (int i = 0; i < G_Practice.Length; i++) { G_Practice[i] = 0; } int[] G_Weeks = new int[G_Groups.Length]; for (int i = 0, j = 0; i < G_Groups.Length && j < N_Groups.Length; j++) { if (G_Groups[i] == N_Groups[j]) { G_Weeks[i] = N_Weeks[j]; i++; j = 0; } } //Дальше идёт инициализация основных объектов данными из массивов. Group[] okkt = new Group[G_Groups.Length]; for (int i = 0; i < G_Groups.Length; i++) { okkt[i] = new Group(G_Groups[i], G_Weeks[i], G_Practice[i]); } for (int i = 0; i < Number_of_prep; i++) { Prep_okkt[i] = new TeacherList(Subjects.SubjectsCount(P_Prepods[i], N_Prepods), P_Prepods[i], P_Opps[i]); } for (int i = 0; i < Prep_okkt.Length; i++) { for (int j = 0, k = 0; j < N_Groups.Length; j++) { if (Prep_okkt[i].teacherName == N_Prepods[j]) { Prep_okkt[i].subjects[k] = new Subjects(N_Subjects[j], N_Total[j], N_Weeks[i], N_Groups[j], okkt); k++; } } } for (int i = 0; i < Prep_okkt.Length; i++) { for (int j = 0; j < C_Prepods.Length; j++) { if (Prep_okkt[i].teacherName == C_Prepods[j]) { Prep_okkt[i].Cabinet = C_cabs[j]; break; } } } TeacherList temp; //список преподов для сортировки for (int i = 0; i < Prep_okkt.Length - 1; i++) //Сортировка по убыванию свободных мест { for (int j = i + 1; j < Prep_okkt.Length; j++) { if (Prep_okkt[i].possibilitiesCount - AdeptMech.OccHours(Prep_okkt[i]) > Prep_okkt[j].possibilitiesCount - AdeptMech.OccHours(Prep_okkt[j])) { temp = Prep_okkt[i]; Prep_okkt[i] = Prep_okkt[j]; Prep_okkt[j] = temp; } } } Group temp2; for (int i = 0; i < okkt.Length - 1; i++)//Сортировка групп по количеству часов. Почему-то не работает (наверное(я не знаю)) { for (int j = i + 1; j < okkt.Length; j++) { if (AdeptMech.GroupHours(Prep_okkt, okkt[i].Name) < AdeptMech.GroupHours(Prep_okkt, okkt[j].Name)) { temp2 = okkt[i]; okkt[i] = okkt[j]; okkt[j] = temp2; } } } for (int i = 0; i < okkt.Length; i++)//Создание расписания погруппно { okkt[i] = AdeptMech.CreatRoz(ref Prep_okkt, okkt[i]); } String[] Workout = { "Понедельник", "Вторник", "Среда", "Четверг", "Пятница" }; //вывод расписания for (int d = 0; d < okkt.Length; d++) { for (int i = 0; i < 5; i++) { for (int k = 0; k < 6; k++) { if (okkt[d].TimeTable[i, k].EvenWeek.Subject == okkt[d].TimeTable[i, k].OddWeek.Subject) { okkt[d].TotalTimetable[i, k] = okkt[d].TimeTable[i, k].EvenWeek.Subject + " " + okkt[d].TimeTable[i, k].EvenWeek.Teacher + " " + okkt[d].TimeTable[i, k].EvenWeek.Cabinet; } else { okkt[d].TotalTimetable[i, k] = okkt[d].TimeTable[i, k].EvenWeek.Subject + " " + okkt[d].TimeTable[i, k].EvenWeek.Teacher + " " + okkt[d].TimeTable[i, k].EvenWeek.Cabinet + " | " + okkt[d].TimeTable[i, k].OddWeek.Subject + " " + okkt[d].TimeTable[i, k].OddWeek.Teacher + " " + okkt[d].TimeTable[i, k].OddWeek.Cabinet; } } } } AdeptMech.UploadTimetable(okkt); }