Esempio n. 1
0
        public void CommitTransaction()
        {
            var operationId = Guid.Empty;

            try
            {
                operationId = _diagnosticListener.WriteDbSessionCommitBefore(this);
                #region Impl
                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    _logger.LogDebug("CommitTransaction.");
                }
                if (Transaction == null)
                {
                    if (_logger.IsEnabled(LogLevel.Error))
                    {
                        _logger.LogError("Before CommitTransaction,Please BeginTransaction first!");
                    }
                    throw new SmartSqlException("Before CommitTransaction,Please BeginTransaction first!");
                }
                Transaction.Commit();
                ReleaseTransaction();
                Committed?.Invoke(this, DbSessionEventArgs.None);
                #endregion
                _diagnosticListener.WriteDbSessionCommitAfter(operationId, this);
            }
            catch (Exception ex)
            {
                _diagnosticListener.WriteDbSessionCommitError(operationId, this, ex);
                throw;
            }
        }
Esempio n. 2
0
        public void Commit()
        {
            if (!IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            var completionSet = SelectedCompletionSet;
            var completion    = completionSet?.SelectionStatus.Completion;

            if (completion != null)
            {
                Debug.Assert(completionSet.SelectionStatus.IsSelected);
                if (completion is ICustomCommit customCommit)
                {
                    customCommit.Commit();
                }
                else
                {
                    var insertionText = completion.InsertionText;
                    if (insertionText != null)
                    {
                        var replaceSpan = completionSet.ApplicableTo;
                        var buffer      = replaceSpan.TextBuffer;
                        var span        = replaceSpan.GetSpan(buffer.CurrentSnapshot);
                        buffer.Replace(span.Span, insertionText);
                    }
                }
            }
            Committed?.Invoke(this, EventArgs.Empty);
            Dismiss();
        }
Esempio n. 3
0
        private void OnCommit()
        {
            hotSpot.Text = Text.Trim();

            Committed?.Invoke(this, EventArgs.Empty);

            Visible = false;
        }
Esempio n. 4
0
 protected virtual void OnCommitted()
 {
     if (Committed == null)
     {
         return;
     }
     Committed.Invoke(this, new EventArgs());
 }
Esempio n. 5
0
        /// <summary>
        ///     Asynchronously commits all changes made in this unit of work context to the database.
        /// </summary>
        /// <param name="cancellationToken">
        ///     The token that propagates a cancellation request to interrupt the operation.
        /// </param>
        /// <returns>
        ///     A task that represents the asynchronous commit operation.
        ///     The task result contains the number of affected entries in the database.
        /// </returns>
        /// <exception cref="DbUpdateException">Thrown when an error is encountered while saving to the database.</exception>
        /// <exception cref="DbUpdateConcurrencyException">Thrown when a concurrency violation is encountered while saving to the database.</exception>
        public virtual async Task <int> CommitAsync(CancellationToken cancellationToken = default)
        {
            Committing?.Invoke(this, new UnitOfWorkCommittingEventArgs(_registeredRepositories));

            var affectedEntries = await Context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);

            Committed?.Invoke(this, new UnitOfWorkCommittedEventArgs(affectedEntries, _registeredRepositories));

            return(affectedEntries);
        }
Esempio n. 6
0
        /// <summary>
        ///     Commits all changes made in this unit of work context to the database.
        /// </summary>
        /// <returns>The number of affected entries in the database.</returns>
        /// <exception cref="DbUpdateException">Thrown when an error is encountered while saving to the database.</exception>
        /// <exception cref="DbUpdateConcurrencyException">Thrown when a concurrency violation is encountered while saving to the database.</exception>
        public virtual int Commit()
        {
            Committing?.Invoke(this, new UnitOfWorkCommittingEventArgs(_registeredRepositories));

            var affectedEntries = Context.SaveChanges();

            Committed?.Invoke(this, new UnitOfWorkCommittedEventArgs(affectedEntries, _registeredRepositories));

            return(affectedEntries);
        }
Esempio n. 7
0
        public void Dispose()
        {
            if (_isCommitted)
            {
                throw new Exception("UnitOfWork was already disposed earlier.");
            }

            Committed?.Invoke(this, EventArgs.Empty);
            _isCommitted = true;
        }
        public async Task Commit(CompletionItem item = null)
        {
            if (item == null)
            {
                item = CompletionListControl.Items[CompletionListControl.SelectedIndex].item;
            }

            Committed?.Invoke(this, new CompletionCommitEventArgs(item));

            await SetSelectedIndex(-1);
        }
Esempio n. 9
0
        private void OnCommit()
        {
            hotSpot.Text = Text.Trim();

            try
            {
                hotSpot.Node.Update(hotSpot);
            }
            catch (Exception ex)
            {
                Program.Logger.Log(ex);
            }

            Committed?.Invoke(this, EventArgs.Empty);

            Visible = false;
        }
Esempio n. 10
0
 public void Commit()
 {
     if (!IsStarted)
     {
         throw new InvalidOperationException();
     }
     if (IsDismissed)
     {
         throw new InvalidOperationException();
     }
     if (SelectedCompletionSet.SelectionStatus.IsSelected)
     {
         SelectedCompletionSet.Commit();
     }
     Committed?.Invoke(this, EventArgs.Empty);
     Dismiss();
 }
Esempio n. 11
0
        /// <summary>
        /// Commits the current transaction.
        /// </summary>
        public void Commit()
        {
            if (!_isInTransaction)
            {
                throw new InvalidOperationException("The transaction was either already committed or rolled back.");
            }

            _rollbackOnDispose = false;
            _isInTransaction   = false;

            Committing?.Invoke(this, EventArgs.Empty);

            _parentTransaction.Release(_savePoint);

            Committed?.Invoke(this, EventArgs.Empty);
            Finished?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 12
0
        /// <summary>
        /// Commits the current transaction.
        /// </summary>
        public void Commit()
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            if (!_isInTransaction)
            {
                throw new InvalidOperationException("The transaction was either already committed or rolled back.");
            }

            Committing?.Invoke(this, EventArgs.Empty);
            _connection.Commit();
            Committed?.Invoke(this, EventArgs.Empty);

            FinishTransaction();
        }
Esempio n. 13
0
        public void Commit()
        {
            if (SelectedCompletionSet != null)
            {
                Completion selectedCompletion = SelectedCompletionSet.SelectionStatus.Completion;
                if (selectedCompletion != null && selectedCompletion.InsertionText != null)
                {
                    ITrackingSpan applicableTo = SelectedCompletionSet.ApplicableTo;
                    ITextBuffer   buffer       = applicableTo.TextBuffer;
                    ITextSnapshot snapshot     = buffer.CurrentSnapshot;
                    SnapshotSpan  replaceSpan  = applicableTo.GetSpan(snapshot);

                    buffer.Replace(replaceSpan.Span, selectedCompletion.InsertionText);
                    TextView.Caret.EnsureVisible();
                }
            }

            Committed?.Invoke(this, EventArgs.Empty);
            Dismiss();
        }
Esempio n. 14
0
        /// <summary>
        ///     Completes the unit of work.
        /// </summary>
        /// <remarks>
        ///     By default, if the subject of the unit of work implements <see cref="IDisposable" />, then it will disposed when the root unit of work is disposed.
        /// </remarks>
        public void Dispose()
        {
            var subject = Subject;

            if (!canCommit && subject != null)
            {
                RejectAll();
            }

            if (isOutermost)
            {
                if (!rejected && subject != null)
                {
                    try
                    {
                        commit(this);

                        // check again that Commit did not fail in a way that requires rejection
                        if (!rejected)
                        {
                            Committed?.Invoke(this, subject);
                        }
                        else
                        {
                            RejectAll();
                        }
                    }
                    catch (Exception ex)
                    {
                        RejectDueTo(ex);
                        RejectAll();
                    }
                }
                SetInContext(null);

                disposables.Dispose();
                resources.Clear();
            }

            disposed = true;
        }
 protected virtual void OnCommitted(SvnCommittedEventArgs e)
 {
     Committed?.Invoke(this, e);
 }
Esempio n. 16
0
 private void Commit(string credential)
 => Committed?.Invoke(credential);
Esempio n. 17
0
 public void Commit()
 {
     raw.Commit();
     Committed?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 18
0
 private void OnCommitted(CommitResult commitResult)
 => Committed?.Invoke(this, new CommitResultEventArgs(commitResult));