/// <summary> /// AIS数据 /// </summary> /// <param name="ais"></param> public void AisAdd(Ais ais) { if (ais != null) { try { using (var context = new MyContext()) { var ship = context.Ship.FirstOrDefault(); bool flag = ais.status == 0 ? true : false; //当航行状态为自动时才将AIS的状态保存到数据库中 if (ship != null && ship.type == 0 && ship.Flag != flag) { ship.Flag = flag; context.Update(ship); context.SaveChanges(); //船状态修改时要推送消息给算法 InitManger im = new InitManger(); im.InitStatus(); } } } catch (Exception ex) { AddReceiveLog("AIS", "", "写入数据失败!" + ex.Message); } } }
private AiListViewModel(ObservableCollection <AiViewModel> ais) { Ais = ais ?? throw new ArgumentNullException(nameof(ais)); var selectedAis = Ais .ToObservableChangeSet() .AutoRefresh(ai => ai.IsChecked) .Filter(ai => ai.IsChecked) .Transform(ai => ai.Ai) .Distinct() .ToCollection(); IsAnyAiSelected = selectedAis.Select(list => list.Any()); }