public Task DeleteSecurityCardAsync(iccard obj)
        {
            return(Task.Run(() =>
            {
                if (obj == null)
                {
                    return;
                }

                _dataService.Delete(m => m.C_icno == obj.C_icno);

                bool needToRefresh = false;
                lock (_SecurityCardLock)
                {
                    if (this._SecurityCard == obj)
                    {
                        this._SecurityCard = null;
                        needToRefresh = true;
                    }
                }
                if (needToRefresh)
                {
                    RefillDataAction.Defer(_refillDelay);
                }
            }));
        }
Ejemplo n.º 2
0
 public AlarmsModel(IDataService <eventwarn> dataService) : base(dataService)
 {
     Messenger.Default.Register <ReceivedAlarm>(this, (msg) =>
     {
         RefillDataAction.Defer(_refillDelay);
     });
 }
Ejemplo n.º 3
0
 public CallOutEventsModel(IDataService <eventcallout> dataService) : base(dataService)
 {
     Messenger.Default.Register <ReceivedCallOutEvent>(this, (msg) =>
     {
         RefillDataAction.Defer(_refillDelay);
     });
 }
        public virtual void Delete(IList objs)
        {
            if (objs == null)
            {
                return;
            }

            lock (_lock)
            {
                List <T> objsToBeRemoved = new List <T>();
                foreach (var obj in objs)
                {
                    objsToBeRemoved.Add(obj as T);
                }

                foreach (var obj in objsToBeRemoved)
                {
                    if (!Delete(obj))
                    {
                        break;
                    }
                }
            }

            RefillDataAction.Defer(_refillDelay);
        }
 public OpenDoorEventsModel(IDataService <eventopendoor> dataService) : base(dataService)
 {
     Messenger.Default.Register <ReceivedOpenDoorEvent>(this, (msg) =>
     {
         RefillDataAction.Defer(_refillDelay);
     });
 }
        public Task DeleteAnnouncementAsync(Announcement obj)
        {
            return(Task.Run(() =>
            {
                if (obj == null)
                {
                    return;
                }

                _dataService.Delete(m => m.AnnouncementID == obj.id);

                bool needToRefresh = false;
                lock (_AnnouncementLock)
                {
                    if (this._Announcement == obj)
                    {
                        this._Announcement = null;
                        needToRefresh = true;
                    }
                }
                if (needToRefresh)
                {
                    RefillDataAction.Defer(_refillDelay);
                }
            }));
        }
Ejemplo n.º 7
0
        public override void Insert(advertisement obj)
        {
            var currentMaxPlayOrder = _dataService.SelectAll().Max((advertisement) => advertisement.C_no);

            obj.C_no   = (currentMaxPlayOrder == null) ? 1 : (currentMaxPlayOrder + 1);
            obj.C_time = DateTime.Now;
            _dataService.Insert(obj);
            RefillDataAction.Defer(_refillDelay);
        }
Ejemplo n.º 8
0
        //private ICollectionModel<Room> _roomDataModel;

        public DevicesModel(
            IDeviceDataService dataService) : base(dataService)
        {
            this._refillTimer = new Timer(new TimerCallback(delegate
            {
                Application.Current.Dispatcher.Invoke(() => RefillDataAction.Defer(_refillDelay));
            }));
            this._refillTimer.Change(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(1000));
        }
Ejemplo n.º 9
0
 public override void Insert(Device obj)
 {
     if (obj.type == (int)DeviceType.Control_Server)
     {
         obj.online = 1;
     }
     _dataService.Insert(obj);
     RefillDataAction.Defer(_refillDelay);
 }
Ejemplo n.º 10
0
 public override void Insert(Room obj)
 {
     try
     {
         _dataService.Insert(obj);
     }
     catch (Exception) { }
     RefillDataAction.Defer(_refillDelay);
 }
Ejemplo n.º 11
0
 public VideoMessagesModel(IDataService <leaveword> dataService) : base(dataService)
 {
     Messenger.Default.Register <ReceivedNewVideoMessageEvent>(this, (msg) =>
     {
         RefillDataAction.Defer(_refillDelay);
     });
     Messenger.Default.Register <VideoMessageHasBeenReadEvent>(this, (msg) =>
     {
         RefillDataAction.Defer(_refillDelay);
     });
 }
Ejemplo n.º 12
0
        public override void Insert(sipaccount obj)
        {
            Random random     = new Random();
            int    randomCode = random.Next() % 10000;

            obj.C_password       = GeneratePassword(randomCode);
            obj.C_randomcode     = randomCode.ToString();
            obj.C_updatetime     = DateTime.Now;
            obj.C_registerstatus = 0;
            obj.C_sync           = 0;
            _dataService.Insert(obj);
            RefillDataAction.Defer(_refillDelay);
        }
        public void SetAnnouncement(Announcement obj)
        {
            //bool isDifferent = false;
            lock (_AnnouncementLock)
            {
                //if (_Announcement != obj)
                //{
                _Announcement = obj;
                //    isDifferent = true;
                //}
            }

            //if (isDifferent)
            RefillDataAction.Defer(_refillDelay);
        }
Ejemplo n.º 14
0
        public void SetSecurityCard(iccard obj)
        {
            //bool isDifferent = false;
            lock (_SecurityCardLock)
            {
                //if (_SecurityCard != obj)
                //{
                _SecurityCard = obj;
                //isDifferent = true;
                //}
            }

            //if (isDifferent)
            RefillDataAction.Defer(refillDelay);
        }
Ejemplo n.º 15
0
        public override void Insert(upgrade obj)
        {
            if (obj.device_type == null)
            {
                obj.device_type = -1;
            }
            var defaultObj = _dataService.Select(info => info.filetype == obj.filetype &&
                                                 info.device_type == obj.device_type &&
                                                 info.is_default == 1).FirstOrDefault();

            if (defaultObj == null)
            {
                obj.is_default = 1;
            }
            _dataService.Insert(obj);
            RefillDataAction.Defer(_refillDelay);
        }
Ejemplo n.º 16
0
        public override Task DeleteAsync(IList objs)
        {
            return(Task.Run(() =>
            {
                lock (_lock)
                {
                    List <iccard> objsToBeRemoved = new List <iccard>();
                    foreach (var obj in objs)
                    {
                        objsToBeRemoved.Add(obj as iccard);
                    }

                    foreach (var obj in objsToBeRemoved)
                    {
                        try
                        {
                            if (obj == null)
                            {
                                break;
                            }

                            _dataService.Delete(obj);
                            _data.Remove(obj);
                            _securityCardsDevicesDataModel.DeleteSecurityCardAsync(obj);
                        }
                        catch (EntityException) // TODO: 更好的錯誤提示
                        {
                            // database is offline
                            break;
                        }
                        catch (Exception)
                        {
                            break;
                        }
                    }
                }

                RefillDataAction.Defer(_refillDelay);
            }));
        }
Ejemplo n.º 17
0
        public override Task DeleteAsync(IList objs)
        {
            return(Task.Run(() =>
            {
                lock (_lock)
                {
                    List <advertisement> objsToBeRemoved = new List <advertisement>();
                    foreach (var obj in objs)
                    {
                        objsToBeRemoved.Add(obj as advertisement);
                    }

                    foreach (var obj in objsToBeRemoved)
                    {
                        try
                        {
                            if (obj == null)
                            {
                                break;
                            }

                            _dataService.Delete(obj);
                            _data.Remove(obj);
                        }
                        catch (EntityException) // TODO: 更好的錯誤提示
                        {
                            // database is offline
                            break;
                        }
                        catch (Exception)
                        {
                            break;
                        }
                    }
                    RelabelThePlayOrder();
                }

                RefillDataAction.Defer(_refillDelay);
            }));
        }
Ejemplo n.º 18
0
 public virtual void Insert(T obj)
 {
     _dataService.Insert(obj);
     RefillDataAction.Defer(_refillDelay);
 }
Ejemplo n.º 19
0
        public override Task DeleteAsync(IList objs)
        {
            return(Task.Run(() =>
            {
                lock (_lock)
                {
                    List <upgrade> objsToBeRemoved = new List <upgrade>();
                    foreach (var obj in objs)
                    {
                        objsToBeRemoved.Add(obj as upgrade);
                    }

                    foreach (var obj in objsToBeRemoved)
                    {
                        try
                        {
                            if (obj == null)
                            {
                                break;
                            }

                            _dataService.Delete(obj);
                            _data.Remove(obj);
                        }
                        catch (EntityException) // TODO: 更好的錯誤提示
                        {
                            // database is offline
                            break;
                        }
                        catch (Exception)
                        {
                            break;
                        }
                    }

                    var defaultObjsToBeRemoved = from obj in objsToBeRemoved
                                                 where obj.is_default == 1
                                                 select obj;
                    foreach (var obj in defaultObjsToBeRemoved)
                    {
                        try
                        {
                            var candidateObj = _dataService.Select(info => info.filetype == obj.filetype &&
                                                                   info.device_type == obj.device_type).FirstOrDefault();
                            if (candidateObj == null)
                            {
                                continue;
                            }

                            candidateObj.is_default = 1;
                            _dataService.Update(candidateObj);
                        }
                        catch (EntityException) // TODO: 更好的錯誤提示
                        {
                            // database is offline
                            break;
                        }
                        catch (Exception)
                        {
                            break;
                        }
                    }
                }

                RefillDataAction.Defer(_refillDelay);
            }));
        }