public override int SaveChanges(bool acceptAllChangesOnSuccess)
        {
            int rowsAffected;
            var timestamp = _systemClock.UtcNow;

            IDbContextTransaction transaction = null;

            if (Database.CurrentTransaction == null && Database.GetEnlistedTransaction() == null && Transaction.Current == null)
            {
                transaction = Database.BeginTransaction();
            }

            using (transaction)
            {
                rowsAffected = base.SaveChanges(false);

                var changes = ChangeTracker.Entries()
                              .Where(_ => _.ShouldAuditChanges())
                              .Select(entry => CreateChangeEvent(timestamp, entry))
                              .ToList();

                ChangeTracker.AcceptAllChanges();

                ChangeEvents.AddRange(changes);

                rowsAffected += base.SaveChanges(acceptAllChangesOnSuccess);

                transaction?.Commit();
            }

            return(rowsAffected);
        }
        public override async Task <int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
        {
            int result;
            var timestamp = _systemClock.UtcNow;

            IDbContextTransaction transaction = null;

            if (Database.CurrentTransaction == null && Database.GetEnlistedTransaction() == null && Transaction.Current == null)
            {
                transaction = await Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);
            }

            using (transaction)
            {
                result = await base.SaveChangesAsync(false, cancellationToken).ConfigureAwait(false);

                var changes = ChangeTracker.Entries()
                              .Where(_ => _.ShouldAuditChanges())
                              .Select(entry => CreateChangeEvent(timestamp, entry))
                              .ToList();

                ChangeTracker.AcceptAllChanges();

                await ChangeEvents.AddRangeAsync(changes, cancellationToken).ConfigureAwait(false);

                result += await base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken).ConfigureAwait(false);

                transaction?.Commit();
            }

            return(result);
        }
        public IChangeEvents ConvertChangeEvents(string changeLogToken, IObjectList objectList)
        {
            if (objectList == null)
            {
                return(null);
            }

            ChangeEvents result = new ChangeEvents();

            result.LatestChangeLogToken = changeLogToken;

            result.ChangeEventList = new List <IChangeEvent>();
            if (objectList.Objects != null)
            {
                foreach (IObjectData objectData in objectList.Objects)
                {
                    if (objectData == null)
                    {
                        continue;
                    }

                    result.ChangeEventList.Add(ConvertChangeEvent(objectData));
                }
            }

            result.HasMoreItems  = objectList.HasMoreItems;
            result.TotalNumItems = objectList.NumItems;

            return(result);
        }
 private void ListSkins_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ChangeEvents.SkinListIndexChanged(this);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void ComboBoxFormat_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (Global.Skins.SkinList.Count > 0)
         {
             ChangeEvents.SkinFormatChanged(this);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void TextBoxName_LostFocus(object sender, EventArgs e)
 {
     try
     {
         if (Global.Skins.SkinList.Count > 0)
         {
             ChangeEvents.SkinNameChanged(this);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public RegisterPropertyChangeAttribute(ChangeEvents ChangeEvents)
 {
     this.ChangeEvents = ChangeEvents;
 }