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(); }
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) { } } }
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(); } }
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(); } }
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(); } }
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(); } }
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; } }
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))); } }
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)); }
public virtual void OnTslStatusChanged(int phoneNumberId, eTslStatusType type, eTslStatus result, int?hostClientId) { }
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; } }