当前位置: 首页>>代码示例>>C#>>正文


C# SPItemEventProperties类代码示例

本文整理汇总了C#中SPItemEventProperties的典型用法代码示例。如果您正苦于以下问题:C# SPItemEventProperties类的具体用法?C# SPItemEventProperties怎么用?C# SPItemEventProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SPItemEventProperties类属于命名空间,在下文中一共展示了SPItemEventProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ItemUpdating

        /// <summary>
        /// An item is being updated.
        /// </summary>
        public override void ItemUpdating(SPItemEventProperties properties)
        {
            bool allowed = true;

            if (properties.ListTitle == "Open Positions")
            {
                allowed = checkItem(properties);
            }

            try
            {

                if (!allowed)
                {
                    properties.Status = SPEventReceiverStatus.CancelWithError;
                    properties.ErrorMessage = "The job you have entered is not defined in the Job Definitions List";
                    properties.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                properties.Status = SPEventReceiverStatus.CancelWithError;
                properties.ErrorMessage = ex.Message;
                properties.Cancel = true;
            }
        }
开发者ID:vijaymca,项目名称:SharePoint,代码行数:29,代码来源:EventReceiver1.cs

示例2: GiveUserPrivelegesToWorkspace

        private void GiveUserPrivelegesToWorkspace(SPUser user, SPItemEventProperties properties)
        {
            InitializeWebAppProperties(properties);
            string workspaceURL = properties.Web.ServerRelativeUrl;
            //workspaceURL = workspaceURL.Remove(0, emisSiteURL.Length);
            workspaceURL = workspaceURL.Substring(workspaceURL.IndexOf("Agenda-"));

            using (SPSite emisSite = new SPSite(emisSiteURL))
            {
                using (SPWeb currentWorkspace = emisSite.OpenWeb(workspaceURL))
                {
                    currentWorkspace.AllowUnsafeUpdates = true;

                    SPRoleAssignment role;

                    role = new SPRoleAssignment(currentWorkspace.EnsureUser(user.LoginName));

                    role.RoleDefinitionBindings.Add(currentWorkspace.RoleDefinitions["Restricted Contribute"]);

                    currentWorkspace.RoleAssignments.Add(role);
                    currentWorkspace.AllowUnsafeUpdates = false;
                    currentWorkspace.Update();
                }
            }
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:25,代码来源:KeyPeopleAddedEventReceiver.cs

示例3: GetLatestItemOrderNo

        private int GetLatestItemOrderNo(SPItemEventProperties properties)
        {
            int orderNo = 0;

            string caml = string.Empty;
            var expressionsAnd = new List<Expression<Func<SPListItem, bool>>>();

            if (expressionsAnd.Count > 0)
                caml = Camlex.Query().WhereAll(expressionsAnd).OrderBy(x => x[Constants.ORDER_NUMBER_COLUMN] as Camlex.Desc).ToString();
            else
                caml = Camlex.Query().OrderBy(x => x[Constants.ORDER_NUMBER_COLUMN] as Camlex.Desc).ToString();

            SPQuery spQuery = new SPQuery();
            spQuery.Query = caml;

            spQuery.RowLimit = 1;

            SPList currentList = properties.List;
            SPListItemCollection items = currentList.GetItems(spQuery);

            if (items != null && items.Count > 0)
            {
                SPListItem item = items[0];

                if (item != null)
                {
                    orderNo = Convert.ToInt32(item[Constants.ORDER_NUMBER_COLUMN]);
                }
            }

            return orderNo;
        }
开发者ID:chutinhha,项目名称:aiaintranet,代码行数:32,代码来源:NewsItemContentTypeEventReciever.cs

示例4: EventReceiverContext

 public EventReceiverContext(SPItemEventProperties properties)
 {
     Site = new SPSite(properties.SiteId);
     Web = Site.OpenWeb(properties.RelativeWebUrl);
     List = Web.Lists[properties.ListId];
     Item = List.GetItemByIdAllFields(properties.ListItemId);
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:7,代码来源:EventReceiverContext.cs

示例5: AddFileInfo

        private void AddFileInfo(SPItemEventProperties properties)
        {
            try
            {
                var url = properties.WebUrl + "/" + properties.AfterUrl;
                var fileName = properties.AfterUrl;

                using (var site = new SPSite(properties.Web.Site.ID))
                using (var web = site.RootWeb)
                {
                    var list = web.Lists[LogList.ListName];
                    var listItems = list.Items;

                    var item = listItems.Add();
                    item["Title"] = fileName;
                    item["URL"] = url;
                    item.Update();
                }

                ULSLog.LogDebug(String.Format("Added {0} to {1} list", url, LogList.ListName));
            }
            catch (Exception ex)
            {
                ULSLog.LogError(ex);
            }
        }
开发者ID:egil,项目名称:SPADD,代码行数:26,代码来源:FileChangedEventReceiver.cs

示例6: Execute

        private void Execute(SPItemEventProperties properties)
        {
            this.EventFiringEnabled = false;

            try
            {
                BLL.Logger.LogEvent(properties.WebUrl, properties.ListItem.Title + ".OnChange");

                SPListItem item = properties.ListItem;
                SPWeb web = properties.Web;

                Update_LookupRefFields(item);

                Update_FolderInLibrary(item, web);
            }
            catch (Exception ex)
            {
                BLL.Logger.LogEvent(properties.WebUrl, ex.ToString());
                var result = ElasticEmail.EmailGenerator.ReportError(ex, properties.WebUrl.ToString());
            }
            finally
            {
                this.EventFiringEnabled = true;
            }
        }
开发者ID:fraczo,项目名称:Biuromagda,代码行数:25,代码来源:tabKlienciER.cs

示例7: GetSPUser

        private SPUser GetSPUser(SPItemEventProperties properties, string key)
        {
            string rawUserName = Convert.ToString(properties.AfterProperties["AssignedTo"]);

            int separatorIndex = rawUserName.IndexOf(";#");
            string claimsUserName = rawUserName.Substring(separatorIndex + 2);

            SPClaimProviderManager claimsManager = SPClaimProviderManager.Local;

            string userName = null;

            if (claimsManager != null)
            {
                userName = claimsManager.DecodeClaim(claimsUserName).Value;
            }

            return properties.Web.EnsureUser(userName);

            //SPContentType martaTaskCT = properties.Web.ContentTypes["MARTATask"];

            //SPFieldUser field = martaTaskCT.Fields[key] as SPFieldUser;

            //if (field != null)
            //{
            //    SPFieldUserValue fieldValue = field.GetFieldValue(Convert.ToString(properties.AfterProperties["AssignedTo"])) as SPFieldUserValue;
            //    if (fieldValue != null)
            //    {
            //        return fieldValue.User;
            //    }
            //}
            //return null;
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:32,代码来源:TaskAddedReceiver.cs

示例8: Execute

        private void Execute(SPItemEventProperties properties)
        {
            this.EventFiringEnabled = false;

            try
            {
                BLL.Logger.LogEvent(properties.WebUrl, properties.ListItem.Title + ".OnUpdate");

                SPListItem item = properties.ListItem;

                if (item.Title.StartsWith(":"))
                {
                    item["_DISPLAY"] = item.Title;
                }
                else
                {
                    item["_DISPLAY"] = string.Format("{0}::{1}",
                     item["selGrupaProcedury"] != null ? new SPFieldLookupValue(item["selGrupaProcedury"].ToString()).LookupValue : string.Empty,
                     item.Title);
                }

                item.SystemUpdate();

            }
            catch (Exception ex)
            {
                BLL.Logger.LogEvent(properties.WebUrl, ex.ToString());
                var result = ElasticEmail.EmailGenerator.ReportError(ex, properties.WebUrl.ToString());
            }
            finally
            {
                this.EventFiringEnabled = true;
            }
        }
开发者ID:fraczo,项目名称:Animus,代码行数:34,代码来源:tabProceduryER.cs

示例9: ItemAdded

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            SPWeb spWeb = properties.Web;
            SPPushNotificationSubscriberCollection pushSubscribers = spWeb.PushNotificationSubscribers;
            PushNotification pushNotification = new PushNotification();

            SPListItem listItem = properties.ListItem;

            string jobAssignment = "[Unassigned]";

            // This event receiver is intended to be associated with a specific list,
            // but the list may not have an "AssignedTo" field, so using try/catch here.
            try
            {
                jobAssignment = listItem["AssignedTo"].ToString();
            }
            catch { }

            PushNotificationResponse pushResponse = null;

            foreach (SPPushNotificationSubscriber ps in pushSubscribers)
            {
                // Send a toast notification to be displayed on subscribed phones on which the app is not running.
                pushResponse = pushNotification.PushToast(ps, "New job for:", jobAssignment, string.Empty, ToastIntervalValuesEnum.ImmediateToast);
                UpdateNotificationResultsList(spWeb, ps.User.Name, pushResponse);

                // Also send a raw notification to be displayed on subscribed phones on which the app is running when the item is added.
                pushResponse = pushNotification.PushRaw(ps, string.Format("New job for: {0}", jobAssignment), RawIntervalValuesEnum.ImmediateRaw);
                UpdateNotificationResultsList(spWeb, ps.User.Name, pushResponse);
            }

            base.ItemAdded(properties);
        }
开发者ID:zohaib01khan,项目名称:Sharepoint-training-for-Learning,代码行数:36,代码来源:ListItemEventReceiver.cs

示例10: ItemUpdating

 public override void ItemUpdating(SPItemEventProperties properties) {
   string title = properties.AfterProperties["Title"].ToString();
   if (title.ToLower().Contains("lobster") || title.ToLower().Contains("clam")) {
     properties.Status = SPEventReceiverStatus.CancelWithError;
     properties.ErrorMessage = "Do not use inflamitory terms such as 'lobster' or'clam'.";
   }
 }
开发者ID:modulexcite,项目名称:TrainingContent,代码行数:7,代码来源:AnnouncementsListEventReceiver.cs

示例11: ItemUpdated

        /// <summary>
        /// Asynchronous After event that occurs after an existing item is changed, for example, when the user changes data in one or more fields.
        /// </summary>
        /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPItemEventProperties" /> object that represents properties of the event handler.</param>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);

            using (var childScope = NavigationContainerProxy.BeginWebLifetimeScope(properties.Web))
            {
                this.EventFiringEnabled = false;
                var logger = childScope.Resolve<ILogger>();

                try
                {
                    var navigationTermService = childScope.Resolve<INavigationTermBuilderService>();
                    var variationHelper = childScope.Resolve<IVariationHelper>();

                    var item = properties.ListItem;

                    // If the content is created at the source label, sync the term
                    if (variationHelper.IsCurrentWebSourceLabel(item.Web))
                    {
                        // Create term in other term sets
                        navigationTermService.SyncNavigationTerm(properties.ListItem);
                    }
                }
                catch (Exception e)
                {
                    logger.Exception(e);
                }
                finally
                {
                    this.EventFiringEnabled = true;
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:Dynamite-Components,代码行数:37,代码来源:TargetContentItemEvents.cs

示例12: ItemUpdated

        public override void ItemUpdated(SPItemEventProperties properties)
        {
            SPListItem item1 = properties.ListItem;
            var delemans = item1["Delegates"].AsString();
            if (delemans.AsString().IsNullOrWhitespace())
            {
                return;
            }
            char[] split = { '#' };
            string[] deles = delemans.Split(split);
            List<SPPrincipal> principals = new List<SPPrincipal>();
            for (int i = 0; i < deles.Length; i++)
            {
                if (deles[i].IsNullOrWhitespace())
                {
                    continue;
                }
                principals.Add(item1.Web.Users[deles[i]]);
            }

            if (principals.Count > 0)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate
                {
                    using (SPSite site = new SPSite(properties.SiteId))
                    {
                        using (SPWeb web = site.OpenWeb("WorkFlowCenter"))
                        {
                            try
                            {
                                SPListItem item = web.Lists["Travel Request Workflow2"].GetItemById(item1.ID);
                                if (!item.HasUniqueRoleAssignments)
                                {
                                    item.BreakRoleInheritance(true);
                                }

                                SPRoleDefinition AdminRoleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
                                SPRoleDefinition GuestRoleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Guest);
                                foreach (SPPrincipal principal in principals)
                                {
                                    SPRoleAssignment RoleAssignment = new SPRoleAssignment(principal);
                                    RoleAssignment.RoleDefinitionBindings.Add(AdminRoleDefinition);
                                    RoleAssignment.RoleDefinitionBindings.Remove(GuestRoleDefinition);
                                    item.RoleAssignments.Remove(principal);
                                    item.RoleAssignments.Add(RoleAssignment);
                                }
                                item["Delegates"] = string.Empty;
                                base.DisableEventFiring();
                                item.Update();
                                base.EnableEventFiring();
                            }
                            catch (Exception ex)
                            {
                                //TO-DO
                            }
                        }
                    }
                });
            }
        }
开发者ID:porter1130,项目名称:C-A,代码行数:60,代码来源:TravelRequestHandlerReceiver.cs

示例13: ItemUpdated

        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
            SPListItem listItem = properties.ListItem;

            HandleSecurityRules(listItem, properties.EventType);
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:7,代码来源:SecurityEventReciever.cs

示例14: checkItem

 bool checkItem(SPItemEventProperties properties)
 {
     string jobTitle = properties.AfterProperties["Title"].ToString();
        bool allowed = false;
        SPWeb jobDefWeb = null;
        SPList jobDefList;
        SPUser privilegedAccount = properties.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
        SPUserToken privilegedToken = privilegedAccount.UserToken;
        try
        {
        using (SPSite elevatedSite = new SPSite(properties.Web.Url, privilegedToken))
        {
            using (SPWeb elevatedWeb = elevatedSite.OpenWeb())
            {
                jobDefWeb = elevatedWeb.Webs["JobDefinitions"];
                jobDefList = jobDefWeb.Lists["Job Definitions"];
                foreach (SPListItem item in jobDefList.Items)
                {
                    if (item["Title"].ToString() == jobTitle)
                    {
                        allowed = true;
                        break;
                    }
                }
            }
        }
        return (allowed);
        }
        finally
        {
        jobDefWeb.Dispose();
        }
 }
开发者ID:vijaymca,项目名称:SharePoint,代码行数:33,代码来源:EventReceiver1.cs

示例15: GetKeyPeopleForAgenda

        public static SPFieldUserValueCollection GetKeyPeopleForAgenda(string agendaType, string agmOffice, SPItemEventProperties eventProperties)
        {
            string masterKeyPeopleListName = null;
            //SPFolder defaultDocuments =rootWeb.RootWeb.Folders["Default Documents"];
            SPWebApplication webApplication = eventProperties.Web.Site.WebApplication;
            if (webApplication.Properties != null && webApplication.Properties.Count > 0)
            {
                masterKeyPeopleListName = webApplication.Properties["MasterKeyPeopleListName"].ToString();
            }

            SPList list = eventProperties.Web.Lists[masterKeyPeopleListName];

            SPFieldUserValueCollection authUsers = new SPFieldUserValueCollection();

            if (list != null)
            {
                foreach (SPListItem item in list.Items)
                {
                    if ((item["Agenda Type"].ToString() == agendaType) && (item["AGM Office"].ToString() == agmOffice) && (item["Position"].ToString() == "Agenda Coordinator"))
                    {
                        string authUsersFieldValue = item["KeyPerson"].ToString();

                        authUsers.Add(new SPFieldUserValue(item.Web, authUsersFieldValue));
                        //break;
                    }
                }
                return authUsers;
            }
            else
                return null;
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:31,代码来源:AgendaStatus.cs


注:本文中的SPItemEventProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。