【问题标题】:How to retrieve recurring appointments如何检索定期约会
【发布时间】:2011-06-14 12:47:43
【问题描述】:

我正在使用 service.FindItems 方法从交换服务器检索约会,但它没有返回定期约会。它返回重复项目的第一个实例,但之后不再返回,并且 IsRecurring 在约会时设置为 false。

这是代码:

private void loadUsersAppointments(string user, int rscID)
    {
        // Add a search filter that searches on the body or subject.
        List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
        searchFilterCollection.Add(new SearchFilter.IsGreaterThan(AppointmentSchema.Start, DateTime.Today.AddDays(-7)));

        // Create the search filter.
        SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());

        CalendarView V = new CalendarView(DateTime.Today.AddDays(-7), DateTime.Today.AddMonths(1), 1000);
        V.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
        V.Traversal = ItemTraversal.Shallow;

        // Create a view with a page size of 50.
        ItemView view = new ItemView(10000);

        // Identify the Subject and DateTimeReceived properties to return.
        // Indicate that the base property will be the item identifier
        view.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

        // Order the search results by the DateTimeReceived in descending order.
        view.OrderBy.Add(AppointmentSchema.Start, SortDirection.Descending);

        // Set the traversal to shallow. (Shallow is the default option; other options are Associated and SoftDeleted.)
        view.Traversal = ItemTraversal.Shallow;

        // Send the request to search the Inbox and get the results.
        ExchangeService service = GlobalFunc.ElevateGetBinding();
        service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, user+"@works.local");
        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, searchFilter, view);

        List<Item> items = new List<Item>();
        foreach (Microsoft.Exchange.WebServices.Data.Appointment appointment in findResults)
        {
            items.Add(appointment);
        }
        service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);

        // Process each item.
        foreach (Microsoft.Exchange.WebServices.Data.Appointment myItem in items)
        {
            DevExpress.XtraScheduler.Appointment AddAppt = new DevExpress.XtraScheduler.Appointment();

            try {
                if (myItem.Subject.StartsWith("Advisor Appointment"))
                    AddAppt.LabelId = 8;
                else
                    AddAppt.LabelId = 2;
                AddAppt.Subject = myItem.Subject;
            }
            catch { }
            try
            {

            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            try { AddAppt.Start = myItem.Start; }
            catch { }
            try { AddAppt.Description = myItem.Body; }
            catch { }
            try { AddAppt.End = myItem.End; }
            catch { }
            AddAppt.ResourceId = rscID;




            schStorage.Appointments.Add(AddAppt);
        }
    }

任何想法都将不胜感激。

谢谢

【问题讨论】:

    标签: c# exchangewebservices


    【解决方案1】:

    您需要使用 CalendarView 来获得定期约会。定期约会的实例不是 Exchange 数据库中的真实项目。相反,当您查询特定时间范围时,Exchange 会即时创建虚拟物品。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-26
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多