1

我正在尝试更新一个定期日历列表实例,当我第一次更新时它一切正常,但是当我获取更新的项目并尝试更新它时,它没有得到更新。

这是我为更新重复项目所做的代码

    //fetch List item, in my case it will be exact one item per day
list = web.Lists["Calendar"];

SPQuery query1 = new SPQuery();query1.Query = string.Concat(
//Today"<Where><DateRangesOverlap>","<FieldRef Name='EventDate' />","<FieldRef Name='EndDate' />","<FieldRef Name='RecurrenceID' />","<Value type='DateTime'>","<Today/>","</Value>","</DateRangesOverlap>",
"</Where>");

query1.ExpandRecurrence = true;
query1.CalendarDate = DateTime.Parse(txtCalendarDate.Text);

//as only one item is fetched updated the fetched item
SPListItem Newitem = list.Items.Add();

                        //The guid of the  recurrence item id
                        string uid_old = Convert.ToString(items[0]["UID"]);
                        Newitem["UID"] = new Guid(uid_old);

                        Newitem["Title"] = ttl;
                        Newitem["Location"] = ttl;

                        //Override the EventDate and EndDate
                        Newitem["EventDate"] = startdate;//Same date as item fetched but different time
                        Newitem["EndDate"] = Enddate;//Same date as item fetched but different time

                        // recurrence item’s ID
                        int masterID;
                        if (Convert.ToString(items[0]["MasterSeriesItemID"]) == "" || Convert.ToString(items[0]["MasterSeriesItemID"]) == "0")
                            masterID = items[0].ID;
                        else
                            masterID = Convert.ToInt32(items[0]["MasterSeriesItemID"]);
                        Newitem["MasterSeriesItemID"] = masterID;

                        //Take recurrence item’s EventDate as RecurrenceID
                        Newitem["RecurrenceID"] = Convert.ToDateTime(items[0]["EventDate"].ToString());

                        Newitem["fRecurrence"] = 1;
                        Newitem["fAllDayEvent"] = 0;
                        Newitem["TimeZone"] = items[0]["TimeZone"].ToString();// What ever is the time zone.
                        //4 for override the recurrence item
                        Newitem["EventType"] = 4;

                        Newitem["RecurrenceData"] =  Convert.ToString(items[0]["RecurrenceData"]);

                        Newitem.Update();
                        list.Update();

谁能帮我弄清楚为什么我第二次尝试更新时更新不起作用?已正确获取更新的条目,但不会对其进行更新。第一次更新的条目保持原样,可以在所有事件中的当前事件中看到另一个条目被创建,但它不会反映在重复项目中,如果我尝试在同一天获取条目而不是第一次更新的条目被提取。

请参考图片: http ://social.msdn.microsoft.com/Forums/getfile/185919

请帮帮我~

4

0 回答 0