private bool FilterByEndDate(object obj)
        {
            eventopendoor @event = obj as eventopendoor;

            if (@event != null && (@event.C_time.Date <= EndDateFilterValue.Value.Date))
            {
                return(true);
            }
            return(false);
        }
        private bool FilterByLobbyPhoneAddress(object obj)
        {
            eventopendoor @event = obj as eventopendoor;

            if (@event != null && (@event.C_from.StartsWith(this.LobbyPhoneAddressFilterValue)))
            {
                return(true);
            }
            return(false);
        }
 async Task UpdateSnapshotAsync(eventopendoor openDoorEvent)
 {
     await Task.Run(() =>
     {
         var snapshot = this._dataServiceSnapshot.Select(photo => photo.C_srcaddr == openDoorEvent.C_from &&
                                                         photo.C_time == openDoorEvent.C_time).FirstOrDefault();
         if (snapshot != null)
         {
             this.Snapshot = ByteToImage(snapshot.C_img);
         }
         else
         {
             this.Snapshot = null;
         }
     });
 }
Пример #4
0
        private void EventopendoordataGridView_SelectionChanged(object sender, EventArgs e)
        {
            eventopendoor opendoor = eventopendoorbindingSource.Current as eventopendoor;

            if (opendoor == null)
            {
                return;
            }

            var photo = (from p in m_db.Photographs
                         where p.C_time == opendoor.C_time
                         select p).FirstOrDefault();

            if (photo != null)
            {
                pictureBoxSnap.Image = ByteToImage(photo.C_img);
            }
            else
            {
                pictureBoxSnap.Image = null;
            }
        }
        private void AddEntrances(string DeviceId, IEnumerable <XElement> events)
        {
            if (events.Count() == 0)
            {
                return;
            }

            using (var db = new ICMDBContext())
            {
                foreach (var e in events)
                {
                    eventopendoor entrance = new eventopendoor
                    {
                        C_from = DeviceId
                    };

                    string mode = e.Attribute("mode").Value;
                    switch (mode)
                    {
                    case "pwd":
                        if (e.Attribute("ro") != null)
                        {
                            entrance.C_open_object = e.Attribute("ro").Value;
                            entrance.C_time        = Convert.ToDateTime(e.Attribute("time").Value);
                            entrance.C_mode        = mode;
                            entrance.C_verified    = e.Attribute("verified").Value == "true" ? 1 : 0;
                        }
                        break;

                    case "card":
                        if (e.Attribute("card") != null)
                        {
                            entrance.C_open_object = e.Attribute("card").Value;
                            entrance.C_time        = Convert.ToDateTime(e.Attribute("time").Value);
                            entrance.C_mode        = mode;
                            entrance.C_verified    = e.Attribute("verified").Value == "true" ? 1 : 0;
                        }
                        break;

                    case "remote":
                        if (e.Attribute("ro") != null)
                        {
                            entrance.C_open_object = e.Attribute("ro").Value;
                            entrance.C_time        = Convert.ToDateTime(e.Attribute("time").Value);
                            entrance.C_mode        = mode;
                            entrance.C_verified    = 1;
                        }
                        break;

                    default:
                        continue;
                    }

                    db.Eventopendoors.Add(entrance);
                }
                try
                {
                    db.SaveChanges();
                }
                catch (Exception) { }
            }
        }