JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
using System;
using System.Collections.Generic;
 
namespace Shared.SimpleControl.Phone
{
    public class Databackup : FrameLayout
    {
        //WebServiceBackup service_backup = new WebServiceBackup ();
 
        VerticalScrolViewLayout VerticalScrolViewMiddle;
 
        /// <summary>
        /// 构造函数
        /// </summary>
        public Databackup ()
        {
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        public override void RemoveFromParent ()
        {
#if wallon 
            MainPage.LoginUser = null;
#endif
            base.RemoveFromParent ();
        }
 
        public void DatabackupShow ()
        {
            this.RemoveAll ();
            #region 标题
            var topView = new FrameLayout () {
                Y = Application.GetRealHeight (36),
                Height = Application.GetRealHeight (90),
                BackgroundColor = SkinStyle.Current.MainColor
            };
            AddChidren (topView);
 
            var title = new Button () {
                TextAlignment = TextAlignment.Center,
                Text = UserConfig.Instance.CurrentRegion.RegionName + " " + Language.StringByID (R.MyInternationalizationString.Backup),
                TextSize = 19,
                TextColor = SkinStyle.Current.TextColor1,
            };
            topView.AddChidren (title);
            title.MouseUpEventHandler += (sdf, asf) => {
#if wallon
                return;
#endif
                Dialog dialog = new Dialog ();
 
                FrameLayout bodyView = new FrameLayout ();
                dialog.AddChidren (bodyView);
                bodyView.MouseUpEventHandler += (lkj, oiu) => {
                    dialog.Close ();
                };
 
                VerticalScrolViewLayout dialogBodyView = new VerticalScrolViewLayout () {
                    Y = Application.GetRealHeight (126),
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth (500),
                    Height = Application.GetRealHeight (360),
                    BackgroundColor = SkinStyle.Current.MainColor,
                    Radius = 5,
                    BorderColor = SkinStyle.Current.Transparent,
                    BorderWidth = 0
                };
                bodyView.AddChidren (dialogBodyView);
 
                foreach (var homeTemp in UserConfig.Instance.HomeLists) {
                    var rowView = new RowLayout () {
                        Height = Application.GetRealHeight (110),
                    };
                    dialogBodyView.AddChidren (rowView);
 
                    Button btnRowLine = new Button () {
                        Y = Application.GetRealHeight (107),
                        Height = Application.GetRealHeight (3),
                        BackgroundColor = SkinStyle.Current.Black50Transparent
                    };
                    rowView.AddChidren (btnRowLine);
 
                    var btnPoint = new Button () {
                        Width = Application.GetRealWidth (10),
                        Height = Application.GetRealHeight (10),
                        X = Application.GetRealWidth (50),
                        Gravity = Gravity.CenterVertical,
                        UnSelectedImagePath = "Item/Point.png",
                        SelectedImagePath = "Item/Point.png",
                        Visible = homeTemp.RegionID != UserConfig.Instance.CurrentRegion.RegionID
                    };
                    rowView.AddChidren (btnPoint);
 
                    var btnName = new Button () {
                        Width = Application.GetRealWidth (550),
                        Text = homeTemp.RegionName,
                        TextAlignment = TextAlignment.CenterLeft,
                        X = Application.GetRealWidth (90),
                        TextColor = SkinStyle.Current.TextColor1,
                    };
                    rowView.AddChidren (btnName);
 
                    if (homeTemp.RegionID == UserConfig.Instance.CurrentRegion.RegionID) {
                        Button btnCheck = new Button () {
                            X = Application.GetRealWidth (20),
                            Y = Application.GetRealHeight (25),
                            Width = Application.GetRealWidth (72),
                            Height = Application.GetRealHeight (61),
                            UnSelectedImagePath = "Skin/Check.png",
                        };
                        rowView.AddChidren (btnCheck);
                    }
 
                    btnName.MouseUpEventHandler += (ss, ee) => {
                        if (UserConfig.Instance.CurrentRegion == homeTemp) {
                            dialog.Close ();
                            return;
                        }
                        MainPage.Loading.Start ("");
                        System.Threading.Tasks.Task.Run (() => {
                            try {
                                var backuplist = IO.FileUtils.ReadFiles ();
                                int index = 0;
                                string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.RegionID.ToString());
                                IO.FileUtils.DeleteRegionFiles (oldRegionRootPath);
                                foreach (var fileName in backuplist) {
                                    if (fileName == "linphonerc" || fileName == "AccountListDB")
                                        continue;
                                    System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName);
                                    if (fileInfo.Exists) {
                                        fileInfo.MoveTo (oldRegionRootPath + fileName);
                                        Console.WriteLine ("move file : " + fileName);
                                    }
                                    index++;
                                    Application.RunOnMainThread (() => {
                                        int pro = (int)(index * 1.0 / backuplist.Count * 50);
                                        MainPage.Loading.Text = pro.ToString () + "%";
                                    });
                                }
                                IO.FileUtils.DeleteAllFile ();
 
                                string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.RegionID.ToString ());
                                IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
                                UserConfig.Instance.RefreshUserConfig ();
                                UserConfig.Instance.CurrentRegion = homeTemp;
                                UserConfig.Instance.SaveUserConfig ();
 
                                Room.InitAllRoom ();
                                //UserConfig.Instance.RefreshUserConfig ();
                                //MainPage.LoginUser.SaveUserInfo ();
                                Application.RunOnMainThread (() => {
                                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully),
                                              Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                    this.DatabackupShow ();
                                    EquipmentPublicClass.CheckLinkRemote (2);
                                });
                            } catch (Exception ex) {
                                Application.RunOnMainThread (() => {
                                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
                                               Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                });
                                Console.WriteLine (ex.Message);
                            } finally {
                                Application.RunOnMainThread (() => {
                                    MainPage.Loading.Hide ();
                                    dialog.Close ();
                                });
                            }
                        });
                    };
                }
                dialog.Show ();
            };
 
            Button ItemButton = new Button () {
                Width = Application.GetRealWidth (55),
                Height = Application.GetRealHeight (55),
                UnSelectedImagePath = "Item/+.png",
                SelectedImagePath = "Item/+.png",
                Y = Application.GetRealHeight (15),
                X = Application.GetRealWidth (640 - 80),
            };
#if wallon
#else
            topView.AddChidren (ItemButton);
 
            ItemButton.MouseUpEventHandler += (sender, e) => {
                Dialog dialog = new Dialog ();
 
                FrameLayout dialogBodyView = new FrameLayout () {
                    Gravity = Gravity.Center,
                    Width = Application.GetRealWidth (500),
                    Height = Application.GetRealHeight (500),
                    BackgroundColor = SkinStyle.Current.DialogColor,
                    Radius = 5,
                    BorderColor = SkinStyle.Current.Transparent,
                    BorderWidth = 0,
                };
                dialog.AddChidren (dialogBodyView);
 
                Button btnTitle = new Button () { 
                    Height = Application.GetRealHeight(80),
                    BackgroundColor = SkinStyle.Current.DialogTitle,
                    TextAlignment = TextAlignment.Center,
                    TextID = R.MyInternationalizationString.Backup,
                    TextColor = SkinStyle.Current.DialogTextColor
                };
                dialogBodyView.AddChidren (btnTitle);
                Button btnGoDownTip = new Button () {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight (90 - 26),
                    Width = Application.GetRealWidth (53),
                    Height = Application.GetRealHeight (26),
                    UnSelectedImagePath = "Room/godown.png",
                };
                dialogBodyView.AddChidren (btnGoDownTip);
 
                Button btnackupRemark = new Button () {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight (100),
                    Width = Application.GetRealWidth (400),
                    Height = Application.GetRealHeight (80),
                    TextID = R.MyInternationalizationString.Remark,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = SkinStyle.Current.TextColor,
                };
                dialogBodyView.AddChidren (btnackupRemark);
 
                EditText etBackupRemark = new EditText () {
                    Gravity = Gravity.CenterHorizontal,
                    Y = btnackupRemark.Bottom ,
                    Width = Application.GetRealWidth (400),
                    Height = Application.GetRealHeight (80),
                    TextAlignment = TextAlignment.Center,
                    Radius = 5,
                    BorderColor = SkinStyle.Current.BorderColor,
                    BorderWidth = 1,
                    TextColor = SkinStyle.Current.TextColor,
                };
                dialogBodyView.AddChidren (etBackupRemark);
                etBackupRemark.EditorEnterAction += (obj) => {
                    Application.HideSoftInput ();
                };
                FrameLayout bottomView = new FrameLayout () { 
                    Y = Application.GetRealHeight(420),
                    Height = Application.GetRealHeight(85),
                    BackgroundColor = SkinStyle.Current.DialogTitle
                };
                dialogBodyView.AddChidren (bottomView);
 
                Button btnClose = new Button () {
                    Width = Application.GetRealWidth (249),
                    TextID = R.MyInternationalizationString.Close,
                    TextAlignment = TextAlignment.Center
                };
                bottomView.AddChidren (btnClose);
                btnClose.MouseUpEventHandler += (send2er, e2) => {
                    dialog.Close ();
                };
 
                Button btnBottomLine = new Button () { 
                    X = btnClose.Right,
                    Width =1,
                    BackgroundColor = SkinStyle.Current.Black50Transparent,
                };
                bottomView.AddChidren (btnBottomLine);
 
                Button btnSave = new Button () { 
                    X = btnBottomLine.Right,
                    Width = Application.GetRealWidth(249),
                    TextID = R.MyInternationalizationString.SAVE,
                    TextAlignment = TextAlignment.Center
                };
                bottomView.AddChidren (btnSave);
 
                btnSave.MouseUpEventHandler += (sender2, e2) => {
                    if (etBackupRemark.Text.Trim () == "") {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.InputNewBakeUpFilesName),
                                       Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                        return;
                    }
                    if (MainPage.LoginUser == null) {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseLoginSystem),
                                      Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                        return;
                    }
                    userBakeupFile (etBackupRemark.Text.Trim ());
                    dialog.Close ();
                };
                dialog.Show ();
            };
#endif
            var back = new Button () {
                Height = Application.GetRealHeight (90),
                Width = Application.GetRealWidth (85),
                UnSelectedImagePath = "Item/Back.png",
                Gravity = Gravity.CenterVertical,
            };
            topView.AddChidren (back);
            back.MouseUpEventHandler += (sender, e) => {
                (Parent as PageLayout).PageIndex -= 1;
            };
#endregion
 
            var FrameLayoutView = new FrameLayout () {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight (Application.DesignHeight - 126),
                Y = topView.Bottom,
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            AddChidren (FrameLayoutView);
 
            VerticalScrolViewMiddle = new VerticalScrolViewLayout ();
            VerticalScrolViewMiddle.RemoveAll ();
            FrameLayoutView.AddChidren (VerticalScrolViewMiddle);
 
            System.Threading.Tasks.Task.Run (() => {
                try {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
                    });
                    GetUserFolderObj requestObj = new GetUserFolderObj () { LevelID = UserConfig.Instance.CurrentRegion.RegionID };
                    var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
                    var revertObj = new ResponsePack ();
#if wallon
                    revertObj = MainPage.RequestHttps ("GetAllBackup", "",true,false);
#else
                    revertObj = MainPage.RequestHttps ("GetUserFolder", requestJson);
#endif
                    if (revertObj.StateCode == "SUCCESS") {
                        var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FolderRes>> (revertObj.ResponseData.ToString ());
                        Application.RunOnMainThread (() => {
                            foreach(var folder in responseDataObj)
                            {
                                addRow (folder.FolderName,folder.FolderID);
                            }
                        });
                    }
                    //var groupNames = service_backup.GetUserGroup (MainPage.LoginUser.MasterID, 0);
                    //Application.RunOnMainThread (() => {
                    //    foreach (UserBackup groupName in groupNames) {
                    //        addRow (groupName.UserGroup);
                    //    }
                    //});
                } catch {
                    Application.RunOnMainThread (() => {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    });
                } finally {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                    });
                }
            });
        }
 
        void addRow (string groupName,int folderID)
        {
            var rowView = new RowLayout () {
                Height = Application.GetRealHeight (110),
            };
            VerticalScrolViewMiddle.AddChidren (rowView);
 
            Button btnRowLine = new Button () {
                Y = Application.GetRealHeight (107),
                Height = Application.GetRealHeight (3),
                BackgroundColor = SkinStyle.Current.Black50Transparent
            };
            rowView.AddChidren (btnRowLine);
 
            var btnDelFile = new Button () {
                TextID = R.MyInternationalizationString.Del,
                BackgroundColor = SkinStyle.Current.DelColor
            };
            btnDelFile.MouseUpEventHandler += (sender, e) => {
                Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AreYouSureToDeleteFile), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
                alert.ResultEventHandler += ( sender2,  e2) => {
                    if (e2) {
                        MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
                        System.Threading.Tasks.Task.Run (() => {
                            try {
                                DeleteFolderDataObj requestObj = new DeleteFolderDataObj () { Id = folderID };
                                var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
                                var revertObj = MainPage.RequestHttps ("DeleteFolderData", requestJson);
                                if (revertObj.StateCode == "SUCCESS") {
                                    Application.RunOnMainThread (() => {
                                        DatabackupShow ();
                                    });
                                }
                            } catch { } finally {
                                Application.RunOnMainThread (() => {
                                    MainPage.Loading.Hide ();
                                });
                            }
                        });
                    }
                };
                alert.Show ();
            };
            if (MainPage.LoginUser.AccountType != 1) {
                rowView.AddRightView (btnDelFile);
            }
 
            var btnPoint = new Button () {
                Width = Application.GetRealWidth (10),
                Height = Application.GetRealHeight (10),
                X = Application.GetRealWidth (25),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Point.png",
                SelectedImagePath = "Item/Point.png",
            };
            rowView.AddChidren (btnPoint);
 
            var btnName = new Button () {
                Width = Application.GetRealWidth (342),
                Height = LayoutParams.MatchParent,
                Text = groupName.Trim (),
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (50),
                TextColor = SkinStyle.Current.TextColor1,
            };
            rowView.AddChidren (btnName);
 
            var backupIcon = new Button () {
                Width = Application.GetRealWidth (72),
                Height = Application.GetRealHeight (57),
                X = Application.GetRealWidth (452),
            };
            rowView.AddChidren (backupIcon);
 
            var Backup_restores = new Button () {
                Width = Application.GetMinRealAverage (56),
                Height = Application.GetMinRealAverage (57),
                X = backupIcon.Right + Application.GetRealWidth (20),
                UnSelectedImagePath = "Register/Backup_ restores.png",
                SelectedImagePath = "Register/Backup_ restores.png",
                Gravity = Gravity.CenterVertical,
            };
            rowView.AddChidren (Backup_restores);
            Backup_restores.MouseDownEventHandler += (sender, e) => {
                Backup_restores.IsSelected = true;
            };
            Backup_restores.MouseUpEventHandler += (sender, e) => {
                Backup_restores.IsSelected = false;
                UserBakeupFileDetailedInformation (folderID);
            };
        }
 
        /// <summary>
        /// 用户备份文件
        /// </summary>
        void userBakeupFile (string groupName)
        {
            MainPage.Loading.Start ("Upload...");
            System.Threading.Tasks.Task.Run (() => {
                try {
                    AddFolderObj requestObj = new AddFolderObj () { LevelID = UserConfig.Instance.CurrentRegion.RegionID, Name = groupName };
                    var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
                    var revertObj = MainPage.RequestHttps ("AddFolder", requestJson);
                    if (revertObj.StateCode == "SUCCESS") {
                        var addFolderID = Convert.ToInt32 (revertObj.ResponseData);
                        var backuplist = IO.FileUtils.ReadFiles ();
                        int index = 0;
                        foreach (var fileName in backuplist) {
                            index++;
                            /// <summary>
                            /// 如果是特殊的注册登录文件,则不需要备份到服务器
                            /// </summary>
                            if (fileName == UserInfo.GlobalRegisterFile) {
                                continue;
                            }
                            AddUserBackupObj requestObj2 = new AddUserBackupObj () { LevelID = Convert.ToInt32 (revertObj.ResponseData), Name = fileName, DetailByte = IO.FileUtils.ReadFile (fileName) };
                            var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
                            var revertObj2 = MainPage.RequestHttps ("AddUserBackup", requestJson2);
                            if (revertObj2.StateCode == "SUCCESS") {
                                Application.RunOnMainThread (() => {
                                    int pro = (int)(index * 1.0 / backuplist.Count * 100);
                                    MainPage.Loading.Text = pro.ToString () + "%";
                                });
                            }
                        }
                    }
 
                } catch (Exception ex) {
                    Shared.Application.RunOnMainThread (() => {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
                                   Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                        Console.WriteLine (ex.Message);
                    });
                } finally {
                    Shared.Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                        DatabackupShow ();
                    });
                }
            });
        }
 
        /// <summary>
        /// 用户恢复文件
        /// </summary>
        public void UserBakeupFileDetailedInformation (int folderID)
        {
            //是否确定恢复该文件数据信息
            Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SureToRestoreFileInformation), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
            alert.ResultEventHandler += ( sender2,  e2) => {
                if (e2) {
                    MainPage.Loading.Start ("Download...");
                    System.Threading.Tasks.Task.Run (() => {
                        try {
                            var fileNames = IO.FileUtils.ReadFiles ();
                            foreach (var fileName in fileNames) {
                                if (fileName == UserInfo.GlobalRegisterFile) {
                                    continue;
                                }
                                IO.FileUtils.DeleteFile (fileName);
                            }
                            //获取所有文件组名
                            var requestObj2 = new UserBackupListObj () { LevelID = folderID };
                            var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
                            var revertObj2 = MainPage.RequestHttps ("UserBackupList", requestJson2);
                            if (revertObj2.StateCode == "SUCCESS") {
                                var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BackupInfoRes>> (revertObj2.ResponseData.ToString ());
                                int index = 0;
                                foreach (var file in responseDataObj) {
                                    if (file.FileName == "null" || file.FileName == "UserConfig" || file.FileName == "Register_File" || file.FileName == "AccountListDB") {
                                        continue;
                                    }
 
                                    var requestObj3 = new BackupDetailObj () { Id = file.Id };
                                    var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3);
                                    var revertObj3 = MainPage.RequestHttps ("BackupDetail", requestJson3);
                                    if (revertObj3.StateCode == "SUCCESS") {
                                        var jsonBytes = Newtonsoft.Json.JsonConvert.SerializeObject (revertObj3.ResponseData);
                                        var byresss = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]> (jsonBytes);
                                        IO.FileUtils.WriteFileByBytes (file.FileName, byresss);
                                        index++;
                                        //新增加了住宅区域,旧的备份数据没有区域属性,当获取到这个文件时,把当前到住宅信息更新到当前备份到数据里面
                                        //if("UserConfig" == file.FileName){
                                        //    var regionTemp = UserConfig.Instance.CurrentRegion;
                                        //    UserConfig.Instance.RefreshUserConfig ();
                                        //    UserConfig.Instance.CurrentRegion = regionTemp;
                                        //}
                                        Application.RunOnMainThread (() => {
                                            int pro = (int)(index * 1.0 / responseDataObj.Count * 100);
                                            MainPage.Loading.Text = pro.ToString () + "%";
                                        });
                                    }
                                }
                                //var requestHomeListObj = Newtonsoft.Json.JsonConvert.SerializeObject (new HomeListObj ());
                                //var revertHomeListObj = MainPage.RequestHttps ("HomeList", requestHomeListObj);
                                //if (revertHomeListObj.StateCode == "SUCCESS") {
                                //    var responseHomeListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertHomeListObj.ResponseData.ToString ());
                                //    UserConfig.Instance.HomeLists = responseHomeListObj;
                                //    UserConfig.Instance.SaveUserConfig ();
                                //}
                                MainPage.LoginUser.SaveUserInfo ();
                                Room.InitAllRoom ();
                                Application.RunOnMainThread (() => {
                                    if (CommonPage.IsRemote)
                                        SmartHome.MqttCommon.DisConnectRemoteMqttClient ("UserBakeupFileDetailedInformation");
                                    this.RemoveFromParent ();
                                    UserMiddle.Init ();
                                    EquipmentPublicClass.CheckLinkRemote (2);
                                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.RestoreFileIsSuccessfull),
                                    Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                });
                            }
                        } catch (Exception ex) {
                            Shared.Application.RunOnMainThread (() => {
                                new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
                                           Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                            });
                            Console.WriteLine (ex.ToString());
                        } finally {
                            Shared.Application.RunOnMainThread (() => {
                                MainPage.Loading.Hide ();
                            });
                        }
                    });
                }
            };
            alert.Show ();
        }
    }
}