void INovaAlertService.DoTslTask(int phoneNumberId, eTslStatusType type)
        {
            var task = new TslTask()
            {
                Client = GetClient(), Type = type
            };

            var uv = _resources.UnitPhones.Where(u => u.PhoneNumberId == phoneNumberId).FirstOrDefault();

            if (uv == null)
            {
                return;
            }
            else
            {
                task.Unit = uv.UnitPhone;
            }

            var ts     = new ThreadStart(() => DoTaskThread(task));
            var thread = new Thread(ts);

            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;
            thread.Start();
        }
예제 #2
0
 void INovaAlertServiceCallback.OnTslStatusChanged(int phoneNumberId, eTslStatusType type, eTslStatus result, int?hostClientId)
 {
     if (this.TSLController != null)
     {
         this.TSLController.OnTslStatusChanged(phoneNumberId, type, result, hostClientId);
     }
 }
        void INovaAlertService.UpdateTslStatus(int phoneNumberId, eTslStatusType type, eTslStatus status)
        {
            TslRepository.Instance.UpdateStatus(phoneNumberId, type, status);
            var client = GetClient();

            NotifyTslStatusChanged(phoneNumberId, type, status, client.Id);
        }
        public override void OnTslStatusChanged(int phoneNumberId, eTslStatusType type, eTslStatus result, int?hostClientId)
        {
            var unit = this.ClientApp.GetUnits(u => u.PhoneNumberId == phoneNumberId)
                       .OfType <TSL_ALertUnitPhoneViewModel>().FirstOrDefault();

            if (unit != null)
            {
                if (type == eTslStatusType.Prepare)
                {
                    unit.PrepareStatus = result;
                }
                else
                {
                    unit.ResultStatus = result;
                }
            }

            if (hostClientId == this.ClientApp.ClientId)
            {
                lock (this)
                {
                    Monitor.PulseAll(this);
                }
            }
        }
        void NotifyTslStatusChanged(int phoneNumberId, eTslStatusType type, eTslStatus status, int?hostClientId = null)
        {
            var clients = _resources.GetActiveClients();

            foreach (var client in  clients)
            {
                try
                {
                    client.Callback.OnTslStatusChanged(phoneNumberId, type, status, hostClientId);
                }
                catch (Exception ex)
                {
                }
            }
        }
예제 #6
0
 public void UpdateStatus(int phoneNumberId, eTslStatusType type, eTslStatus status)
 {
     using (var ctx = new NovaAlertContext())
     {
         var st = new TslStatusDb()
         {
             CreatedDate   = DateTime.Now,
             PhoneNumberId = phoneNumberId,
             Type          = (byte)type,
             Status        = (byte)status
         };
         ctx.TslStatusDbs.Add(st);
         ctx.SaveChanges();
     }
 }
예제 #7
0
 public void DoTslTask(int phoneNumberId, eTslStatusType type)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         _realProxy.DoTslTask(phoneNumberId, type);
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
예제 #8
0
 public void UpdateTslStatus(int phoneNumberId, eTslStatusType type, eTslStatus status)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         _realProxy.UpdateTslStatus(phoneNumberId, type, status);
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
예제 #9
0
 public TslStatus GetLatestTslStatus(int phoneNumberId, eTslStatusType type)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         return(_realProxy.GetLatestTslStatus(phoneNumberId, type));
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
예제 #10
0
 public void OnDoTask(eTslStatusType type)
 {
     if (this.CurrentTask != null)
     {
         this.CurrentTask.IsCanceledByUser = true;
         this.ClientApp.Service.CancelTslTask();
         return;
     }
     else
     {
         var selectedUnits = this.GetSelectedUnits();
         var task          = new TSL_Task(this, selectedUnits, type);
         task.PropertyChanged += task_PropertyChanged;
         this.CurrentTask      = task;
     }
 }
예제 #11
0
        public void ClearStatus(eTslStatusType type)
        {
            var units = GetSelectedUnits();

            if (units.Count == 0)
            {
                this.ClientApp.ShowError("Vui lòng chọn đơn vị cần xóa trạng thái.");
            }
            else
            {
                foreach (var u in units)
                {
                    this.ClientApp.Service.UpdateTslStatus(u.PhoneNumberId, type, eTslStatus.None);
                }

                this.ClientApp.AddLog(string.Format("Xóa trạng thái {0} của {1}",
                                                    type == eTslStatusType.Prepare ? "CBNL" : "nhận KQ", TranslateToText(units)));
            }
        }
예제 #12
0
        public TslStatus GetLatestStatus(int phoneNumberId, eTslStatusType type)
        {
            using (var ctx = new NovaAlertContext())
            {
                var st = ctx.TslStatusDbs.Where(t => t.PhoneNumberId == phoneNumberId && t.Type == (byte)type)
                         .OrderByDescending(t => t.Id).FirstOrDefault();

                if (st != null)
                {
                    return(new TslStatus()
                    {
                        Id = st.Id,
                        Type = (eTslStatusType)st.Type,
                        Status = (eTslStatus)st.Status,
                        CreatedDate = st.CreatedDate,
                        DeletedDate = st.DeletedDate
                    });
                }
                else
                {
                    return(null);
                }
            }
        }
 TslStatus INovaAlertService.GetLatestTslStatus(int phoneNumberId, eTslStatusType type)
 {
     return(TslRepository.Instance.GetLatestStatus(phoneNumberId, type));
 }
예제 #14
0
 public virtual void OnTslStatusChanged(int phoneNumberId, eTslStatusType type, eTslStatus result, int?hostClientId)
 {
 }
예제 #15
0
        public TSL_Task(TSL_AlertController controller, List <TSL_ALertUnitPhoneViewModel> units, eTslStatusType type)
        {
            _isCompleted      = false;
            _isCanceledByUser = false;
            _sb = new StringBuilder();

            this.Controller = controller;
            this.Units      = units;
            this.TaskType   = type;

            var desc = (string.Format("Gởi y/c {0} đến {1}", type == eTslStatusType.Prepare ? "CBNL" : "nhận KQ", TSL_AlertController.TranslateToText(units)));

            this.Controller.ClientApp.AddLog(desc);
            this.AddLog(desc);

            string s = string.Empty;

            if (this.TaskType == eTslStatusType.Prepare)
            {
                s = this.Controller.ClientApp.Service.GetParameterValue(eGlobalParameter.TSL_PrepareTries);
            }
            else
            {
                s = this.Controller.ClientApp.Service.GetParameterValue(eGlobalParameter.TSL_ReceiveTries);
            }

            if (!int.TryParse(s, out _retryCount) || _retryCount < 1)
            {
                _retryCount = 1;
            }
        }