void OnImportAppointment(object sender, AppointmentImportingEventArgs e) { VCalendarAppointmentImportingEventArgs args = (VCalendarAppointmentImportingEventArgs)e; Appointment apt = args.Appointment; VEvent ev = args.VEvent; VEventExtension ext = ev.Extensions[CustomFieldName]; // restore the custom information if (ext != null) { CustomObject obj = new CustomObject(); obj.Name = ext.Name; obj.ObjectType = ext.Parameters["TYPE"].Value; obj.ValueType = ext.Parameters["VALUE"].Value; obj.Value = ext.Value; apt.CustomFields[CustomFieldName] = obj; } }
void OnExportAppointment(object sender, AppointmentExportingEventArgs e) { VCalendarAppointmentExportingEventArgs args = (VCalendarAppointmentExportingEventArgs)e; Appointment apt = args.Appointment; VEvent ev = args.VEvent; // !!! only work time if (apt.Start.Hour < 8 || apt.Start.Hour > 17) { args.Cancel = true; return; } // save the custom information CustomObject obj = (CustomObject)apt.CustomFields[CustomFieldName]; VEventExtension ext = new VEventExtension(obj.Name, obj.Value); ext.Parameters.Add(new VCalendarParameter("TYPE", obj.ObjectType)); ext.Parameters.Add(new VCalendarParameter("VALUE", obj.ValueType)); ev.Extensions.Add(ext); }