我正在使用p4.net API從元數據生成一些報告。p4.net無法連接Perforce
在其中一個報告中,我需要爲每個變更集報告生成更改行數。
作爲一個報告工具,我使用MS SQL Reporting services 2008,並且我編寫了一個使用p4.net API的自定義dll來計算更改的行數。它在當地工作沒有任何問題。但是,當我在服務器上運行代碼時,它會計算讓我們先說%20部分然後開始拋出無法連接到Perforce服務器! 無法連接到Perforce!例外。
我在本地嘗試相同的憑據,它的工作原理..我在服務器上使用相同憑據的命令行,它的工作原理。
任何人都可以幫我解決,如果遇到過嗎?
這是我使用的代碼。如果需要
public static class PerforceLib
{
public static P4Connection p4conn = null;
private static void CheckConn()
{
try
{
if (p4conn == null)
{
p4conn = new P4Connection();
p4conn.Port = "address";
p4conn.User = "user";
p4conn.Password = "pwd*";
p4conn.Connect();
p4conn.Login("pwd");
}
else if (p4conn != null)
{
if(!p4conn.IsValidConnection(true, false))
{
Log("Check CONN : Connection is not valid, reconnecting");
p4conn.Login("pwd*");
}
}
}
catch (Exception ex)
{
Log(ex.Message);
}
}
public static int DiffByChangeSetNumber(string ChangeSetNumber)
{
try
{
CheckConn();
P4Record set = p4conn.Run("describe", "-s",ChangeSetNumber)[0];
string[] files = set.ArrayFields["depotFile"].ToArray<string>();
string[] revs = set.ArrayFields["rev"].ToArray<string>();
string[] actions = set.ArrayFields["action"].ToArray<string>();
int totalChanges = 0;
List<P4File> lstFiles = new List<P4File>();
for (int i = 0; i < files.Count(); i++)
{
if (actions[i].ToString() == "edit")
lstFiles.Add(new P4File() { DepotFile = files[i].ToString(), Revision = revs[i].ToString(), Action = actions[i].ToString() });
}
foreach (var item in lstFiles)
{
if (item.Revision != "1")
{
string firstfile = string.Format("{0}#{1}", item.DepotFile, (int.Parse(item.Revision) - 1).ToString());
string secondfile = string.Format("{0}#{1}", item.DepotFile, item.Revision);
P4UnParsedRecordSet rec = p4conn.RunUnParsed("diff2", "-ds", firstfile, secondfile);
if (rec.Messages.Count() > 1)
{
totalChanges = PerforceUtil.GetDiffResults(rec.Messages[1].ToString(), item.DepotFile);
}
}
}
GC.SuppressFinalize(lstFiles);
Log(string.Format("{0}/{1}", ChangeSetNumber,totalChanges.ToString() + Environment.NewLine));
return totalChanges;
}
catch (Exception ex)
{
Log(ex.Message + Environment.NewLine);
return -1;
}
}
}
您的幫助將不勝感激
非常感謝
這個問題只發生在Windows Server 2003中的任何幫助。我已經在Vista中,XP下測試它和Windows 7機器和工作正常..我使用默認配置設置了一個新的Windows 2003服務器環境,並試用了它,但它不起作用。 – AnarchistGeek