Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EWS从主定期约会获取所有事件_C#_Exchangewebservices - Fatal编程技术网

C# EWS从主定期约会获取所有事件

C# EWS从主定期约会获取所有事件,c#,exchangewebservices,C#,Exchangewebservices,我使用EWSfindappoint获取日期之间的所有约会 有了这个,我就形成了另一个我的主人约会的清单 我正在尝试使用Masters检索系列中的每个约会,但这正是我遇到的问题。 我试图遍历列表() 公共列表getAllOccurrencesFromMaster(约会主事件){ List retVal=新列表(); int-iCurrentIndex=1; DateTime occurStart=masterOccurse.Start; 试一试{ //获取位于序列中当前索引处的约会。 约会序列ap

我使用EWS
findappoint
获取日期之间的所有约会

有了这个,我就形成了另一个我的主人约会的清单

我正在尝试使用Masters检索系列中的每个约会,但这正是我遇到的问题。
我试图遍历列表()

公共列表getAllOccurrencesFromMaster(约会主事件){
List retVal=新列表();
int-iCurrentIndex=1;
DateTime occurStart=masterOccurse.Start;
试一试{
//获取位于序列中当前索引处的约会。
约会序列appt=Appointment.BindToOccurrence(this.exchangeService,新项目Id(masterOccurrence.Id.ToString()),iCurrentIndex);
retVal.Add(系列应用);
while(true){
试一试{
约会appt=Appointment.BindToOccurrence(this.exchangeService,新条目Id(masterOccurrence.Id.ToString()),iCurrentIndex+1);
检索添加(附件);
}捕获(ServiceResponseException sre){
Console.WriteLine(“具有此索引的事件先前已从重复中删除。”+sre.ToString());
}捕获(例外e){
投掷e;
}
}
iCurrentIndex++;
}
}捕获(例外e){
如果(e.Message==“发生索引超出重复范围。”){
WriteLine(“已到达系列的末尾”);
}否则{
Console.WriteLine(“错误。”+e.ToString());
投掷e;
}
}
返回返回;
}
我对上述代码的问题是,当到达已删除的项目时,它会抛出与索引超出范围时相同的异常:
ServiceResponseException

这是一个问题,因为一个我想继续,另一个我想中断,我不会根据消息文本切换。此外,我需要删除的事件。如何获得定期系列中的所有约会


我还尝试使用主约会的
DeletedOccurances
属性,但没有一个条目的ID已填充。我们从Exchange到系统进行单向同步,我需要知道删除了哪些内容,以便将其从系统中删除。我们跟踪calenderItem.ID,因此当删除某些内容时,我需要它来知道在我们的系统中删除哪个会议。

,而不是获取该系列中的所有约会。我使用了主定期
约会。定期
对象以及删除和修改的事件来了解约会发生了什么,并正确地同步我们这方面的事情。

跟进时间很长,但我需要反复阅读一系列内容,因此看到了这篇文章。原始问题的简短答案是使用
ServiceResponseException.ErrorCode
,当您点击缺少的实例时,
ErrorCalendarOccurrenceIsDeletedFromRecurrence
,当您点击系列末尾时,
ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange
。某人。

这篇文章中的信息对你有帮助吗?
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(start, end, 1000);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> findAppointmentResults = calendar.FindAppointments(cView);
Appointment.BindToRecurringMaster(this.exchangeService, new ItemId(occurrence.Id.ToString()));
 public List<Appointment> getAllOccurrencesFromMaster(Appointment masterOccurrence) {
            List<Appointment> retVal = new List<Appointment>();


            int iCurrentIndex = 1;
            DateTime occurStart = masterOccurrence.Start;
            try {
                // Get the appointment that is located at the current index in the series.
                Appointment seriesAppt = Appointment.BindToOccurrence(this.exchangeService, new ItemId(masterOccurrence.Id.ToString()), iCurrentIndex);
                retVal.Add(seriesAppt);

                while (true) {
                    try {
                        Appointment appt = Appointment.BindToOccurrence(this.exchangeService, new ItemId(masterOccurrence.Id.ToString()), iCurrentIndex + 1);
                        retVal.Add(appt);
                    } catch (ServiceResponseException sre) {
                        Console.WriteLine("Occurrence with this index was previously deleted from the recurrence. " + sre.ToString());
                    } catch (Exception e) {
                            throw e;
                        }
                    }
                    iCurrentIndex++;
                }
            }catch (Exception e) {
                if (e.Message == "Occurrence index is out of recurrence range.") {
                    Console.WriteLine("The end of the series has been reached.");
                } else {
                    Console.WriteLine("bad error. " + e.ToString());
                    throw e;
                }
            }

            return retVal;
        }