예제 #1
0
 public MainForm()
 {
     _presenter  = new ChangeTracker(this);
     _mySettings = new MySettings();
     InitializeComponent();
     InitFormView();
     CreateStatusBar();
 }
예제 #2
0
 public MainForm()
 {
     _presenter = new ChangeTracker(this);
     _mySettings = new MySettings();
     InitializeComponent();
     InitFormView();
     CreateStatusBar();
 }
예제 #3
0
        public void ScanWorker()
        {
            MySettings settings = new MySettings();
            _shouldStopScan = false;
            List<string> availableTables = new List<string>();

            _view.Status("Scanner: Getting all tables list");
            _view.Log("===================================================================");
            using (var command = new SqlCommand(settings.GetAllTablesSql, _sqlConnection))
            {
                try
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (_shouldStopScan)
                            {
                                SetScanIsCanceled();
                                return;
                            }
                            availableTables.Add(reader[0].ToString());
                        }
                    }
                }
                catch(Exception e)
                {
                    _view.LogError("Get All tables execution failed");
                    _view.LogError("QUERY: " + settings.GetAllTablesSql);
                    _view.LogError(e.Message);
                }
            }

            _view.InitProgress(availableTables.Count);

            using (var command = new SqlCommand())
            {
                command.Connection = _sqlConnection;
                foreach (var table in availableTables)
                {
                    if (_shouldStopScan )
                    {
                        SetScanIsCanceled();
                        return;
                    }
                    _view.Status("Scanning: " + table);
                    _view.PerformStep();
                    command.CommandText = String.Format(settings.GetCheckSumSql, table);
                    Int32? checksum = 0;
                    try
                    {
                        checksum = command.ExecuteScalar() as Int32?;
                    }
                    catch (Exception e)
                    {

                        _view.LogError(e.Message + " TABLE " + table);
                        _view.LogError("QUERY: " + settings.GetCheckSumSql);
                        continue;
                    }

                    bool printchanged = false;

                    if (!_lastTables.ContainsKey(table))
                    {
                        _lastTables[table] = 0;
                    }

                    if (_lastTables[table] != checksum)
                    {
                        printchanged = true;
                        _lastTables[table] = checksum;
                    }

                    if (printchanged)
                    {
                        _view.Log(table);
                    }

                }
                IsScanInProgress = false;
                _view.Status("Ready");
                _view.UpdateScanIsStopped();
            }
        }
예제 #4
0
        public void ScanWorker()
        {
            MySettings settings = new MySettings();

            _shouldStopScan = false;
            List <string> availableTables = new List <string>();

            _view.Status("Scanner: Getting all tables list");
            _view.Log("===================================================================");
            using (var command = new SqlCommand(settings.GetAllTablesSql, _sqlConnection))
            {
                try
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (_shouldStopScan)
                            {
                                SetScanIsCanceled();
                                return;
                            }
                            availableTables.Add(reader[0].ToString());
                        }
                    }
                }
                catch (Exception e)
                {
                    _view.LogError("Get All tables execution failed");
                    _view.LogError("QUERY: " + settings.GetAllTablesSql);
                    _view.LogError(e.Message);
                }
            }

            _view.InitProgress(availableTables.Count);


            using (var command = new SqlCommand())
            {
                command.Connection = _sqlConnection;
                foreach (var table in availableTables)
                {
                    if (_shouldStopScan)
                    {
                        SetScanIsCanceled();
                        return;
                    }
                    _view.Status("Scanning: " + table);
                    _view.PerformStep();
                    command.CommandText = String.Format(settings.GetCheckSumSql, table);
                    Int32?checksum = 0;
                    try
                    {
                        checksum = command.ExecuteScalar() as Int32?;
                    }
                    catch (Exception e)
                    {
                        _view.LogError(e.Message + " TABLE " + table);
                        _view.LogError("QUERY: " + settings.GetCheckSumSql);
                        continue;
                    }


                    bool printchanged = false;


                    if (!_lastTables.ContainsKey(table))
                    {
                        _lastTables[table] = 0;
                    }

                    if (_lastTables[table] != checksum)
                    {
                        printchanged       = true;
                        _lastTables[table] = checksum;
                    }

                    if (printchanged)
                    {
                        _view.Log(table);
                    }
                }
                IsScanInProgress = false;
                _view.Status("Ready");
                _view.UpdateScanIsStopped();
            }
        }