/// <summary> /// 设置书签的值 /// </summary> /// <param name="bookMark">书签节点</param> private void SetBookMarkValue(WordTemplateParser.Structs.BookMark bookMark, List <Dictionary <PrintDataType, object> > Items, int desc) { Dictionary <PrintDataType, object> currentMeter = Items[desc]; //获取当前表对象 if (bookMark == null || string.IsNullOrEmpty(bookMark.Text.ToLower())) { return; } string[] arrMarkValue = bookMark.Text.ToLower().Split(':'); //标签每个元素间用:隔开 if (arrMarkValue.Length == 6 && arrMarkValue[0] == "loop") { WordTemplateParser.WordProcess loopMarkParser = null; if (arrMarkValue[1] == "meter") { loopMarkParser = ParserLoopMarkMeter(Items, arrMarkValue); } else { loopMarkParser = ParserLoopMarkMeterData(currentMeter, arrMarkValue); } //回填解析后的文档 if (loopMarkParser != null) { bookMark.SetContentValue(loopMarkParser); } else { bookMark.SetValue("Invalid BookMark:" + bookMark.Text); } return; } //TODO:处理非对象标签 SetBookMarkValue(bookMark, currentMeter); }
private void SetBookMarkValue(WordTemplateParser.Structs.BookMark bookMark, Dictionary <PrintDataType, object> Item) { if (bookMark == null || string.IsNullOrEmpty(bookMark.Text.ToLower())) { return; } string TmpValue = ""; string Tmp_Label = bookMark.Text.ToLower(); string[] Arr_Tmp = Tmp_Label.Split(':'); //标签每个元素间用:隔开 //TODO:解析标签 switch (Arr_Tmp.Length) { case 1: //书签文本格式只有一级表示为基本信息"meterid" if (Arr_Tmp[0].ToLower() == "checker" || Arr_Tmp[0].ToLower() == "verificationer") { if (PrintInfo.PrintHuman) { TmpValue = this.GetColValue(PrintDataType.基本信息, Item[PrintDataType.基本信息], Arr_Tmp[0].ToLower()); } } else { TmpValue = this.GetColValue(PrintDataType.基本信息, Item[PrintDataType.基本信息], Arr_Tmp[0].ToLower()); } break; case 2: //如果有2级,表示为多功能信息“Dgn:通信测试” TmpValue = this.GetColValue(PrintDataType.多功能数据, Item[PrintDataType.多功能数据], Arr_Tmp[1].ToLower()); break; case 3: //如果有3级,表示为误差信息"P+:H10_Imax:WcHzz" TmpValue = this.GetColValue(PrintDataType.误差数据, Item[PrintDataType.误差数据], Tmp_Label, clsMain.GetWcNum(Arr_Tmp[2], PrintInfo.PrintStyle, PrintTypeName)); break; case 4: //走字数据"ZZDATA:P+:FL:FL(FL\Qm\Zm\Wc\Result\Mc\zhwc\ZhResult)" if (Arr_Tmp[0].ToLower() == "zzdata") { TmpValue = this.GetColValue(PrintDataType.走字数据, Item[PrintDataType.走字数据], Tmp_Label); } break; } if (TmpValue == "") { TmpValue = PrintInfo.NotCheck; } bookMark.SetValue(TmpValue); }