/// <summary>
 /// Raises the <see cref="E:Error"/> event.
 /// </summary>
 /// <param name="eventArgs">The <see cref="Xtensive.Orm.Reprocessing.ExecuteErrorEventArgs"/> instance containing the event data.</param>
 /// <returns>True if needs to reprocess the task.</returns>
 protected virtual bool OnError(ExecuteErrorEventArgs eventArgs)
 {
     if (Error != null)
     {
         Error(this, eventArgs);
     }
     return(eventArgs.Attempt < Attempts);
 }
        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="eventArgs">The <see cref="Xtensive.Orm.Reprocessing.ExecuteErrorEventArgs"/> instance containing the exception data.</param>
        /// <returns>
        /// True if needs to reprocess the task, otherwise false.
        /// </returns>
        protected override bool HandleException(ExecuteErrorEventArgs eventArgs)
        {
            if (eventArgs.Transaction != null && eventArgs.Transaction.IsNested &&
                eventArgs.Transaction.IsolationLevel == IsolationLevel.Snapshot)
            {
                return(false);
            }
            if (eventArgs.Exception is UniqueConstraintViolationException)
            {
                return(OnError(eventArgs));
            }
            var ex = eventArgs.Exception as StorageException;

            if (ex != null)
            {
                var ex1 = ex.InnerException as SqlException;
                if (ex1 != null && ex1.Number == 2601)
                {
                    return(OnError(eventArgs));
                }
            }
            return(base.HandleException(eventArgs));
        }
Esempio n. 3
0
 /// <summary>
 /// Handles the exception.
 /// </summary>
 /// <param name="eventArgs">The <see cref="Xtensive.Orm.Reprocessing.ExecuteErrorEventArgs"/> instance containing the exception data.</param>
 /// <returns>True if needs to reprocess the task, otherwise false.</returns>
 protected virtual bool HandleException(ExecuteErrorEventArgs eventArgs) => false;
 /// <summary>
 /// Handles the exception.
 /// </summary>
 /// <param name="eventArgs">The <see cref="Xtensive.Orm.Reprocessing.ExecuteErrorEventArgs"/> instance containing the exception data.</param>
 /// <returns>True if needs to reprocess the task, otherwise false.</returns>
 protected virtual bool HandleException(ExecuteErrorEventArgs eventArgs)
 {
     return(false);
 }