Пример #1
0
        /// <summary>
        ///     Synchronous Before event that occurs before an existing item is completely deleted.
        /// </summary>
        /// <param name="properties"></param>
        public override void ItemDeleting(SPItemEventProperties properties)
        {
            try
            {
                // We are sending false here because delete event does not need column information. it is required in Insert and Update event to create SQL statements
                if (Initialize(false, properties))
                {
                    DeleteItem();

                    string tableName = _myWorkReportData.GetTableName(_listItem.ParentList.ID);
                    if (_myWorkReportData.ListReportsWork(tableName))
                    {
                        _myWorkReportData.DeleteWork(_listId, _properties.ListItemId);
                    }
                }
                else
                {
                    properties.Status       = SPEventReceiverStatus.CancelWithError;
                    properties.ErrorMessage = $"Failed to delete item: {properties.BeforeProperties["Title"]}";
                }
            }
            catch (Exception exception)
            {
                properties.Status       = SPEventReceiverStatus.CancelWithError;
                properties.ErrorMessage = exception.Message;
                SPSecurity.RunWithElevatedPrivileges(
                    () => LogEvent(exception, 6003, "EPMLive My Work Reporting Item Deleting"));
            }
            finally
            {
                _myWorkReportData?.Dispose();
            }
        }
Пример #2
0
        // Public Methods (3) 

        /// <summary>
        ///     Asynchronous After event that occurs after a new item has been added to its containing object.
        /// </summary>
        /// <param name="properties"></param>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            try
            {
                if (Initialize(true, properties))
                {
                    InsertItem();
                }

                _myWorkReportData.Dispose();
            }
            catch (Exception exception)
            {
                SPSecurity.RunWithElevatedPrivileges(
                    () => LogEvent(exception, 6001, "EPMLive My Work Reporting Item Added"));
            }
        }