मैं इस
/// <summary>
/// Return last check-in History of a file
/// </summary>
/// <param name="filename">filename for which history is required</param>
/// <returns>TFS history command</returns>
private string GetTfsHistoryCommand(string filename)
{
//tfs history command (return only one recent record stopafter:1)
return string.Format("history /stopafter:1 {0} /noprompt", filename); // return recent one row
}
निष्पादन के बाद मैं पार्स इस आदेश के उत्पादन में changeset संख्या
using (StreamReader Output = ExecuteTfsCommand(GetTfsHistoryCommand(fullFilePath)))
{
string line;
bool foundChangeSetLine = false;
Int64 latestChangeSet;
while ((line = Output.ReadLine()) != null)
{
if (foundChangeSetLine)
{
if (Int64.TryParse(line.Split(' ').First().ToString(), out latestChangeSet))
{
return latestChangeSet; // this is the lastest changeset number of input file
}
}
if (line.Contains("-----")) // output stream contains history records after "------" row
foundChangeSetLine = true;
}
}
यह पाने के लिए मैं आदेश पर अमल के लिए tf आदेश के बाद का उपयोग करें
/// <summary>
/// Executes TFS commands by setting up TFS environment
/// </summary>
/// <param name="commands">TFS commands to be executed in sequence</param>
/// <returns>Output stream for the commands</returns>
private StreamReader ExecuteTfsCommand(string command)
{
logger.Info(string.Format("\n Executing TFS command: {0}",command));
Process process = new Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = _tFPath;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.Arguments = command;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.WaitForExit(); // wait until process finishes
// log the error if there's any
StreamReader errorReader = process.StandardError;
if(errorReader.ReadToEnd()!="")
logger.Error(string.Format(" \n Error in TF process execution ", errorReader.ReadToEnd()));
return process.StandardOutput;
}
एक कुशल तरीका नहीं है लेकिन अभी भी एक समाधान यह टीएफएस 2008 में काम करता है, उम्मीद है कि इससे मदद मिलती है।
(TFS जावा एसडीके में यह
VersionControlClient.getLatestChangesetId
है) ऐसा लगता है VersionControlServer भी एक GetLatestChangesetId विधि है। यह बहुत छोटा है :-) – tbaskanहम नीचे दिए गए टीएफएस कनेक्शन 'var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection (नया Uri (tfsServer)) के लिए उपयोगकर्ता नाम और pwd पास कर सकते हैं; tfs.Connect (ConnectOptions.None); ' bcoz आईआईएस सर्वर से मेरे जाल पृष्ठ की तैनाती के बाद मैं TFS जानकारी प्राप्त करने में असमर्थ हूँ लेकिन स्थानीय होस्ट के लिए मैं एक ही वेब पृष्ठों के लिए TFS जानकारी प्राप्त करने में सक्षम हूँ। मैं नीचे हो रही हूँ गलती Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: // tfsserver:: 8080/TFS/mycollection आप http उपयोग करने के लिए अधिकृत नहीं हैं। Microsoft.TeamFoundation.Client.TfsConnection.ThrowAuthorizationException (अपवाद ई) – picnic4u
@ picnic4u शायद इसके लिए एक नया प्रश्न उठा रहा है। – DaveShaw