• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SPItemEventProperties类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ItemAdded

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties) {
            base.ItemAdded(properties);

            try {
                string lopnummerStr = properties.Web.Properties["lopnummer"];
                int lopnummer;
                if (int.TryParse(lopnummerStr, out lopnummer)) {
                    string nyttLopnummer = (lopnummer + 1).ToString();
                    string code = properties.Web.Properties["municipalAreaCode"];
                    string letter = properties.Web.Properties["municipalRegionLetter"];
                    string kundnummer = letter + code + "-" + nyttLopnummer;
                    string strAdress = (string)properties.ListItem[new Guid("b5c833ef-df4e-44f3-9ed5-316ed61a59c9")];
                    if (!string.IsNullOrEmpty(strAdress)) {
                        SPFieldLookupValue adress = new SPFieldLookupValue(strAdress);
                        properties.ListItem[new Guid("fa564e0f-0c70-4ab9-b863-0177e6ddd247")] = adress.LookupValue;
                    }
                    else {
                        properties.ListItem[new Guid("fa564e0f-0c70-4ab9-b863-0177e6ddd247")] = kundnummer;
                    }
                    properties.ListItem[new Guid("353eabaa-f0d3-40cc-acc3-4c6b23d3a64f")] = kundnummer;
                    
                    properties.ListItem.Update();
                    properties.Web.Properties["lopnummer"] = nyttLopnummer;
                    properties.Web.Properties.Update();
                }
                WriteLog("Success", EventLogEntryType.Information, 1000);
            }
            catch (Exception ex) {
                WriteLog("Message:\r\n" + ex.Message + "\r\n\r\nStacktrace:\r\n" + ex.StackTrace, EventLogEntryType.Error, 2000);
            }
        }
开发者ID:Jerntorget,项目名称:UPCOR.TillsynKommun,代码行数:34,代码来源:KundkortEventReceiver.cs


示例17: 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);
            this.EventFiringEnabled = false;

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

                try
                {
                    var browserTitleService = childScope.Resolve<IBrowserTitleBuilderService>();

                    // Set slugs
                    browserTitleService.SetBrowserTitle(properties.Web, properties.ListItem);
                }
                catch (Exception e)
                {
                    logger.Exception(e);
                }
                finally
                {
                    this.EventFiringEnabled = true;
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:Dynamite-Components,代码行数:31,代码来源:BrowsableItemEvents.cs


示例18: ItemAdded

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties) {
            base.ItemAdded(properties);

            try {
                _dbg = "butik";
                object oButik = properties.ListItem[new Guid("a209aa87-f7e4-46cf-8865-37ea0002294b")];
                string strButik = oButik as string;

                if (strButik != null) {
                    SPFieldLookupValue butik = new SPFieldLookupValue(strButik);
                    _dbg = "ct";
                    string contenttype = properties.ListItem.ContentType.Name;
                    _dbg = "id";
                    int id = properties.ListItemId;
                    _dbg = "set";
                    properties.ListItem["Title"] = contenttype + " #" + id.ToString() + " - " + butik.LookupValue;
                    _dbg = "klar";
                    properties.ListItem.Update();
                    _dbg = "upd";
                    WriteLog("ItemAdded", EventLogEntryType.Information, 1002);
                }
            }
            catch (Exception ex) {
                WriteLog("Message:\r\n" + ex.Message + "\r\n\r\nStacktrace:\r\n" + ex.StackTrace + "\r\n\r\nDebug:\r\n" + _dbg, EventLogEntryType.Error, 2002);
            }
        }
开发者ID:Jerntorget,项目名称:UPCOR.TillsynKommun,代码行数:29,代码来源:AktiviteterEventReceiver.cs


示例19: AssignDelegation

 private void AssignDelegation(SPItemEventProperties properties, Delegation validDelegation)
 {
     properties.AfterProperties["OriginalAssignee"] = GetSPUserValue(properties, "AssignedTo");
     properties.AfterProperties["AssignedTo"] = ConvertStringToUser(properties, validDelegation.AssignedTo);
     properties.AfterProperties["IsDelegated"] = true;
     properties.AfterProperties["DelegationType"] = validDelegation.DelegationType.ToString();
 }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:7,代码来源:TaskAddedReceiver.cs


示例20: ItemUpdated

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
            this.EventFiringEnabled = false;

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                using (var site = new SPSite(properties.Web.Site.ID))
                {
                    using (var web = site.OpenWeb(properties.Web.ID))
                    {
                        //var list = web.Lists.GetList(properties.ListId, true);
                        //var item = list.GetItemById(properties.ListItemId);
                        //try
                        //{
                        //    SetPermission(web, item);
                        //}
                        //finally
                        //{
                        //    this.EventFiringEnabled = true;
                        //}
                    }

                }
            });
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:29,代码来源:NewsEventReceiver.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SPList类代码示例发布时间:2022-05-24
下一篇:
C# SPIF类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap