Click here to Skip to main content
15,892,537 members
Articles / Desktop Programming / Windows Forms

SQLite Compare Utility

Rate me:
Please Sign up or sign in to vote.
4.89/5 (68 votes)
21 Feb 2015LGPL35 min read 284.8K   37.2K   131  
Utility for comparing two SQLite database files for both structure and data
using System;
using System.Collections.Generic;
using System.Text;

namespace SQLiteTurbo
{
    /// <summary>
    /// This class is responsible to delete rows from the specified table
    /// </summary>
    public class RowsDeleter : AbstractWorker
    {
        #region Constructor
        public RowsDeleter(TableChanges tchanges, string diff, List<TableChangesRange> rows, bool left)
            : base("RowsDeleter")
        {
            _diff = diff;
            _changes = tchanges;
            _rows = rows;
            _left = left;
        }
        #endregion

        #region Protected Overrided Methods
        protected override void DoWork()
        {
            // Ask the table changes object to do the deletion
            _changes.DeleteRows(_diff, _rows, _left, RowsDeletionHandler);
        }

        protected override bool IsDualProgress
        {
            get
            {
                return false;
            }
        }
        #endregion

        #region Private Methods
        private void RowsDeletionHandler(int rowsDeleted, int totalRows, ref bool cancel)
        {
            cancel = WasCancelled;
            if (totalRows > 0)
            {
                int progress = (int)(100.0 * rowsDeleted / totalRows);
                if (progress > _progress)
                {
                    NotifyPrimaryProgress(false, progress, rowsDeleted.ToString() + "/" + totalRows.ToString() + " deleted", null);
                    _progress = progress;
                }
            }
        }
        #endregion

        #region Private Variables
        private string _diff;
        private int _progress;
        private TableChanges _changes;
        private List<TableChangesRange> _rows;
        private bool _left;
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer
Israel Israel
My name is Liron Levi and I'm developing software for fun & profit for 15 years already.

Comments and Discussions