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

C# SPRemoteEventProperties类代码示例

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

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



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

示例1: ProcessEvent

        /// <summary>
        /// Handles events that occur before an action occurs, such as when a user adds or deletes a list item.
        /// </summary>
        /// <param name="properties">Holds information about the remote event.</param>
        /// <returns>Holds information returned from the remote event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();

            switch (properties.EventType)
            {
                case SPRemoteEventType.ItemUpdating:
                    result.ErrorMessage = "You cannot add this list item";
                    result.Status = SPRemoteEventServiceStatus.CancelNoError;
                    break;
                case SPRemoteEventType.ItemAdding:
                    result.ErrorMessage = "You cannot add this list item";
                    result.Status = SPRemoteEventServiceStatus.CancelNoError;
                    break;
            }

            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
            {
                if (clientContext != null)
                {
                    clientContext.Load(clientContext.Web);
                    clientContext.ExecuteQuery();
                }
            }

            return result;
        }
开发者ID:nganbui,项目名称:SP,代码行数:32,代码来源:RERCalendar.svc.cs


示例2: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();
            try
            {
                switch (properties.EventType)
                {
                    case SPRemoteEventType.ItemAdded:                        
                        HandleAutoTaggingItemAdded(properties);
                        break;
                       
                    case SPRemoteEventType.AppInstalled:
                        AppInstalled(properties);
                        break;

                    case SPRemoteEventType.AppUninstalling:
                        AppUninstalling(properties);
                        break;

                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(ex.Message + ex.StackTrace, LogSeverity.Error);
            }

            return result;
        }
开发者ID:stephaneey,项目名称:Eyskens.AutoTaggerGit,代码行数:33,代码来源:AppEventReceiver.svc.cs


示例3: HandleItemUpdated

        private void HandleItemUpdated(SPRemoteEventProperties properties)
        {
            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
            {
                if(clientContext != null)
                {
                    List requestList = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
                    ListItem item = requestList.GetItemById(properties.ItemEventProperties.ListItemId);
                    clientContext.Load(item);
                    clientContext.ExecuteQuery();

                    if (String.Compare(item[SiteRequestFields.State].ToString(), "Approved", true) == 0)
                    {
                        try
                        {
                            string site_title = item[SiteRequestFields.Title].ToString();
                            string site_description = item[SiteRequestFields.Description].ToString();
                            string site_template = item[SiteRequestFields.Template].ToString();
                            string site_url = item[SiteRequestFields.Url].ToString();
                            SharePointUser site_owner = LabHelper.BaseSetUser(clientContext, item, SiteRequestFields.Owner);
                            LabHelper.CreateSiteCollection(clientContext, site_url, site_template, site_title, site_description, site_owner.Email);
                            item[SiteRequestFields.State] = "COMPLETED";
                        }
                        catch(Exception ex)
                        {
                            item[SiteRequestFields.State] = "ERROR";
                            item[SiteRequestFields.StatusMessage] = ex.Message;
                        }
                        item.Update();
                        clientContext.ExecuteQuery();
                    }
                }
            }
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:34,代码来源:AppEventReceiver.svc.cs


示例4: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
            {
                if (clientContext != null)
                {
                    string listTitle = "External Events";
                    string remoteEventReceiverSvcTitle = "ConnectORGRER";
                    string remoteEventReceiverName = "ConnectORGRemoteEvent";
                    clientContext.Load(clientContext.Web);
                    List myList = clientContext.Web.Lists.GetByTitle(listTitle);
                    clientContext.Load(myList);
                    clientContext.ExecuteQuery();

                    if (properties.EventType == SPRemoteEventType.AppInstalled)
                    {
                        string opContext = OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.Substring(0, OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.LastIndexOf("/"));
                        string remoteEventReceiverSvcUrl = string.Format("{0}/{1}.svc", opContext, remoteEventReceiverSvcTitle);
                        RegisterEventReceiver(clientContext, myList, remoteEventReceiverName, remoteEventReceiverSvcUrl, EventReceiverType.ItemUpdated, 15010);
                    }
                    else if (properties.EventType == SPRemoteEventType.AppUninstalling)
                    {
                        UnregisterAllEventReceivers(clientContext, myList, remoteEventReceiverName);
                    }
                }
            }

            return result;

        }
开发者ID:fernandoklst,项目名称:Development,代码行数:37,代码来源:AppEventReceiver.svc.cs


示例5: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult _result = new SPRemoteEventResult();

            try
            {
                switch (properties.EventType)
                {
                    case SPRemoteEventType.AppInstalled:
                        HandleAppInstalled(properties);
                        break;
                    case SPRemoteEventType.AppUninstalling:
                        HandleAppUninstalling(properties);
                        break;
                    case SPRemoteEventType.ItemAdding:
                        new RemoteEventReceiverManager().ItemAddingToListEventHandler(properties, _result);
                        break;
                    case SPRemoteEventType.ItemUpdated:
                        HandleItemUpdated(properties);
                        break;
                }
                _result.Status = SPRemoteEventServiceStatus.Continue;
            }
            catch (Exception ex)
            {
                //You should log here.
            }
            return _result;
        }
开发者ID:RapidCircle,项目名称:O365-DefaultValues,代码行数:34,代码来源:AppEventReceiver.svc.cs


示例6: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            
            SPRemoteEventResult result = new SPRemoteEventResult();

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
            {
                if (clientContext != null)
                {
                    clientContext.Load(clientContext.Site);
                    clientContext.ExecuteQuery();
                    if (properties.EventType == SPRemoteEventType.AppInstalled)
                    {
                        AddJsLink(clientContext, clientContext.Site, BuildScript(), "PTCTopMenu", true );
                    }
                    else if (properties.EventType == SPRemoteEventType.AppUninstalling)
                    {
                        DeleteJsLink(clientContext, clientContext.Site, "PTCTopMenu");
                    }
                    
                }
            }
            result.Status = SPRemoteEventServiceStatus.Continue;

            return result;
        }
开发者ID:dmf07,项目名称:PTC.TopMenu,代码行数:31,代码来源:AppEventReceiver.svc.cs


示例7: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
            {
                if (clientContext != null)
                {
                    clientContext.Load(clientContext.Web);
                    clientContext.ExecuteQuery();

                    switch (properties.EventType)
                    {
                        case SPRemoteEventType.AppInstalled:
                            RemoveQuickLaunchNode(clientContext);
                            AddSiteInformationJsLink(clientContext);
                            result.Status = SPRemoteEventServiceStatus.Continue;
                            break;
                        case SPRemoteEventType.AppUninstalling:
                            RemoveQuickLaunchNode(clientContext);
                            Web web = clientContext.Web;
                            clientContext.Load(web, w => w.UserCustomActions, w => w.Url, w => w.AppInstanceId);
                            clientContext.ExecuteQuery();
                            DeleteExistingActions(clientContext, web);
                            break;
                    }
                }
            }

            return result;
        }
开发者ID:tandis,项目名称:PnP,代码行数:36,代码来源:AppEventReceiver.svc.cs


示例8: RERIsEnabled

 protected Boolean RERIsEnabled(SPRemoteEventProperties properties, ClientContext clientContext)
 {
     //check and execute if RER is enabled on list
     string DbxlRerEnabledProperty = properties.ItemEventProperties.ListId + Constants.KEY_DBXL_PROPERTY_RER_ENABLED;
     Boolean RerEnabled = Convert.ToBoolean(WebUtils.GetAppProperty(DbxlRerEnabledProperty, clientContext));
     return RerEnabled;
 }
开发者ID:rayeckel,项目名称:genreadySP,代码行数:7,代码来源:Dbxl.cs


示例9: AppPartPropertyUIOverrider

 /// <summary>
 /// Initializes a new instance of the <see cref="AppPartPropertyUIOverrider" /> class.
 /// </summary>
 /// <param name="hostWebManager">The host web manager.</param>
 /// <param name="properties">The properties of the app event receiver event.</param>
 /// <param name="jQueryFileName">Filename of jquery-x.x.x.min.js sitting in the ASP.NET (Remote Web) Scripts directory.  Example: "jquery-2.1.0.min.js"</param>
 /// <param name="remoteWebFullUrlOverride">Optional override to the remote web full url detection logic.  Example: "https://acutalurl.contoso.com"</param>
 public AppPartPropertyUIOverrider(HostWebManager hostWebManager, SPRemoteEventProperties properties, string jQueryFileName, string remoteWebFullUrlOverride)
 {
     this.hostWebManagerField = hostWebManager;
     this.propertiesField = properties;
     this.jQueryFileNameField = jQueryFileName;
     this.remoteWebFullUrlOverrideField = remoteWebFullUrlOverride;
 }
开发者ID:NicolajLarsen,项目名称:PnP,代码行数:14,代码来源:AppPartPropertyUIOverrider.cs


示例10: ProcessEvent

        /// <summary>
        ///     Handles events that occur before an action occurs, such as when a user adds or deletes a list item.
        /// </summary>
        /// <param name="properties">Holds information about the remote event.</param>
        /// <returns>Holds information returned from the remote event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            Trace.WriteLine("Processing remote event. " + properties.EventType);

            var result = new SPRemoteEventResult();
            try
            {
                using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
                {
                    if (clientContext != null)
                    {
                        if (properties.EventType == SPRemoteEventType.AppInstalled)
                        {
                            Trace.WriteLine("Creating sharepoints objects.");
                            EnsureObjectsCreated(clientContext);
                            Trace.WriteLine("Sharepoints objects created.");
                        }

                        if (properties.EventType == SPRemoteEventType.AppUninstalling)
                        {
                            Trace.WriteLine("Removing sharepoint objects.");
                            RemoveObjects(clientContext);
                            Trace.WriteLine("Sharepoint objects removed.");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("An error occured during processing remote event: " + e);
                result.ErrorMessage = e.ToString();
            }

            return result;
        }
开发者ID:ricardocarneiro,项目名称:sharepoint-2,代码行数:40,代码来源:RemoteEventReceiver.svc.cs


示例11: ProcessEvent

        /// <summary>
        /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
        /// </summary>
        /// <param name="properties">Holds information about the app event.</param>
        /// <returns>Holds information returned from the app event.</returns>
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();
            switch (properties.EventType)
            {

                case SPRemoteEventType.WebProvisioned:
                    WebProvisionedMethod(properties);
                    break;
                case SPRemoteEventType.AppInstalled:
                    AppInstalledMethod(properties);
                    break;
                case SPRemoteEventType.AppUpgraded:
                    // not implemented
                    break;
                case SPRemoteEventType.AppUninstalling:
                    AppUnistallingMethod(properties);
                    break;
                case SPRemoteEventType.WebAdding:
                    // you can implement webaddding event
                    break;
                case SPRemoteEventType.WebDeleting:
                    //you can implemet web deleting event if needed.
                default:
                    break;
            }

            return result;
        }
开发者ID:DiveshSingh,项目名称:RemoteWebProvisionedEventReciever,代码行数:34,代码来源:AppEventReceiver.svc.cs


示例12: CreateList

        private Guid CreateList(String listTitle, SPRemoteEventProperties properties)
        {
            Guid listID = Guid.Empty;

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
            {
                if (clientContext != null)
                {
                    // SharePoint might be retrying the event after a time-out. It
                    // may have created the list on the last try of this handler, so
                    // check to see if there's already a list with that name.                                
                    List targetList = GetListByTitle(listTitle, clientContext);

                    // If there isn't one, create it.
                    if (targetList == null)
                    {
                        ListCreationInformation listInfo = new ListCreationInformation();
                        listInfo.Title = listTitle;
                        listInfo.TemplateType = (int)ListTemplateType.GenericList;
                        listInfo.Url = listTitle;
                        targetList = clientContext.Web.Lists.Add(listInfo);
                        clientContext.Load(targetList, l => l.Id);
                        clientContext.ExecuteQuery();
                        listID = targetList.Id;
                    }
                }
            }
            return listID;
        }
开发者ID:CherifSy,项目名称:PnP,代码行数:29,代码来源:AppEventReceiver.svc.cs


示例13: ProcessEvent

        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            TraceHelper.RemoteLog("app event triggered: " + properties.EventType.ToString());

            SPRemoteEventResult result = new SPRemoteEventResult();

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
            {
                if (clientContext != null)
                {
                    clientContext.Load(clientContext.Web);
                    clientContext.Load(clientContext.Web.SiteUsers);
                    clientContext.ExecuteQuery();

                    RegisterEventReceivers(clientContext);

                    PlaybasisHelper.Instance.Auth();
                    foreach (var user in clientContext.Web.SiteUsers)
                    {
                        if (string.IsNullOrWhiteSpace(user.Email))
                            continue;
                        PlaybasisHelper.Instance.Register(user, true);
                    }
                }
            }

            return result;
        }
开发者ID:playbasis,项目名称:sdk-sharepoint,代码行数:28,代码来源:AppEventReceiver.svc.cs


示例14: ProcessEvent

  public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties) {

    // create SPRemoteEventResult object to use as return value
    SPRemoteEventResult result = new SPRemoteEventResult();

    // inspect the event type of the current event
    if ((properties.EventType == SPRemoteEventType.ItemAdding) ||
        (properties.EventType == SPRemoteEventType.ItemUpdating)) {

      // get user input to perform validation
      string title = properties.ItemEventProperties.AfterProperties["Title"].ToString();
      string body = properties.ItemEventProperties.AfterProperties["Body"].ToString();

      // perform simple validation on user input
      if (title.ToLower().Contains("lobster") || title.ToLower().Contains("clam") ) {
        // cancel action due to validation error
        result.Status = SPRemoteEventServiceStatus.CancelWithError;
        result.ErrorMessage = "Title cannot contain inflammatory terms such as 'lobster' or 'clam'";
      }

      // Process user input before it's added to the content database
      if (!title.ToUpper().Equals(title)) {
        result.ChangedItemProperties.Add("Title", title.ToUpper());
      }
    }    
    return result; // always return SPRemoteEventResult back to SharePoint host
  }
开发者ID:chrissimusokwe,项目名称:TrainingContent,代码行数:27,代码来源:AnnouncementsEventReceiver.svc.cs


示例15: TryUpdateInventory

        private bool TryUpdateInventory(SPRemoteEventProperties properties)
        {
            bool successFlag = false;

            try
            {
                var arrived = Convert.ToBoolean(properties.ItemEventProperties.AfterProperties["Arrived"]);
                var addedToInventory = Convert.ToBoolean(properties.ItemEventProperties.AfterProperties["Added_x0020_to_x0020_Inventory"]);

                if (arrived && !addedToInventory)
                {

                    using (SqlConnection conn = SQLAzureUtilities.GetActiveSqlConnection())
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        conn.Open();
                        cmd.CommandText = "UpdateInventory";
                        cmd.CommandType = CommandType.StoredProcedure;
                        SqlParameter tenant = cmd.Parameters.Add("@Tenant", SqlDbType.NVarChar);
                        tenant.Value = properties.ItemEventProperties.WebUrl + "/";
                        SqlParameter product = cmd.Parameters.Add("@ItemName", SqlDbType.NVarChar, 50);
                        product.Value = properties.ItemEventProperties.AfterProperties["Title"]; // not "Product"
                        SqlParameter quantity = cmd.Parameters.Add("@Quantity", SqlDbType.SmallInt);
                        quantity.Value = Convert.ToUInt16(properties.ItemEventProperties.AfterProperties["Quantity"]);
                        cmd.ExecuteNonQuery();
                    }
                    successFlag = true;
                }
            }
            catch (KeyNotFoundException)
            {
                successFlag = false;
            }
            return successFlag;
        }
开发者ID:OfficeDev,项目名称:SharePoint_Provider-hosted_Add-ins_Tutorials,代码行数:35,代码来源:RemoteEventReceiver1.svc.cs


示例16: ProcessOneWayEvent

 public void ProcessOneWayEvent(SPRemoteEventProperties properties)
 {
     using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) {
     if (clientContext != null) {
       clientContext.Load(clientContext.Web);
       clientContext.ExecuteQuery();
     }
       }
 }
开发者ID:kimberpjub,项目名称:GSA2013,代码行数:9,代码来源:AnnRemoteEventReceiver.svc.cs


示例17: ProcessOneWayEvent

 /// <summary>
 /// This method is a required placeholder, but is not used by app events.
 /// </summary>
 /// <param name="properties">Unused.</param>
 public void ProcessOneWayEvent(SPRemoteEventProperties properties)
 {
     switch(properties.EventType)
     {
         case SPRemoteEventType.ItemUpdated:
             HandleItemUpdated(properties);
             break;
     }
 }
开发者ID:nitewolfgtr,项目名称:PnP,代码行数:13,代码来源:AppEventReceiver.svc.cs


示例18: ProcessOneWayEvent

 /// <summary>
 /// This method is a required placeholder, but is not used by app events.
 /// </summary>
 /// <param name="properties">Unused.</param>
 public void ProcessOneWayEvent(SPRemoteEventProperties properties)
 {
     //Handles asynchronus events
     switch(properties.EventType)
     {
         case SPRemoteEventType.ListAdded:
             HandleListAdded(properties);
             break;
     }
 }
开发者ID:rahulsuryawanshi,项目名称:HostWebSPRemoteEventReceiver,代码行数:14,代码来源:AppEventReceiver.svc.cs


示例19: AppUnistallingMethod

 /// <summary>
 /// takes care of app uninstalling to remove web provisioned event receiver
 /// </summary>
 /// <param name="_properties"></param>
 private void AppUnistallingMethod(SPRemoteEventProperties _properties)
 {
     using (ClientContext _clientContext = TokenHelper.CreateAppEventClientContext(_properties, false))
     {
         if (_clientContext != null)
         {
             new RemoteEventReceiverManager().RemoveWebProvisionedEventReceiver(_clientContext);
         }
     }
 }
开发者ID:DiveshSingh,项目名称:RemoteWebProvisionedEventReciever,代码行数:14,代码来源:AppEventReceiver.svc.cs


示例20: HandleItemAdding

 private void HandleItemAdding(SPRemoteEventProperties properties)
 {
     using(ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
     {
         if(null != clientContext)
         {
             new RemoteEventReceiverManager().ItemAddingListEventHandler(clientContext, properties.ItemEventProperties.ListId, properties.ItemEventProperties.ListItemId);
         }
     }
 }
开发者ID:rahulsuryawanshi,项目名称:HostWebSPRemoteEventReceiver,代码行数:10,代码来源:AppEventReceiver.svc.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SPSite类代码示例发布时间:2022-05-24
下一篇:
C# SPQuery类代码示例发布时间: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