List <UnitPhone> INovaAlertService.GetUnitPhones(int?groupId, eTaskType taskType, bool includeTask) { if (groupId.HasValue) { List <UnitPhone> list = new List <UnitPhone>(); var ids = NovaAlertCommon.GetUnitsInGroup(groupId.Value); foreach (var u in _resources.UnitPhones) { var g = ids.FirstOrDefault(gu => gu.UnitId == u.Id); if (g != null) { var up = new UnitPhone(u.Id, u.Name) { PhoneNumberId = u.PhoneNumberId, AreaCode = u.AreaCode, Number = u.Number, Password = u.Password, ListOrder = g.ListOrder, }; if (includeTask) { up.Task = NovaAlertCommon.GetLastestTask(u.PhoneNumberId, taskType); } list.Add(up); } } return(list); } else { return(_resources.UnitPhones.Select(vm => vm.Phone).OfType <UnitPhone>().ToList()); } }
public void SetSelectContact(int id) { ClearTempUnits(); UnitPhone up = null; if (this.App.IsCCPKAlertMode) { up = this.App.Service.GetUnitPhone(id, eTaskType.CCPK); } else { up = this.App.Service.GetUnitPhone(id, eTaskType.CTT); } if (up != null) { var phone = new UnitPhone(up.PhoneNumberId, up.Name); var vm = new UnitPhoneViewModel(phone) { AreaCode = up.AreaCode, Number = up.Number, ListOrder = -1, Password = up.Password }; vm.ListOrder = -1; this.App.Units.Items.Add(vm); vm.OnClickCommand.Execute(null); } }
public void SetSelectedContact(Contact ct) { ClearTempUnits(); if (ct == null) { return; } var vm = this.Items.Where(it => it.PhoneNumberId == ct.PhoneNumberId).FirstOrDefault(); if (vm != null) { if (vm.SelectedPanelId == null) { vm.OnClickCommand.Execute(null); } } else { var phone = new UnitPhone(ct.PhoneNumberId, ct.UnitName); vm = new UnitPhoneViewModel(phone) { AreaCode = ct.AreaCode, Number = ct.Number, ListOrder = -1, //GroupId = -1, Password = ct.Password }; //vm.SelectedPanelId = this.App.ClientId; vm.ListOrder = -1; this.App.Units.Items.Add(vm); vm.OnClickCommand.Execute(null); } }
public TslResult SendAndReceiveResult(UnitPhone unit) { CheckModem(); string number = string.Format("{0}{1}", unit.TSLAreaCode, unit.TSLNumber).Trim(); return(SendAndReceiveResult(number, unit.PhoneNumberId, NovaAlertCommon.SaveSubResult)); }
public TslResult SendPrepareCommand(UnitPhone unit) { CheckModem(); string number = string.Format("{0}{1}", unit.TSLAreaCode, unit.TSLNumber).Trim(); return(SendPrepareCommand(number)); }
public static List <UnitPhone> LoadUnitPhones(int?id = null) { var list = new List <UnitPhone>(); using (var ctx = new NovaAlertContext()) { var query = ctx.PhoneNumbers.OfType <PhoneNumber>().Where(u => u.DeletedDate == null); if (id.HasValue) { query = query.Where(u => u.PhoneNumberId == id.Value); } foreach (var item in query.ToList()) { var up = new UnitPhone(item.PhoneNumberId, item.NameAbbr) { AreaCode = item.AreaCode, Number = item.Number, ListOrder = -1, PhoneNumberId = item.PhoneNumberId, Password = item.Password, TSLAreaCode = item.TSLAreaCode, TSLNumber = item.TSLNumber }; list.Add(up); } } return(list); }
public TslResult SendPrepareCommand(UnitPhone unit) { System.Threading.Thread.Sleep(5000); return(new TslResult() { Connected = true, Responsed = true }); }
public TslResult SendAndReceiveResult(UnitPhone unit) { System.Threading.Thread.Sleep(5000); return(new TslResult() { Connected = true }); }
public static void UpdateTask(UnitPhone unit, long?duration, eTaskType taskType) { Entities.Task task = NovaAlert.Dal.NovaAlertCommon.GetLastestTask(unit.Id, Entities.eTaskType.CTT); using (var ctx = new NovaAlertContext()) { var dt = new GroupUnitTask() { GroupId = 0, //unit.GroupId, TaskType = (byte)taskType, PhoneNumberId = unit.PhoneNumberId, Task = (byte)unit.Task.CurrentTask, Level = (byte)unit.Task.Level, Result = (byte)unit.Task.Result, CreatedDate = DateTime.Now, Duration = duration }; ctx.GroupUnitTasks.Add(dt); ctx.SaveChanges(); } }
public static UnitPhoneViewModel Create(eWorkingMode mode, UnitPhone item) { UnitPhoneViewModel up = null; switch (mode) { case eWorkingMode.Alert: up = new AlertUnitPhoneViewModel(item); break; case eWorkingMode.MultiDest: up = new UnitPhoneViewModel(item); break; case eWorkingMode.CCPK_Alert: up = new CCPK_ALertUnitPhoneViewModel(item); break; case eWorkingMode.TSL_Alert: up = new TSL_ALertUnitPhoneViewModel(item); break; } return(up); }
public CCPK_ALertUnitPhoneViewModel(UnitPhone phone) : base(phone) { }
public AlertUnitPhoneViewModel(UnitPhone phone) : base(phone) { }
public TSL_ALertUnitPhoneViewModel(UnitPhone phone) : base(phone) { _prepareStatus = eTslStatus.None; _resultStatus = eTslStatus.None; }
public UnitPhoneViewModel(UnitPhone phone) : base(phone) { this.Task = new TaskViewModel(phone.Task); this.Task.PropertyChanged += Task_PropertyChanged; }