微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.然而,这是一个问题,因为目前我们没有“父”约会的识别信息,只有例外的信息.

所以,我的问题如下(大致按照优先顺序排列):

>有没有办法通过自定义字段值从约会存储中获取约会对象,忽略约会的类型?是否有包含例外和正常/模式约会的集合?
>我们知道约会预先成为例外,因为约会的类型已经存储.有没有办法搜索此特定自定义字段值的所有异常?
>有没有办法通过数据源引用从约会存储中获取约会对象?用作DataSource的BindingSource包含异常约会.有没有办法,给定BindingSource集合中的项目,将它与存储中的项目相关联?

欢迎任何其他建议.感谢您的关注!

解决方法

您可以尝试通过GetAppointments()方法获取所有约会,看看是否有所作为:

Appointment findAppointment = StandingSchedulerControl.Storage
    .GetAppointments(startDate,endDate)
    .FirstOrDefault(a => (Guid)a.CustomFields["standingOrderKEY"] == 
                         standingOrderKEY);

我希望以这种方式获得约会将包括其他事件,包括您正在搜索的项目.

我不知道只是通过异常搜索的方式.

你的第三个问题是,鉴于来自BindingSource的项目,你能从AppointmentStorage获得预约吗?这与第一个问题基本上是同一个问题:给定BindingSource项目中包含的数据,您仍然需要搜索Scheduler控件存储中的约会.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐