Пример #1
0
        public CreateMinorVersionViewModel(DatabaseDisplayData DatabaseDisplayData)
        {
            if (DatabaseDisplayData == null)
            {
                throw new System.ArgumentNullException("DatabaseDisplayData", "DatabaseDisplayData == null");
            }
            this.DatabaseDisplayData = DatabaseDisplayData;

            this.CreateMinorVersionViewModelCtor();
        }
        public ImportWindowViewModel(IProcessManager processManager, DatabaseDisplayData SelectedDatabase)
        {
            if (processManager == null)
            {
                throw new System.ArgumentNullException("processManager", "processManager == null");
            }
            this.processManager = processManager;

            if (SelectedDatabase == null)
            {
                throw new System.ArgumentNullException("SelectedDatabase", "SelectedDatabase == null");
            }
            this.SelectedDatabase = SelectedDatabase;

            this.ImportWindowViewModelCtor();
        }
        /// <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");
            }
        }