private void CreateNewSession(SessionTypeEnum sessionType) { if (leftSource != null && rightSource != null) { Session session = new Session(); session.SessionUniqueId = Guid.NewGuid().ToString(); session.FriendlyName = string.Format(ModelResources.SessionFriendlyNameString, sessionType); session.LeftMigrationSourceUniqueId = leftSource.InternalUniqueId; session.RightMigrationSourceUniqueId = rightSource.InternalUniqueId; session.SessionType = sessionType; Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell shell = DataContext as Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell; shell.ViewModel.DataModel.Configuration.SessionGroup.Sessions.Session.Add(session); } }
private void providerButton_Click(object sender, RoutedEventArgs e) { MigrationProviderView providerView = providerListBox.SelectedItem as MigrationProviderView; Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell shell = this.DataContext as Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell; if (providerView != null && shell != null) { // TODO: This hack disables the button unless a doc is open if (shell.ViewModel.DataModel != null) { ICollection <ProviderElement> providers = shell.ViewModel.DataModel.Configuration.Providers.Provider; ProviderElement provider = providers.FirstOrDefault(x => string.Equals(x.ReferenceName, providerView.ProviderId, StringComparison.OrdinalIgnoreCase)); if (provider == null) { provider = new ProviderElement(); provider.FriendlyName = providerView.Name; provider.ReferenceName = providerView.ProviderId; providers.Add(provider); shell.ViewModel.DataModel.Configuration.SessionGroup.Linking.CreationTime = DateTime.Now; } // TODO: Hack, look it up by provider id //MigrationSourceCommand command = shell.ViewModel.ExtensibileViewModel.MigrationServerViews[0].Command.Target as MigrationSourceCommand; //bool b = shell.ViewModel.ExtensibileViewModel.MigrationServerViews[0].Command.Target is MigrationSourceCommand; //MigrationSourceView serverView = shell.ViewModel.ExtensibileViewModel.MigrationServerViews.FirstOrDefault(x => string.Equals((x.Command.Target as MigrationSourceCommand).ProviderReferenceName, provider.ReferenceName)); MigrationSourceView serverView = shell.ViewModel.ExtensibileViewModel.MigrationServerViews[0]; MigrationSource migrationSource = new MigrationSource(); serverView.Command(migrationSource); if (migrationSource.InternalUniqueId != null) { shell.ViewModel.DataModel.Configuration.SessionGroup.MigrationSources.MigrationSource.Add(migrationSource); } } } }