本文整理汇总了C#中LocationCollection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LocationCollection.ToString方法的具体用法?C# LocationCollection.ToString怎么用?C# LocationCollection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocationCollection
的用法示例。
在下文中一共展示了LocationCollection.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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,
//.........这里部分代码省略.........