我正在使用 VersionOne SDK 并不断收到有关 OID 无效的错误。但是,当我使用该 OID 在 VersionOne 中查找测试时,它是测试的正确 OID。
A first chance exception of type 'VersionOne.SDK.APIClient.OidException' occurred in VersionOne.SDK.APIClient.dll
Invalid OID token: Test:32423
我将一个包含“Test:32423”的字符串传递给该方法。
public void UpdateTestResults(string strTestId, string strActualResult)
{
var testId = Oid.FromToken(strTestId, _metaModel);
var query = new Query(testId);
var assetType = _metaModel.GetAssetType("Test");
var addResults = assetType.GetAttributeDefinition("ActualResults");
query.Selection.Add(addResults);
var result = _services.Retrieve(query);
var test = result.Assets[0];
var oldResult = GetValue(test.GetAttribute(addResults).Value);
var time = DateTime.Now;
const string format = "MMM ddd d HH:mm yyyy";
test.SetAttributeValue(addResults, "<p>" + "\n" + oldResult + time.ToString(format) + "-->" + strActualResult + "</p>");
_services.Save(test);
_logger.Log(Loglevel.Debug, test.Oid.Token, oldResult, GetValue(test.GetAttribute(addResults).Value));
}
我注意到该错误仅在背靠背运行一系列测试时发生。当我只运行一个测试时,这个错误永远不会发生。
这是我放在类顶部的代码,用于制作连接器和构造函数。
const string ApplicationUrl = "https://www12.v1host.com/VersionOneAccount/";
readonly NetworkCredential _credentials = new NetworkCredential("userName", "passWord");
readonly IMetaModel _metaModel = new MetaModel(new VersionOneAPIConnector(ApplicationUrl + "meta.v1/"));
readonly IServices _services;
public V1Tools(ref DataObject masterData)
{
_services = new Services(_metaModel, new VersionOneAPIConnector(ApplicationUrl + "rest-1.v1/", _credentials));
_logger = masterData.Logger;
}