CrabtreeOn,印度客户定制APP,迁移2.0平台版本
JLChen
2021-02-24 50b7b7a486f56fab27c83b59eb45673c6d9f0935
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Shared.SimpleControl;
 
namespace Shared
{
    public class CommonUtlis
    {
 
        #region ■ Current___________________________
        /// <summary>
        /// 通用方法
        /// </summary>
        private static CommonUtlis m_Current = null;
        /// <summary>
        /// 通用方法
        /// </summary>
        public static CommonUtlis Current {
            get {
                if (m_Current == null) {
                    m_Current = new CommonUtlis ();
                }
                return m_Current;
            }
        }
 
        #endregion
 
        #region ■ 各种正确检测_______________________
 
        /// <summary>
        /// 用于中国大陆验证手机号正则表达式
        /// </summary>
        public static string PhoneRegexStr = "^[1][0-9]{10}$";
        /// <summary>
        /// 用于验证非中国大陆手机号正则表达式
        /// </summary>
        public static string PhoneForForeignRegexStr = "^[0-9]*$";
        /// <summary>
        /// 用于验证邮箱正则表达式
        /// </summary>
        public static string EmailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$";
        /// <summary>
        /// 用于密码强度正则表达式
        /// 密码必须为8-20个字符,包含字母、数字和符号
        /// </summary>
        //public static string PasswordRegexStr = "^(?![0-9]+$)(?![a-zA-Z]+$)(?![0-9a-zA-Z]+$)(?![0-9\\W]+$)(?![a-zA-Z\\W]+$)[0-9A-Za-z\\W]{8,20}$";
        public static string PasswordRegexStr = @"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,20}$";//必须包含一个大写,一个小写字母,一个数字,一个特殊字符,且长度为8到20位
 
 
 
 
        /// <summary>
        /// 判断是否包含大写字母
        /// </summary>
        /// <returns><c>true</c>, if contain upper was checked, <c>false</c> otherwise.</returns>
        /// <param name="value">Value.</param>
        public bool CheckContainUpper (string value)
        {
            Regex reg = new Regex ("[A-Z]+");
            return reg.IsMatch (value);
        }
 
        /// <summary>
        /// 判断是否包含小写字母
        /// </summary>
        /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
        /// <param name="value">Value.</param>
        public bool CheckContainLower (string value)
        {
            Regex reg = new Regex ("[a-z]+");
            return reg.IsMatch (value);
        }
 
        /// <summary>
        /// 判断是否包含数字
        /// </summary>
        /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
        /// <param name="value">Value.</param>
        public bool CheckContainNum (string value)
        {
            Regex reg = new Regex ("[0-9]+");
            return reg.IsMatch (value);
        }
 
        /// <summary>
        /// 判断是否包含符号
        /// </summary>
        /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
        /// <param name="value">Value.</param>
        public bool CheckContainSymbol (string value)
        {
            Regex reg = new Regex ("([^a-z0-9A-Z])+");
            return reg.IsMatch (value);
        }
 
        /// <summary>
        /// 检测邮箱是否合法
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool CheckEmail (string email)
        {
            Regex reg = new Regex (EmailRegexStr);
            return reg.IsMatch (email);
        }
 
        /// <summary>
        /// 检测手机号是否合法
        /// </summary>
        /// <param name="phoneNumber">手机号</param>
        /// <param name="areaCode">地区代码</param>
        /// <returns></returns>
        public bool CheckPhoneNumber (string phoneNumber, string areaCode)
        {
            //校验外国手机号
            if (areaCode != "86") {
                Regex reg = new Regex (PhoneForForeignRegexStr);
                return reg.IsMatch (phoneNumber);
            }
 
            //校验国内手机号
            if (phoneNumber.Length > 11) {
                return false;
            } else if (phoneNumber.Length == 11) {
                Regex reg = new Regex (PhoneRegexStr);
                return reg.IsMatch (phoneNumber);
            } else {
                //正则表达式判断是否数字
                Regex reg = new Regex ("^[0-9]*$");
                return reg.IsMatch (phoneNumber);
            }
        }
 
        /// <summary>
        /// 检测密码是否合法
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool CheckPassword (string password)
        {
            Regex reg = new Regex (PasswordRegexStr);
            return reg.IsMatch (password);
        }
 
        #endregion
 
        /// <summary>
        /// 检测iOS是否越狱和Android是否root
        /// </summary>
        public void CheckIfJailBreak ()
        {
 
#if __IOS__
             var mes = "Your phone has been Jailbroken and you cannot use the APP.";
#else
            var mes = "Your phone has been ROOT and you cannot use the APP.";
#endif
 
            //if (Shared.HDLUtils.ISJailBreak ()) {
 
            //    Alert alert = new Alert ("", mes, Language.StringByID (SimpleControl.R.MyInternationalizationString.Confrim));
            //    alert.ResultEventHandler += (sender2, e2) => {
            //        Shared.HDLUtils.ExitApplication ();
            //    };
            //    alert.Show ();
            //}
 
 
        }
 
        /// <summary>
        /// 弹窗提示
        /// </summary>
        /// <param name="mes">弹窗提示信息</param>
        /// <param name="okAction">确认按钮事件</param>
        public void ShowActionAlert (string mes, Action okAction)
        {
            Alert alert = new Alert ("", mes, Language.StringByID (SimpleControl.R.MyInternationalizationString.Cancel), Language.StringByID (SimpleControl.R.MyInternationalizationString.Confrim));
            alert.ResultEventHandler += (sender2, e2) => {
                if (e2) {
                    okAction?.Invoke ();
                }
            };
            alert.Show ();
        }
 
        #region ■ 通用Dialog_______________________
        /// <summary>
        /// 通用编辑Dialog
        /// </summary>
        /// <param name="nameStr"></param>
        /// <param name="titleStr"></param>
        public void ShowEditTextDialog (string nameStr, Action<string> saveAction, string titleStr = "")
        {
            Dialog dialog = new Dialog ();
 
            FrameLayout dialogBodyView = new FrameLayout () {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth (500),
                Height = Application.GetRealHeight (330),
                Radius = 5,
                BorderColor = SkinStyle.Current.Transparent,
                BorderWidth = 0,
                BackgroundColor = SkinStyle.Current.DialogColor,
            };
            dialog.AddChidren (dialogBodyView);
 
            Button btnTitle = new Button () {
                Height = Application.GetRealHeight (80),
                TextAlignment = TextAlignment.Center,
                Text = titleStr,
                TextColor = SkinStyle.Current.DialogTextColor,
                BackgroundColor = SkinStyle.Current.DialogTitle,
            };
            dialogBodyView.AddChidren (btnTitle);
 
            EditText etZoneName = new EditText () {
                X = Application.GetRealWidth (50),
                Y = Application.GetRealHeight (120),
                Width = Application.GetRealWidth (400),
                Height = Application.GetRealHeight (80),
                TextColor = SkinStyle.Current.TextColor,
                TextAlignment = TextAlignment.Center,
                Radius = 5,
                BorderColor = SkinStyle.Current.BorderColor,
                BorderWidth = 2,
                Text = nameStr,
            };
            dialogBodyView.AddChidren (etZoneName);
 
            FrameLayout BottomView = new FrameLayout () {
                Y = dialogBodyView.Height - Application.GetRealHeight (88),
                Height = Application.GetRealHeight (90),
                BackgroundColor = SkinStyle.Current.Black50Transparent,
            };
            dialogBodyView.AddChidren (BottomView);
 
            Button btnClose = new Button () {
                Width = Application.GetRealWidth (250),
                TextID = SimpleControl.R.MyInternationalizationString.Close,
                TextColor = SkinStyle.Current.DialogTextColor,
                BackgroundColor = SkinStyle.Current.DialogTitle,
            };
            BottomView.AddChidren (btnClose);
            btnClose.MouseUpEventHandler += (sdf, fds) => {
                dialog.Close ();
            };
 
            Button btnOption = new Button () {
                X = btnClose.Right + Application.GetRealWidth (2),
                Width = Application.GetRealWidth (250),
                TextID = SimpleControl.R.MyInternationalizationString.SAVE,
                TextColor = SkinStyle.Current.DialogTextColor,
                BackgroundColor = SkinStyle.Current.DialogTitle,
            };
            BottomView.AddChidren (btnOption);
 
            btnOption.MouseUpEventHandler += (sdf, fds) => {
                //修改名称
                var newStr = etZoneName.Text.Trim ();
                if (nameStr != newStr) {
                    saveAction?.Invoke (newStr);
                }
                dialog.Close ();
            };
            dialog.Show ();
        }
        #endregion
 
 
        #region ■ 共用上传备份操作_______________________
        /// <summary>
        /// 将当前本地数据上传到自动备份
        /// </summary>
        /// <param name="finishAction">上传结束事件</param>
        public void ShowUploadToAutomaticBackupDialog (Action finishAction)
        {
            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 = SimpleControl.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 = SimpleControl.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 = SimpleControl.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 = SimpleControl.R.MyInternationalizationString.SAVE,
                TextAlignment = TextAlignment.Center
            };
            bottomView.AddChidren (btnSave);
 
            btnSave.MouseUpEventHandler += (sender2, e2) => {
                if (etBackupRemark.Text.Trim () == "") {
                    new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.InputNewBakeUpFilesName),
                                   Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
                    return;
                }
                if (MainPage.LoginUser == null) {
                    new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.PleaseLoginSystem),
                                  Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
                    return;
                }
                userBakeupFile (etBackupRemark.Text.Trim (), finishAction);
                dialog.Close ();
            };
            dialog.Show ();
 
        }
 
 
        ///// <summary>
        ///// 交互备份
        ///// </summary>
        //int InteractiveBackup = 0;
        ///// <summary>
        ///// 自定义工程备份
        ///// </summary>
        //int CustomProjectBackup = 1;
        ///// <summary>
        ///// 用户自动备份
        ///// </summary>
        //int UserAutoBackup = 2;
        ///// <summary>
        ///// 用户自定义备份
        ///// </summary>
        //int UserCustomizedBackup = 3;
        /// <summary>
        /// 用户备份文件
        /// </summary>
        void userBakeupFile (string folderName, Action finishAction)
        {
            MainPage.Loading.Start ("Upload...");
            System.Threading.Tasks.Task.Run (() => {
                try {
                    var revertObj = HttpServerRequest.Current.CreateBackupFolder(folderName);
                    if (revertObj.Code == StateCode.SUCCESS) {
                        var mBackupFolderCreateRes = Newtonsoft.Json.JsonConvert.DeserializeObject<BackupFolderCreateRes> (revertObj.Data.ToString ());
                        //UpLoadBackupFileNEW (mBackupFolderCreateRes.id);
                        UpLoadBackupFileOne (mBackupFolderCreateRes.id);
                    } else {
                        IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
                    }
                } catch (Exception ex) {
                    Shared.Application.RunOnMainThread (() => {
                        new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.CheckInternet),
                                   Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
                        Shared.Utlis.WriteLine (ex.Message);
                    });
                } finally {
                    Shared.Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                        //结束事件
                        finishAction?.Invoke ();
                    });
                }
            });
        }
 
        
 
 
        //2020-01-11
        /// <summary>
        /// 删除某个备份
        /// </summary>
        /// <param name="folderID"></param>
        void DeleteFolderDataAfterUploadFailed (string folderID)
        {
            try {
                var revertObj = HttpServerRequest.Current.DeleteBackupFolder (folderID);
                if (revertObj.Code == StateCode.SUCCESS) {
                    //GetHomeDataBackupList ();
                } else {
                    //IMessageCommon.Current.ShowErrorInfoAlter (API.API_DELETE_Folder_Delete, revertObj.StateCode);
                }
            } catch { } finally {
                Application.RunOnMainThread (() => {
                    MainPage.Loading.Hide ();
                });
            }
        }
 
        /// <summary>
        /// 上传备份文件
        /// 多次上传多个文件
        /// </summary>
        /// <param name="mBackupClassId"></param>
        public void UpLoadBackupFileOne (string folderId)
        {
            var backuplist = IO.FileUtils.ReadFiles ();
            var mFileList = backuplist.FindAll ((obj) => obj != "null" && obj != UserConfig.configFile && obj != UserInfo.GlobalRegisterFile && obj != "AccountListDB" && obj != CommonConfig.ConfigFile && (!obj.Contains (".json")));
            if (mFileList.Count <= 0) return;
 
            int resultCount = mFileList.Count;
            int index = 0;
            foreach (var fileName in mFileList) {
                byte [] fileBytes = IO.FileUtils.ReadFile (fileName);
                var result = UploadDataBackupByOne (folderId, fileName, fileBytes);
                if (result) {
                    index++;
                    Application.RunOnMainThread (() => {
                        int pro = (int)(index * 1.0 / resultCount * 100);
                        MainPage.Loading.Text = pro.ToString () + "%";
                    });
                } else {
                    Console.WriteLine ("上传失败:" + fileName);
                }
            }
 
 
            Utlis.WriteLine ($"上传完成");
 
            if (index != resultCount) {
                //2020-01-11 备份失败
                DeleteFolderDataAfterUploadFailed (folderId);
                Shared.Application.RunOnMainThread (() => {
                    new Alert ("", Language.StringByID (SimpleControl.R.MyInternationalizationString.FailedToBackupFile), Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
                    MainPage.Loading.Hide ();
                });
                return;
            }
 
            Application.RunOnMainThread (() => {
                //MainPage.Loading.Text = "100%";
                new Alert ("", Language.StringByID (SimpleControl.R.MyInternationalizationString.BackupFileIsSuccessful), Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
            });
 
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="folderId"></param>
        /// <param name="fileName"></param>
        /// <param name="fileBytes"></param>
        /// <returns></returns>
        bool UploadDataBackupByOne (string folderId, string fileName, byte [] fileBytes)
        {
            try {
                var queryDic = new Dictionary<string, object> ();
                queryDic.Add ("folderId", folderId);
                queryDic.Add ("fileName", fileName);
                queryDic.Add ("homeId", UserConfig.Instance.CurrentRegion.Id);
 
                var revertObj = HttpUtil.RequestHttpsUpload (RestSharp.Method.POST, NewAPI.API_POST_File_Create, fileBytes, queryDic, null, UserConfig.Instance.CurrentRegion.regionUrl);
                if (revertObj.Code == StateCode.SUCCESS) {
                    return true;
                } else {
                    //提示错误
                    return false;
                }
            } catch {
                return false;
            }
        }
 
 
        #endregion
 
        //#region ■ 文件操作_______________________
        ///// <summary>
        ///// 删除本地文件
        ///// </summary>
        //public void ReadFilesAndDelete ()
        //{
        //    var fileNames = IO.FileUtils.ReadFiles ();
        //    foreach (var fileName in fileNames) {
        //        if (fileName == UserInfo.GlobalRegisterFile || fileName == UserConfig.configFile || fileName == MqttInfoConfig.ConfigFile || fileName == APIInfoConfig.ConfigFile) {
        //            continue;
        //        }
        //        IO.FileUtils.DeleteFile (fileName);
        //    }
 
        //}
        //#endregion
 
 
        #region 设备列表过滤
        /// <summary>
        /// 找出需要显示的设备,加载当前APP支持的所有设备类型
        /// </summary>
        /// <returns></returns>
        public List<string> GetAllLocalEquipments () {
            //找出需要显示的设备
            var filesList = IO.FileUtils.ReadFiles ().FindAll ((obj) => {
                string [] str = obj.Split ('_');
                return obj.StartsWith ("Equipment_") && str.Length == 5;
            });
            var localEquipments = filesList.FindAll ((obj) => {
                string typeString = obj.Split ('_') [1];
                return (
                #region light
                    typeString.ToString () == DeviceType.LightCCT.ToString () ||
                typeString.ToString () == DeviceType.LightRGB.ToString () ||
                typeString.ToString () == DeviceType.LightDALI.ToString () ||
                typeString.ToString () == DeviceType.LightRGBW.ToString () ||
                typeString.ToString () == DeviceType.LightLogic.ToString () ||
                typeString.ToString () == DeviceType.LightSwitch.ToString () ||
                typeString.ToString () == DeviceType.LightDimming.ToString () ||
                typeString.ToString () == DeviceType.LightMixSwitch.ToString () ||
                typeString.ToString () == DeviceType.LightRGBandCCT.ToString () ||
                typeString.ToString () == DeviceType.LightMixDimming.ToString () ||
                typeString.ToString () == DeviceType.LightEnergySwitch.ToString () ||
                typeString.ToString () == DeviceType.LightEnergySocket.ToString () ||
                typeString.ToString () == DeviceType.LightSwitchSocket.ToString ()
                || typeString.ToString () == DeviceType.DMX48.ToString ()
                #endregion
                #region light
                    || typeString.ToString () == DeviceType.SensorCH4.ToString () ||
                typeString.ToString () == DeviceType.SensorCO2.ToString () ||
                typeString.ToString () == DeviceType.SensorLPG.ToString () ||
                typeString.ToString () == DeviceType.SensorCOH2.ToString () ||
                typeString.ToString () == DeviceType.SensorPM25.ToString () ||
                typeString.ToString () == DeviceType.SensorTVOC.ToString () ||
                typeString.ToString () == DeviceType.SensorPower.ToString () ||
                typeString.ToString () == DeviceType.SensorSmoke.ToString () ||
                typeString.ToString () == DeviceType.SensorWater.ToString () ||
                typeString.ToString () == DeviceType.SensorWeight.ToString () ||
                typeString.ToString () == DeviceType.SensorCurrent.ToString () ||
                typeString.ToString () == DeviceType.SensorVoltage.ToString ()
                || typeString.ToString () == DeviceType.SensorRainfall.ToString ()
                || typeString.ToString () == DeviceType.SensorVelocity.ToString ()
                || typeString.ToString () == DeviceType.SensorMenciAndwindowMagnetic.ToString ()
                || typeString.ToString () == DeviceType.SensorMobileDetection.ToString ()
                || typeString.ToString () == DeviceType.SensorLiquidPressure.ToString ()
                || typeString.ToString () == DeviceType.SensorVibration.ToString ()
                || typeString.ToString () == DeviceType.SensorLiquidFlow.ToString ()
                || typeString.ToString () == DeviceType.SensorLiquidDepth.ToString ()
                || typeString.ToString () == DeviceType.SensorTemperature.ToString ()
                || typeString.ToString () == DeviceType.SensorHeightLength.ToString ()
                || typeString.ToString () == DeviceType.SensorIllumination.ToString ()
                || typeString.ToString () == DeviceType.SensorWindPressure.ToString ()
                || typeString.ToString () == DeviceType.SensorHumidity.ToString ()
                #endregion
                #region curtain
                    || typeString.ToString () == DeviceType.CurtainModel.ToString ()
                || typeString.ToString () == DeviceType.CurtainRoller.ToString ()
                || typeString.ToString () == DeviceType.CurtainTrietex.ToString ()
                #endregion
                #region ac
                    || typeString.ToString () == DeviceType.ACPanel.ToString ()
                || typeString.ToString () == DeviceType.ACDevice.ToString ()
                || typeString.ToString () == DeviceType.ACInfrared.ToString ()
                || typeString.ToString () == DeviceType.ACCoolmaster.ToString ()
                || typeString.ToString () == DeviceType.CustomAC.ToString ()
                || typeString.ToString () == DeviceType.HVAC.ToString ()
                #endregion
                #region foolheat
                    || typeString.ToString () == DeviceType.FoolHeat.ToString ()
                || typeString.ToString () == DeviceType.FoolHeatPanel.ToString ()
                #endregion
                #region 
                    || typeString.ToString () == DeviceType.InfraredMode.ToString ()
                || typeString.ToString () == DeviceType.DoorLock.ToString ()
                || typeString.ToString () == DeviceType.FanModule.ToString ()
                || typeString.ToString () == DeviceType.FreshAir.ToString ()
                || typeString.ToString () == DeviceType.InfraredTV.ToString ()
                || typeString.ToString () == DeviceType.UniversalDevice.ToString ()
                || typeString.ToString () == DeviceType.MusicModel.ToString ()
                || typeString.ToString () == DeviceType.SecurityModule.ToString ()
                || typeString.ToString () == DeviceType.LogicModule.ToString ()
                || typeString.ToString () == DeviceType.SecurityPanel.ToString ()
                #endregion
                    );
            });
 
            return localEquipments;
        }
 
 
        #endregion
 
        /// <summary>
        /// 本地Common匹配云端的FunctionList 返回Function
        /// 匹配子网号、设备号、回路号、大类小类
        /// </summary>
        /// <param name="common">本地设备</param>
        /// <returns></returns>
        public Function CommonToFunction (Common common, List<Function> FunctionList)
        {
            if (FunctionList == null) return null;
 
            foreach (var function in FunctionList) {
                if (common.SubnetID == function.bus.SubnetID &&
                    common.DeviceID == function.bus.DeviceID &&
                    common.LoopID == function.bus.LoopId &&
                    common.DeviceTypeString == function.DeviceTypeString
                    ) {
                    return function;
                }
            }
            return null;
        }
    }
}