Ejemplo n.º 1
0
        private void MergeDatabaseView()
        {
            var newList = _databases.Select(
                db => new DatabaseReference()
            {
                Name    = db,
                Caption = Connection.PowerBIFileName.Length > 0 ? Connection.PowerBIFileName : db
            }).OrderBy(db => db.Name);

            // remove deleted databases
            for (int i = _databasesView.Count - 1; i >= 0; i--)
            {
                var found = newList.Where(db => db.Name == _databasesView[i].Name).Any();
                if (!found)
                {
                    _databasesView.RemoveAt(i);
                }
            }

            // add new databases
            foreach (DatabaseReference dbRef in newList)
            {
                var found = _databasesView.Where(db => db.Name == dbRef.Name).DefaultIfEmpty();
                if (found != null)
                {
                    _databasesView.Add(dbRef);
                }
            }

            NotifyOfPropertyChange(() => DatabasesView);
            if (SelectedDatabase == null)
            {
                SelectedDatabase = DatabasesView.FirstOrDefault();
            }
        }
Ejemplo n.º 2
0
 private void ActiveDocumentPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "IsQueryRunning")
     {
         NotifyOfPropertyChange(() => CanSelectDatabase);
         NotifyOfPropertyChange(() => CanSelectModel);
     }
     if (e.PropertyName == "SelectedDatabase")
     {
         var selectedDB = DatabasesView.FirstOrDefault(db => db.Name == ActiveDocument.SelectedDatabase);
         if (selectedDB != null)
         {
             SelectedDatabase = selectedDB;
         }
         // TODO - should we log a warning here?
     }
 }