コード例 #1
0
        public static void ItemUpdated(SPItemEventProperties properties)
        {
            try
            {
                if (InTransaction(properties))
                {
                    return;
                }

                var data = new Dictionary <string, object>
                {
                    { "Id", properties.ListItemId },
                    { "Title", GetTitle(properties) },
                    { "URL", properties.List.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + properties.ListItemId },
                    { "ListTitle", properties.ListTitle },
                    { "ListId", properties.ListId },
                    { "WebId", properties.Web.ID },
                    { "SiteId", properties.SiteId },
                    { "UserId", new SPFieldUserValue(properties.Web, (string)properties.ListItem["Editor"]).LookupId },
                    { "ActivityTime", properties.ListItem["Modified"] }
                };

                GetAssignedToUsers(properties, data);
                GetAssociatedListItems(properties, data);

                SocialEngineProxy.ProcessActivity(ObjectKind.ListItem, ActivityKind.Updated, data, properties.Web);
            }
            catch { }
            try
            {
                ParentItemUpdate.UpdateParent(properties);
            }
            catch { }
        }
コード例 #2
0
        public static void ItemDeleting(SPItemEventProperties properties)
        {
            try
            {
                if (InTransaction(properties))
                {
                    return;
                }
                var regionalSettings = properties.Web.CurrentUser.RegionalSettings ??
                                       properties.Web.RegionalSettings;
                var data = new Dictionary <string, object>
                {
                    { "Id", properties.ListItemId },
                    { "Title", GetTitle(properties) },
                    { "URL", properties.List.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + properties.ListItemId },
                    { "ListTitle", properties.ListTitle },
                    { "ListId", properties.ListId },
                    { "WebId", properties.Web.ID },
                    { "SiteId", properties.SiteId },
                    { "UserId", properties.Web.CurrentUser.ID },
                    { "ActivityTime", regionalSettings.TimeZone.UTCToLocalTime(DateTime.UtcNow) },
                };

                GetAssociatedListItems(properties, data);

                SocialEngineProxy.ProcessActivity(ObjectKind.ListItem, ActivityKind.Deleted, data, properties.Web);
            }
            catch { }
            try
            {
                ParentItemUpdate.UpdateParent(properties);
            }
            catch { }
        }