public bool WorkspaceExists(string workspaceName)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection();
            bool Result = WorkspaceExists(workspaceName, ServerConnection);

            return(Result);
        }
        public string GetWorkSpaceName(string connectionRefId, string path)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection(connectionRefId);
            string Name = this.GetWorkSpaceName(path, ServerConnection);

            return(Name);
        }
        public Workspace GetWorkspace(string workspaceName, string localItem, TfsServerConnection serverConnection)
        {
            Workspace MyWorkspace = null;

            if (String.IsNullOrEmpty(workspaceName) && String.IsNullOrEmpty(localItem))
            {
                throw new BuildException("Unable to determine Workspace to use as both the WorkspaceName and LocalItem are not set.");
            }

            if (!String.IsNullOrEmpty(workspaceName))
            {
                MyWorkspace = this.GetWorkspaceByName(workspaceName, serverConnection.SourceControl);
            }

            if (MyWorkspace == null && !String.IsNullOrEmpty(localItem))
            {
                MyWorkspace = this.GetLocalWorkspace(localItem, serverConnection);
            }

            if (MyWorkspace == null)
            {
                throw new BuildException(String.Format("Unable to determine Workspace to use: WorkspaceName is set to {0} and LocalItem is set to {1}.", workspaceName, localItem));
            }

            return(MyWorkspace);
        }
        private string GetWorkSpaceName(string path, TfsServerConnection serverConnection)
        {
            WorkspaceInfo Info = Workstation.Current.GetLocalWorkspaceInfo(path);
            string        Name;

            Name = Info.Name;
            return(Name);
        }
        private Workspace GetWorkspace(string connectionRefId, string workspaceName)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection(connectionRefId);
            WorkspaceAssistant  Helper           = new WorkspaceAssistant();
            Workspace           MyWorkspace      = Helper.GetWorkspaceByName(workspaceName, ServerConnection.SourceControl);

            return(MyWorkspace);
        }
        public bool LabelExists(string connectionRefId, string label, string scope)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection(connectionRefId);

            bool Result = this.LabelExists(label, scope, ServerConnection);

            return(Result);
        }
        private bool LabelExists(string label, string scope, TfsServerConnection ServerConnection)
        {
            VersionControlLabel[] Labels = ServerConnection.SourceControl.QueryLabels(label, scope, null, true);
            bool Result;

            Result = Labels.Length > 0;
            return(Result);
        }
        private bool WorkspaceExists(string workspaceName, TfsServerConnection ServerConnection)
        {
            bool Result = false;

            Workspace[] Workspaces = ServerConnection.SourceControl.QueryWorkspaces(workspaceName, ServerConnection.SourceControl.AuthenticatedUser, Workstation.Current.Name);
            if (Workspaces.Length > 0)
            {
                Result = true;
            }
            return(Result);
        }
        private TfsServerConnection GetServerConnection(string connectionRefId)
        {
            if (!this.Project.DataTypeReferences.Contains(connectionRefId))
            {
                throw new BuildException(String.Format("The refid {0} is not defined.", connectionRefId));
            }

            TfsServerConnection ServerConnection = (TfsServerConnection)this.Project.DataTypeReferences[connectionRefId];

            return(ServerConnection);
        }
        public int GetLatestChangeSetIdFromPath(TfsServerConnection serverConnection, string path)
        {
            IEnumerable Enumerable = serverConnection.SourceControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 1, false, false);
            IEnumerator Enumerator = Enumerable.GetEnumerator();
            bool        Exists     = Enumerator.MoveNext();

            if (Exists)
            {
                return(((Changeset)Enumerator.Current).ChangesetId);
            }
            return(0);
        }
        public Workspace GetLocalWorkspace(string localItem, TfsServerConnection serverConnection)
        {
            Workspace MyWorkspace;

            if (!Workstation.Current.IsMapped(localItem))
            {
                throw new BuildException(String.Format("Unable to determine the Workspace to use, the path {0} does not map to a workspace.", localItem));
            }

            WorkspaceInfo MyWorkSpaceInfo = Workstation.Current.GetLocalWorkspaceInfo(localItem);

            MyWorkspace = MyWorkSpaceInfo.GetWorkspace(serverConnection.TFS);

            return(MyWorkspace);
        }
        public int GetLatestChangeSetIdFromPath(string connectionRefId, string path)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection(connectionRefId);

            return(this.GetLatestChangeSetIdFromPath(ServerConnection, path));
        }
        public int GetLatestChangeSetId(string connectionRefId)
        {
            TfsServerConnection ServerConnection = this.GetServerConnection(connectionRefId);

            return(this.GetLatestChangeSetId(ServerConnection));
        }
        public int GetLatestChangeSetId()
        {
            TfsServerConnection ServerConnection = this.GetServerConnection();

            return(this.GetLatestChangeSetId(ServerConnection));
        }
 public int GetLatestChangeSetId(TfsServerConnection serverConnection)
 {
     return(serverConnection.SourceControl.GetLatestChangesetId());
 }