Beispiel #1
0
        private void SaveFile()
        {
            _fileActionProgBar.Visible = true;
            var amt     = _sqlItems.Count;
            var current = 0;

            this._dataContext.Connection.Open();

            foreach (var item in _sqlItems.ToList())
            {
                _fileActionProgBar.Window.ProcessUpdates(true);

                while (Application.EventsPending())
                {
                    Application.RunIteration(true);
                }

                current++;
                Console.WriteLine(_fileActionProgBar.Fraction);

                SQLiteCommand sql = null;

                if (item.IsAdding)
                {
                    sql = item.SqlAdd;
                }
                else if (item.IsDeleting)
                {
                    sql = item.SqlDelete;
                }
                else if (item.IsModifying)
                {
                    sql = item.SqlModify;
                }

                if (sql != null)
                {
                    sql.Connection = this._dataContext.Connection;
                    sql.ExecuteNonQuery();
                }

                _sqlItems.Remove(item);
                _fileActionProgBar.Fraction = (float)current / amt;
            }

            _fileActionProgBar.Fraction = 1;
            _fileActionProgBar.Visible  = false;
            _fileActionProgBar.Fraction = 0;

            this._dataContext.Connection.Close();
            RefreshData();
        }