Exemple #1
0
        public GettingDialog(VersionControlServer vcs, Workspace workspace, GetRequest[] requests)
            : base("Progress")
        {
            VBox.Spacing = 10;
                VBox.Add(new Label("Getting files from the server..."));

                progressBar = new ProgressBar();
                VBox.Add(progressBar);

                fileLabel = new Label("");
                VBox.Add(fileLabel);

                AddCloseButton("Cancel");
                DefaultResponse = ResponseType.Cancel;

                ShowAll();

                getLatestList.Clear();
                vcs.Getting += MyGettingEventHandler;

                GetStatus status = workspace.Get(requests, GetOptions.GetAll|GetOptions.Overwrite);
                foreach (string file in getLatestList)
                    {
                        Console.WriteLine(file);
                        Pulse("Setting permissions: " + file);
                        if (! FileTypeDatabase.ShouldBeExecutable(file)) continue;
                        FileType.MakeExecutable(file);
                    }
        }
Exemple #2
0
        public bool AddToTFVC(string[] _files, WorkItem _wi, Workspace _ws)
        {
            try
             {
                 _ws.Get();
                 // Now add everything.
                 _ws.PendAdd(_files, false);
                 WorkItemCheckinInfo[] _wici = new WorkItemCheckinInfo[1];

                 _wici[0] = new WorkItemCheckinInfo(_wi, WorkItemCheckinAction.Associate);

                 if (_ws.CheckIn(_ws.GetPendingChanges(), null, null, _wici, null) > 0)
                 {
                     _ws.Delete();
                     return true;

                 }
                 else
                 {
                     return false;
                 }

             }
             catch
             {
                 return false;
             }
        }
 internal static void Open(List <ExtendedItem> items, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
 {
     using (var dialog = new CheckOutDialog())
     {
         dialog.FillStore(items);
         if (dialog.Run(Xwt.Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
         {
             var itemsToCheckOut = dialog.SelectedItems;
             using (var progress = VersionControlService.GetProgressMonitor("Check Out", VersionControlOperationType.Pull))
             {
                 progress.BeginTask("Check Out", itemsToCheckOut.Count);
                 foreach (var item in itemsToCheckOut)
                 {
                     var path = item.IsInWorkspace ? item.LocalItem : workspace.GetLocalPathForServerPath(item.ServerPath);
                     workspace.Get(new GetRequest(item.ServerPath, RecursionType.Full, VersionSpec.Latest), GetOptions.None, progress);
                     progress.Log.WriteLine("Check out item: " + item.ServerPath);
                     var failures = workspace.PendEdit(new List <FilePath> {
                         path
                     }, RecursionType.Full, dialog.LockLevel);
                     if (failures != null && failures.Any())
                     {
                         if (failures.Any(f => f.SeverityType == SeverityType.Error))
                         {
                             foreach (var failure in failures.Where(f => f.SeverityType == SeverityType.Error))
                             {
                                 progress.ReportError(failure.Code, new Exception(failure.Message));
                             }
                             break;
                         }
                         foreach (var failure in failures.Where(f => f.SeverityType == SeverityType.Warning))
                         {
                             progress.ReportWarning(failure.Message);
                         }
                     }
                 }
                 progress.EndTask();
                 progress.ReportSuccess("Finish Check Out.");
             }
         }
     }
 }
        private void GetLatestVersion(List <ExtendedItem> items)
        {
            List <GetRequest> requests = new List <GetRequest>();

            foreach (var item in items)
            {
                RecursionType recursion = item.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full;
                requests.Add(new GetRequest(item.ServerPath, recursion, VersionSpec.Latest));
            }
            using (var progress = VersionControlService.GetProgressMonitor("Get", VersionControlOperationType.Pull))
            {
                var option = GetOptions.None;
                progress.Log.WriteLine("Start downloading items. GetOption: " + option);
                foreach (var request in requests)
                {
                    progress.Log.WriteLine(request);
                }
                _currentWorkspace.Get(requests, option, progress);
                progress.ReportSuccess("Finish Downloading.");
            }
            RefreshList(items);
        }
        void OnGet(object sender, System.EventArgs e)
        {
            var requests = new List <GetRequest>();

            for (int row = 0; row < listStore.RowCount; row++)
            {
                var isChecked = listStore.GetValue(row, isSelectedField);
                if (isChecked)
                {
                    var item    = listStore.GetValue(row, itemField);
                    var spec    = new ItemSpec(item.ServerPath, item.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full);
                    var version = (int)versionBox.SelectedItem == 0 ? new ChangesetVersionSpec(Convert.ToInt32(changeSetNumber.Value)) : VersionSpec.Latest;
                    requests.Add(new GetRequest(spec, version));
                    if (forceGet.State == CheckBoxState.On)
                    {
                        workspace.ResetDownloadStatus(item.ItemId);
                    }
                }
            }
            var option = GetOptions.None;

            if (forceGet.State == CheckBoxState.On)
            {
                option |= GetOptions.GetAll;
            }
//            if (overrideGet.State == CheckBoxState.On)
//                option |= GetOptions.Overwrite;
            using (var progress = VersionControlService.GetProgressMonitor("Get", VersionControlOperationType.Pull))
            {
                progress.Log.WriteLine("Start downloading items. GetOption: " + option);
                foreach (var request in requests)
                {
                    progress.Log.WriteLine(request);
                }
                workspace.Get(requests, option, progress);
                progress.ReportSuccess("Finish Downloading.");
            }
            Respond(Command.Ok);
        }
		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;
			}
		}
        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
            {}
            
        }
        private static bool GetLatest(string targetPath, List<MergeRelation> mergeRelationships, Workspace workspace)
        {
            var getLatestFiles = new List<string>();
            foreach (var mergeRelationship in mergeRelationships.Where(r => r.TargetItemType == ItemType.File && r.GetLatesPath != null))
            {
                if (mergeRelationship.GetLatesPath.StartsWith(targetPath))
                    getLatestFiles.Add(mergeRelationship.GetLatesPath);
            }

            var getLatestFilesArray = getLatestFiles.ToArray();
            if (getLatestFilesArray.Length > 0)
            {
                const RecursionType recursionType = RecursionType.None;
                var getLatestResult = workspace.Get(getLatestFilesArray, VersionSpec.Latest, recursionType, GetOptions.None);
                if (!getLatestResult.NoActionNeeded)
                {
                    // HACK.
                    getLatestResult = workspace.Get(getLatestFilesArray, VersionSpec.Latest, recursionType, GetOptions.None);
                    if (!getLatestResult.NoActionNeeded)
                    {
                        return false;
                    }
                }
            }

            return true;
        }