private void FillListElementUncertain(FillParameter parameter) { base.Continue = true; base.CurrentIndex = -1; FillIndexes.Add(this); FillParameter tmp = null; String value = String.Empty; while (base.Continue) { base.Continue = false; base.CurrentIndex++; if (string.IsNullOrEmpty(parameter.href)) { tmp = parameter; } else { tmp = new FillParameter() { href = string.Format(parameter.href, base.CurrentIndex + 1) } }; FillElement(tmp, ref value); this.Wait(); } FillIndexes.RemoveAt(FillIndexes.Count - 1); }
private void FillListElement(List <KeyValuePair <FillParameterKey, object> > list, List <string> values) { if (list.Count == 0) { return; } if (list.Count == 1 && (list[0].Key.Type == Matcher.TYPE_SUBMIT || list[0].Key.Type == "BUTTON/SUBMIT" || list[0].Key.Type == Matcher.TYPE_BUTTON)) { FillListElementUncertain(list[0].Value as FillParameter); list.Clear(); values.Clear(); return; } string[] valueArray = null; int maxValueLength = 0; List <string[]> valueList = new List <string[]>(); foreach (var value in values) { valueArray = value == null ? emptyStringArray : value.Split(base.Converter.SpliterChars[0]); valueList.Add(valueArray); maxValueLength = Math.Max(maxValueLength, valueArray.Length); } base.CurrentIndex = 0; FillIndexes.Add(this); for (int valueIndex = 0; valueIndex < maxValueLength; valueIndex++) { base.CurrentIndex = valueIndex; // 更新当前填报索引 FillParameterKey key = null; object elementContainer = null; string parameterValue = ""; for (int i = 0; i < list.Count; i++) { key = list[i].Key; elementContainer = list[i].Value; if (list[i].Key.Type == Matcher.TYPE_SUBMIT || list[i].Key.Type == "BUTTON/SUBMIT") { parameterValue = null; } else if (valueList[i].Length > valueIndex) { parameterValue = valueList[i][valueIndex]; } else { parameterValue = ""; } FillElement(key, elementContainer, parameterValue); } this.Wait(); } list.Clear(); values.Clear(); FillIndexes.RemoveAt(FillIndexes.Count - 1); }
private void FillListElementUncertain(FillParameter parameter) { base.Continue = true; base.CurrentIndex = -1; FillIndexes.Add(this); while (base.Continue) { base.Continue = false; base.CurrentIndex++; FillElement(parameter, null); this.Wait(); } FillIndexes.RemoveAt(FillIndexes.Count - 1); }
/// <summary> /// 填充元素(分割元素) /// </summary> /// <param name="list"></param> /// <param name="values"></param> private void FillListElement(List <KeyValuePair <FillParameterKey, object> > list, List <string> values) { //包含分割字符串 if (list.Count == 1 && (list[0].Key.Type == Matcher.TYPE_SUBMIT || list[0].Key.Type == "BUTTON/SUBMIT" || list[0].Key.Type == Matcher.TYPE_BUTTON)) { //仅包含新增按钮的新增列表 FillListElementUncertain(list[0].Value as FillParameter); list.Clear(); values.Clear(); return; } string[] valueArray = null; int maxValueLength = 0; List <string[]> valueList = new List <string[]>(); foreach (var value in values) { valueArray = value == null ? emptyStringArray : value.Split(base.Converter.SpliterChars[0]); valueList.Add(valueArray); maxValueLength = Math.Max(maxValueLength, valueArray.Length); } base.CurrentIndex = 0; string name = ((FillParameter)(list[0].Value)).Name; bool skipLastButton = (string.IsNullOrEmpty(name) == false && name.Contains("[") && name.Contains("]")); FillIndexes.Add(this); for (int valueIndex = 0; valueIndex < maxValueLength; valueIndex++) { base.CurrentIndex = valueIndex; // 更新当前填报索引 FillParameterKey key = null; //具体的某个控件 object elementContainer = null; string parameterValue = ""; if (valueIndex > 0) { nameNum++; } for (int i = 0; i < list.Count; i++) { key = list[i].Key; elementContainer = list[i].Value; if (list[i].Key.Type == Matcher.TYPE_SUBMIT || list[i].Key.Type == Matcher.TYPE_A || list[i].Key.Type == "BUTTON/SUBMIT" || list[i].Key.Type == Matcher.TYPE_BUTTON) { if (valueIndex == maxValueLength - 1 && skipLastButton) { continue; } parameterValue = null; } else if (valueList[i].Length > valueIndex) { parameterValue = valueList[i][valueIndex]; } else { parameterValue = ""; } //判断所填写是否为新增元素 if (valueIndex > 0) { //修改name FillParameter fp = (FillParameter)elementContainer; name = fp.Name; if (string.IsNullOrEmpty(name) == false && name.Contains("[") && name.Contains("]")) { int index1 = name.IndexOf("["), index2 = name.IndexOf("]", index1 == -1 ? 0 : index1); System.Diagnostics.Trace.Assert(index1 != -1 && index2 != -1); string left = name.Substring(0, index1); string right = name.Substring(index2 + 1); //拼接name fp.Name = string.Format("{0}[{1}]{2}", left, nameNum, right); fp.FindCode = ""; } } FillElement(key, elementContainer, parameterValue); }//end for this.Wait(); } FillIndexes.RemoveAt(FillIndexes.Count - 1); list.Clear(); values.Clear(); }