0

我有一个 XtraScheduler SchedulerControl 配置如下:

private DevExpress.XtraScheduler.SchedulerControl _SchedulerControl;
public DevExpress.XtraScheduler.SchedulerControl ConvSchedulerControl
{
    get
    {
        if (_SchedulerControl == null)
        {
            _SchedulerControl = new DevExpress.XtraScheduler.SchedulerControl();

            _SchedulerControl.Storage = new SchedulerStorage();
            _SchedulerControl.Storage.Appointments.Mappings.Subject = "StandingOrderIDString";
            _SchedulerControl.Storage.Appointments.Mappings.Start = "ScheduledDate";
            _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"));

            BindingSource bs = new BindingSource();
            bs.DataSource = new List<StandingOrder>();
            _SchedulerControl.Storage.Appointments.DataSource = bs;
        }
        return _SchedulerControl;
    }
}

我正在尝试以编程方式添加带有重复信息的约会,如http://help.devexpress.com/#WindowsForms/CustomDocument6201中给出的示例所示。但是,当方法执行到达将创建的约会添加到存储的最后一行(已指示)时,它“挂起”。从来没有抛出异常;我让它运行了 15 分钟以上,没有任何变化:

public void SetRecurrence(DateTime startDate, DateTime? endDate)
{
    Appointment appointmentObj = ConvSchedulerControl.Storage.CreateAppointment(AppointmentType.Pattern);

    if (endDate != null &&
        endDate != DateTime.Parse("12/31/2999"))
    {
        appointmentObj.End = (DateTime)endDate;
    }
    else
    {
        appointmentObj.RecurrenceInfo.Range = RecurrenceRange.NoEndDate;
    }

    appointmentObj.Start = startDate;
    appointmentObj.RecurrenceInfo.Type = RecurrenceType.Weekly;
    appointmentObj.RecurrenceInfo.WeekDays = WeekDays.Monday;
    appointmentObj.AllDay = true;

//Program execution reaches this line, but never proceeds past it.
    ConvSchedulerControl.Storage.Appointments.Add(appointmentObj);
}

我可以想象配置有问题导致存储无法成功添加约会,但我无法找到有关该主题的任何其他信息。有谁知道为什么这种方法不适合将约会添加到存储中,以及如何纠正它?

4

1 回答 1

1

您未能为“结束”字段提供映射。这是必需的映射。老实说,我只是在设计师中创建了一个日历才知道这一点。当您将 SchedulerControl 放置到窗体/控件上时,设计器为您提供的其中一件事是“映射向导”。“开始”和“结束”字段在向导中标记为必填项。

于 2012-08-01T16:25:11.867 回答