From 3292b5b7fe6c14476df002d78bf186e80f2aab08 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 18 五月 2020 09:30:30 +0800
Subject: [PATCH] 2020-05-28-1
---
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs | 532 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 400 insertions(+), 132 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
index bcfc50f..0dd08fd 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
@@ -16,9 +16,13 @@
/// </summary>
private VerticalListControl listView = null;
/// <summary>
- /// 浣忓畢鏁版嵁
+ /// 浣忓畢鏁版嵁(鏈夌綉鏃朵娇鐢�)
/// </summary>
private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
+ /// <summary>
+ /// 浣忓畢鏁版嵁(鏃犵綉鏃朵娇鐢�)
+ /// </summary>
+ private List<House> listLocalHouse = null;
/// <summary>
/// 浣忓畢椤哄簭
/// </summary>
@@ -36,16 +40,20 @@
//璁剧疆鏍囬淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.ResidenceManagement));
- //鍙充笂娣诲姞鎸夐挳
- var btnTopIcon = new MostRightIconControl(69, 69);
- btnTopIcon.UnSelectedImagePath = "Item/Add.png";
- topFrameLayout.AddChidren(btnTopIcon);
- btnTopIcon.InitControl();
- btnTopIcon.ButtonClickEvent += (sender, e) =>
+ //铏氭嫙浣忓畢鏃犳硶鏂板缓浣忓畢
+ if (Common.Config.Instance.Home.IsVirtually == false)
{
- //鏄剧ず娣诲姞浣忓畢鍚嶇О鐨勭敾闈�
- this.ShowAddNameForm();
- };
+ //鍙充笂娣诲姞鎸夐挳
+ var btnTopIcon = new MostRightIconControl(69, 69);
+ btnTopIcon.UnSelectedImagePath = "Item/Add.png";
+ topFrameLayout.AddChidren(btnTopIcon);
+ btnTopIcon.InitControl();
+ btnTopIcon.ButtonClickEvent += (sender, e) =>
+ {
+ //鏄剧ず娣诲姞浣忓畢鍚嶇О鐨勭敾闈�
+ this.ShowAddNameForm();
+ };
+ }
//鍒濆鍖栦腑閮ㄦ帶浠�
this.InitMiddleFrame();
@@ -64,46 +72,75 @@
if (strData != null)
{
listResidenceSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData);
- strData = null;
}
listView = new VerticalListControl(29);
- listView.Y = Application.GetRealHeight(-6);
listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
listView.BackgroundColor = UserCenterColor.Current.White;
bodyFrameLayout.AddChidren(listView);
- HdlThreadLogic.Current.RunThread(() =>
+ //璁剧疆浣忓畢淇℃伅
+ this.SetResidenceInfo(1);
+ }
+
+ /// <summary>
+ /// 璁剧疆浣忓畢淇℃伅(1:鍏堣鍙栦簯绔�,鏃犳硶鑱旂綉,鍐嶈鍙栨湰鍦� 2:鍙浜戠 3:鍙鏈湴)
+ /// </summary>
+ /// <param name="div">1:鍏堣鍙栦簯绔�,鏃犳硶鑱旂綉,鍐嶈鍙栨湰鍦� 2:鍙浜戠 3:鍙鏈湴</param>
+ private void SetResidenceInfo(int div)
+ {
+ HdlThreadLogic.Current.RunThread(async () =>
{
- //璁剧疆浣忓畢淇℃伅
- this.SetResidenceInfo();
+ //铏氭嫙浣忓畢鐨勮瘽,鍙鏈湴
+ if (div == 3 || Config.Instance.Home.IsVirtually == true)
+ {
+ //鍙鏈湴
+ this.SetResidenceInfoByOffline();
+ }
+ else
+ {
+ //寮�鍚繘搴︽潯
+ this.ShowProgressBar();
+ //璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)
+ var result = await this.SetResidenceInfoByOnline();
+ if (result == true)
+ {
+ //浜戠璇诲彇鎴愬姛
+ this.CloseProgressBar();
+ return;
+ }
+ if (div == 2)
+ {
+ //濡傛灉鍙浜戠 鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return;
+ }
+ //濡傛灉鍦ㄦ病缃戠殑鎯呭喌涓�,浠庢枃浠跺す璺緞涓幏鍙栧叏閮ㄤ綇瀹�,鐒跺悗鏄剧ず
+ this.SetResidenceInfoByOffline();
+
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ }
});
}
#endregion
- #region 鈻� 璁剧疆浣忓畢淇℃伅_______________________
+ #region 鈻� 璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)_____________
/// <summary>
- /// 璁剧疆浣忓畢淇℃伅
+ /// 璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)
/// </summary>
- private async void SetResidenceInfo()
+ private async System.Threading.Tasks.Task<bool> SetResidenceInfoByOnline()
{
- //寮�鍚繘搴︽潯
- this.ShowProgressBar();
-
//鑾峰彇浣忓畢淇℃伅
var Pra = new GetResidenceInfoPra();
- string resultData = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra);
+ var listNotCheck = new List<string>() { "NotSetAgain" };
+ string resultData = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra, listNotCheck);
if (resultData == null)
{
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar(ShowReLoadMode.YES);
- return;
+ return false;
}
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
-
var pageData = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResidenceRes>(resultData);
//鏆傛椂瀛樺偍鏁版嵁
@@ -117,43 +154,52 @@
listResidenceSort.Add(pageData.PageData[i].Id);
}
}
+ for (int i = 0; i < listResidenceSort.Count; i++)
+ {
+ //绉婚櫎鎺変笉瀛樺湪浜嗙殑椤哄簭
+ if (dicData.ContainsKey(listResidenceSort[i]) == false)
+ {
+ listResidenceSort.RemoveAt(i);
+ i--;
+ }
+ }
//淇濆瓨椤哄簭
string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ResidenceSortFile);
UserCenterLogic.SaveFileContent(fullName, listResidenceSort);
- Application.RunOnMainThread(() =>
+ HdlThreadLogic.Current.RunMain(() =>
{
if (this.Parent == null)
{
return;
}
- listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
+ listView.Height = bodyFrameLayout.Height;
this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
for (int i = 0; i < listResidenceSort.Count; i++)
{
- var info = dicData[listResidenceSort[i]];
- if (info.IsOthreShare == false)
+ if (dicData.ContainsKey(listResidenceSort[i]) == false)
{
- //鏀堕泦璇ヨ处鍙锋墍鎷ユ湁鐨勮嚜宸辩殑浣忓畢鐨勬暟鎹�
- this.dicResidenceData[info.Id] = info;
+ continue;
}
- this.AddRowLayout(info, i != listResidenceSort.Count - 1);
+ var info = dicData[listResidenceSort[i]];
+
+ //鏀堕泦璇ヨ处鍙蜂綇瀹呯殑鏁版嵁
+ this.dicResidenceData[info.Id] = info;
+ //娣诲姞浣忓畢鐨勮(鏈夌綉鎯呭喌)
+ this.AddRowLayoutByOnline(info, i != listResidenceSort.Count - 1);
}
//璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
this.listView.AdjustRealHeight(Application.GetRealHeight(23));
});
+ return true;
}
- #endregion
-
- #region 鈻� 娣诲姞浣忓畢鐨勮_______________________
-
/// <summary>
- /// 娣诲姞浣忓畢鐨勮
+ /// 娣诲姞浣忓畢鐨勮(鏈夌綉鎯呭喌)
/// </summary>
/// <param name="info"></param>
- private void AddRowLayout(Common.ResponseEntity.ResidenceObj info, bool addLine)
+ private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, bool addLine)
{
var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
this.listView.AddChidren(rowLayout);
@@ -206,20 +252,26 @@
{
HdlThreadLogic.Current.RunThread(async () =>
{
- ProgressBar.Show();
+ //寮�鍚繘搴︽潯
+ this.ShowProgressBar();
+
+ //妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
+ this.CheckIsExsitResidence(info);
+
Config.Instance.HomeId = info.Id;
- Global.CreateHomeDirectory(info.Id);
+ //閲嶆柊鍒濆鍖栦綇瀹呭璞�
+ Config.Instance.Home = House.GetHouseByHouseId(info.Id);
Config.Instance.Save();
//鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
- await UserCenterLogic.InitUserCenterMenmoryAndThread();
+ await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
- Room.InitAllRoom();
-
- Application.RunOnMainThread(() =>
+ HdlThreadLogic.Current.RunMain(() =>
{
//閲嶆柊鍒锋柊鍒楄〃
this.listView.RemoveAll();
- this.SetResidenceInfo();
+ this.SetResidenceInfo(2);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
});
});
});
@@ -239,17 +291,137 @@
return;
}
//鏇存敼
- var btnChanged = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false);
- btnChanged.BackgroundColor = 0xff4a4a4a;
- btnChanged.TextSize = 12;
- btnChanged.TextColor = UserCenterColor.Current.White;
- btnChanged.TextAlignment = TextAlignment.Center;
+ var btnChanged = rowLayout.AddEditorControl();
btnChanged.TextID = R.MyInternationalizationString.uChanged1;
- rowLayout.AddRightView(btnChanged);
btnChanged.ButtonClickEvent += (sender, e) =>
{
//鏄剧ず缂栬緫鍚嶇О鐣岄潰
- this.ShowEditorNameForm(info, btnHome);
+ this.ShowEditorNameForm(info, null, btnHome);
+ };
+ }
+
+ #endregion
+
+ #region 鈻� 璁剧疆浣忓畢淇℃伅(鏃犵綉鎯呭喌)_____________
+
+ /// <summary>
+ /// 璁剧疆浣忓畢淇℃伅(鏃犵綉鎯呭喌)
+ /// </summary>
+ private void SetResidenceInfoByOffline()
+ {
+ //浠庢枃浠跺す涓幏鍙栧叏閮ㄧ殑浣忓畢瀵硅薄
+ this.listLocalHouse = HdlResidenceLogic.Current.GetAllLocalResidenceListByDirectory();
+ if (listLocalHouse.Count == 0)
+ {
+ return;
+ }
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ listView.Height = bodyFrameLayout.Height;
+
+ for (int i = 0; i < listLocalHouse.Count; i++)
+ {
+ //娣诲姞浣忓畢鐨勮(鏃犵綉鎯呭喌)
+ this.AddRowLayoutByOffline(listLocalHouse[i], i != listLocalHouse.Count - 1);
+ }
+ //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+ this.listView.AdjustRealHeight(Application.GetRealHeight(23));
+ });
+ }
+
+ /// <summary>
+ /// 娣诲姞浣忓畢鐨勮(鏃犵綉鎯呭喌)
+ /// </summary>
+ /// <param name="i_home"></param>
+ private void AddRowLayoutByOffline(House i_home, bool addLine)
+ {
+ var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
+ this.listView.AddChidren(rowLayout);
+
+ //鍥炬爣
+ var btnIcon = rowLayout.frameTable.AddLeftIcon(81);
+ btnIcon.UnSelectedImagePath = "Item/ResidenceIcon.png";
+ //褰撳墠浣忓畢
+ NormalViewControl btnHome = null;
+ if (i_home.Id == Config.Instance.Home.Id)
+ {
+ //浣忓畢鍚嶇О
+ btnHome = rowLayout.frameTable.AddLeftCaption(i_home.Name, 800, 60, true);
+ btnHome.TextSize = 15;
+ btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
+ rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEventOnly);
+
+ //褰撳墠浣忓畢
+ var btnNowView = rowLayout.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowResidence), 800, 49, true);
+ btnNowView.Y = Application.GetRealHeight(72) + rowLayout.chidrenYaxis;
+ btnNowView.TextSize = 12;
+ btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
+ rowLayout.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
+ }
+ else
+ {
+ //浣忓畢鍚嶇О
+ btnHome = rowLayout.frameTable.AddLeftCaption(i_home.Name, 800, true);
+ btnHome.TextSize = 15;
+ }
+ //鍙崇澶�
+ rowLayout.frameTable.AddRightArrow();
+ if (addLine == true)
+ {
+ //搴曠嚎
+ rowLayout.frameTable.AddBottomLine();
+ }
+
+ rowLayout.frameTable.ButtonClickEvent += (sender, e) =>
+ {
+ if (i_home.Id != Config.Instance.Home.Id)
+ {
+ //纭鍒囨崲褰撳墠浣忓畢鍒般�屻��?
+ string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
+ if (msg.Contains("{0}") == true)
+ {
+ msg = string.Format(msg, i_home.Name);
+ }
+ this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ {
+ HdlThreadLogic.Current.RunThread(async () =>
+ {
+ this.ShowProgressBar();
+
+ Config.Instance.HomeId = i_home.Id;
+ //閲嶆柊鍒濆鍖栦綇瀹呭璞�
+ Config.Instance.Home = House.GetHouseByHouseId(i_home.Id);
+ Config.Instance.Save();
+ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+ await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //閲嶆柊鍒锋柊鍒楄〃
+ this.listView.RemoveAll();
+ this.SetResidenceInfo(3);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ });
+ });
+ });
+ }
+ else
+ {
+ //妫�娴嬭兘鍚﹀垹闄や綇瀹�
+ bool flage = this.CheckIsCanDeleteResidence(i_home);
+ var form = new ResidenceManagementForm();
+ form.AddForm(flage);
+ }
+ };
+ //鏇存敼
+ var btnChanged = rowLayout.AddEditorControl();
+ btnChanged.TextID = R.MyInternationalizationString.uChanged1;
+ btnChanged.ButtonClickEvent += (sender, e) =>
+ {
+ //鏄剧ず缂栬緫鍚嶇О鐣岄潰
+ this.ShowEditorNameForm(null, i_home, btnHome);
};
}
@@ -260,16 +432,18 @@
/// <summary>
/// 鏄剧ず缂栬緫浣忓畢鍚嶇О鐣岄潰
/// </summary>
- /// <param name="info"></param>
- private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
+ /// <param name="info">鏈夌綉鏃朵娇鐢�</param>
+ /// <param name="i_house">鏃犵綉鏃堕�傜敤</param>
+ private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, House i_house, NormalViewControl btnHome)
{
+ string oldName = info != null ? info.Name : i_house.Name;
//鐢熸垚涓�涓脊绐楃敾闈�
- var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
+ var dialogForm = new DialogInputControl();
//缂栬緫浣忓畢
dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedName));
//璇疯緭鍏ヤ綇瀹呭悕绉�
dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName));
- dialogForm.Text = info.Name;
+ dialogForm.Text = oldName;
//鎸変笅纭鎸夐挳
dialogForm.ComfirmClickEvent += ((textValue) =>
@@ -283,11 +457,25 @@
}
//鐢婚潰鍏抽棴
dialogForm.CloseDialog();
-
- if (info.Name != textValue)
+ if (oldName != textValue)
{
- //缂栬緫浜戠鐨勪綇瀹呭悕绉�
- this.EditorResidenceName(textValue, info);
+ if (info != null)
+ {
+ //缂栬緫浜戠鐨勪綇瀹呭悕绉�
+ this.EditorResidenceName(textValue, info, btnHome);
+ }
+ else
+ {
+ //鐩存帴缂栬緫浣忓畢缂撳瓨
+ if (this.CheckIsCanSaveResidence(i_house.Id, textValue, true) == false)
+ {
+ return;
+ }
+ //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
+ House.EditorHouseByHouseId(i_house.Id, textValue);
+ //鏇存敼鏄剧ず鐨勫悕瀛�
+ btnHome.Text = textValue;
+ }
}
});
}
@@ -298,7 +486,7 @@
/// <param name="ResidenceName"></param>
/// <param name="info"></param>
/// <returns></returns>
- private async void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info)
+ private async void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
{
//妫�娴嬭兘鍚︿繚瀛樹綇瀹�
if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
@@ -311,23 +499,21 @@
var Pra = new EditorResidencePra();
Pra.HomeId = info.Id;
Pra.Name = ResidenceName;
- if (info.IsOthreShare == true)
- {
- Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
- }
+ Pra.IsOtherAccountCtrl = false;
+ Pra.LoginAccessToken = Config.Instance.Token;
+
//缂栬緫浣忓畢
- bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", info.IsOthreShare, Pra);
- if (flage == false)
+ bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+
+ if (flage == true)
{
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
- return;
+ //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
+ House.EditorHouseByHouseId(info.Id, ResidenceName);
+ //鏇存敼鏄剧ず鐨勫悕瀛�
+ btnHome.Text = ResidenceName;
}
- //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
- House.EditorHouseByHouseId(info.Id, ResidenceName);
- //閲嶆柊鍒锋柊鍒楄〃
- this.listView.RemoveAll();
- this.SetResidenceInfo();
}
#endregion
@@ -340,7 +526,7 @@
private void ShowAddNameForm()
{
//鐢熸垚涓�涓脊绐楃敾闈�
- var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
+ var dialogForm = new DialogInputControl();
//鍒涘缓浣忓畢
dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uCreatResidence));
//璇疯緭鍏ヤ綇瀹呭悕绉�
@@ -394,7 +580,7 @@
House.AddHouse(newInfo[0].Id, ResidenceName, 0);
//閲嶆柊鍒锋柊鍒楄〃
this.listView.RemoveAll();
- this.SetResidenceInfo();
+ this.SetResidenceInfo(2);
}
#endregion
@@ -402,26 +588,88 @@
#region 鈻� 涓�鑸柟娉昣__________________________
/// <summary>
- /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�
+ /// 妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
+ /// </summary>
+ /// <param name="info"></param>
+ private void CheckIsExsitResidence(Common.ResponseEntity.ResidenceObj info)
+ {
+ var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, info.Id);
+ bool isExsit = System.IO.Directory.Exists(path);
+ if (isExsit == true) { return; }
+ //鍒涘缓鏂囦欢澶�
+ Global.CreateHomeDirectory(info.Id);
+ //鍒涘缓鏂扮殑浣忓畢
+ var house = new House();
+ house.Id = info.Id;
+ house.Name = info.Name;
+ house.IsOthreShare = info.IsOthreShare;
+ house.AccountType = info.AccountType;
+ house.MainUserDistributedMark = info.MainUserDistributedMark;
+ house.Longitude = info.Longitude;
+ house.Latitude = info.Latitude;
+ house.Save(false);
+
+ string fileName = house.FileName;
+ if (Config.Instance.HomeFilePathList.Contains(fileName) == false)
+ {
+ //娣诲姞鍒楄〃
+ Config.Instance.HomeFilePathList.Add(fileName);
+ }
+ }
+
+ /// <summary>
+ /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�(鏈夌綉浣跨敤)
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private bool CheckIsCanDeleteResidence(Common.ResponseEntity.ResidenceObj info)
{
- if (this.dicResidenceData.Count == 1)
+ if (info.IsOthreShare == false)
{
- //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓嚜宸辩殑浣忓畢锛屽綋鍒犻櫎杩欎釜浣忓畢鏃讹紝鎻愮ず涓嶈兘鍒犻櫎
- //鍥犱负鏈�灏戣鏈変竴涓綇瀹�
- if (this.dicResidenceData.ContainsKey(info.Id) == true)
+ int myCount = 0;
+ foreach (var data in this.dicResidenceData.Values)
+ {
+ if (data.IsOthreShare == false)
+ {
+ myCount++;
+ }
+ }
+ //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓嚜宸辩殑浣忓畢锛屽垯涓嶈兘鍐嶅垹闄�
+ if (myCount == 1)
{
return false;
}
}
- if (info.IsOthreShare == true)
+ return true;
+ }
+
+ /// <summary>
+ /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�(鏃犵綉浣跨敤)
+ /// </summary>
+ /// <param name="info"></param>
+ /// <returns></returns>
+ private bool CheckIsCanDeleteResidence(House i_house)
+ {
+ if (i_house.IsVirtually == false)
{
- //鍒嗕韩杩囨潵鐨勪綇瀹呬笉鑳藉垹闄�
+ //闈炶櫄鎷熶綇瀹呴兘涓嶅厑璁稿垹闄�,鍙湁鍦ㄨ兘鑱旂綉鐨勬椂鍊�,鎵嶈兘鍒犻櫎
return false;
}
+
+ int myCount = 0;
+ foreach (var data in this.listLocalHouse)
+ {
+ if (data.IsVirtually == true)
+ {
+ myCount++;
+ }
+ }
+ //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓櫄鎷熺殑浣忓畢锛屽垯涓嶈兘鍐嶅垹闄�
+ if (myCount == 1)
+ {
+ return false;
+ }
+
return true;
}
@@ -434,16 +682,43 @@
/// <returns></returns>
private bool CheckIsCanSaveResidence(string residenceId, string residenceName, bool isEditor)
{
- //浣忓畢鍚嶅瓧閲嶅妫�娴�
- foreach (string strId in this.dicResidenceData.Keys)
+ if (this.dicResidenceData != null)
{
- if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
+ //浣忓畢鍚嶅瓧閲嶅妫�娴�
+ foreach (string strId in this.dicResidenceData.Keys)
{
- //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
- int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
- string msg = Language.StringByID(msgId);
- this.ShowMassage(ShowMsgType.Error, msg);
- return false;
+ if (this.dicResidenceData[strId].IsOthreShare == true)
+ {
+ //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
+ continue;
+ }
+ if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
+ {
+ //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
+ int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
+ string msg = Language.StringByID(msgId);
+ this.ShowMassage(ShowMsgType.Error, msg);
+ return false;
+ }
+ }
+ }
+ else
+ {
+ foreach (var myHouse in this.listLocalHouse)
+ {
+ if (myHouse.IsOthreShare == true)
+ {
+ //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
+ continue;
+ }
+ if (residenceId != myHouse.Id && residenceName == myHouse.Name)
+ {
+ //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
+ int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
+ string msg = Language.StringByID(msgId);
+ this.ShowMassage(ShowMsgType.Error, msg);
+ return false;
+ }
}
}
return true;
@@ -458,22 +733,38 @@
/// </summary>
public override int FormActionAgainEvent()
{
- foreach (string keys in dicResidenceData.Keys)
+ if (dicResidenceData != null)
{
- if (Config.Instance.HomeFilePathList.Contains($"House_{keys}.json") == false)
+ foreach (string keys in dicResidenceData.Keys)
{
- //淇濆瓨椤哄簭
- listResidenceSort.Remove(keys);
- Room.CurrentRoom.SaveFloorSort(listResidenceSort);
-
- this.listView.RemoveAll();
- //鏁版嵁宸茬粡鍙樻洿
- HdlThreadLogic.Current.RunThread(() =>
+ if (Config.Instance.HomeFilePathList.Contains($"House_{keys}.json") == false)
{
- //閲嶆柊璁剧疆浣忓畢淇℃伅
- this.SetResidenceInfo();
- });
- break;
+ //淇濆瓨椤哄簭
+ listResidenceSort.Remove(keys);
+ HdlRoomLogic.Current.SaveFloorSort(listResidenceSort);
+
+ this.listView.RemoveAll();
+ //鏁版嵁宸茬粡鍙樻洿 閲嶆柊璁剧疆浣忓畢淇℃伅
+ this.SetResidenceInfo(2);
+ break;
+ }
+ }
+ }
+ else
+ {
+ //妫�娴嬭繕鏈夎繖涓綇瀹呮枃浠跺悧
+ var strPath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid);
+ foreach (var myHouse in this.listLocalHouse)
+ {
+ string fullName = System.IO.Path.Combine(strPath, myHouse.FileName);
+ //濡傛灉涓嶅瓨鍦ㄤ簡鐨勮瘽
+ if (System.IO.File.Exists(fullName) == false)
+ {
+ //鏁版嵁宸茬粡鍙樻洿 閲嶆柊璁剧疆浣忓畢淇℃伅
+ this.listView.RemoveAll();
+ this.SetResidenceInfo(3);
+ return 1;
+ }
}
}
return 1;
@@ -513,7 +804,7 @@
public PageSettingInfo PageSetting = new PageSettingInfo()
{
Page = 1,
- PageSize = 500
+ PageSize = 5000
};
}
@@ -545,29 +836,6 @@
/// ZigbeeHomeGuid
/// </summary>
public string Id = string.Empty;
- }
-
- /// <summary>
- /// 缂栬緫浣忓畢鐨勫惎鍔ㄥ弬鏁�
- /// </summary>
- public class EditorResidencePra : IfacePraCommon
- {
- /// <summary>
- /// RequestVersion
- /// </summary>
- public string RequestVersion = Common.CommonPage.RequestVersion;
- /// <summary>
- /// LoginAccessToken
- /// </summary>
- public string LoginAccessToken = Common.Config.Instance.Token;
- /// <summary>
- /// ZigbeeHomeId
- /// </summary>
- public string HomeId = "";
- /// <summary>
- /// Name
- /// </summary>
- public string Name = string.Empty;
}
#endregion
--
Gitblit v1.8.0