无论我做什么,之前和之后的标题总是空的。这是会议或活动列表中的项目更新接收器
!
[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");
}]