コード例 #1
0
        private void MapItem(List <ExtendedItem> items)
        {
            var item = items.FirstOrDefault(i => i.ItemType == ItemType.Folder);

            if (_currentWorkspace == null || item == null)
            {
                return;
            }
            using (Xwt.SelectFolderDialog folderSelect = new Xwt.SelectFolderDialog("Browse For Folder"))
            {
                folderSelect.Multiselect      = false;
                folderSelect.CanCreateFolders = true;
                if (folderSelect.Run())
                {
                    _currentWorkspace.Map(item.ServerPath, folderSelect.Folder);
                }
                RefreshList(items);
            }
        }
コード例 #2
0
		private void Deploy()
		{
			var collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);

			const string workspaceName = "MyWorkspace";

			Workspace[] workspaces = vcs.QueryWorkspaces(workspaceName, vcs.AuthorizedUser, Workstation.Current.Name);
			foreach (var workspace in workspaces)
			{
				foreach (var workingFolder in workspace.Folders)
				{
					if (Directory.Exists(workingFolder.LocalItem))
					{
						var files = Directory.GetFiles(workingFolder.LocalItem, "*.*", SearchOption.AllDirectories);
						foreach (var file in files)
							File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);

						Directory.Delete(workingFolder.LocalItem, true);
					}
					workspace.DeleteMapping(workingFolder);
				}
				vcs.DeleteWorkspace(workspace.Name, vcs.AuthorizedUser);
			}

			string projectPath = tp.ServerItem;
			string workingDirectory = ClonedRepoFolder;

			Directory.CreateDirectory(workingDirectory);

			_workspace = vcs.CreateWorkspace(workspaceName, vcs.AuthorizedUser, "Test Workspace");

			try
			{
				_workspace.Map(projectPath, workingDirectory);
				GetRequest request = new GetRequest(new ItemSpec(projectPath, RecursionType.Full), VersionSpec.Latest);
				GetStatus status = _workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);
			}
			catch
			{
				throw;
			}
		}
コード例 #3
0
        private void Deploy()
        {
            TfsTeamProjectCollection collection;

            // if setting "Domen" in config file initialized - it means that test run on the local machine, 
            // otherwise means that test run on the specialized testing machine
            if (string.IsNullOrEmpty(ConfigHelper.Instance.Domen))
                collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.TestCollection));
            else
                collection = new TfsTeamProjectCollection(
                    new Uri(ConfigHelper.Instance.TestCollection),
                    new NetworkCredential(ConfigHelper.Instance.Login, ConfigHelper.Instance.Password, ConfigHelper.Instance.Domen));

            var vcs = collection.GetService<VersionControlServer>();
            TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.TestCollectionProject);

            string workspaceName = "MyWorkspace";
            string projectPath = tp.ServerItem;
            string workingDirectory = ClonedRepoFolder;

            if (Directory.Exists(workingDirectory))
            {
                var files = Directory.GetFiles(workingDirectory, "*.*", SearchOption.AllDirectories);
                foreach (var file in files)
                    File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);

                Directory.Delete(workingDirectory, true);
            }
                
            Directory.CreateDirectory(workingDirectory);

            Workspace[] workspaces = vcs.QueryWorkspaces(workspaceName, vcs.AuthorizedUser, Workstation.Current.Name);
            if (workspaces.Length > 0)
                vcs.DeleteWorkspace(workspaceName, vcs.AuthorizedUser);

            _workspace = vcs.CreateWorkspace(workspaceName, vcs.AuthorizedUser, "Test Workspace");

            try
            {
                _workspace.Map(projectPath, workingDirectory);
                GetRequest request = new GetRequest(new ItemSpec(projectPath, RecursionType.Full), VersionSpec.Latest);
                GetStatus status = _workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite); 
            }
            catch
            {}
            
        }