/// <summary>
        /// The use properties.
        /// </summary>
        /// <param name="properties">
        /// The properties.
        /// </param>
        private void UseProperties(SPItemEventProperties properties)
        {
            UnifiedLoggingServer.LogMedium("---- UseProperties ----");

            if (properties.ListTitle.Contains("Drop Off Library"))
            {
                try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        SPListItem dropOffListItem = properties.ListItem;

                        using (RecordCentreManager rcm = new RecordCentreManager(dropOffListItem, properties.WebUrl))
                        {
                            UnifiedLoggingServer.LogMedium(rcm.ToString());
                            rcm.TraceLog("TraceLog_RCM_");
                        }
                    });
                }
                catch (Exception e)
                {
                    throw new SPException("An error occured while processing the list Feature/ UseProperties.\n" + e.Message, e);
                }
            }
        }
Esempio n. 2
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        /// <summary>
        /// The feature activated.
        /// </summary>
        /// <param name="properties">
        /// The properties.
        /// </param>
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (RecordCentreManager rcm = new RecordCentreManager("http://dev2010/sites/rc/"))
                {
                    UnifiedLoggingServer.LogMedium(rcm.ToString());
                }

                /*if ((properties.Feature.Parent as SPSite) != null)
                 *  using (SPSite spSite = properties.Feature.Parent as SPSite)
                 *  {
                 *      MessageBox.Show(spSite.Url);
                 *  using (SPWeb web2 = site.OpenWeb(properties.Web.ID))
                 *  {
                 *      SPListItem item = web2.Lists.GetList(properties.List.ID, false).GetItemById(properties.ListItemId);
                 *
                 *      Records.BypassLocks(item, delegate(SPListItem newItem)
                 *      {
                 *          newItem["Title"] = "Hello from code";
                 *          newItem.Audit.WriteAuditEvent(SPAuditEventType.Custom, SPAuditEventSource.ObjectModel.ToString(), "<Data>Audit text</Data>");
                 *          newItem.SystemUpdate(false);
                 *      });
                 *
                 *  }
                 * }*/
            });
        }
        /// <summary>
        /// The item updated.
        /// </summary>
        /// <param name="properties">
        /// The properties.
        /// </param>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            // base.ItemUpdated(properties);
            UnifiedLoggingServer.LogMedium("---- ItemUpdated ----");

            if ((callNumber % 2) == 0)
            {
                UnifiedLoggingServer.LogMedium("---- UseProperties Granted " +
                                               (callNumber % 2) + " " + this.EventFiringEnabled);
                this.EventFiringEnabled = false;
                this.UseProperties(properties);
                this.EventFiringEnabled = true;
            }

            callNumber++;
        }