将我的新Sharepoint Online Office 365的服务器端事件接收方转换为远程事件接收方 [英] Convert my Server side event reciever to remote event reciever for my new sharepoint online office 365

查看:52
本文介绍了将我的新Sharepoint Online Office 365的服务器端事件接收方转换为远程事件接收方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常在内部使用sharepoint 2013,当我使用企业Wiki网站集时,我编写以下服务器端事件接收器,该接收器主要更新友好的URL术语以匹配更新的Wiki页面名称.如我创建的defualt 如果新的维基页面名为"test 123",则其友好网址将为"test-123".但是如果我将Wiki页面名称修改为例如等于测试123更新名称",则此新名称将不会反映在友好的url中 学期.因此,当我在内部部署时,我会写以下ItemUpdated事件接收者:-

I usually work with sharepoint on-premises 2013, and when i work with enterprise wiki site collection, i write the following server side event receiver, which mainly update the friendly URL term to match the updated wiki page name. as by defualt if i create a new wiki page named "test 123", then its friendly url will be "test-123". but if i modify the wiki page name for example to be equal to "test 123 updated name".. then this new name will not be reflected inside the friendly url term. so when i am inside on-premises i write the following ItemUpdated event reciever :-

public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
//code goes here
// main code is
 SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite site = new SPSite(properties.SiteId))
                        {
                            string currenweburl = properties.RelativeWebUrl;
                            using (SPWeb spCurrentSite = site.OpenWeb(currenweburl))
                            {

                                Term currenttermset = null;
                                TaxonomySession txSession = new TaxonomySession(site);
                                TermStore tc = txSession.TermStores[termstorename.Trim()];
                                Group g = tc.Groups[groupname.Trim()];
                                TermSet ts = g.TermSets[termsetname.Trim()];
                                foreach (Term t56 in ts.Terms)
                                {
                                    string targetPageURL = "";
                                    if (t56.LocalCustomProperties.Keys.Contains("_Sys_Nav_TargetUrl"))
                                    {
                                        targetPageURL = t56.LocalCustomProperties["_Sys_Nav_TargetUrl"];//.Replace("%5B", "[");
                                    }
                                    // string targetPageURL = t56.LocalCustomProperties["_Sys_Nav_TargetUrl"];//.Replace("%5B", "[");
                                    //  targetPageURL = targetPageURL.Replace("%5D", "]");
                                    if (targetPageURL.ToString().ToLower().Trim().Contains(properties.ListItem.Name.ToLower().Trim()))
                                    {
                                        currenttermset = t56;
                                        break;
                                    }
                                }
                                if (currenttermset != null && currenttermset.Id != null)
                                {
                                    string modifieddisplayname = properties.ListItem.DisplayName.Replace(";", "");// since the ; is the only charecters which is allowed inside the Name but not insdie the term. so if the name contain ; an eror will be raised when i try to add the term
                                    modifieddisplayname = System.Text.RegularExpressions.Regex.Replace(modifieddisplayname, @"\s+", " ");//i did so since if the name contain two white spaces or more it will be added as single white space inside the term
                                    string modifeidtemr = System.Text.RegularExpressions.Regex.Replace(currenttermset.Name, @"\s+", " ");
                                    if (!String.IsNullOrEmpty(properties.ListItem["Title"].ToString())
                                        && (modifeidtemr.Trim() != modifieddisplayname.Trim()))
                                    {
                                        string modifieddisplayname2 = properties.ListItem.DisplayName.Replace(";", "");
                                        currenttermset.Name = modifieddisplayname2;

                                        tc.CommitAll();
                                        SPListItem newlogentry = xlogs.AddItem();
                                        newlogentry["Title"] = "Term= " + modifieddisplayname2;
                                        newlogentry.Update();



                                    }

                                }
                            }
                        }
                    });


一切都会顺利进行.但现在我正在研究一个新的Office 365网站集.所以我不确定如何将上面的代码转换为远程事件接收器内部?现在我们的客户正在使用" Office 365 Business Essentials "执照.


and things will be working well. but now i am working on a new office 365 site collection. so i am not sure how i can convert the above code to be inside remote event receiver?  now our customer is using the "Office 365 Business Essentials" license.

推荐答案

要将上面的代码转换为远程事件接收器内部,请结合使用CSOM和C#来实现.

To convert the above code to be inside remote event receiver, please use CSOM with C# to achieve it.

以下文章供您参考:

SharePoint中的托管元数据和导航

https://dev.office.com/sharepoint /docs/general-development/managed-metadata-and-navigation-in-sharepoint

SharePoint Online中的远程事件接收器(RER)

https://www.codeproject.com/Articles/1043978 /Remote-Event-Receivers-RER-in-SharePoint-在线

最好的问候,

Dennis

这篇关于将我的新Sharepoint Online Office 365的服务器端事件接收方转换为远程事件接收方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆