Posted 25 April 2019, 7:48 am ESTI had a C1Scheduler. I want to save the appointment objects through serialization so I created a serializable custom object to hold all information of the appointment and then serialized them into a file. When I tried to read the file, I created new appointment objects and put all information from the custom objects in there. However, I couldn't modify the links, resource and category property of the appointment objects since they're readonly. Is there any way to save the appointment object without using database? Please help. Thank you.
Cannot modify links, resources and categories of appointment object
Posted by: sunnyl on 25 April 2019, 7:48 am EST
Marked as Answer
Replied 25 April 2019, 10:49 pm ESTHi,
C1Scheduler has Importand Exportmethods in DataStorage that allows one to import and export scheduler's data from/to a file in formats like Binary, xml etc. You can use these methods as they save all the information of the appointments.
Once you have read the data, instead of modifying their you should first add the Resource/Contact/Category instances to their respective collection like DataStorage.ResourceStorage.Resources/ DataStorage.ContactStorage.Contacts/ DataStorage.CategoryStorage.Categories respectively, before adding them to the appointment objects.
// load data from the file.
ContactCollection contColl = this.c1Schedule1.DataStorage.ContactStorage.Contacts;
Contact conct1 = new Contact();
conct1.Text = "Andrey";
ResourceCollection resColl = this.c1Schedule1.DataStorage.ResourceStorage.Resources;
Resource res1 = new C1.C1Schedule.Resource();
res1.Text = "Digital Projector";
CategoryCollection catColl= this.c1Schedule1.DataStorage.CategoryStorage.Categories;
Category category = new Category();
category.Text = "Suppliers";
foreach (Appointment app in c1Schedule1.DataStorage.AppointmentStorage.Appointments)
app.Body = "Body of Appointment";