如何从Sharepoint日历中获取两个日期之间的事件列表 [英] How to get a list of events from a Sharepoint calendar that are between two date

查看:91
本文介绍了如何从Sharepoint日历中获取两个日期之间的事件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sharepoint中有一个日历,现在我希望得到两个日期之间的事件..

但我的代码不起作用!





I have a calendar in sharepoint,now i want get events of between two date..
but My code does not work!


DateTime startDate = faDatePicker1.SelectedDateTime;
 DateTime EndDate = faDatePicker2.SelectedDateTime;




using (ClientContext context = new ClientContext(siteUrl))
           {
               context.Credentials = new NetworkCredential(Properties.Settings.Default.Username, "123", "mesbahsoft.local");
               List oList = context.Web.Lists.GetByTitle("Vacation");

               CamlQuery camlQuery = new CamlQuery();
               camlQuery.ViewXml = "<query><Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'>" + startDate + "</Value>" +
               "</Geq><Leq><FieldRef Name='EventDate' /><Value Type='DateTime'>" + EndDate + "</Value></Leq><And><Geq><FieldRef Name='EndDate' /><Value Type='DateTime'>" + startDate + "</Value></Geq><Leq><FieldRef Name='EndDate' /><Value Type='DateTime'>" + EndDate + "</Value></Leq></Where></query>"; 
               ListItemCollection collListItem = oList.GetItems(camlQuery);

               context.Load(collListItem);

               
                   context.ExecuteQuery();
}

推荐答案

我认为粗鲁你在不同的地方问同样的问题论坛,只是为了检查谁先给出熟食代码



http://sharepoint.stackexchange.com/questions/120743/get-a-list-of-events-that - 两次约会 [ ^ ]



除此之外,CAML不是火箭科学。您是否尝试过调试?

如果从CAML中删除过滤器,会得到什么结果?你传递的startdate和enddate的格式是否正确?



有很多变数,但真正帮助的最好的人就是你自己。
I consider it rude that you are asking the same question all over different forums, just to check who gives the cooked code first.

http://sharepoint.stackexchange.com/questions/120743/get-a-list-of-events-that-are-between-two-date[^]

Apart from that CAML isn't rocket science. Have you tried to debug?
What are the results you get if you remove the filter from CAML? Is the format of startdate and enddate you are passing is correct?

There are so many variables but the best person who can really help is you yourself.


这篇关于如何从Sharepoint日历中获取两个日期之间的事件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆