我正在使用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