本文整理汇总了C#中LibraryChannel.SetEntities方法的典型用法代码示例。如果您正苦于以下问题:C# LibraryChannel.SetEntities方法的具体用法?C# LibraryChannel.SetEntities怎么用?C# LibraryChannel.SetEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibraryChannel
的用法示例。
在下文中一共展示了LibraryChannel.SetEntities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetectAccess
//.........这里部分代码省略.........
biblio_access_list.Add("delete");
}
strBiblioAccess = StringUtil.MakePathList(biblio_access_list);
// 模拟实体追加写入
EntityInfo info = new EntityInfo();
{
XmlDocument item_dom = new XmlDocument();
item_dom.LoadXml("<root />");
info.Style = "simulate";
info.RefID = Guid.NewGuid().ToString();
DomUtil.SetElementText(item_dom.DocumentElement,
"parent", "0");
info.OldRecPath = "";
info.OldRecord = "";
info.OldTimestamp = null;
info.Action = "new";
info.NewRecPath = "";
info.NewRecord = item_dom.DocumentElement.OuterXml;
info.NewTimestamp = null;
}
EntityInfo[] entities = new EntityInfo[1];
entities[0] = info;
EntityInfo[] errorinfos = null;
lRet = channel.SetEntities(
stop,
strPath,
entities,
out errorinfos,
out strError);
if (lRet == -1)
{
List<string> normal_errors = new List<string>();
List<string> accessdenied_errors = new List<string>();
GetErrorInfo(errorinfos, out normal_errors, out accessdenied_errors);
if (normal_errors.Count > 0)
{
strError = StringUtil.MakePathList(normal_errors, " ; ");
return -1;
}
}
else
{
entity_access_list.Add("append");
}
// 模拟实体覆盖写入
info.Action = "change";
lRet = channel.SetEntities(
stop,
strPath,
entities,
out errorinfos,
out strError);
if (lRet == -1)
{
List<string> normal_errors = new List<string>();
示例2: SaveEntities
// 分批进行保存
// return:
// -2 部分成功,部分失败
// -1 出错
// 0 保存成功,没有错误和警告
int SaveEntities(
EntityInfo[] entities,
out string strError)
{
strError = "";
int nRet = 0;
bool bWarning = false;
EntityInfo[] errorinfos = null;
string strWarning = "";
// 确定目标服务器 目标书目库
AccountInfo _currentAccount = _base.GetAccountInfo(this._biblio.ServerName);
if (_currentAccount == null)
{
strError = "' 服务器名 '" + this._biblio.ServerName + "' 没有配置";
return -1;
}
_channel = _base.GetChannel(_currentAccount.ServerUrl, _currentAccount.UserName);
try
{
string strBiblioRecPath = this._biblio.BiblioRecPath;
int nBatch = 100;
for (int i = 0; i < (entities.Length / nBatch) + ((entities.Length % nBatch) != 0 ? 1 : 0); i++)
{
int nCurrentCount = Math.Min(nBatch, entities.Length - i * nBatch);
EntityInfo[] current = GetPart(entities, i * nBatch, nCurrentCount);
long lRet = _channel.SetEntities(
Progress,
strBiblioRecPath,
entities,
out errorinfos,
out strError);
if (lRet == -1)
return -1;
// 把出错的事项和需要更新状态的事项兑现到显示、内存
string strError1 = "";
if (this._biblio.RefreshOperResult(errorinfos, out strError1) == true)
{
bWarning = true;
strWarning += " " + strError1;
}
if (lRet == -1)
return -1;
}
if (string.IsNullOrEmpty(strWarning) == false)
strError += " " + strWarning;
if (bWarning == true)
return -2;
// line._biblioRegister.EntitiesChanged = false; // 所有册都保存成功了
return 0;
}
finally
{
_base.ReturnChannel(_channel);
_channel = null;
_currentAccount = null;
}
}