| | |
| | | /// <summary>
|
| | | /// 住宅数据(有网时使用)
|
| | | /// </summary>
|
| | | private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
|
| | | private Dictionary<string, ResidenceInformation> dicResidenceData = null;
|
| | | /// <summary>
|
| | | /// 住宅数据(无网时使用)
|
| | | /// </summary>
|
| | |
| | | private bool SetResidenceInfoByOnline()
|
| | | {
|
| | | //获取住宅信息
|
| | | var Pra = new GetResidenceInfoPra();
|
| | | string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra, new List<string> { "NotCheck" }, false);
|
| | | if (string.IsNullOrEmpty(resultData) == true)
|
| | | var listHouse = HdlResidenceLogic.Current.GetHomeListsFromDb(ShowNetCodeMode.No);
|
| | | if (listHouse == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var pageData = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResidenceRes>(resultData);
|
| | | //排序住宅
|
| | | var listHouse = HdlResidenceLogic.Current.SortHouse(pageData.PageData);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (this.Parent == null)
|
| | |
| | | }
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | |
|
| | | this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
|
| | | this.dicResidenceData = new Dictionary<string, ResidenceInformation>();
|
| | | for (int i = 0; i < listHouse.Count; i++)
|
| | | {
|
| | | var info = listHouse[i];
|
| | |
| | | /// 添加住宅的行(有网情况)
|
| | | /// </summary>
|
| | | /// <param name="info"></param>
|
| | | private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, bool addLine)
|
| | | private void AddRowLayoutByOnline(ResidenceInformation info, bool addLine)
|
| | | {
|
| | | var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
|
| | | this.listView.AddChidren(rowLayout);
|
| | |
| | | if (info.Id == Config.Instance.Home.Id)
|
| | | {
|
| | | //住宅名称
|
| | | btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, 60, true);
|
| | | btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, 60, true);
|
| | | btnHome.TextSize = 15;
|
| | | btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
|
| | | rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEvent);
|
| | |
| | | else
|
| | | {
|
| | | //住宅名称
|
| | | btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, true);
|
| | | btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, true);
|
| | | btnHome.TextSize = 15;
|
| | | }
|
| | | //右箭头
|
| | |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
|
| | | if (msg.Contains("{0}") == true)
|
| | | {
|
| | | msg = string.Format(msg, info.Name);
|
| | | msg = string.Format(msg, info.HomeName);
|
| | | }
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | |
| | | }
|
| | | };
|
| | |
|
| | | if (info.IsOthreShare == true)
|
| | | if (info.IsOtherShare == true)
|
| | | {
|
| | | //分享的,不能更改
|
| | | return;
|
| | |
| | | /// </summary>
|
| | | /// <param name="info">有网时使用</param>
|
| | | /// <param name="i_house">无网时适用</param>
|
| | | private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, House i_house, NormalViewControl btnHome)
|
| | | private void ShowEditorNameForm(ResidenceInformation info, House i_house, NormalViewControl btnHome)
|
| | | {
|
| | | string oldName = info != null ? info.Name : i_house.Name;
|
| | | string oldName = info != null ? info.HomeName : i_house.Name;
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputControl();
|
| | | //编辑住宅
|
| | |
| | | return;
|
| | | }
|
| | | //刷新内存的住宅名
|
| | | HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue);
|
| | | HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue, null, null);
|
| | | //更改显示的名字
|
| | | btnHome.Text = textValue;
|
| | | }
|
| | |
| | | /// <param name="ResidenceName"></param>
|
| | | /// <param name="info"></param>
|
| | | /// <returns></returns>
|
| | | private void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
|
| | | private void EditorResidenceName(string ResidenceName, ResidenceInformation info, NormalViewControl btnHome)
|
| | | {
|
| | | //检测能否保存住宅
|
| | | if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
|
| | |
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName);
|
| | | var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName, null, null);
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //刷新内存的住宅名
|
| | | HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName);
|
| | | HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName, null, null);
|
| | | //更改显示的名字
|
| | | btnHome.Text = ResidenceName;
|
| | | info.Name = ResidenceName;
|
| | | info.HomeName = ResidenceName;
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | var Pra = new AddResidencePra();
|
| | | Pra.Name = ResidenceName;
|
| | | //添加住宅
|
| | | string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/AddHome", false, Pra);
|
| | | if (string.IsNullOrEmpty(resultData) == true)
|
| | | //创建住宅
|
| | | var newId = HdlResidenceLogic.Current.CreatNewResidence(ResidenceName, null, null);
|
| | | this.CloseProgressBar();
|
| | |
|
| | | if (newId != null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //重新刷新列表
|
| | | this.listView.RemoveAll();
|
| | | this.SetResidenceInfo(2);
|
| | | });
|
| | | }
|
| | |
|
| | | var newInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NewResidenceInfo>>(resultData);
|
| | |
|
| | | HdlResidenceLogic.Current.AddHouseToMemmory(newInfo[0].Id, ResidenceName);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //重新刷新列表
|
| | | this.listView.RemoveAll();
|
| | | this.SetResidenceInfo(2);
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | var result2 = HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
|
| | | if (result2 == false)
|
| | | {
|
| | | //临时这么写,新云端就会写到R文件了
|
| | | this.ShowMassage(ShowMsgType.Tip, "绑定网关失败,请重新操作");
|
| | | //绑定网关失败,请重新操作
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindGatewayFailPleaseDoAgain));
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | //检测它有没有备份
|
| | | var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB();
|
| | | var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A手动备份);
|
| | | this.CloseProgressBar();
|
| | |
|
| | | if (listBack == null)
|
| | |
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //创建一个备份名字
|
| | | string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue);
|
| | | string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue, BackUpMode.A手动备份);
|
| | | if (backupClassId == null)
|
| | | {
|
| | | //创建备份名字失败
|
| | |
| | | /// 检测本地有没有这个住宅
|
| | | /// </summary>
|
| | | /// <param name="info"></param>
|
| | | private void CheckIsExsitResidence(Common.ResponseEntity.ResidenceObj info)
|
| | | private void CheckIsExsitResidence(ResidenceInformation info)
|
| | | {
|
| | | var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, info.Id);
|
| | | bool isExsit = System.IO.Directory.Exists(path);
|
| | |
| | | //创建新的住宅
|
| | | 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.Name = info.HomeName;
|
| | | house.IsOtherShare = info.IsOtherShare;
|
| | | house.AccountType = info.AccountType == "ADMIN" ? 1 : 0;
|
| | | house.Longitude = info.Longitude;
|
| | | house.Latitude = info.Latitude;
|
| | | house.Save(false);
|
| | |
| | | /// </summary>
|
| | | /// <param name="info"></param>
|
| | | /// <returns></returns>
|
| | | private bool CheckIsCanDeleteResidence(Common.ResponseEntity.ResidenceObj info)
|
| | | private bool CheckIsCanDeleteResidence(ResidenceInformation info)
|
| | | {
|
| | | if (info.IsOthreShare == false)
|
| | | if (info.IsOtherShare == false)
|
| | | {
|
| | | int myCount = 0;
|
| | | foreach (var data in this.dicResidenceData.Values)
|
| | | {
|
| | | if (data.IsOthreShare == false)
|
| | | if (data.IsOtherShare == false)
|
| | | {
|
| | | myCount++;
|
| | | }
|
| | |
| | | //住宅名字重复检测
|
| | | foreach (string strId in this.dicResidenceData.Keys)
|
| | | {
|
| | | if (this.dicResidenceData[strId].IsOthreShare == true)
|
| | | if (this.dicResidenceData[strId].IsOtherShare == true)
|
| | | {
|
| | | //分享的住宅不考虑
|
| | | continue;
|
| | | }
|
| | | if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
|
| | | if (residenceId != strId && residenceName == this.dicResidenceData[strId].HomeName)
|
| | | {
|
| | | //住宅名字已经存在
|
| | | int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
|
| | |
| | | {
|
| | | foreach (var myHouse in this.listLocalHouse)
|
| | | {
|
| | | if (myHouse.IsOthreShare == true)
|
| | | if (myHouse.IsOtherShare == true)
|
| | | {
|
| | | //分享的住宅不考虑
|
| | | continue;
|