c# – 使用XtraScheduler按特定自定义字段值获取约会
我目前正在使用调度程序控件来保存和恢复应用程序中SQL数据库的预定约会数据.调度程序控件本身配置为使用几个自定义字段,如下所示:
private DevExpress.XtraScheduler.SchedulerControl _SchedulerControl; private DevExpress.XtraScheduler.SchedulerControl StandingSchedulerControl { get { if (_SchedulerControl == null) { _SchedulerControl = new DevExpress.XtraScheduler.SchedulerControl(); BindingSource bs = new BindingSource(); bs.DataSource = StandingOrderList; _SchedulerControl.Storage = new SchedulerStorage(this.components); _SchedulerControl.Storage.Appointments.AutoReload = true; _SchedulerControl.Storage.Appointments.Mappings.Subject = "Description"; _SchedulerControl.Storage.Appointments.Mappings.RecurrenceInfo = "RecurrenceInfo"; _SchedulerControl.Storage.Appointments.Mappings.Type = "Type"; _SchedulerControl.Storage.Appointments.CustomFieldMappings.Add(new DevExpress.XtraScheduler.AppointmentCustomFieldMapping("Inactive","Inactive")); _SchedulerControl.Storage.Appointments.CustomFieldMappings.Add(new DevExpress.XtraScheduler.AppointmentCustomFieldMapping("StandingOrderKEY","StandingOrderKEY")); _SchedulerControl.Storage.Appointments.DataSource = bs; _SchedulerControl.EditRecurrentAppointmentFormShowing += new EditRecurrentAppointmentFormEventHandler(_SchedulerControl_EditRecurrentAppointmentFormShowing); } return _SchedulerControl; } } 其中“StandingOrderList”被定义为StandingOrder业务对象的列表.这可以正确地保存和恢复,但是在应用程序中可能只有一个值“StandingOrderKEY”,并且需要从该值获取存储中的Appointment对象.到现在为止,我的解决方案是: private Appointment GetAppointmentByStandingOrderKEY(Guid standingOrderKEY) { Appointment findAppointment = StandingSchedulerControl.Storage.Appointments.Items.Find(appointment => (Guid)appointment.CustomFields["StandingOrderKEY"] == standingOrderKEY); return findAppointment; } 但是,StandSchedulerControl.Storage.Appointments.Items似乎只包含具有Normal或Pattern类型的约会,这意味着如果StandingOrderKEY与已保存的ChangedOccurrence或DeletedOccurrence相关联,则将找不到相关的约会. 我已经验证从列表创建的BindingSource实际上包含所有约会的例外.似乎当它被设置为AppointmentStorage的DataSource时,异常被置于其模式约会的“内部”,并且只能通过首先获得对父约会的引用然后在该约会上调用GetExceptions()并搜索最终收集了StandingOrderKEY.然而,这是一个问题,因为目前我们没有“父”约会的识别信息,只有例外的信息. 所以,我的问题如下(大致按照优先顺序排列): >有没有办法通过自定义字段值从约会存储中获取约会对象,忽略约会的类型?是否有包含例外和正常/模式约会的集合? 欢迎任何其他建议.感谢您的关注! 解决方法
您可以尝试通过GetAppointments()方法获取所有约会,看看是否有所作为:
Appointment findAppointment = StandingSchedulerControl.Storage .GetAppointments(startDate,endDate) .FirstOrDefault(a => (Guid)a.CustomFields["standingOrderKEY"] == standingOrderKEY); 我希望以这种方式获得约会将包括其他事件,包括您正在搜索的项目. 我不知道只是通过异常搜索的方式. 你的第三个问题是,鉴于来自BindingSource的项目,你能从AppointmentStorage获得预约吗?这与第一个问题基本上是同一个问题:给定BindingSource项目中包含的数据,您仍然需要搜索Scheduler控件存储中的约会. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |