private void OpenCloseReportView() { ICollection <int> deletedReports = new List <int>(); var args = new DialogParameters(); args.Add("model", deletedReports); _dialogService.ShowModal("CloseReportView", args, callback => { if (deletedReports.Count > 0) { foreach (var room in RoomsCollection) { var id = deletedReports.FirstOrDefault(x => x == room.ActiveDevice.ReportId); if (id > 0) { var device = new ActiveDevice { DeviceType = Domain.Enumerations.DeviceType.Default, IPAddress = room.ActiveDevice.IPAddress, IsActive = true, IsAdded = true, Nick = room.ActiveDevice.Nick, }; _activeDeviceRepository.CheckDevice(device).Wait(); room.ActiveDevice.Id = device.Id; room.ActiveDevice.Report = null; room.ActiveDevice.ReportId = 0; room.ActiveDevice.IsSelected = false; } } } }); }
private void DoWOSweep() { // while (!IsStopped) { if (!WOSweepOccuring) { WOSweepOccuring = true; List <WorkOrder> WosWaitingLongerThanAverage = WorkOrder.GetWorkOrdersRequiringReassignment(); // Re-arrange WOs foreach (WorkOrder wo in WosWaitingLongerThanAverage) { // Remove device from active ids try { ActiveDevice.Populate(wo.SlaveWorkerId.Value).Delete(); } catch { } using (WorkOrder oWO = WorkOrder.Populate(wo.WorkOrderId)) { oWO.WorkOrderStatus = "BEING_REASSIGNED"; oWO.Save(); } // Rearrange WO NewWorkOrders.Send(new BrokeredMessage(wo.WorkOrderId)); } WOSweepOccuring = false; } }
private void Upsert(DeviceActor.Events.DeviceDeployed evt) { ActiveDevice d; if (_devices.ContainsKey(evt.IMEI)) { d = _devices[evt.IMEI]; } else { d = new ActiveDevice(); _devices.Add(evt.IMEI, d); } d.IMEI = evt.IMEI; d.ShipperId = evt.ShipperId; d.Consignee = evt.Consignee; d.ContainerNumber = evt.ContainerNumber; d.SecuritySealNumber = evt.SecuritySealNumber; d.ShippingLine = evt.ShippingLine; d.VesselName = evt.VesselName; d.VoyageNumber = evt.VoyageNumber; d.OriginPort = evt.OriginPort; d.DestinationPort = evt.DestinationPort; d.EstimatedDeparture = evt.EstimatedDeparture; d.EstimateArrival = evt.EstimateArrival; d.DeviceDeploymentDate = evt.DeviceDeploymentDate; _isSaved = false; Self.Tell(new SaveCommand()); }
private void Current_AddToCollectionEvent(ActiveDevice arg1, RoomInfo arg2) { TemperatureGraphInfo.GraphLineModel.AddDataPoint(TemperatureGraphInfo.GraphLineModel.GetFirst(), new DataPoint(DateTimeAxis.ToDouble(arg2.Date.AddMinutes(10)), arg2.Temperature)); HumidityGraphInfo.GraphLineModel.AddDataPoint(HumidityGraphInfo.GraphLineModel.GetLast(), new DataPoint(DateTimeAxis.ToDouble(arg2.Date.AddMinutes(10)), arg2.Humidity)); TemperatureGraphInfo.GraphLineModel.InvalidatePlot(true); HumidityGraphInfo.GraphLineModel.InvalidatePlot(true); }
public async Task <bool> UpdateAsync(ActiveDevice activeDevice) { using (var connection = _factory.CreateConnection()) { var b = await connection.UpdateAsync(activeDevice); return(b); } }
public void MakePillsForSymptom(Symptom sym) { if (sym == null) { throw new ArgumentNullException(); } ActiveDevice.Machzeug(sym.Wirkstoffe); }
private void ProcessCommunication(CommunicationPackage cp) { try { // CommunicationPackage cp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommunicationPackage>(cpSerialized); UserDevice ud = UserDevice.Populate(cp.TargetDeviceId); ActiveDevice ad; // Have to try and catch the exception, since might not exist in the current context try { ad = ActiveDevice.Populate(ud.DeviceId); } catch (Exception) { ad = null; } CommunicationPackage fetchRequest = CommunicationPackage.CreateFetchRequest(cp.TargetDeviceId); // If last fetch from device was less than 3 mins ago, don't send GCM if (ad != null && ad.LastFetch < DateTime.Now.AddMinutes(-1)) { // Send GCM if (fetchRequest.SendAttempts < 3 && fetchRequest.SubmitDate < DateTime.Now.AddSeconds(-30)) { Pusher.SendNotification(ud.GCMCode, fetchRequest.Serialize()); fetchRequest.SubmitDate = DateTime.Now; fetchRequest.SendAttempts++; fetchRequest.Save(); } else if (fetchRequest.SendAttempts >= 3 && fetchRequest.SubmitDate < DateTime.Now.AddSeconds(-40)) { // Device might not be active, delete it from the active device list. try { ad.Delete(); } catch { } // If not results, re-arrange WO List <int?> workOrdersToBeRearranged = ud.CommunicationPackages.Where(x => x.Status == null && x.Response == null && x.CommunicationType != (int)CommunicationPackage.UpdateType.Result).Select(x => x.WorkOrderId).ToList(); // Delete current Comm Packages to the device if they are requests for work. ud.DeleteOutstandingSlaveCommPackages(); // Rearange work orders foreach (int?woId in workOrdersToBeRearranged) { if (woId.HasValue) { NewWorkOrders.Send(new BrokeredMessage(woId.Value)); } } } } // handle if less than 10 ... etc.. } catch (Exception e) { Debug.WriteLine(e.Message); } }
public async Task SwapReportId(ActiveDevice from, ActiveDevice to) { using (var connection = _factory.CreateConnection()) { string query = @"UPDATE ActiveDevices SET reportid = 0 Where id=@a1; UPDATE ActiveDevices SET reportid = @r1 Where id=@a2;"; var entities = await connection.ExecuteAsync(query, new { a1 = from.Id, a2 = to.Id, r1 = from.ReportId }); } }
public async Task <bool> DeatachDevice(ActiveDevice activeDevice) { using (var connection = _factory.CreateConnection()) { activeDevice.IsAdded = false; var b = await connection.UpdateAsync(activeDevice); return(b); } }
public void MarkDeviceInactive(string at, int deviceId) { AuthenticationToken oAt = new AuthSvc().AuthUser(at, -1, deviceId); try { ActiveDevice ad = ActiveDevice.Populate(deviceId); ad.Delete(); //TODO: Re-assign work orders } catch { } }
public override void DeviceInformationViewModel_AddToCollectionEvent(ActiveDevice active, MultiRoomInfo room) { room.DeviceId = active.Id; Task.Run(async() => { await _multiRoomRepository.SaveAsync(room); }).ContinueWith(t => { _logger.Error("Не удлаось добавить данные в {0}", active?.IPAddress); _logger.Error("Ошибка {0}", t.Exception?.Message); _logger.Error("Ошибка {0}", t.Exception?.InnerException); }, TaskContinuationOptions.OnlyOnFaulted); }
public static void UpdateDeviceLastCommunicated(int deviceId) { if (IsDeviceActive(deviceId)) { ActiveDevice ad = ActiveDevice.Populate(deviceId); ad.LastActiveSend = DateTime.Now; ad.Save(); } else { ActiveDevice.CreateActiveDevice(deviceId); } }
protected override void CloseDialogOnOk(IDialogParameters parameters) { if (SelectedServer == null) { return; } Result = ButtonResult.OK; parameters = new DialogParameters(); var activeDevice = new ActiveDevice(SelectedServer); activeDevice.IsAdded = true; activeDevice.IsActive = true; parameters.Add("model", activeDevice); CloseDialog(parameters); }
public InputManager(Game game, ActiveDevice device = ActiveDevice.Keyboard | ActiveDevice.Pad, int lever = 500) { Game = game; DirectInput = new SharpDX.DirectInput.DirectInput(); LeverDead = lever; MouseState = new MouseState(); var ms = MSInput::Mouse.GetState(); MouseState.X = ms.X; MouseState.Y = ms.Y; ControlState = new ControlState(); GamePlayControlState = new ControlState(); keyConfig = KeyboardConfig.GetDefault(); padConfig = PadConfig.GetDefault(); InitDevices(device); GetPushedKey();//������ }
private void SelectedDeviceChangeEvent(ActiveDevice value) { if (value != null) { value.IsAdded = !value.IsAdded; var d = DevicesForViewCollection.FirstOrDefault(x => x.IPAddress == value.IPAddress); if (d != null && !value.IsAdded) { DevicesForViewCollection.Remove(d); } else if (value.IsAdded) { DevicesForViewCollection.Add(value); } } }
public async Task <ActiveDevice> CheckDevice(ActiveDevice activeDevice) { string query = "SELECT *From ActiveDevices Where id=@id"; using (var connection = _factory.CreateConnection()) { var device = await connection.QueryFirstOrDefaultAsync <ActiveDevice>(query, new { id = activeDevice.Id }); if (device != null) { device.IsActive = true; await connection.UpdateAsync(device); } else { activeDevice.Id = await connection.InsertAsync(activeDevice); } return(activeDevice); } }
private void ActiveDevicePageBindingContextChanged(object sender, EventArgs e) { var newActiveDevice = this.BindingContext as ActiveDevice; if (this.activeDevice != null && this.activeDevice != newActiveDevice) { this.activeDevice.PropertyChanged -= this.ActiveDevicePropertyChanged; this.activeDevice.AppLaunchStatusChanged -= this.AppLaunchStatusChanged; } this.activeDevice = newActiveDevice; if (this.activeDevice != null) { this.activeDevice.PropertyChanged += this.ActiveDevicePropertyChanged; this.activeDevice.AppLaunchStatusChanged += this.AppLaunchStatusChanged; this.RunningProcessesChanged(); this.AppLaunchStatusChanged(AppLaunchStatus.None); } }
private void OpenGraph(ActiveDevice activeDevice) { var dialogParametr = new DialogParameters(); dialogParametr.Add("date", DateTimeSpan); if (activeDevice.DeviceType == Domain.Enumerations.DeviceType.Default) { var room = new RoomLineGraphInfo(activeDevice); dialogParametr.Add("model", room); _dialogService.Show("GraphView", dialogParametr, x => { }); } if (activeDevice.DeviceType == Domain.Enumerations.DeviceType.Multi) { var room = new MultiRoomLineGraphInfo(activeDevice); dialogParametr.Add("model", room); _dialogService.Show("MultiGraphView", dialogParametr, x => { }); } }
public virtual void OpenNewDevcieView() { ActiveDevice newDevice = null; _dialogService.ShowModal("SelectionDeviceViewOld", x => { if (x.Result == ButtonResult.OK) { newDevice = x.Parameters.GetValue <ActiveDevice>("model"); } }); if (newDevice != null) { var room = RoomsCollection.FirstOrDefault(x => x.ActiveDevice.IPAddress == newDevice.IPAddress); if (room == null) { TRoomLine roomLine = Activator.CreateInstance(typeof(TRoomLine), newDevice, true) as TRoomLine; roomLine.AddToCollectionEvent += DeviceInformationViewModel_AddToCollectionEvent; RoomsCollection.Add(roomLine); Task.Run(async() => { newDevice.DeviceType = _deviceType; await _activeDeviceRepository.CheckDevice(newDevice); _logger.Information("Added new device to listen {0}", newDevice.IPAddress); await roomLine.InitializeDeviceAsync(); }).ContinueWith(t => { _logger.Error(t.Exception.Message); _logger.Error(t.Exception?.InnerException?.Message); }, TaskContinuationOptions.OnlyOnFaulted); } } }
public virtual void InitDevices(ActiveDevice device) { Device = device; if ((Device & ActiveDevice.Keyboard) != 0) { KeyBoard = new KeyBoard(); } if ((Device & ActiveDevice.Pad) != 0) { int padNum = GetPadNum(); if (padNum == 0) { Device -= ActiveDevice.Pad; } else { GamePads = Enumerable.Range(0, padNum) .Select<int, GamePadBase>(i => new GamePad(LeverDead, i, DirectInput)) .Concat(XInputPad.GetAvailableControllers() .Select(x=>new XInputPad(x))) .ToArray(); } //try //{ // gamePad = new GamePad(game, lever); //} //catch (Exception) //{ // Device -= ActiveDevice.Pad; //} } ApplyConfig(); }
public static Boolean IsDeviceActive(int deviceId) { return(ActiveDevice.DeviceIsActive(deviceId)); }
/// <summary> /// 呼び出すとControlStateと各パッドのコンフィグが初期化される /// </summary> /// <param name="device"></param> public override void InitDevices(ActiveDevice device) { base.InitDevices(device); ControlStates = new[] { new ControlState() }.Concat(GamePads.Select(x => x != null ? new ControlState() : null)).ToArray(); }
public virtual void DeviceInformationViewModel_AddToCollectionEvent(ActiveDevice active, TRoom room) { }