|
@@ -224,22 +224,24 @@ namespace PTMedicalInsurance.Forms
|
|
|
}
|
|
|
}
|
|
|
fields[1] = fields[1].Replace("【】", "");
|
|
|
- lstMap.Items.Remove(lstMap.SelectedItem);
|
|
|
FieldMapping field = QuerySelectedField();
|
|
|
if (field != null)
|
|
|
{
|
|
|
this.fieldMappings.Remove(field);
|
|
|
}
|
|
|
+ lstMap.Items.Remove(lstMap.SelectedItem);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private FieldMapping QuerySelectedField()
|
|
|
{
|
|
|
if (lstMap.SelectedItem == null) return null;
|
|
|
-
|
|
|
+ // TODO:如果目标是数组未处理
|
|
|
string text = lstMap.SelectedItem.ToString();
|
|
|
string[] fields = text.Split(separator.ToCharArray());
|
|
|
// remove from fieldMapping
|
|
|
- FieldMapping field = this.fieldMappings.FirstOrDefault(m => (m.Source == fields[0] && m.Target == fields[1]) || (m.Target == fields[0] && m.Value == fields[1]));
|
|
|
+ string txtValue = fields[1].Replace("【","").Replace("】","");
|
|
|
+ FieldMapping field = this.fieldMappings.FirstOrDefault(m => (m.Source == fields[0] && m.Target == fields[1]) || (m.Target == fields[0] && m.Value == txtValue));
|
|
|
return field;
|
|
|
}
|
|
|
|
|
@@ -439,16 +441,61 @@ namespace PTMedicalInsurance.Forms
|
|
|
string text = lstLocal.SelectedItem + separator + "【" + strValue + "】";
|
|
|
lstMap.Items.Add(text);
|
|
|
|
|
|
- FieldMapping fieldMapping = new FieldMapping();
|
|
|
- fieldMapping.Target = lstLocal.SelectedItem.ToString();
|
|
|
- fieldMapping.Value = strValue;
|
|
|
+ string target = lstLocal.SelectedItem.ToString();
|
|
|
|
|
|
- this.fieldMappings.Add(fieldMapping);
|
|
|
+ if (target.Contains(arrayPattern))
|
|
|
+ {
|
|
|
+ string prefix_target = target.Substring(0, target.IndexOf(arrayPattern) + 2);
|
|
|
+ var rtn = GetFieldMappingByTarget(prefix_target);
|
|
|
+ FieldMapping fieldMapping = rtn.mapping;
|
|
|
+ if (!rtn.exists)
|
|
|
+ {
|
|
|
+ this.fieldMappings.Add(rtn.mapping);
|
|
|
+ }
|
|
|
+
|
|
|
+ fieldMapping.Target = prefix_target;
|
|
|
+ List<FieldMapping> childs = fieldMapping.Child ?? new List<FieldMapping>();
|
|
|
+ string subKey = target.Replace(prefix_target + ".", "");
|
|
|
+
|
|
|
+ FieldMapping subField = childs.FirstOrDefault(m => (m.Target == subKey));
|
|
|
+ if (subField == null)
|
|
|
+ {
|
|
|
+ subField = new FieldMapping();
|
|
|
+ childs.Add(subField);
|
|
|
+ }
|
|
|
+ subField.Source = null;
|
|
|
+ subField.Target = subKey;
|
|
|
+ subField.Value = strValue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var rtn = GetFieldMappingByTarget(target);
|
|
|
+ FieldMapping fieldMapping = rtn.mapping;
|
|
|
+ if (!rtn.exists)
|
|
|
+ {
|
|
|
+ this.fieldMappings.Add(rtn.mapping);
|
|
|
+ }
|
|
|
+ fieldMapping.Target = target;
|
|
|
+ fieldMapping.Value = strValue;
|
|
|
+ }
|
|
|
|
|
|
// clear selectedItem
|
|
|
lstLocal.Items.Remove(lstLocal.SelectedItem);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private (bool exists,FieldMapping mapping) GetFieldMappingByTarget(string target)
|
|
|
+ {
|
|
|
+ FieldMapping fieldMapping = this.fieldMappings.FirstOrDefault(m => (m.Target == target));
|
|
|
+ //数组中的固定值
|
|
|
+ if (fieldMapping == null)
|
|
|
+ {
|
|
|
+ fieldMapping = new FieldMapping();
|
|
|
+ return (false, fieldMapping);
|
|
|
+ }
|
|
|
+ return (true,fieldMapping);
|
|
|
+ }
|
|
|
+
|
|
|
private void AddGlobalVar(string key)
|
|
|
{
|
|
|
FieldMapping fieldMapping = new FieldMapping();
|