Exemple #1
0
        /// <summary>
        /// Removes the ItemAdded ReR from the list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnScenario4_Click(object sender, EventArgs e)
        {
            var spContext      = SharePointContextProvider.Current.GetSharePointContext(Context);
            var _sampleLibrary = this.GetLibaryInformationItemAdded();

            using (var ctx = spContext.CreateUserClientContextForSPHost())
            {
                try
                {
                    if (ctx.Web.ListExists(_sampleLibrary.Title))
                    {
                        List _list = ctx.Web.Lists.GetByTitle(_sampleLibrary.Title);
                        ReceiverHelper.RemoveEventReceiver(ctx, _list, ScenarioHandler.AUTOTAGGING_ITEM_ADDED_RERNAME);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Used to create a library & Rer for ItemAdded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnScenario2_Click(object sender, EventArgs e)
        {
            var _libraryToCreate = this.GetLibaryInformationItemAdded();

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var ctx = spContext.CreateUserClientContextForSPHost())
            {
                try
                {
                    if (!ctx.Web.ListExists(_libraryToCreate.Title))
                    {
                        ScenarioHandler _scenario = new ScenarioHandler();
                        _scenario.CreateContosoDocumentLibrary(ctx, _libraryToCreate);
                    }
                    List _list = ctx.Web.Lists.GetByTitle(_libraryToCreate.Title);
                    EventReceiverDefinitionCreationInformation _rec = ReceiverHelper.CreateEventReciever(ScenarioHandler.AUTOTAGGING_ITEM_ADDED_RERNAME, EventReceiverType.ItemAdded);
                    ReceiverHelper.AddEventReceiver(ctx, _list, _rec);
                }
                catch (Exception)
                {
                }
            }
        }