public static void UploadNotes(ScheduleRepository repo, CancellationToken cToken) { var jsonSerializer = new JavaScriptSerializer { MaxJsonLength = 10000000 }; cToken.ThrowIfCancellationRequested(); var notes = repo.ScheduleNotes.GetAllScheduleNotes(); var mySqlNotes = MySQLScheduleNote.FromNotes(notes); var wud = new WnuUploadData { dbPrefix = "", tableSelector = "scheduleNotes", data = jsonSerializer.Serialize(mySqlNotes) }; string json = jsonSerializer.Serialize(wud); UploadTableData(json, @"http://wiki.nayanova.edu/_php/includes/"); }
public static void UploadSchedule(ScheduleRepository repo, string databaseTablesPrefix, string uploadEndPoint, CancellationToken cToken) { var jsonSerializer = new JavaScriptSerializer {MaxJsonLength = 20000000}; cToken.ThrowIfCancellationRequested(); var allAuditoriums = repo.Auditoriums.GetAll(); var mySqlAuditoriums = MySqlAuditorium.FromAuditoriumList(allAuditoriums); var wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "auditoriums", data = jsonSerializer.Serialize(mySqlAuditoriums) }; string json = jsonSerializer.Serialize(wud); var result = UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var allBuildings = repo.Buildings.GetAllBuildings(); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "buildings", data = jsonSerializer.Serialize(allBuildings) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var calendars = repo.Calendars.GetAllCalendars(); var mySqlCalendars = MySqlCalendar.FromCalendarList(calendars); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "calendars", data = jsonSerializer.Serialize(mySqlCalendars) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var rings = repo.Rings.GetAllRings(); var mySqlRings = MySqlRing.FromRingList(rings); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "rings", data = jsonSerializer.Serialize(mySqlRings) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var students = repo.Students.GetAllStudents(); var mySqlStudents = MySqlStudent.FromStudentList(students); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "students", data = jsonSerializer.Serialize(mySqlStudents) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var studentGroups = repo.StudentGroups.GetAllStudentGroups(); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "studentGroups", data = jsonSerializer.Serialize(studentGroups) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var teachers = repo.Teachers.GetAllTeachers(); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "teachers", data = jsonSerializer.Serialize(teachers) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var disciplines = repo.Disciplines.GetAllDisciplines(); var mySqlDisciplines = MySqlDiscipline.FromDisciplineList(disciplines); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "disciplines", data = jsonSerializer.Serialize(mySqlDisciplines) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); int splitCount = 1000; var studentsInGroups = repo.StudentsInGroups.GetAllStudentsInGroups(); var partsCount = Math.Ceiling((double)studentsInGroups.Count / splitCount); for (int i = 0; i < partsCount; i++) { var studentsInGroupsChunk = studentsInGroups.Skip(i * splitCount).Take(splitCount).ToList(); var mySqlStudentsInGroups = MySqlStudentsInGroups.FromStudentsInGroupsList(studentsInGroupsChunk); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "studentsInGroups", append = (i == 0) ? "" : "1", data = jsonSerializer.Serialize(mySqlStudentsInGroups) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); } cToken.ThrowIfCancellationRequested(); var teacherForDisciplines = repo.TeacherForDisciplines.GetAllTeacherForDiscipline(); var mySqlTeacherForDisciplines = MySqlTeacherForDiscipline.FromTeacherForDisciplineList(teacherForDisciplines); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "teacherForDisciplines", data = jsonSerializer.Serialize(mySqlTeacherForDisciplines) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); splitCount = 1000; var lessons = repo.Lessons.GetFiltredLessons(l => l.State == 0 || l.State == 1); partsCount = Math.Ceiling((double)lessons.Count / splitCount); for (int i = 0; i < partsCount; i++) { var lessonsChunk = lessons.Skip(i * splitCount).Take(splitCount).ToList(); var mySqlLessons = MySqlLesson.FromLessonList(lessonsChunk); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "lessons", append = (i == 0) ? "" : "1", data = jsonSerializer.Serialize(mySqlLessons) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); } cToken.ThrowIfCancellationRequested(); var configs = repo.ConfigOptions.GetAllConfigOptions(); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "configs", data = jsonSerializer.Serialize(configs) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); splitCount = 1000; var lessonsLogEvents = repo.LessonLogEvents.GetAllLessonLogEvents(); partsCount = Math.Ceiling((double)lessonsLogEvents.Count / splitCount); for (int i = 0; i < partsCount; i++) { var lessonLogEventsChunk = lessonsLogEvents.Skip(i * splitCount).Take(splitCount).ToList(); var mySqlLogEvent = MySqlLessonLogEvent.FromLessonLogList(lessonLogEventsChunk); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "lessonLogEvents", append = (i == 0) ? "" : "1", data = jsonSerializer.Serialize(mySqlLogEvent) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); } cToken.ThrowIfCancellationRequested(); var auditoriumEvents = repo.AuditoriumEvents.GetAllAuditoriumEvents(); var mySqlauditoriumEvents = MySqlAuditoriumEvent.FromAuditoriumEventList(auditoriumEvents); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "auditoriumEvents", data = jsonSerializer.Serialize(mySqlauditoriumEvents) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var faculties = repo.Faculties.GetAllFaculties(); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "faculties", data = jsonSerializer.Serialize(faculties) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); cToken.ThrowIfCancellationRequested(); var gifs = repo.GroupsInFaculties.GetAllGroupsInFaculty(); var mySqlgifs = MySqlGroupsInFaculty.FromGroupsInFacultyList(gifs); wud = new WnuUploadData { dbPrefix = databaseTablesPrefix, tableSelector = "GroupsInFaculties", data = jsonSerializer.Serialize(mySqlgifs) }; json = jsonSerializer.Serialize(wud); UploadTableData(json, uploadEndPoint); }
private void UploadClick(object sender, EventArgs e) { var jsonSerializer = new JavaScriptSerializer(); var mySqlExams = MySqlExam.FromExamList(_repo.Exams.GetAllExamRecords()); var wud = new WnuUploadData { tableSelector = "exams", data = jsonSerializer.Serialize(mySqlExams) }; string json = jsonSerializer.Serialize(wud); WnuUpload.UploadTableData(json, siteToUpload.Text); var mySqLlogEvents = MySqlExamLogEvent.FromLogEventList(_repo.Exams.GetAllLogEvents()); wud = new WnuUploadData { tableSelector = "examsLogEvents", data = jsonSerializer.Serialize(mySqLlogEvents) }; json = jsonSerializer.Serialize(wud); WnuUpload.UploadTableData(json, siteToUpload.Text); }