HDL Home App 第二版本 旧平台金堂用 正在使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
using Shared.Common;
using System;
using System.Collections.Generic;
 
namespace Shared.Phone.UserCenter.Residence
{
    /// <summary>
    /// 住宅管理的画面★
    /// </summary>
    public class ResidenceListMainForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listView = null;
        /// <summary>
        /// 住宅数据(有网时使用)
        /// </summary>
        private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
        /// <summary>
        /// 住宅数据(无网时使用)
        /// </summary>
        private List<House> listLocalHouse = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.ResidenceManagement));
 
            //虚拟住宅无法新建住宅
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                //右上添加按钮
                var btnTopIcon = new MostRightIconControl(69, 69);
                btnTopIcon.UnSelectedImagePath = "Item/Add.png";
                topFrameLayout.AddChidren(btnTopIcon);
                btnTopIcon.InitControl();
                btnTopIcon.ButtonClickEvent += (sender, e) =>
                {
                    //显示添加住宅名称的画面
                    this.ShowAddNameForm();
                };
            }
 
            //初始化中部控件
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            listView = new VerticalListControl(29);
            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
 
            //设置住宅信息
            this.SetResidenceInfo(1);
        }
 
        /// <summary>
        /// 设置住宅信息(1:先读取云端,无法联网,再读取本地  2:只读云端  3:只读本地)
        /// </summary>
        /// <param name="div">1:先读取云端,无法联网,再读取本地  2:只读云端  3:只读本地</param>
        private void SetResidenceInfo(int div)
        {
            HdlThreadLogic.Current.RunThread(() =>
            {
                //虚拟住宅的话,只读本地
                if (div == 3 || Config.Instance.Home.IsVirtually == true)
                {
                    //只读本地
                    this.SetResidenceInfoByOffline();
                }
                else
                {
                    //开启进度条
                    this.ShowProgressBar();
                    //设置住宅信息(有网情况)
                    var result = this.SetResidenceInfoByOnline();
                    if (result == true)
                    {
                        //云端读取成功
                        this.CloseProgressBar();
                        return;
                    }
                    if (div == 2)
                    {
                        //如果只读云端 关闭进度条
                        this.CloseProgressBar(ShowReLoadMode.YES);
                        return;
                    }
                    //如果在没网的情况下,从文件夹路径中获取全部住宅,然后显示
                    this.SetResidenceInfoByOffline();
 
                    //关闭进度条
                    this.CloseProgressBar();
                }
            });
        }
 
        #endregion
 
        #region ■ 设置住宅信息(有网情况)_____________
 
        /// <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)
            {
                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)
                {
                    return;
                }
                listView.Height = bodyFrameLayout.Height;
 
                this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
                for (int i = 0; i < listHouse.Count; i++)
                {
                    var info = listHouse[i];
 
                    //收集该账号住宅的数据
                    this.dicResidenceData[info.Id] = info;
                    //添加住宅的行(有网情况)
                    this.AddRowLayoutByOnline(info, i != listHouse.Count - 1);
                }
                //调整列表控件的高度
                this.listView.AdjustRealHeight(Application.GetRealHeight(23));
            });
            return true;
        }
 
        /// <summary>
        /// 添加住宅的行(有网情况)
        /// </summary>
        /// <param name="info"></param>
        private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, 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 (info.Id == Config.Instance.Home.Id)
            {
                //住宅名称
                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, 60, true);
                btnHome.TextSize = 15;
                btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
                rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEvent);
 
                //当前住宅
                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.BindEvent);
            }
            else
            {
                //住宅名称
                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, true);
                btnHome.TextSize = 15;
            }
            //右箭头
            rowLayout.frameTable.AddRightArrow();
            if (addLine == true)
            {
                //底线
                rowLayout.frameTable.AddBottomLine();
            }
 
            rowLayout.frameTable.ButtonClickEvent += (sender, e) =>
            {
                if (info.Id != Config.Instance.Home.Id)
                {
                    //确认切换当前住宅到「」?
                    string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, info.Name);
                    }
                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                    {
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            //开启进度条
                            this.ShowProgressBar();
 
                            //检测本地有没有这个住宅
                            this.CheckIsExsitResidence(info);
 
                            var result = HdlResidenceLogic.Current.SwitchResidence(info.Id);
 
                            HdlThreadLogic.Current.RunMain(() =>
                            {
                                if (result == true)
                                {
                                    //重新刷新列表
                                    this.listView.RemoveAll();
                                    this.SetResidenceInfo(2);
                                }
                                //关闭进度条
                                this.CloseProgressBar();
                            });
                        });
                    });
                }
                else
                {
                    //检测能否删除住宅
                    bool flage = this.CheckIsCanDeleteResidence(info);
                    var form = new ResidenceManagementForm();
                    form.AddForm(flage);
                }
            };
 
            if (info.IsOthreShare == true)
            {
                //分享的,不能更改
                return;
            }
            //只有切换到当前住宅,并且本地拥有网关的时候,才能过户
            if (info.Id == Config.Instance.Home.Id && HdlGatewayLogic.Current.GetAllLocalGateway().Count > 0)
            {
                //过户
                var btnTransfer = rowLayout.AddDeleteControl();
                btnTransfer.TextID = R.MyInternationalizationString.uTransfer;
                btnTransfer.ButtonClickEvent += (sender, e) =>
                {
                    rowLayout.HideMenu();
                    HdlCheckLogic.Current.CheckSecondarySecurity(() =>
                    {
                        //执行过户操作
                        this.DoTransferResidence();
                    },
                    () =>
                    {
                        //请前往个人中心{0}设置二次安全验证方式
                        string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
                        this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                        {
                            var form = new UserMain.SecondAuthenticationForm();
                            form.AddForm();
                        });
                    });
                };
            }
            //更改
            var btnChanged = rowLayout.AddEditorControl();
            btnChanged.TextID = R.MyInternationalizationString.uChanged1;
            btnChanged.ButtonClickEvent += (sender, e) =>
            {
                //显示编辑名称界面
                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.BindEvent);
 
                //当前住宅
                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.BindEvent);
            }
            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(() =>
                        {
                            var result = HdlResidenceLogic.Current.SwitchResidence(i_home.Id);
 
                            HdlThreadLogic.Current.RunMain(() =>
                            {
                                if (result == true)
                                {
                                    //重新刷新列表
                                    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);
            //};
        }
 
        #endregion
 
        #region ■ 编辑住宅名称_______________________
 
        /// <summary>
        /// 显示编辑住宅名称界面
        /// </summary>
        /// <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 DialogInputControl();
            //编辑住宅
            dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedName));
            //请输入住宅名称
            dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName));
            dialogForm.Text = oldName;
 
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            {
                if (textValue == string.Empty)
                {
                    //请输入住宅名称
                    string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName);
                    this.ShowMassage(ShowMsgType.Error, msg);
                    return;
                }
                //画面关闭
                dialogForm.CloseDialog();
                if (oldName != textValue)
                {
                    if (info != null)
                    {
                        //编辑云端的住宅名称
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            this.EditorResidenceName(textValue, info, btnHome);
                        });
                    }
                    else
                    {
                        //直接编辑住宅缓存
                        if (this.CheckIsCanSaveResidence(i_house.Id, textValue, true) == false)
                        {
                            return;
                        }
                        //刷新内存的住宅名
                        HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue);
                        //更改显示的名字
                        btnHome.Text = textValue;
                    }
                }
            });
        }
 
        /// <summary>
        /// 编辑云端的住宅名称
        /// </summary>
        /// <param name="ResidenceName"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        private void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
        {
            //检测能否保存住宅
            if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
            {
                return;
            }
            //开启进度条
            this.ShowProgressBar();
 
            var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName);
 
            //关闭进度条
            this.CloseProgressBar();
 
            if (result == true)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //刷新内存的住宅名
                    HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName);
                    //更改显示的名字
                    btnHome.Text = ResidenceName;
                    info.Name = ResidenceName;
                });
            }
        }
 
        #endregion
 
        #region ■ 添加住宅名称_______________________
 
        /// <summary>
        /// 显示添加住宅名称的画面
        /// </summary>
        private void ShowAddNameForm()
        {
            //生成一个弹窗画面
            var dialogForm = new DialogInputControl();
            //创建住宅
            dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uCreatResidence));
            //请输入住宅名称
            dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName));
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            {
                if (textValue == string.Empty)
                {
                    //请输入住宅名称
                    string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName);
                    this.ShowMassage(ShowMsgType.Error, msg);
                    return;
                }
                //画面关闭
                dialogForm.CloseDialog();
 
                //保存住宅
                HdlThreadLogic.Current.RunThread(() =>
                {
                    this.AddNewResidence(textValue);
                });
            });
        }
 
        /// <summary>
        /// 向云端添加新的住宅
        /// </summary>
        /// <param name="ResidenceName"></param>
        /// <returns></returns>
        private void AddNewResidence(string ResidenceName)
        {
            //检测能否保存住宅
            if (this.CheckIsCanSaveResidence(string.Empty, ResidenceName, false) == false)
            {
                return;
            }
            //开启进度条
            this.ShowProgressBar();
 
            var Pra = new AddResidencePra();
            Pra.Name = ResidenceName;
            //添加住宅
            string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/AddHome", false, Pra);
            if (string.IsNullOrEmpty(resultData) == true)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
 
            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
 
        #region ■ 过户_______________________________
 
        /// <summary>
        /// 执行过户操作
        /// </summary>
        private void DoTransferResidence()
        {
            this.ShowProgressBar();
            HdlThreadLogic.Current.RunThread(() =>
            {
                //绑定还没有成功的网关
                var result2 = HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
                if (result2 == false)
                {
                    //临时这么写,新云端就会写到R文件了
                    this.ShowMassage(ShowMsgType.Tip, "绑定网关失败,请重新操作");
                    this.CloseProgressBar();
                    return;
                }
                //检测它有没有备份
                var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB();
                this.CloseProgressBar();
 
                if (listBack == null)
                {
                    return;
                }
                HdlThreadLogic.Current.RunMain(() =>
                {
                    if (listBack.Count > 0)
                    {
                        var form = new Transfer.TransferResidenceMainForm();
                        form.AddForm(1);
                    }
                    else
                    {
                        //检测到还没有备份,请先备份
                        this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uIsNotHadBackupByCheckPleaseBackup));
 
                        //生成一个弹窗画面
                        this.ShowDialogInputForm(Language.StringByID(R.MyInternationalizationString.uAddBackup),
                         Config.Instance.Home.Name,
                         Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackupName), (dialogForm, textValue) =>
                         {
                             //画面关闭
                             dialogForm.CloseDialog();
 
                             HdlThreadLogic.Current.RunThread(() =>
                             {
                                 //创建一个备份名字
                                 string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue);
                                 if (backupClassId == null)
                                 {
                                     //创建备份名字失败
                                     string msg = Language.StringByID(R.MyInternationalizationString.uCreatBackupNameFail);
                                     this.ShowMassage(ShowMsgType.Error, msg);
 
                                     return;
                                 }
 
                                 //上传数据到云端
                                 bool result = HdlBackupLogic.Current.UpLoadBackupFileToDB(backupClassId);
                                 if (result == false)
                                 {
                                     //文件上传失败
                                     string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail);
                                     this.ShowMassage(ShowMsgType.Error, msg);
 
                                     //如果上传失败的话,就把它删除
                                     HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
 
                                     return;
                                 }
 
                                 HdlThreadLogic.Current.RunMain(() =>
                                 {
                                     var form = new Transfer.TransferResidenceMainForm();
                                     form.AddForm(1);
                                 });
                             });
                         });
                    }
                });
            });
        }
 
        #endregion
 
        #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 (info.IsOthreShare == false)
            {
                int myCount = 0;
                foreach (var data in this.dicResidenceData.Values)
                {
                    if (data.IsOthreShare == false)
                    {
                        myCount++;
                    }
                }
                //如果此账号下只剩下唯一一个自己的住宅,则不能再删除
                if (myCount == 1)
                {
                    return false;
                }
            }
            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;
        }
 
        /// <summary>
        /// 检测能否保存住宅
        /// </summary>
        /// <param name="residenceId">住宅ID</param>
        /// <param name="residenceName">住宅名</param>
        /// <param name="isEditor">isEditor</param>
        /// <returns></returns>
        private bool CheckIsCanSaveResidence(string residenceId, string residenceName, bool isEditor)
        {
            if (this.dicResidenceData != null)
            {
                //住宅名字重复检测
                foreach (string strId in this.dicResidenceData.Keys)
                {
                    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;
        }
 
        #endregion
 
        #region ■ 界面重新激活事件___________________
 
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            if (dicResidenceData != null)
            {
                foreach (string keys in dicResidenceData.Keys)
                {
                    if (Config.Instance.HomeFilePathList.Contains($"House_{keys}.json") == false)
                    {
                        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;
        }
 
        #endregion
 
        #region ■ 结构体_____________________________
 
        /// <summary>
        /// 访问住宅信息接口的启动参数(查询专用)
        /// </summary>
        public class GetResidenceInfoPra : IfacePraCommon
        {
            /// <summary>
            /// RequestVersion
            /// </summary>
            public string RequestVersion = Common.CommonPage.RequestVersion;
            /// <summary>
            /// ReqDto
            /// </summary>
            public TokenInfo ReqDto = new TokenInfo();
        }
 
        /// <summary>
        /// 访问住宅信息接口的启动参数(查询专用)
        /// </summary>
        public class TokenInfo
        {
            /// <summary>
            /// LoginAccessToken
            /// </summary>
            public string LoginAccessToken = Common.Config.Instance.Token;
            /// <summary>
            /// PageSetting
            /// </summary>
            public PageSettingInfo PageSetting = new PageSettingInfo()
            {
                Page = 1,
                PageSize = 5000
            };
        }
 
        /// <summary>
        ///  添加住宅的启动参数
        /// </summary>
        public class AddResidencePra : IfacePraCommon
        {
            /// <summary>
            /// RequestVersion
            /// </summary>
            public string RequestVersion = Common.CommonPage.RequestVersion;
            /// <summary>
            /// LoginAccessToken
            /// </summary>
            public string LoginAccessToken = Common.Config.Instance.Token;
            /// <summary>
            /// Name
            /// </summary>
            public string Name = string.Empty;
        }
 
        /// <summary>
        /// 新住宅的信息
        /// </summary>
        public class NewResidenceInfo
        {
            /// <summary>
            /// ZigbeeHomeGuid
            /// </summary>
            public string Id = string.Empty;
        }
 
        #endregion
    }
}