使用 XtraScheduler 按特定自定义字段值获取约会

本文关键字:字段 获取 约会 自定义 XtraScheduler 使用 | 更新日期: 2023-09-27 18:37:27

>我当前正在使用计划程序控件从应用程序中的 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"的值,并且需要从此值获取存储中的约会对象。 到目前为止,我的解决方案是这样的:

private Appointment GetAppointmentByStandingOrderKEY(Guid standingOrderKEY)
{
    Appointment findAppointment = StandingSchedulerControl.Storage.Appointments.Items.Find(appointment => (Guid)appointment.CustomFields["StandingOrderKEY"] == standingOrderKEY);
    return findAppointment;
}

但是,StandingSchedulerControl.Storage.Appointments.Items 似乎只包含具有"正常"或"模式"类型的约会,这意味着如果 StandingOrderKEY 与保存的 ChangedOccurrence 或 DeletedOccurrence 相关联,则不会找到相关的约会。

我已经验证了从列表创建的绑定源实际上确实包含所有约会的例外。 似乎当它被设置为AppointmentStorage的数据源时,异常被安置在他们的模式约会中,并且只能通过首先获取对父约会的引用,然后在该约会上调用GetExceptions(),并在生成的集合中搜索StandingOrderKEY来获取。 然而,这是一个问题,因为目前我们没有"家长"约会的识别信息,只有例外的识别信息。

因此,我的问题如下(大致按可取顺序排列):

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

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

使用 XtraScheduler 按特定自定义字段值获取约会

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

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

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

我不知道仅通过异常进行搜索的方法。

您的第三个问题是,给定来自绑定源的项目,您能否从约会存储中获取约会?这基本上与第一个问题相同:给定 BindingSource 项中包含的数据,您仍然必须搜索计划程序控件存储中的约会。

我最终的解决方案是维护我自己的长期订单对象到约会的映射,如以下 DevExpress 解决方案所示: http://www.devexpress.com/Support/Center/p/E3143.aspx

这允许我从源对象获取约会对象,如上面的问题 3 所示。