本文整理汇总了C#中LocationCollection.Build方法的典型用法代码示例。如果您正苦于以下问题:C# LocationCollection.Build方法的具体用法?C# LocationCollection.Build怎么用?C# LocationCollection.Build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocationCollection
的用法示例。
在下文中一共展示了LocationCollection.Build方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceOrderInfoItemRefID
//
// return:
// -1 出错
// 0 没有发生替换修改
// >0 共修改了多少个<distribute>元素内容
/// <summary>
/// 更换 orderInfo 元素里的 distribute 元素中的 refid 字符串
/// </summary>
/// <param name="item_refid_change_table">参考 ID 对照表</param>
/// <param name="strError">返回出错信息</param>
/// <returns>-1 出错; 0 没有发生替换修改; >0 共修改了多少个 distribute 元素内容</returns>
public int ReplaceOrderInfoItemRefID(Hashtable item_refid_change_table,
out string strError)
{
strError = "";
int nRet = 0;
string strOrderInfo = this.OrderInfo;
if (String.IsNullOrEmpty(strOrderInfo) == true)
return 0;
XmlDocument dom = new XmlDocument();
dom.LoadXml("<orderInfo/>");
try
{
dom.DocumentElement.InnerXml = strOrderInfo;
}
catch (Exception ex)
{
strError = "load inner xml error: " + ex.Message;
return -1;
}
int nChangedCount = 0;
XmlNodeList nodes = dom.DocumentElement.SelectNodes("*/distribute");
for (int i = 0; i < nodes.Count; i++)
{
string strDistribute = nodes[i].InnerText;
if (String.IsNullOrEmpty(strDistribute) == true)
continue;
LocationCollection locations = new LocationCollection();
nRet = locations.Build(strDistribute,
out strError);
if (nRet == -1)
return -1;
bool bChanged = false;
for (int j = 0; j < locations.Count; j++)
{
Location location = locations[j];
if (item_refid_change_table.Contains(location.RefID) == true)
{
location.RefID = (string)item_refid_change_table[location.RefID];
bChanged = true;
}
}
if (bChanged == true)
{
nodes[i].InnerText = locations.ToString(true);
nChangedCount++;
}
}
if (nChangedCount > 0)
this.OrderInfo = dom.DocumentElement.InnerXml;
return nChangedCount;
}
示例2: DistributeCross
//
// return:
// -1 出错
// 0 没有任何部分在管辖范围
// 1 至少部分在管辖范围内
/// <summary>
/// 观察一个馆藏分配字符串,看看是否部分在当前用户管辖范围内
/// </summary>
/// <param name="strDistribute">馆藏分配字符串</param>
/// <param name="strLibraryCodeList">当前用户的馆代码列表字符串</param>
/// <param name="strError">返回出错信息</param>
/// <returns>-1: 出错; 0: 没有任何部分在管辖范围; 1: 至少部分在管辖范围内</returns>
public static int DistributeCross(string strDistribute,
string strLibraryCodeList,
out string strError)
{
strError = "";
if (IsGlobalUser(strLibraryCodeList) == true)
return 1;
LocationCollection locations = new LocationCollection();
int nRet = locations.Build(strDistribute, out strError);
if (nRet == -1)
{
strError = "馆藏分配字符串 '" + strDistribute + "' 格式不正确";
return -1;
}
foreach (Location location in locations)
{
// 空的馆藏地点被视为不在分馆用户管辖范围内
if (string.IsNullOrEmpty(location.Name) == true)
continue;
string strLibraryCode = "";
string strPureName = "";
// 解析
ParseCalendarName(location.Name,
out strLibraryCode,
out strPureName);
if (StringUtil.IsInList(strLibraryCode, strLibraryCodeList) == true)
return 1;
}
return 0;
}
示例3: MergeOrderNode
//.........这里部分代码省略.........
return 1;
}
// 检查验收套数的改变,是否正好和distribute字符串内的改变吻合
}
// 比较两个价格字符串
{
string strExistOldValue = "";
string strExistNewValue = "";
ParseOldNewValue(strExistPrice,
out strExistOldValue,
out strExistNewValue);
string strChangedOldValue = "";
string strChangedNewValue = "";
ParseOldNewValue(strChangedPrice,
out strChangedOldValue,
out strChangedNewValue);
if (strExistOldValue != strChangedOldValue)
{
strError = "订购价(方括号左边的部分)不允许修改。(原来='" + strExistPrice + "',新的='" + strChangedPrice + "')";
return 1;
}
if (strExistNewValue != strChangedNewValue)
{
strError = "验收价(方括中的部分)不允许修改。(原来='" + strExistPrice + "',新的='" + strChangedPrice + "')";
return 1;
}
}
LocationCollection new_locations = new LocationCollection();
nRet = new_locations.Build(strNewDistribute, out strError);
if (nRet == -1)
{
strError = "馆藏分配字符串 '" + strNewDistribute + "' 格式不正确";
return -1;
}
LocationCollection exist_locations = new LocationCollection();
nRet = exist_locations.Build(strExistDistribute, out strError);
if (nRet == -1)
{
strError = "馆藏分配字符串 '" + strExistDistribute + "' 格式不正确";
return -1;
}
if (exist_locations.Count != new_locations.Count)
{
strError = "馆藏分配事项个数发生了改变(原来=" + exist_locations.Count.ToString() + ",新的=" + new_locations.Count.ToString() + ")";
return 1;
}
for (int i = 0; i < exist_locations.Count; i++)
{
Location exist_location = exist_locations[i];
Location new_location = new_locations[i];
if (exist_location.Name != new_location.Name)
{
// 进一步检查是否馆代码部分改变了
string strCode1 = "";
string strPureName = "";
string strCode2 = "";
示例4: DistributeInControlled
// 观察一个馆藏分配字符串,看看是否在当前用户管辖范围内
// return:
// -1 出错
// 0 超过管辖范围。strError中有解释
// 1 在管辖范围内
public static int DistributeInControlled(string strDistribute,
string strLibraryCodeList,
out string strError)
{
strError = "";
if (SessionInfo.IsGlobalUser(strLibraryCodeList) == true)
return 1;
LocationCollection locations = new LocationCollection();
int nRet = locations.Build(strDistribute, out strError);
if (nRet == -1)
{
strError = "馆藏分配字符串 '" + strDistribute + "' 格式不正确";
return -1;
}
foreach (Location location in locations)
{
// 空的馆藏地点被视为不在分馆用户管辖范围内
if (string.IsNullOrEmpty(location.Name) == true)
{
strError = "馆代码 '' 不在范围 '" + strLibraryCodeList + "' 内";
return 0;
}
string strLibraryCode = "";
string strPureName = "";
// 解析
LibraryApplication.ParseCalendarName(location.Name,
out strLibraryCode,
out strPureName);
if (StringUtil.IsInList(strLibraryCode, strLibraryCodeList) == false)
{
strError = "馆代码 '" + strLibraryCode + "' 不在范围 '" + strLibraryCodeList + "' 内";
return 0;
}
}
return 1;
}
示例5: GetRefIDs
//
/// <summary>
/// 获得一个馆藏分配字符串里面的所有 参考 ID
/// </summary>
/// <param name="strDistribute">馆藏分配字符串</param>
/// <param name="refids">返回参考 ID 字符串集合</param>
/// <param name="strError">返回出错信息</param>
/// <returns>-1: 出错; 0: 成功</returns>
public static int GetRefIDs(string strDistribute,
out List<string> refids,
out string strError)
{
strError = "";
refids = new List<string>();
LocationCollection locations = new LocationCollection();
int nRet = locations.Build(strDistribute,
out strError);
if (nRet == -1)
return -1;
foreach (Location location in locations)
{
if (string.IsNullOrEmpty(location.RefID) == true)
continue;
string[] parts = location.RefID.Split(new char[] { '|' });
foreach (string text in parts)
{
string strRefID = text.Trim();
if (string.IsNullOrEmpty(strRefID) == true)
continue;
refids.Add(strRefID);
}
}
return 0;
}
示例6: Check
//.........这里部分代码省略.........
/*
if (String.IsNullOrEmpty(item.CatalogNo) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入书目号";
return 1;
}
* */
if (String.IsNullOrEmpty(item.Class) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入类别";
return 1;
}
}
}
if (bStrict == true)
{
// 检查 渠道 + 经费来源 + 价格 3元组是否有重复
for (int i = 0; i < this.Items.Count; i++)
{
Item item = this.Items[i];
// 只检查新规划的事项
if ((item.State & ItemState.ReadOnly) != 0)
continue;
// 2009/2/4 只检查新输入的订购事项
if (String.IsNullOrEmpty(item.StateString) == false)
continue;
string strLocationString = item.location.Value;
LocationCollection locations = new LocationCollection();
nRet = locations.Build(strLocationString, out strError);
if (nRet == -1)
{
strError = "第 " + (i + 1).ToString() + " 行: 去向字符串 '"+strLocationString+"' 格式错误: " + strError;
return -1;
}
string strUsedLibraryCodes = StringUtil.MakePathList(locations.GetUsedLibraryCodes());
// 检查馆代码是否在管辖范围内
// 只检查修改过的事项
if (IsChangedItem(item) == true
&& this.VerifyLibraryCode != null)
{
VerifyLibraryCodeEventArgs e = new VerifyLibraryCodeEventArgs();
e.LibraryCode = strUsedLibraryCodes;
this.VerifyLibraryCode(this, e);
if (string.IsNullOrEmpty(e.ErrorInfo) == false)
{
strError = "第 " + (i + 1).ToString() + " 行: 去向错误: " + e.ErrorInfo;
return -1;
}
}
for (int j = i + 1; j < this.Items.Count; j++)
{
Item temp_item = this.Items[j];
// 只检查新规划的事项
if ((temp_item.State & ItemState.ReadOnly) != 0)
continue;
// 跳过未曾修改过的事项
if (IsChangedItem(temp_item) == false)
continue;
示例7: GetSubOrderRecord
// 从期记录中获得和一个refid有关的订购记录片段
// parameters:
// -1 error
// 0 not found
// 1 found
static int GetSubOrderRecord(XmlDocument dom,
string strRefID,
out string strOrderXml,
out string strError)
{
strError = "";
strOrderXml = "";
XmlNodeList nodes = dom.DocumentElement.SelectNodes("orderInfo/*/distribute");
for (int i = 0; i < nodes.Count; i++)
{
XmlNode node = nodes[i];
string strDistribute = node.InnerText.Trim();
if (String.IsNullOrEmpty(strDistribute) == true)
continue;
LocationCollection locations = new LocationCollection();
int nRet = locations.Build(strDistribute,
out strError);
if (nRet == -1)
return -1;
for (int j = 0; j < locations.Count; j++)
{
DigitalPlatform.Location location = locations[j];
if (location.RefID == strRefID)
{
strOrderXml = node.ParentNode.OuterXml;
return 1;
}
}
}
return 0;
}
示例8: LoadOrderItem
//.........这里部分代码省略.........
out strBiblioText,
out strOutputBiblioRecPath,
out strError);
if (lRet == -1 || lRet == 0)
{
strError = "获取期记录 " + strIssueRecPath + " 时出错: " + strError;
return -1;
}
// 剖析一个期刊xml记录,取出有关信息
XmlDocument issue_dom = new XmlDocument();
try
{
issue_dom.LoadXml(strIssueXml);
}
catch (Exception ex)
{
strError = "期记录 '" + strOutputIssueRecPath + "' XML装入DOM时出错: " + ex.Message;
return -1;
}
// 寻找 /orderInfo/* 元素
XmlNode nodeRoot = issue_dom.DocumentElement.SelectSingleNode("orderInfo/*[refID/text()='" + strRefID + "']");
if (nodeRoot == null)
{
strError = "期记录 '" + strOutputIssueRecPath + "' 中没有找到<refID>元素值为 '" + strRefID + "' 的订购内容节点...";
return -1;
}
string strDistribute = DomUtil.GetElementText(nodeRoot, "distribute");
distributes.Add(strDistribute);
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
if (lStart >= lHitCount || lCount <= 0)
break;
}
}
else
{
string strDistribute = DomUtil.GetElementText(dom.DocumentElement, "distribute");
distributes.Add(strDistribute);
}
if (distributes.Count == 0)
return 0;
foreach (string strDistribute in distributes)
{
LocationCollection locations = new LocationCollection();
nRet = locations.Build(strDistribute,
out strError);
if (nRet == -1)
return -1;
for (int i = 0; i < locations.Count; i++)
{
Location location = locations[i];
if (string.IsNullOrEmpty(location.RefID) == true)
continue;
// 2012/9/4
string[] parts = location.RefID.Split(new char[] { '|' });
foreach (string text in parts)
{
string strRefID = text.Trim();
if (string.IsNullOrEmpty(strRefID) == true)
continue;
// 根据册记录的refid装入册记录
string strItemXml = "";
string strOutputItemRecPath = "";
lRet = Channel.GetItemInfo(
stop,
"@refID:" + strRefID,
"", // "xml",
out strItemXml,
out strOutputItemRecPath,
out item_timestamp,
"recpath",
out strBiblioText,
out strOutputBiblioRecPath,
out strError);
if (lRet == -1 || lRet == 0)
{
strError = "获取册记录 " + strRefID + " 时出错: " + strError;
}
itemrecpaths.Add(strOutputItemRecPath);
}
}
}
return 1;
}
示例9: GetItemRefIDs
// 获得册参考ID列表
public int GetItemRefIDs(out List<string> ids,
out string strError)
{
strError = "";
ids = new List<string>();
XmlNodeList nodes = this.dom.DocumentElement.SelectNodes("orderInfo/*/distribute");
for (int i = 0; i < nodes.Count; i++)
{
XmlNode node = nodes[i];
string strDistribute = node.InnerText.Trim();
if (String.IsNullOrEmpty(strDistribute) == true)
continue;
LocationCollection locations = new LocationCollection();
int nRet = locations.Build(strDistribute,
out strError);
if (nRet == -1)
return -1;
for (int j = 0; j < locations.Count; j++)
{
Location location = locations[j];
// 尚未创建过的事项,跳过
if (location.RefID == "*"
|| String.IsNullOrEmpty(location.RefID) == true)
continue;
ids.Add(location.RefID);
}
}
return 0;
}
示例10: menu_appendCopyElement_Click
// 复制新增
void menu_appendCopyElement_Click(object sender, EventArgs e)
{
int nPos = this.Container.Items.IndexOf(this);
if (nPos == -1)
{
throw new Exception("not found myself");
}
string strError = "";
string strXml = "";
Item source = this.Container.Items[nPos];
// 获得表示事项全部内容的XML记录
int nRet = BuildXml(out strXml, out strError);
if (nRet == -1)
throw new Exception(strError);
string strBatchNo = "";
{
string strDefaultXml = this.Container.GetDefaultXml();
if (string.IsNullOrEmpty(strDefaultXml) == false)
{
XmlDocument dom = new XmlDocument();
dom.LoadXml(strDefaultXml);
strBatchNo = DomUtil.GetElementText(dom.DocumentElement, "batchNo");
}
}
// 修改一些字段
{
XmlDocument dom = new XmlDocument();
dom.LoadXml(strXml);
// 如果单价和总价都有,则要把总价清空
string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price");
string strTotalPrice = DomUtil.GetElementText(dom.DocumentElement, "totalPrice");
if (string.IsNullOrEmpty(strPrice) == false && string.IsNullOrEmpty(strTotalPrice) == false)
DomUtil.SetElementText(dom.DocumentElement, "totalPrice", "");
// 把 location 中的已验收信息清除
string strDistributeString = DomUtil.GetElementText(dom.DocumentElement, "distribute");
if (string.IsNullOrEmpty(strDistributeString) == false)
{
LocationCollection locations = new LocationCollection();
nRet = locations.Build(strDistributeString, out strError);
if (nRet == -1)
throw new Exception("馆藏分配去向字符串 '" + strDistributeString + "' 格式错误: " + strError);
strDistributeString = locations.ToString(false);
DomUtil.SetElementText(dom.DocumentElement, "distribute", strDistributeString);
}
DomUtil.SetElementText(dom.DocumentElement, "state", "");
DomUtil.SetElementText(dom.DocumentElement, "refID", "");
DomUtil.SetElementText(dom.DocumentElement, "range", "");
DomUtil.SetElementText(dom.DocumentElement, "batchNo", strBatchNo);
strXml = dom.DocumentElement.OuterXml;
}
Item target = this.Container.InsertNewItem(nPos + 1, strXml);
#if NO
target.StateString = "";
target.RefID = "";
target.RangeString = ""; // TODO: 可以从上一个事项的时候后面自动计算延展
#endif
target.EnsureVisible();
}
示例11: VerifyFields
// 检查各个字段内容是否正确
// return:
// -1 有错
// 0 正确
public int VerifyFields(out string strError)
{
strError = "";
int nRet = 0;
string strRange = this.Range;
string strOrderTime = this.OrderTime;
if (string.IsNullOrEmpty(strRange) == false)
{
// 检查出版时间范围字符串是否合法
// 如果使用单个出版时间来调用本函数,也是可以的
// return:
// -1 出错
// 0 正确
nRet = LibraryServerUtil.CheckPublishTimeRange(strRange,
out strError);
if (nRet == -1)
return -1;
}
if (string.IsNullOrEmpty(strOrderTime) == false)
{
try
{
DateTime time = DateTimeUtil.FromRfc1123DateTimeString(strOrderTime);
if (time.Year == 1753)
{
strError = "订购时间字符串 '" + strOrderTime + "' 这是一个不太可能的时间";
return -1;
}
}
catch (Exception ex)
{
strError = "订购时间字符串 '" + strOrderTime + "' 格式错误: " + ex.Message;
return -1;
}
}
// 验证馆藏分配字符串
string strDistribute = this.Distribute;
if (string.IsNullOrEmpty(strDistribute) == false)
{
LocationCollection locations = new LocationCollection();
nRet = locations.Build(strDistribute, out strError);
if (nRet == -1)
{
strError = "馆藏分配字符串 '" + strDistribute + "' 格式错误: " + strError;
return -1;
}
}
return 0;
}
示例12: DoItems
void DoItems(List<string> item_xmls, ProcessInfo info)
{
string strError = "";
List<EntityInfo> entityArray = new List<EntityInfo>();
string strRootElementName = "";
foreach (string xml in item_xmls)
{
if (string.IsNullOrEmpty(xml))
continue;
XmlDocument item_dom = new XmlDocument();
item_dom.LoadXml(xml);
strRootElementName = item_dom.DocumentElement.LocalName;
string strPath = item_dom.DocumentElement.GetAttribute("path");
string strTimestamp = item_dom.DocumentElement.GetAttribute("timestamp");
EntityInfo item = new EntityInfo();
string strRefID = DomUtil.GetElementText(item_dom.DocumentElement, "refID");
if (strRootElementName == "item")
{
RefreshRefID(info.ItemRefIDTable, ref strRefID);
}
else if (strRootElementName == "order")
{
RefreshRefID(info.OrderRefIDTable, ref strRefID);
// 记录中 distribute 元素中的 refid 要被替换
string strDistribute = DomUtil.GetElementText(item_dom.DocumentElement, "distribute");
if (string.IsNullOrEmpty(strDistribute) == false)
{
LocationCollection collection = new LocationCollection();
int nRet = collection.Build(strDistribute, out strError);
if (nRet != -1)
{
collection.RefreshRefIDs(ref info.ItemRefIDTable);
}
string strNewDistribute = collection.ToString();
if (strNewDistribute != strDistribute)
{
DomUtil.SetElementText(item_dom.DocumentElement, "distribute", strNewDistribute);
}
}
}
else
{
RefreshRefID(null, ref strRefID);
}
item.RefID = strRefID;
DomUtil.SetElementText(item_dom.DocumentElement, "refID", strRefID);
DomUtil.SetElementText(item_dom.DocumentElement,
"parent", Global.GetRecordID(info.BiblioRecPath));
string strXml = item_dom.DocumentElement.OuterXml;
item.Action = "new";
item.NewRecord = strXml;
item.NewTimestamp = ByteArray.GetTimeStampByteArray(strTimestamp);
item.OldRecord = "";
item.OldTimestamp = null;
entityArray.Add(item);
}
info.stop.SetMessage("正在为书目记录 '" + info.BiblioRecPath + "' 上传 "+info.UploadedSubItems+"+" + entityArray.Count + " 个下属 " + strRootElementName + " 记录 ...");
info.UploadedSubItems += entityArray.Count;
EntityInfo[] errorinfos = null;
long lRet = 0;
if (strRootElementName == "item")
lRet = info.Channel.SetEntities(
info.stop,
info.BiblioRecPath,
entityArray.ToArray(),
out errorinfos,
out strError);
else if (strRootElementName == "order")
lRet = info.Channel.SetOrders(
info.stop,
info.BiblioRecPath,
entityArray.ToArray(),
out errorinfos,
out strError);
else if (strRootElementName == "issue")
lRet = info.Channel.SetIssues(
info.stop,
info.BiblioRecPath,
entityArray.ToArray(),
out errorinfos,
//.........这里部分代码省略.........