Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.Write("Enter source account url: ");
            var sourceContextUrl = Console.ReadLine();

            Console.WriteLine("Connecting to {0}", sourceContextUrl);
            var sourceContext = new TfsContext(sourceContextUrl);

            Console.Write("Enter source project name: ");
            var sourceProjectName = Console.ReadLine();

            Console.WriteLine("Querying work items from source project");
            var query = $"SELECT {TfsContext.ID} FROM WorkItems WHERE [System.TeamProject] = '{sourceProjectName}'";
            var items = sourceContext.GetWorkItemsAsync(query).Result;

            Console.WriteLine("Found {0} work items to copy", items.Count);

            Console.Write("Enter destination account url: ");
            var destinationContextUrl = Console.ReadLine();

            Console.WriteLine("Connecting to {0}", destinationContextUrl);
            var destinationContext = new TfsContext(destinationContextUrl);

            Console.Write("Enter destination project name: ");
            var destinationProjectName = Console.ReadLine();

            Console.WriteLine("Copying started");
            destinationContext.CreateWorkItemsAsync(items, destinationProjectName).Wait();
            Console.WriteLine("Copying finished");

            Console.WriteLine("Live long and prosper!");
            Console.WriteLine("Press 'enter' to close");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static bool ChangeMapping(Workspace workspace, TfsContext tfs, WorkingFolder folder)
        {
            if (workspace == null)
            {
                return(false);
            }

            var dlg = new CreateMappingDialog(tfs, workspace, folder.ServerItem, folder.LocalItem)
            {
                Text       = "Change Mapping",
                ServerItem = folder.ServerItem,
                LocalItem  = folder.LocalItem
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string serverItem = dlg.ServerItem;
                string localItem  = dlg.LocalItem;
                if (serverItem.StartsWith("$"))
                {
                    try
                    {
                        workspace.DeleteMapping(folder);
                        workspace.Map(serverItem, localItem);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                return(false);
            }
            return(false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 protected BaseService(IServiceProvider serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     settingsService      = this.serviceProvider.Get <SettingsService>();
     mainLogic            = this.serviceProvider.Get <MainLogic>();
     statusService        = serviceProvider.Get <GlobalStatusService>();
     tfsContext           = this.serviceProvider.Get <TfsContext>();
 }
Ejemplo n.º 4
0
        private void NavigateToUser(string userName)
        {
            TfsContext tfsContext             = TfsContext;
            var        teamFoundationIdentity = tfsContext.IdentityManager.GetIdentity(userName);

            if (teamFoundationIdentity != null && (UserContext == null || UserContext.Identity != teamFoundationIdentity))
            {
                TeamExplorer.NavigateToPage(GuidList.userInfoPage.ToGuid(), UserContext = new UserInfoContext(teamFoundationIdentity));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public BuildDetailManager(TfsContext tfsContext)
        {
            this.tfsContext = tfsContext;
            settingsService = tfsContext.GetService <SettingsService>();
            tfsContext.ConnectionChanged += TfsContextOnConnectionChanged;
            var isEnabled = settingsService.Get(SettingsKeys.LoadBuildInformationsKey, false);

            SetEnabled(isEnabled);
            UpdateContainingBuilds();
        }
 private Task CopySettingsFromCurrentProfileTo(WorkingProfile newProfile)
 {
     return(Task.Run(() =>
     {
         var settingsService = Settings;
         foreach (var workspace in TfsContext.GetWorkspaces())
         {
             settingsService.CopySettings(SelectedProfile, workspace, newProfile, workspace);
         }
     }));
 }
 public WorkspaceSettingsCopyControl(IServiceProvider serviceProvider, Action <WorkspaceSettingsCopyControl, bool> closeAction)
 {
     this.closeAction    = closeAction;
     tfsContext          = serviceProvider.Get <TfsContext>();
     settingsService     = serviceProvider.Get <SettingsService>();
     CopyCommand         = new DelegateCommand <object>(ExecuteCopyMethod, CanCopy);
     CancelCommand       = new DelegateCommand <object>(ExecuteCancelMethod);
     AvailableWorkspaces = new ObservableCollection <Workspace>();
     UpdateAvailableWorkspaces();
     InitializeComponent();
     DataContext = this;
 }
Ejemplo n.º 8
0
        public void OpenQuery()
        {
            var res = TeamControlFactory.ShowDialogQueryPicker(TfsContext.GetTeamProjects(), SelectedQuery, TeamControlFactory.QueryPickerType.PickQuery) as QueryDefinition;

            if (res != null)
            {
                SelectedQuery = res;
                Query         = res.QueryText;
                if (CanRunQuery)
                {
                    DoRunQuery();
                }
            }
        }
Ejemplo n.º 9
0
 public void SaveQueryAs()
 {
     if (SelectedQuery != null)
     {
         TeamControlFactory.ShowDialogSaveQueryAs(SelectedQuery);
     }
     else
     {
         var folder = TfsContext.GetTeamProject().QueryHierarchy.OfType <QueryFolder>().FirstOrDefault() ??
                      TeamControlFactory.ShowDialogQueryPicker(TfsContext.GetTeamProjects(), null, TeamControlFactory.QueryPickerType.PickFolder) as QueryFolder;
         if (folder != null)
         {
             TeamControlFactory.ShowDialogSaveQueryAs(folder, Query, "New Query");
         }
     }
 }
Ejemplo n.º 10
0
        private string PrepareKey(SettingsKey key)
        {
            try
            {
                if (key.IsGlobal)
                {
                    return(key.Key);
                }
                string     profileKey    = "";
                string     workSpaceName = defaultWorkSpaceName;
                string     serverName    = defaultServerName;
                string     teamName      = defaultTeamName;
                TfsContext tfsContext    = serviceContainer.Get <TfsContext>();
                if (tfsContext != null && tfsContext.IsTfsConnected)
                {
                    if (key.IsServerDepending)
                    {
                        serverName = tfsContext.VersionControlServer.ServerGuid.ToString();
                    }
                    if (key.IsTeamProjectDepending)
                    {
                        teamName = tfsContext.TeamProjectCollection.DisplayName;
                    }
                    if (tfsContext.SelectedWorkspace != null && key.IsWorkspaceDepending)
                    {
                        workSpaceName = tfsContext.SelectedWorkspace.Name;
                    }
                    if (!string.IsNullOrEmpty(tfsContext.SelectedGitBranch) && key.IsGitBranchDepending)
                    {
                        workSpaceName += $" ({tfsContext.SelectedGitBranch})";
                    }

                    if (key.IsProfileDepending && tfsContext.SelectedProfile != null && !tfsContext.SelectedProfile.IsDefault)
                    {
                        profileKey = tfsContext.SelectedProfile.Id.ToString();
                    }
                }
                return($"{profileKey}{serverName}{keySeperator}{teamName}{keySeperator}{workSpaceName}{keySeperator}{key.Key}");
            }
            catch (Exception e)
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 11
0
        public CreateMappingDialog(TfsContext tfsContext, Workspace workspace, string defaultDerverDir, string defaultLocalDir)
        {
            try
            {
                InitializeComponent();
                localItemPath.Workspace  = workspace;
                serverItemPath.Workspace = workspace;
                localItemPath.TfsHelper  = tfsContext;
                serverItemPath.TfsHelper = tfsContext;
                serverItemPath.Text      = @"$/";
                localItemPath.Text       = @"C:\";

                string restServer = defaultDerverDir.Split('/').LastOrDefault();
                this.defaultDerverDir = defaultDerverDir;
                this.defaultLocalDir  = Path.GetDirectoryName(defaultLocalDir);
                if (!string.IsNullOrWhiteSpace(restServer))
                {
                    this.defaultDerverDir = this.defaultDerverDir.Replace(restServer, "");
                }


                if (!string.IsNullOrWhiteSpace(this.defaultDerverDir) && this.defaultDerverDir.StartsWith("$"))
                {
                    serverItemPath.Text = this.defaultDerverDir;
                }

                if (!string.IsNullOrWhiteSpace(this.defaultLocalDir))
                {
                    localItemPath.Text = this.defaultLocalDir;
                }
            }
            catch (Exception)
            {
                serverItemPath.Text = @"$/";
                localItemPath.Text  = @"C:\";
            }

            serverItemPath.WorkingFolder  = new WorkingFolder(ServerItem, LocalItem);
            localItemPath.WorkingFolder   = new WorkingFolder(ServerItem, LocalItem);
            serverItemPath.FolderBrowsed += ServerItemPathOnFolderBrowsed;
        }
Ejemplo n.º 12
0
        public static bool CreateNewMapping(Workspace workspace, TfsContext tfs)
        {
            if (workspace == null)
            {
                return(false);
            }
            //var p = listViewDetails.Items.ToEnumerable().Select(item => item.SubItems[1]).OrderBy(item => item.Name);
            string defaultServerDir = workspace.Folders.FindMatchingServerBasePath();
            string defaultLocalDir  = workspace.Folders.FindMatchingLocalBasePath();

            var dlg = new CreateMappingDialog(tfs, workspace, defaultServerDir, defaultLocalDir);

            if (!String.IsNullOrEmpty(defaultLocalDir))
            {
                dlg.LocalItem = Path.GetDirectoryName(defaultLocalDir);
            }
            if (!String.IsNullOrEmpty(defaultServerDir))
            {
                dlg.ServerItem = defaultServerDir;
            }
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string serverItem = dlg.ServerItem;
                string localItem  = dlg.LocalItem;
                if (serverItem.StartsWith("$"))
                {
                    try
                    {
                        workspace.Map(serverItem, localItem);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                return(false);
            }
            return(false);
        }
 public WorkItemsSectionView()
 {
     InitializeComponent();
     tfsContext = CheckoutAndBuild2Package.GetGlobalService <TfsContext>();
     workItemList.ContextMenuOpening += WorkItemListOnContextMenuOpening;
 }
Ejemplo n.º 14
0
 public WorkSpaceSpecificOptionsPageControl()
 {
     InitializeComponent();
     tfsContext = CheckoutAndBuild2Package.GetGlobalService <TfsContext>();
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public TfsIdentityManager(TfsContext context)
 {
     tfsContext = context;
     tfsContext.ConnectionChanged += TfsContextOnConnectionChanged;
     UpdateIdentities();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public WorkItemManager(TfsContext tfsContext)
 {
     this.tfsContext = tfsContext;
 }