1

无论我做什么,之前和之后的标题总是空的。这是会议或活动列表中的项目更新接收器

[public override void ItemUpdated(SPItemEventProperties properties)
        {
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "BEGIN");
            base.ItemUpdated(properties);
            try
            {
                base.EventFiringEnabled = false;
                SPSite site = properties.Web.Site;
                string sitename= properties.BeforeProperties\["Title"\].ToString();
                SPWeb web = site.RootWeb.Webs\[sitename\];
                web.AllowUnsafeUpdates = true;
                string prefix = properties.BeforeProperties\["Title"\].ToString().Substring(0, 2);
                web.Title = properties.AfterProperties\["Title"\].ToString();
                DateTime eventDate = properties.AfterProperties.GetValueAsDateTime(MeetingsCommon.Constants.FIELDS_EVENTDATE_NAME);
                if (eventDate != DateTime.MinValue)
                {
                    string titleMeetingCalendarItem = eventDate.ToString("yyyyMMdd");
                    titleMeetingCalendarItem = string.Format("{0}{1}", prefix, titleMeetingCalendarItem);
                    properties.AfterProperties.SetAfterPropertyValue("Title", titleMeetingCalendarItem);
                    web.ServerRelativeUrl = "/" + titleMeetingCalendarItem;               
                }
                web.Update();

                web.AllowUnsafeUpdates = false;
                base.EventFiringEnabled = true;
            }
            catch (Exception ex)
            {
                Logger.LogError("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", ex);
                properties.ErrorMessage = ex.Message;
                properties.Cancel = true;
            }
            finally
            {
                base.EventFiringEnabled = true;
            }
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "END");
        }]

在此处输入图像描述

4

1 回答 1

1

在这里回答:

http://www.synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=122

于 2012-08-27T14:25:54.397 回答