Пример #1
0
        /// <summary>
        /// Saves the properties of the database in the settings file.
        /// </summary>
        private void Save()
        {
            var newDatabases = DatabaseSetting.GetDatabaseSettings();

            newDatabases.Single(d => d.Id == this.Id).Name           = this.Database.Name;
            newDatabases.Single(d => d.Id == this.Id).Path           = this.Database.Path;
            newDatabases.Single(d => d.Id == this.Id).IgnoredSchemas = this.Database.IgnoredSchemas.ToList();
            SettingsManager.Get().Setting.DatabaseSettings = newDatabases;
            SettingsManager.Get().Save();
            this.EditMode = false;
        }
Пример #2
0
        partial void AddDatabaseViewModelCtor()
        {
            this.InitializeCommands();

            this.ExecuteInTask(this.SearchDatabaseDirectories, (exec) => this.Loading = exec);

            this.Databases = this.connectionManager.ExecuteCommand <string>(SQLTemplates.GetAllTables());
            this.Databases.Remove(SettingsManager.Get().Setting.Id);

            // remove databases which are already added
            foreach (var db in DatabaseSetting.GetDatabaseSettings())
            {
                this.Databases.Remove(db.Name);
            }

            if (this.Databases.Count == 1)
            {
                this.DatabaseName = this.Databases.Single();
            }
        }
Пример #3
0
        private void CheckData()
        {
            // verify that database exists with a connection
            if (!string.IsNullOrWhiteSpace(this.DatabaseName))
            {
                this.DatabaseExists = this.connectionManager.CheckConnection(this.DatabaseName);
            }

            if (string.IsNullOrWhiteSpace(this.DatabaseName) ||
                string.IsNullOrWhiteSpace(this.DatabasePath) ||
                DatabaseSetting.GetDatabaseSettings().Any(d => d.Name == this.DatabaseName && d.Path == this.DatabasePath) ||
                !this.DatabaseExists)
            {
                this.DataChecked = false;
            }
            else
            {
                this.DataChecked = true;
            }
        }
        /// <summary>
        /// Adds the databases to the list and updates there data.
        /// </summary>
        public void UpdateDatabases()
        {
            lock (this)
            {
                // only update values if databases changed
                if (this.unfilteredDatabases == null ||
                    this.unfilteredDatabases.Count != DatabaseSetting.GetDatabaseSettings().Count)
                {
                    // unregister the old events
                    if (this.unfilteredDatabases != null)
                    {
                        foreach (var database in this.unfilteredDatabases)
                        {
                            database.Removed -= this.DatabaseRemoved;
                        }
                    }

                    this.unfilteredDatabases = new List <DatabaseDisplayData>();
                    foreach (var setting in DatabaseSetting.GetDatabaseSettings())
                    {
                        var databaseDisplayData = new DatabaseDisplayData(this.connectionManager, this.fileSystemAccess, this.processManager, this.differenceCreator, this.sQLFileTester, setting.Id);
                        databaseDisplayData.Removed += this.DatabaseRemoved;
                        this.uiDispatcher.Invoke(() => this.unfilteredDatabases.Add(databaseDisplayData));
                    }

                    var databases = this.unfilteredDatabases.Where(d => string.IsNullOrWhiteSpace(this.FilterText) || d.Database.Name.ToLower().Contains(this.FilterText.ToLower()));
                    this.Databases = new List <DatabaseDisplayData>(databases);
                }

                // update each database in its own task so the slow ones don't
                // delay the others
                foreach (var database in this.unfilteredDatabases)
                {
                    this.ExecuteInTask(() => database.UpdateData());
                }

                Log.Info("Databases successfully updated");
            }
        }