| | |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", KeyValue); |
| | | LogicMethod.dictionary(dic, "value", selectedValue); |
| | | AddDictionaryList(KeyValue, dic, dicSateteList); |
| | | AddDictionaryList(KeyValue, dic); |
| | | } |
| | | /// <summary> |
| | | /// 更新数据列表 |
| | | /// </summary> |
| | | /// <param name="keyValue">设备属性值,云雀上定义好的</param> |
| | | /// <param name="dictionary">选中数据</param> |
| | | /// <param name="dicList">存储数据列表</param> |
| | | /// <param name="dictionary">添加选中数据</param> |
| | | /// <returns></returns> |
| | | private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary, List<Dictionary<string, string>> dicList) |
| | | private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary) |
| | | { |
| | | int indexValue = -1; |
| | | for (int i = 0; i < dicList.Count; i++) |
| | | for (int i = 0; i < dicSateteList.Count; i++) |
| | | { |
| | | var dic = dicList[i]; |
| | | var dic = dicSateteList[i]; |
| | | if (dic.ContainsValue(keyValue)) |
| | | { |
| | | //判断是否存在 |
| | |
| | | if (indexValue != -1) |
| | | { |
| | | //存在移除 |
| | | dicList.RemoveAt(indexValue); |
| | | dicSateteList.RemoveAt(indexValue); |
| | | //重新添加 |
| | | dicList.Insert(indexValue, dictionary); |
| | | dicSateteList.Insert(indexValue, dictionary); |
| | | } |
| | | else |
| | | { |
| | | //新添加 |
| | | dicList.Add(dictionary); |
| | | dicSateteList.Add(dictionary); |
| | | } |
| | | |
| | | } |