public void ExportSolution() { DDay.iCal.iCalendar iCal = new DDay.iCal.iCalendar(); var t = new DBManager(); t.initInputData(); t.initOutputData(); foreach(ScheduledTimeSlot[] solution in (t.solutions)) { for (int i = 0; i < solution.Length; i++) { Event evt = iCal.Create<Event>(); evt.Start = iCalDateTime.Today.AddHours((int)solution[i].timeSlot.StartHour).AddDays((int)(solution[i].timeSlot.Day)); evt.End = iCalDateTime.Today.AddHours((int)solution[i].timeSlot.EndHour).AddDays((int)(solution[i].timeSlot.Day)); evt.Summary = string.Join(", ", solution[i].groups.Select(g => g.name)); evt.Location = solution[i].room.nameOrNumber; } break; } ISerializationContext ctx = new SerializationContext(); ISerializerFactory factory = new DDay.iCal.Serialization.iCalendar.SerializerFactory(); // Get a serializer for our object IStringSerializer serializer = factory.Build(iCal.GetType(), ctx) as IStringSerializer; string output = serializer.SerializeToString(iCal); var bytes = Encoding.UTF8.GetBytes(output); File.WriteAllBytes("solution.ics", bytes); }
private void buttonDummyData_Click(object sender, EventArgs e) { Data.DBManager db = new DBManager(); db.initInputData(); teachers.RemoveAll(x => true); teachers.AddRange(db.teachers); rooms.RemoveAll(x => true); rooms.AddRange(db.rooms); subjects.RemoveAll(x => true); subjects.AddRange(db.subjects); groups.RemoveAll(x => true); groups.AddRange(db.groups); MessageBox.Show("Фалшивите данни са заредени"); }
public void writeTestData() { var d = new DBManager(); d.initOutputData(); var ser = new Newtonsoft.Json.JsonSerializer(); var ser_string = Newtonsoft.Json.JsonConvert.SerializeObject(d.solutions); System.IO.File.WriteAllText(@"..\..\program_generated_test.js", ser_string); }