private static void CreateRecurringAppointment() { using (Session session = new Session(XpoDefault.DataLayer)) { RecurrenceInfo ri = new RecurrenceInfo(DateTime.Now, TimeSpan.FromMinutes(30)); //Dennis: set more options of the RecurrenceInfo class here. DevExpress.Persistent.BaseImpl.Event appointment = new DevExpress.Persistent.BaseImpl.Event(session); appointment.StartOn = DateTime.Now; appointment.Type = (int)AppointmentType.Pattern; RecurrenceInfoXmlPersistenceHelper helper = new RecurrenceInfoXmlPersistenceHelper(ri); appointment.RecurrenceInfoXml = helper.ToXml(); session.Save(appointment); } }
public void InitializeObject(int index) { if (resourceKeys == null) { resourceKeys = new List <Guid>(); for (int i = 0; i < 5; i++) { DevExpress.Persistent.BaseImpl.Resource res = new DevExpress.Persistent.BaseImpl.Resource(Session); res.Caption = "Resource " + i.ToString(); if (i == 0) { res.Color = Color.Blue; } else if (i == 1) { res.Color = Color.Red; } else if (i == 2) { res.Color = Color.Brown; } res.Save(); ((UnitOfWork)Session).CommitChanges(); resourceKeys.Add(res.Oid); } } this.Subject = "Test event #" + index; Random random = new Random((int)DateTime.Now.Ticks); this.AllDay = (index % (8 * random.Next(2) + 10) == 0 && index != 0); int days = (int)(index / 8); this.StartOn = DateTime.Today.Date.AddDays(days - 500).AddHours(9 + random.Next(12)); this.EndOn = this.StartOn.AddHours(random.Next(1) + 1); if (index % (random.Next(1) + 1) == 0) { this.Resources.Add(Session.GetObjectByKey <DevExpress.Persistent.BaseImpl.Resource>(resourceKeys[random.Next(resourceKeys.Count - 1)])); } if (index % (8 * (random.Next(5) + 15)) == 0) { RecurrenceInfo recurrenceInfo = new RecurrenceInfo(this.StartOn, 10); RecurrenceInfoXmlPersistenceHelper persistenceHelper = new RecurrenceInfoXmlPersistenceHelper(recurrenceInfo); this.Type = (int)AppointmentType.Pattern; this.RecurrenceInfoXml = persistenceHelper.ToXml(); } this.Save(); }