From fd3c74df4d30a88d490d0c5b469df821f1bb2d78 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 04 八月 2020 14:53:25 +0800
Subject: [PATCH] 更换新接口之前的备份
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs | 194 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 186 insertions(+), 8 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
index cc3c9ca..c92cefd 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
@@ -160,7 +160,7 @@
home.Name = residenceName;
home.Save();
//浣忓畢淇敼鍚嶇О鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
- UserView.UserPage.Instance.RefreshForm = true;
+ UserView.UserPage.Instance.RefreshAllForm = true;
}
@@ -176,7 +176,7 @@
public House GetHouseByHouseId(string houseId)
{
var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, houseId, $"House_{houseId}.json");
- var file = Shared.IO.FileUtils.ReadFile(path);
+ var file = HdlFileLogic.Current.ReadFileByteContent(path);
if (file == null)
{
return null;
@@ -192,7 +192,7 @@
public House GetHouseByFilePath(string filePath)
{
var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, GetHouseIdByFilePath(filePath), filePath);
- var file = Shared.IO.FileUtils.ReadFile(path);
+ var file = HdlFileLogic.Current.ReadFileByteContent(path);
if (file == null)
{
return null;
@@ -206,9 +206,11 @@
/// <summary>
/// 鑾峰彇浜戠浣忓畢鍒楄〃
/// </summary>
- public List<string> GetHomeListsFromDb()
+ /// <param name="checkNetwork">鏄惁妫�娴嬬綉缁�,濡傛灉璁剧疆妫�娴嬬殑璇�,褰撲笉鑳借仈缃戞椂,鐩存帴杩斿洖鏈湴浣忓畢</param>
+ /// <returns></returns>
+ public List<string> GetHomeListsFromDb(bool checkNetwork)
{
- if (HdlWifiLogic.Current.CanAccessHttp == false)
+ if (checkNetwork == true && HdlWifiLogic.Current.CanAccessHttp == false)
{
//褰撳墠鏃犳硶鑱旂綉
return Config.Instance.HomeFilePathList;
@@ -323,7 +325,7 @@
}
listHome.Add(home);
}
- return listHome;
+ return this.SortHouse(listHome);
}
/// <summary>
@@ -350,7 +352,7 @@
if (arryHouse.Length > 0)
{
//璇诲彇鏂囦欢鍐呭
- var textValue = UserCenterLogic.LoadFileContent(System.IO.Path.Combine(nowPath, arryHouse[0]));
+ var textValue = HdlFileLogic.Current.ReadFileTextContent(System.IO.Path.Combine(nowPath, arryHouse[0]));
if (textValue == null)
{
continue;
@@ -359,7 +361,183 @@
listHome.Add(myHouse);
}
}
- return listHome;
+ return this.SortHouse(listHome);
+ }
+
+ #endregion
+
+ #region 鈻� 浣忓畢鎺掑簭___________________________
+
+ /// <summary>
+ /// 浣忓畢鎺掑簭
+ /// </summary>
+ /// <param name="i_listHouse"></param>
+ /// <returns></returns>
+ public List<House> SortHouse(List<House> i_listHouse)
+ {
+ //浠庝竴鍫嗘枃瀛椾腑,鑾峰彇杩欎竴鍫嗘枃瀛楅噷闈㈡暟瀛楀瓧绗︿覆鐨勬渶闀块暱搴�
+ var listName = new List<string>();
+ foreach (var house in i_listHouse)
+ {
+ listName.Add(house.Name);
+ }
+ int numberLength = this.GetNumberMaxLength(listName);
+
+ var listSort = new List<string[]>();
+ var dicHouse = new Dictionary<string, House>();
+ foreach (var house in i_listHouse)
+ {
+ //涓存椂缂撳瓨
+ dicHouse[house.Id] = house;
+
+ var strArry = new string[2];
+ strArry[0] = house.Id;
+ strArry[1] = string.Empty;
+
+ string value = string.Empty;
+ foreach (var c in house.Name)
+ {
+ if (char.IsNumber(c) == true)
+ {
+ //鏁板瓧
+ value += c.ToString();
+ continue;
+ }
+ else if (value != string.Empty)
+ {
+ //濡傛灉鎴块棿鍚嶅瓧甯︽湁鏁板瓧鐨勮瘽,鍒欏乏杈瑰姞闆�,鍥犱负杩欓噷鏈変釜鎺掑簭鐨勯棶棰�
+ strArry[1] += value.PadLeft(numberLength, '0');
+ value = string.Empty;
+ }
+ strArry[1] += c.ToString();
+ }
+ if (value != string.Empty)
+ {
+ //浠ユ暟瀛楃粨灏剧殑璇�
+ strArry[1] += value.PadLeft(numberLength, '0');
+ }
+ listSort.Add(strArry);
+ }
+ //鎺掑簭
+ listSort.Sort((obj1, obj2) =>
+ {
+ if (obj1[1].CompareTo(obj2[1]) > 0)
+ {
+ return 1;
+ }
+ return -1;
+ });
+ var listSortHouse = new List<House>();
+ foreach (var strArry in listSort)
+ {
+ listSortHouse.Add(dicHouse[strArry[0]]);
+ }
+ return listSortHouse;
+ }
+
+ /// <summary>
+ /// 浜戠浣忓畢鎺掑簭
+ /// </summary>
+ /// <param name="i_listData"></param>
+ /// <returns></returns>
+ public List<Common.ResponseEntity.ResidenceObj> SortHouse(List<Common.ResponseEntity.ResidenceObj> i_listData)
+ {
+ //浠庝竴鍫嗘枃瀛椾腑,鑾峰彇杩欎竴鍫嗘枃瀛楅噷闈㈡暟瀛楀瓧绗︿覆鐨勬渶闀块暱搴�
+ var listName = new List<string>();
+ foreach (var house in i_listData)
+ {
+ listName.Add(house.Name);
+ }
+ int numberLength = this.GetNumberMaxLength(listName);
+
+ var listSort = new List<string[]>();
+ var dicHouse = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
+ foreach (var house in i_listData)
+ {
+ //涓存椂缂撳瓨
+ dicHouse[house.Id] = house;
+
+ var strArry = new string[2];
+ strArry[0] = house.Id;
+ strArry[1] = string.Empty;
+
+ string value = string.Empty;
+ foreach (var c in house.Name)
+ {
+ if (char.IsNumber(c) == true)
+ {
+ //鏁板瓧
+ value += c.ToString();
+ continue;
+ }
+ else if (value != string.Empty)
+ {
+ //濡傛灉鎴块棿鍚嶅瓧甯︽湁鏁板瓧鐨勮瘽,鍒欏乏杈瑰姞闆�,鍥犱负杩欓噷鏈変釜鎺掑簭鐨勯棶棰�
+ strArry[1] += value.PadLeft(numberLength, '0');
+ value = string.Empty;
+ }
+ strArry[1] += c.ToString();
+ }
+ if (value != string.Empty)
+ {
+ //浠ユ暟瀛楃粨灏剧殑璇�
+ strArry[1] += value.PadLeft(numberLength, '0');
+ }
+ listSort.Add(strArry);
+ }
+ //鎺掑簭
+ listSort.Sort((obj1, obj2) =>
+ {
+ if (obj1[1].CompareTo(obj2[1]) > 0)
+ {
+ return 1;
+ }
+ return -1;
+ });
+ var listSortHouse = new List<Common.ResponseEntity.ResidenceObj>();
+ foreach (var strArry in listSort)
+ {
+ listSortHouse.Add(dicHouse[strArry[0]]);
+ }
+ return listSortHouse;
+ }
+
+ /// <summary>
+ /// 浠庝竴鍫嗘枃瀛椾腑,鑾峰彇杩欎竴鍫嗘枃瀛楅噷闈㈡暟瀛楀瓧绗︿覆鐨勬渶闀块暱搴�
+ /// </summary>
+ /// <param name="listText"></param>
+ /// <returns></returns>
+ private int GetNumberMaxLength(List<string> listText)
+ {
+ int maxLength = 0;
+ foreach (var text in listText)
+ {
+ string value = string.Empty;
+ foreach (var c in text)
+ {
+ if (char.IsNumber(c) == true)
+ {
+ //鏁板瓧
+ value += c.ToString();
+ continue;
+ }
+ else if (value != string.Empty)
+ {
+ //鍒ゆ柇鏁板瓧闀垮害
+ if (maxLength <= value.Length)
+ {
+ maxLength = value.Length;
+ }
+ value = string.Empty;
+ }
+ }
+ //鍒ゆ柇鏁板瓧闀垮害
+ if (maxLength <= value.Length)
+ {
+ maxLength = value.Length;
+ }
+ }
+ return maxLength;
}
#endregion
--
Gitblit v1.8.0