本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# VersionControlServer.GetItems方法的具体用法?C# VersionControlServer.GetItems怎么用?C# VersionControlServer.GetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer
的用法示例。
在下文中一共展示了VersionControlServer.GetItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildItems
public static List<string> GetChildItems(VersionControlServer server)
{
/*var path = "$/Main/PartnerAccess/PALibraries/PAUdb/.nuget";
var items = server.GetItems(path, new ChangesetVersionSpec(2538), RecursionType.OneLevel);*/
var path = "$/Main/PartnerAccess/PALibraries/PAUdb/udbcodegen";
//var items = server.GetItems(path, new ChangesetVersionSpec(2538), RecursionType.OneLevel);
var items = server.GetItems(path, RecursionType.OneLevel);
return items
.Items
.Select(i => i.ServerItem)
.Where(i => i != path)
.ToList();
}
示例2: ShowChangeset
public static void ShowChangeset(VersionControlServer vcs,
ChangesetVersionSpec versionSpec,
bool brief, DiffOptions diffOpts)
{
int changesetId = versionSpec.ChangesetId;
Changeset changeset = vcs.GetChangeset(changesetId, true, true);
// fetch all items in one fell swoop
List<int> ids = new List<int>();
foreach (Change change in changeset.Changes)
ids.Add(change.Item.ItemId);
// find items in prior changeset
Item[] items = vcs.GetItems(ids.ToArray(), changesetId-1, true);
SortedList<int, Item> itemList = new SortedList<int, Item>();
foreach (Item item in items)
{
// itemId of 0 means a null item, IOW file was added in this changeset
// and missing in prior changeset
if (item.ItemId == 0) continue;
itemList.Add(item.ItemId, item);
}
foreach (Change change in changeset.Changes)
{
// skip folders
if (change.Item.ItemType == ItemType.Folder) continue;
string p = change.Item.ServerItem.Substring(2);
if (brief)
{
Console.WriteLine(p);
continue;
}
IDiffItem a = new DiffItemNull();
IDiffItem b = new DiffItemNull();
string tnameA = null;
string tnameB = null;
if (((change.ChangeType & ChangeType.Add) != ChangeType.Add) &&
(itemList.ContainsKey(change.Item.ItemId)))
{
Item itemA = itemList[change.Item.ItemId];
tnameA = Path.GetTempFileName();
itemA.DownloadFile(tnameA);
a = new DiffItemLocalFile(tnameA, itemA.Encoding,
changeset.CreationDate, true);
}
if ((change.ChangeType & ChangeType.Delete) != ChangeType.Delete)
{
tnameB = Path.GetTempFileName();
change.Item.DownloadFile(tnameB);
b = new DiffItemLocalFile(tnameB, change.Item.Encoding,
changeset.CreationDate, true);
}
diffOpts.TargetLabel = versionSpec.DisplayString;
Difference.DiffFiles(vcs, a, b, diffOpts, p, true);
if (!String.IsNullOrEmpty(tnameA))
File.Delete(tnameA);
if (!String.IsNullOrEmpty(tnameB))
File.Delete(tnameB);
}
}
示例3: RunForItemSpec
private void RunForItemSpec(VersionControlServer versionControl, string itemSpec)
{
_logger.Info(string.Format("Starting for ItemSpec: {0}", itemSpec));
try
{
DateTime startTime = DateTime.UtcNow;
// Retrieving list of items
_logger.Info("Retrieving list of items...");
var items = versionControl.GetItems(itemSpec, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.File, true);
DateTime finishTimeGetItems = DateTime.UtcNow;
TimeSpan elapsedTimeGetItems = finishTimeGetItems - startTime;
_logger.Info("Retrieved {0} items to warm up. Retrieval time: {1}", items.Items.Length, elapsedTimeGetItems);
if (elapsedTimeGetItems > TimeSpan.FromMinutes(MAX_MINUTES_FOR_GETITEMS))
{
_logger.Warn("Retrieval of items for the ItemSpec took more than {0} minutes, actual time: {1}. Consider reconfiguration of ItemSpecs for the Project Collection.",
MAX_MINUTES_FOR_GETITEMS, elapsedTimeGetItems);
}
// Processing retrieved items
_logger.Info("Downloading items...");
foreach (var item in items.Items)
{
try
{
// Extracting file ID from the item's download URL to avoid downloading of already warmed up files
// during this session
int fileId = item.GetFileId();
if (!_alreadyDownloadedFileIds.Contains(fileId))
{
// Requesting file and closing stream, because we don't need the file itself
item.DownloadFile().Dispose();
_logger.Debug("Downloaded: {0}:{1}", item.ServerItem, item.ChangesetId);
// Marking the file as downloaded during this session
_alreadyDownloadedFileIds.Add(fileId);
}
else
_logger.Debug("Skipped (already downloaded): {0}:{1}", item.ServerItem, item.ChangesetId);
}
catch (Exception ex)
{
_logger.WarnException(string.Format("Failed to process item: {0}:{1}", item.ServerItem, item.ChangesetId), ex);
}
}
// Calculating elapsed time
DateTime finishTime = DateTime.UtcNow;
TimeSpan elapsedTime = finishTime - startTime;
_logger.Info("Warm up for the ItemSpec done. Elapsed time: {0}", elapsedTime);
}
catch (Exception ex)
{
_logger.ErrorException(string.Format("Warm up for the ItemSpec failed with error: {0}", ex.Message), ex);
}
}