public SourceItem[] QueryItems(int revision, string path, Recursion recursion) { List <SourceItem> list = null; persistentCache.UnitOfWork(delegate { string serverPath = GetServerPath(path); if (serverPath == Constants.ServerRootPath && recursion == Recursion.None) { SourceItem[] items = sourceControlService.QueryItems(serverUrl, credentials, serverPath, RecursionType.None, VersionSpec.FromChangeset(revision), DeletedState.NonDeleted, ItemType.Any); list = new List <SourceItem>(items); return; } EnsureRevisionIsCached(revision, path); string cacheKey = GetItemsListCacheKey(recursion, revision, serverPath); list = persistentCache.GetList <SourceItem>(cacheKey); list.Sort(delegate(SourceItem x, SourceItem y) { return(x.RemoteName.CompareTo(y.RemoteName)); }); }); return(list.ToArray()); }
private SourceItem[] QueryItemsInternal(int revision, ref string serverPath) { SourceItem[] items = sourceControlService.QueryItems(serverUrl, credentials, serverPath, RecursionType.Full, VersionSpec.FromChangeset(revision), DeletedState.NonDeleted, ItemType.Any); if (items.Length == 1 && items[0].ItemType == ItemType.File) { //change it to the directory name, can't use the Path class // because that will change the '/' to '\' serverPath = serverPath.Substring(0, serverPath.LastIndexOf('/')); items = sourceControlService.QueryItems(serverUrl, credentials, serverPath, RecursionType.Full, VersionSpec.FromChangeset(revision), DeletedState.NonDeleted, ItemType.Any); } return(items); }
public SourceItem[] QueryItems(int revision, string[] paths, Recursion recursion) { List <ItemSpec> itemSpecs = new List <ItemSpec>(); foreach (string path in paths) { ItemSpec itemspec = new ItemSpec(); itemspec.item = GetServerPath(path); itemspec.recurse = RecursionType.None; switch (recursion) { case Recursion.OneLevel: itemspec.recurse = RecursionType.OneLevel; break; case Recursion.Full: itemspec.recurse = RecursionType.Full; break; } itemSpecs.Add(itemspec); } ItemSet[] items = sourceControlService.QueryItems(serverUrl, credentials, VersionSpec.FromChangeset(revision), itemSpecs.ToArray()); SortedList <string, SourceItem> result = new SortedList <string, SourceItem>(); foreach (ItemSet itemset in items) { foreach (Item item in itemset.Items) { SourceItem sourceItem = new SourceItem(); sourceItem.RemoteChangesetId = item.cs; sourceItem.RemoteDate = item.date.ToUniversalTime(); sourceItem.ItemType = item.type; sourceItem.ItemId = item.itemid; sourceItem.RemoteName = item.item; var downloadUrlExtension = serverUrl.Contains("/tfs/") ? "ashx" : "asmx"; sourceItem.DownloadUrl = serverUrl + "/VersionControl/v1.0/item." + downloadUrlExtension + "?" + item.durl; if (!result.ContainsKey(sourceItem.RemoteName)) { result.Add(sourceItem.RemoteName, sourceItem); } } } List <SourceItem> result2 = new List <SourceItem>(); foreach (SourceItem sourceItem in result.Values) { result2.Add(sourceItem); } return(result2.ToArray()); }