黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DeviceDoorLock
{
    /// <summary>
    /// 门锁的历史记录界面
    /// </summary>
    public class DoorLockHistoryLogForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalFrameRefreshControl listView = null;
        /// <summary>
        /// 日期From控件
        /// </summary>
        private DateSelectControl dateFromControl = null;
        /// <summary>
        /// 日期To控件
        /// </summary>
        private DateSelectControl dateToControl = null;
        /// <summary>
        /// 成员信息
        /// </summary>
        private List<MemberInfoRes> listMenberInfo = null;
        /// <summary>
        /// 设备对象
        /// </summary>
        private CommonDevice DeviceDoor = null;
        /// <summary>
        /// 检索对象的ID(-1:所有 -9999:其他)
        /// </summary>
        private List<string> listSearchUserId = new List<string>() { "-1" };
        /// <summary>
        /// 检索开锁方式的ID(-1:所有 0:密码 15:指纹 3:IC卡 9000:常开模式(自定义的))
        /// </summary>
        private List<int> listSearchLockId = new List<int>() { -1 };
        /// <summary>
        /// 获取到的历史记录
        /// </summary>
        private List<DoorHistoryLogInfo> listHistoryInfo = null;
        /// <summary>
        /// 其他消息的主键,它存在另外的一张数据库表中
        /// </summary>
        private List<string> listOtherMsgId = new List<string>();
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_DeviceMac">门锁的Mac地址</param>
        public void ShowForm(string i_DeviceMac)
        {
            this.DeviceDoor = HdlDeviceCommonLogic.Current.GetDevicesByMac(i_DeviceMac, false)[0];
 
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryLog));
 
            //成员不允许清空记录
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2)
            {
                //删除
                var btnDelete = new MostRightIconControl(69, 69);
                btnDelete.UnSelectedImagePath = "Item/DeleteIcon2Selected.png";
                topFrameLayout.AddChidren(btnDelete);
                btnDelete.InitControl();
                btnDelete.ButtonClickEvent += (sender, e) =>
                {
                    var form = new TopRightMenuControl(1, 2);
                    //清空记录
                    form.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uClearLog), "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
                    {
                        if (this.listView.frameTable.ChildrenCount == 0)
                        {
                            //无数据可删
                            return;
                        }
                        //确认清空当前记录?
                        this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uConfirmClearNowLog), () =>
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                //清空所有记录
                                this.ClearAllHistoryLog();
                            });
                        });
                    });
                };
            }
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //初始化头部检索控件
            this.InitTitleSearchControl();
 
            //初始化记录列表
            this.InitLogListInfo(true);
        }
 
        /// <summary>
        /// 初始化头部检索控件
        /// </summary>
        private void InitTitleSearchControl()
        {
            var frameTitle = new FrameRowControl();
            frameTitle.UseClickStatu = false;
            frameTitle.Height = Application.GetRealHeight(115);
            frameTitle.BackgroundColor = topFrameLayout.BackgroundColor;
            bodyFrameLayout.AddChidren(frameTitle);
 
            var btnDateIcon = frameTitle.AddLeftIcon(69);
            btnDateIcon.UnSelectedImagePath = "Item/DateSearchIcon.png";
 
            dateFromControl = new DateSelectControl(Language.StringByID(R.MyInternationalizationString.uStartDate));
            dateFromControl.Y = Application.GetRealHeight(35);
            dateFromControl.X = Application.GetRealWidth(138);
            dateFromControl.dateValue = DateTime.Now.ToString("yyyyMMdd");
            frameTitle.AddChidren(dateFromControl, ChidrenBindMode.NotBind);
            dateFromControl.DateSelectEvent += (dateValue) =>
            {
                //初始化记录列表
                this.InitLogListInfo(true);
            };
 
            var btnTemp = new NormalViewControl(26, 58, true);
            btnTemp.Y = Application.GetRealHeight(29);
            btnTemp.X = dateFromControl.Right + Application.GetRealWidth(12);
            btnTemp.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTemp.Text = "-";
            frameTitle.AddChidren(btnTemp, ChidrenBindMode.NotBind);
 
            dateToControl = new DateSelectControl(Language.StringByID(R.MyInternationalizationString.uEndDate));
            dateToControl.Y = Application.GetRealHeight(35);
            dateToControl.X = btnTemp.Right + Application.GetRealWidth(12);
            dateToControl.dateValue = DateTime.Now.ToString("yyyyMMdd");
            frameTitle.AddChidren(dateToControl, ChidrenBindMode.NotBind);
            dateToControl.DateSelectEvent += (dateValue) =>
            {
                //初始化记录列表
                this.InitLogListInfo(true);
            };
 
            //类型筛选
            var btnScreening = frameTitle.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uScreeningType), 145);
            btnScreening.TextSize = 12;
            btnScreening.Width = btnScreening.GetRealWidthByText();
            btnScreening.X = frameTitle.Width - Application.GetRealWidth(58) - btnScreening.Width;
            btnScreening.ButtonClickEvent += (sender, e) =>
            {
                //显示类型筛选界面
                this.ShowDoorLockScreeningTypeForm();
            };
            frameTitle.ChangedChidrenBindMode(btnScreening, ChidrenBindMode.NotBind);
            //类型筛选的图标
            var btnScreeningIcon = new IconViewControl(69);
            btnScreeningIcon.X = btnScreening.X - Application.GetRealWidth(12) - btnScreeningIcon.IconSize;
            btnScreeningIcon.Gravity = Gravity.CenterVertical;
            btnScreeningIcon.UnSelectedImagePath = "Item/ScreeningType.png";
            frameTitle.AddChidren(btnScreeningIcon, ChidrenBindMode.NotBind);
            btnScreeningIcon.ButtonClickEvent += (sender, e) =>
            {
                //显示类型筛选界面
                this.ShowDoorLockScreeningTypeForm();
            };
 
            //底线
            frameTitle.AddBottomLine();
 
            this.listView = new VerticalFrameRefreshControl(29);
            listView.Y = frameTitle.Bottom - Application.GetRealHeight(3);
            listView.Height = bodyFrameLayout.Height - frameTitle.Bottom + Application.GetRealHeight(3);
            bodyFrameLayout.AddChidren(listView);
            listView.frameTable.BackgroundColor = UserCenterColor.Current.White;
            listView.BeginHeaderRefreshingAction += () =>
            {
                //下拉刷新
                this.InitLogListInfo(true);
            };
        }
 
        #endregion
 
        #region ■ 初始化记录列表_____________________
 
        /// <summary>
        /// 初始化记录列表
        /// </summary>
        /// <param name="reReadData">是否从新从云端读取数据</param>
        private void InitLogListInfo(bool reReadData)
        {
            this.listView.frameTable.RemoveAll();
            listView.frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3);
 
            //如果From>To的时候,不鸟它
            if (Convert.ToInt32(dateFromControl.dateValue) > Convert.ToInt32(dateToControl.dateValue))
            {
                //开始时间大于结束时间
                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uFromTimeIsOverToTime));
                return;
            }
            if (reReadData == true)
            {
                //置空后,重新获取
                this.listHistoryInfo = null;
            }
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                //打开进度条
                this.ShowProgressBar();
                //成员列表
                var result = this.GetMemberListInfo();
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar(ShowReLoadMode.YES);
                    return;
                }
                //成员信息
                var dicMemberName = new Dictionary<string, string>();
                for (int i = 0; i < listMenberInfo.Count; i++)
                {
                    dicMemberName.Add(listMenberInfo[i].ChildAccountId, listMenberInfo[i].ShowName);
                }
                //历史记录
                var historyLog = this.GetHistoryLogInfo(dicMemberName);
                if (historyLog == null)
                {
                    //关闭进度条
                    this.CloseProgressBar(ShowReLoadMode.YES);
                    return;
                }
                //关闭进度条
                this.CloseProgressBar();
 
                HdlThreadLogic.Current.RunMain(() =>
                {
                    for (int i = 0; i < historyLog.Count; i++)
                    {
                        //添加记录行
                        this.AddLogInfoRow(historyLog[i], dicMemberName, i != historyLog.Count - 1);
                    }
                    //隐藏下拉刷新特效
                    listView.EndHeaderRefreshing();
 
                    if (listView.frameTable.ChildrenCount == 0)
                    {
                        return;
                    }
                    //调整列表控件的高度
                    listView.AdjustTableHeight(Application.GetRealHeight(23));
                });
            });
        }
 
        /// <summary>
        /// 获取成员列表信息
        /// </summary>
        /// <returns></returns>
        private bool GetMemberListInfo()
        {
            if (listMenberInfo != null)
            {
                //只初始化一次
                return true;
            }
            listMenberInfo = new List<MemberInfoRes>();
            //把自己也加进去
            var myInfo = new MemberInfoRes()
            {
                ChildAccountEmail = HdlUserCenterResourse.UserInfo.UserEmail,
                ChildAccountPhone = HdlUserCenterResourse.UserInfo.UserPhone,
                ChildNickName = HdlUserCenterResourse.UserInfo.NickName,
                ChildAccountId = Common.Config.Instance.Guid
            };
            listMenberInfo.Add(myInfo);
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3)
            {
                //成员只能看自己的
                return true;
            }
            //获取成员列表
            var listInfo = HdlMemberLogic.Current.GetMemberListInfo(ShowNetCodeMode.YES);
            if (listInfo == null)
            {
                return false;
            }
            var checkList = new List<string>();
            foreach (MemberInfoRes infoRes in listInfo)
            {
                if (checkList.Contains(infoRes.ChildAccountId) == true)
                {
                    continue;
                }
                checkList.Add(infoRes.ChildAccountId);
                listMenberInfo.Add(infoRes);
            }
            return true;
        }
 
        #endregion
 
        #region ■ 添加记录行_________________________
 
        /// <summary>
        ///  添加记录行
        /// </summary>
        /// <param name="historyInfo">历史记录</param>
        /// <param name="dicName">名字</param>
        /// <param name="addLine">添加底线</param>
        private void AddLogInfoRow(DoorHistoryLogInfo historyInfo, Dictionary<string, string> dicName, bool addLine = true)
        {
            var frameTable = new FrameRowControl(listView.rowSpace / 2);
            frameTable.UseClickStatu = false;
            this.listView.AddChidren2(frameTable);
            //图标
            var btnIcon = frameTable.AddLeftIcon();
            //信息
            var btnMsg = frameTable.AddTopView("", 600);
            //人物
            string perName = dicName.ContainsKey(historyInfo.UserId) == true ? dicName[historyInfo.UserId] : Language.StringByID(R.MyInternationalizationString.uOther);
            frameTable.AddBottomView(perName, 600);
            //时间
            if (this.dateFromControl.dateValue == this.dateToControl.dateValue)
            {
                //如果日期范围一样,则不显示年月日
                frameTable.AddMostRightView(HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(historyInfo.UnlockTime).ToString("HH:mm:ss"), 400);
            }
            else
            {
                //如果日期范围不一样,则显示年月日
                frameTable.AddMostRightView(HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(historyInfo.UnlockTime).ToString("yyyy/MM/dd HH:mm:ss"), 700);
            }
            //底线
            if (addLine == true)
            {
                
                frameTable.AddBottomLine();
            }
 
            //其他消息
            if (historyInfo.UnLockMode == -1)
            {
                //图片
                var device = HdlDeviceCommonLogic.Current.GetDevice(historyInfo.DeviceMac, historyInfo.DeviceEpoint);
                if (device == null)
                {
                    btnIcon.UnSelectedImagePath = "Device/IntelligentLocks.png";
                }
                else
                {
                    HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnIcon, device);
                }
                //消息
                btnMsg.Text = historyInfo.AlarmMsg;
            }
            //门锁常开模式
            else if (historyInfo.UnLockMode == 9000)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png";
                //这里是网关或者门锁自己推送
                btnMsg.Text = historyInfo.AlarmMsg;
            }
            //常开模式手动开启
            else if (historyInfo.UnLockMode == 9001)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png";
                btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualOpen;
            }
            //常开模式手动取消
            else if (historyInfo.UnLockMode == 9002)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png";
                btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualClose;
            }
            //常开模式启用{0}小时
            else if (historyInfo.UnLockMode == 9003)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png";
                btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenModeOpenSomeTime).Replace("{0}", historyInfo.NormallyOpenContinuedTime);
            }
            //常开自动化手动取消
            else if (historyInfo.UnLockMode == 9004)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png";
                btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenLogicManualClose);
            }
            //开锁成功
            else if (historyInfo.IsUnlockSuccess == true)
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png";
                //消息
                if (historyInfo.UnLockMode == 0)
                {
                    //密码开锁成功
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordSuccess;
                }
                else if (historyInfo.UnLockMode == 3)
                {
                    //IC卡开锁成功
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardSuccess;
                }
                else if (historyInfo.UnLockMode == 13)
                {
                    //静脉纹开锁成功
                    btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockSuccess;
                }
                else if (historyInfo.UnLockMode == 14)
                {
                    //人脸识别开锁成功
                    btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockSuccess;
                }
                else if (historyInfo.UnLockMode == 15)
                {
                    //指纹开锁成功
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintSuccess;
                }
            }
            //开锁失败
            else
            {
                //图片
                btnIcon.UnSelectedImagePath = "Item/UnLockFail.png";
                //消息
                if (historyInfo.UnLockMode == 0)
                {
                    //密码开锁失败
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordFail;
                }
                else if (historyInfo.UnLockMode == 3)
                {
                    //IC卡开锁失败
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardFail;
                }
                else if (historyInfo.UnLockMode == 13)
                {
                    //静脉纹开锁失败
                    btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockFail;
                }
                else if (historyInfo.UnLockMode == 14)
                {
                    //人脸识别开锁失败
                    btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockFail;
                }
                else if (historyInfo.UnLockMode == 15)
                {
                    //指纹开锁失败
                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintFail;
                }
            }
        }
 
        #endregion
 
        #region ■ 类型筛选___________________________
 
        /// <summary>
        /// 显示类型筛选界面
        /// </summary>
        private void ShowDoorLockScreeningTypeForm()
        {
            var dic = new Dictionary<string, string>();
            for (int i = 0; i < listMenberInfo.Count; i++)
            {
                dic.Add(listMenberInfo[i].ChildAccountId, listMenberInfo[i].ShowName);
            }
            //显示底部类型筛选
            var form = new DoorLockScreeningTypeForm();
            form.AddForm(dic, listSearchUserId, listSearchLockId);
            form.FinishSelectEvent += (selectUser, selectLock) =>
            {
                listSearchUserId.Clear();
                listSearchUserId.AddRange(selectUser);
                listSearchLockId.Clear();
                listSearchLockId.AddRange(selectLock);
                //初始化记录列表
                this.InitLogListInfo(false);
            };
        }
 
        #endregion
 
        #region ■ 筛选记录___________________________
 
        /// <summary>
        /// 筛选历史记录
        /// </summary>
        /// <returns></returns>
        private List<DoorHistoryLogInfo> ScreeningHistoryData(Dictionary<string, string> dicMemberName)
        {
            //历史记录太麻烦了,存在不同的数据库表里,并且数据还不一样,只能这样一个个判断了
            var listScreeningData = new List<DoorHistoryLogInfo>();
            //清除掉之前的记录
            this.listOtherMsgId = new List<string>();
 
            //是否选择全选用户
            bool selectAllUser = this.listSearchUserId.Contains("-1");
            //是否单选了其他
            bool selectOtherUser = this.listSearchUserId.Contains("-9999");
            //是否选择全选开锁方式
            bool selectAllLockMode = this.listSearchLockId.Contains(-1);
 
            //一个个去遍历
            foreach (var data in this.listHistoryInfo)
            {
                //检测该历史记录能否显示
                bool result = this.CheckHistoryDataCanShow(data, dicMemberName, selectAllUser, selectOtherUser, selectAllLockMode);
                if (result == true)
                {
                    listScreeningData.Add(data);
                }
            }
 
            return listScreeningData;
        }
 
        /// <summary>
        /// 检测该历史记录能否显示
        /// </summary>
        /// <param name="info">检测对象</param>
        /// <param name="dicMemberName">成员信息</param>
        /// <param name="selectAllUser">是否选择全选用户</param>
        /// <param name="selectOtherUser">是否单选了其他</param>
        /// <param name="slectAllLockMode">是否选择全选开锁方式</param>
        private bool CheckHistoryDataCanShow(DoorHistoryLogInfo info, Dictionary<string, string> dicMemberName,
            bool selectAllUser, bool selectOtherUser, bool slectAllLockMode)
        {
            //如果没有选择  全选用户
            if (selectAllUser == false)
            {
                //如果这个用户ID不包含在指定选择的成员列表里面
                if (this.listSearchUserId.Contains(info.UserId) == false)
                {
                    if (dicMemberName.ContainsKey(info.UserId) == true)
                    {
                        //如果能够识别这个id的话,则表示它不属于其他类,并且也不再选择目标内
                        return false;
                    }
                    //如果没有选择 其他的话,不显示
                    if (selectOtherUser == false)
                    {
                        return false;
                    }
                }
            }
            //如果是成员身份,并且用户ID不为空
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3 && info.UserId != string.Empty)
            {
                //成员不能看到 其他人的记录(成员的时候,这个变量里面只有他自己一个)
                if (dicMemberName.ContainsKey(info.UserId) == false)
                {
                    return false;
                }
            }
            //如果没有选择  全选开锁方式
            if (slectAllLockMode == false)
            {
                //如果这个开锁方式不在选择的列表里面的话
                if (this.listSearchLockId.Contains(info.UnLockMode) == false)
                {
                    return false;
                }
            }
 
            //另一张表的数据主键
            if (info.UnLockMode == -1 || info.UnLockMode == 9000)
            {
                if (info.MsgKeyId != string.Empty)
                {
                    //其他消息的主键,它存在另外的一张数据库表中
                    this.listOtherMsgId.Add(info.MsgKeyId);
                }
            }
 
            return true;
        }
 
        #endregion
 
        #region ■ 获取门锁打开记录___________________
 
        /// <summary>
        /// 获取历史记录
        /// </summary>
        /// <returns></returns>
        private List<DoorHistoryLogInfo> GetHistoryLogInfo(Dictionary<string, string> dicMemberName)
        {
            if (this.listHistoryInfo != null)
            {
                //不二次获取,主要针对的是筛选功能
                return this.ScreeningHistoryData(dicMemberName);
            }
 
            var dateFrom = new DateTime(dateFromControl.Year, dateFromControl.Month, dateFromControl.Day, 0, 0, 0);
            var dateTo = new DateTime(dateToControl.Year, dateToControl.Month, dateToControl.Day, 23, 59, 59);
 
            //获取门锁的打开和关闭记录
            var listAllLog = HdlDeviceDoorLockLogic.Current.GetDoorHistoryLogInfo(this.GetDoorId(), dateFrom, dateTo);
 
            //获取门锁的其他记录
            var listOtherLog = this.GetDoorOtherHistoryLog(dateFrom, dateTo);
            listAllLog.AddRange(listOtherLog);
 
            //排序一下
            var dicAllData = new Dictionary<string, List<DoorHistoryLogInfo>>();
            var listSortTime = new List<string>();
 
            foreach (var data in listAllLog)
            {
                //按时间分组
                if (dicAllData.ContainsKey(data.UnlockTime) == false)
                {
                    dicAllData[data.UnlockTime] = new List<DoorHistoryLogInfo>();
                    listSortTime.Add(data.UnlockTime);
                }
                dicAllData[data.UnlockTime].Add(data);
            }
 
            //执行排序,时间大的在前面
            listSortTime.Sort();
            this.listHistoryInfo = new List<DoorHistoryLogInfo>();
            for (int i = listSortTime.Count - 1; i >= 0; i--)
            {
                this.listHistoryInfo.AddRange(dicAllData[listSortTime[i]]);
            }
            //筛选历史记录
            return this.ScreeningHistoryData(dicMemberName);
        }
 
        #endregion
 
        #region ■ 获取门锁其他记录___________________
 
        /// <summary>
        /// 获取门锁的其他记录
        /// </summary>
        /// <returns></returns>
        private List<DoorHistoryLogInfo> GetDoorOtherHistoryLog(DateTime beginTime, DateTime endTime)
        {
            var listLog = new List<DoorHistoryLogInfo>();
            //转为utc时间
            var utcFrom = beginTime.ToUniversalTime();
            var utcTo = endTime.ToUniversalTime();
 
            //去另一张表去获取它的其他消息记录
            var listMsg = HdlMessageLogic.Current.GetListMessageFromDb();
            if (listMsg == null)
            {
                return listLog;
            }
            foreach (var msgInfo in listMsg)
            {
                //时间不是13位的都不理
                if (msgInfo.CreateTime.Length != 13) { continue; }
                //获取门锁其他类信息上报
                if (msgInfo.MessageTitle == "/Alarms/SendAlarmInform")
                {
                    //判断是不是这个时间段
                    var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime);
                    if (utcFrom <= checkDate && checkDate <= utcTo)
                    {
                        this.AdjustDoorOtherAlarmData(ref listLog, msgInfo);
                    }
                }
                //从自动化中,获取常开模式记录
                else if (msgInfo.MessageTitle == "/Logic/Execute_Respon")
                {
                    //判断是不是这个时间段
                    var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime);
                    if (utcFrom <= checkDate && checkDate <= utcTo)
                    {
                        this.AdjustDoorNormallyOpenData(ref listLog, msgInfo);
                    }
                }
                //获取门锁临时密码开锁记录
                else if (msgInfo.MessageTitle == "/DoorLock/DoorLockOperatingEventNotificationCommand")
                {
                    //判断是不是这个时间段
                    var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime);
                    if (utcFrom <= checkDate && checkDate <= utcTo)
                    {
                        this.AdjustDoorTemporaryPasswordData(ref listLog, msgInfo);
                    }
                }
            }
 
            return listLog;
        }
 
        /// <summary>
        /// 处理门锁常开模式记录信息
        /// </summary>
        /// <param name="listLog"></param>
        /// <param name="i_msgData"></param>
        private void AdjustDoorOtherAlarmData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData)
        {
            string doorKey = this.GetDoorId();
            //设备对象
            var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand);
            string deviceAddr = jobject.Value<string>("DeviceAddr");
            int deviceEpoint = jobject.Value<int>("Epoint");
            if (doorKey != deviceAddr + "_" + deviceEpoint)
            {
                //不是同一个门锁的记录
                return;
            }
 
            var data = new DoorHistoryLogInfo();
            data.DeviceMac = deviceAddr;
            data.DeviceEpoint = deviceEpoint;
            //消息
            var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(jobject);
            data.AlarmMsg = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered);
            //时间
            data.UnlockTime = i_msgData.CreateTime;
            //主键
            data.MsgKeyId = i_msgData.Id;
            //消息区分
            if (msgInfo.MsgDiv == 9000)
            {
                data.UnLockMode = 9000;
            }
            listLog.Add(data);
        }
 
        /// <summary>
        /// 处理门锁常开模式信息上报
        /// </summary>
        /// <param name="listLog"></param>
        /// <param name="i_msgData"></param>
        private void AdjustDoorNormallyOpenData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData)
        {
            string doorKey = this.GetDoorId();
            var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand);
            var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(jobject["Data"].ToString());
            if (myActionData.ActionData == null || myActionData.ActionData.Actiontype != 8)
            {
                //不是常开模式的自动化
                return;
            }
            string deviceAddr = myActionData.ActionData.MacStr;
            int deviceEpoint = myActionData.ActionData.Epoint;
            if (doorKey != deviceAddr + "_" + deviceEpoint)
            {
                //不是同一个门锁的记录
                return;
            }
 
            var data = new DoorHistoryLogInfo();
            data.DeviceMac = deviceAddr;
            data.DeviceEpoint = deviceEpoint;
            //消息
            if (myActionData.ActionData.PassDataString == "055704010112")
            {
                //常开模式开启(自动化触发)
                data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg11);
            }
            else if (myActionData.ActionData.PassDataString == "055704010113")
            {
                //常开模式结束(自动化触发)
                data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg12);
            }
            else
            {
                return;
            }
            //时间
            data.UnlockTime = i_msgData.CreateTime;
            //主键
            data.MsgKeyId = i_msgData.Id;
            //消息区分
            data.UnLockMode = 9000;
 
            listLog.Add(data);
        }
 
        /// <summary>
        /// 处理门锁临时密码上报
        /// </summary>
        /// <param name="listLog"></param>
        /// <param name="i_msgData"></param>
        private void AdjustDoorTemporaryPasswordData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData)
        {
            string doorKey = this.GetDoorId();
            var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand);
            string deviceAddr = jobject.Value<string>("DeviceAddr");
            int deviceEpoint = jobject.Value<int>("Epoint");
            if (doorKey != deviceAddr + "_" + deviceEpoint)
            {
                //不是同一个门锁的记录
                return;
            }
            var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<PasswordOperationData>(jobject["Data"].ToString());
            if (myActionData.UserID != 246)
            {
                //不是临时密码
                return;
            }
            var data = new DoorHistoryLogInfo();
            data.DeviceMac = deviceAddr;
            data.DeviceEpoint = deviceEpoint;
            //消息
            if (myActionData.OperationEventCode == 2)
            {
                //临时密码开锁成功
                data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg13);
            }
            else
            {
                //临时密码开锁失败
                data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg14);
            }
            //时间
            data.UnlockTime = i_msgData.CreateTime;
            //主键
            data.MsgKeyId = i_msgData.Id;
 
            listLog.Add(data);
        }
 
        #endregion
 
        #region ■ 清空记录___________________________
 
        /// <summary>
        /// 清空所有记录
        /// </summary>
        private void ClearAllHistoryLog()
        {
            DateTime dateFrom = new DateTime(dateFromControl.Year, dateFromControl.Month, dateFromControl.Day, 0, 0, 0);
            DateTime dateTo = new DateTime(dateToControl.Year, dateToControl.Month, dateToControl.Day, 23, 59, 59);
            //打开进度条
            this.ShowProgressBar();
 
            //不管结果
            var result = HdlDeviceDoorLockLogic.Current.ClearAllDoorHistoryLog(this.GetDoorId(), dateFrom, dateTo, listOtherMsgId);
 
            //清空
            this.listOtherMsgId = new List<string>();
            this.listHistoryInfo = null;
 
            HdlThreadLogic.Current.RunMain(() =>
            {
                //重新刷新界面
                this.InitLogListInfo(true);
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 获取访问云端的DoorID
        /// </summary>
        /// <returns></returns>
        private string GetDoorId()
        {
            return this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint;
        }
 
        #endregion
 
        #region ■ 结构体_____________________________
 
        /// <summary>
        /// 临时密码数据
        /// </summary>
        private class PasswordOperationData
        {
            /// <summary>
            /// 0:密码 15:指纹 3:IC卡
            /// </summary>
            public int OperationEventSoure = -1;
            /// <summary>
            /// 2:开锁成功
            /// </summary>
            public int OperationEventCode = -1;
            /// <summary>
            /// 246代表临时密码
            /// </summary>
            public int UserID = -1;
        }
 
        #endregion
    }
}