public override Task OnDisconnected(bool stop) { UserDataDto user; var events = new SignalREventHandlers(Context.QueryString["access_token"]); if (_users.Keys.Contains(Context.ConnectionId)) { Groups.Remove(Context.ConnectionId, _users[Context.ConnectionId].GroupName); if (_users.TryRemove(Context.ConnectionId, out user)) { if (!user.GroupName.Contains("PulseServer#")) { ProcessNotification(Context, ProcessType.Disconnected, KioskStatus.offline, user.MachineId, user.SystemName, user.GroupName); Clients.Group(user.GroupName).OnDisconnected(user.MachineId); AsyncHelper.RunSync(() => events.TriggerSystemEventAsync(new SystemEventArgs { Action = ActionType.Disconnected, Description = "Disconnected", MachineId = user.MachineId, MachineName = user.SystemName, Status = SystemEventStatus.Hight, })); } } } return(base.OnDisconnected(false)); }
private NotifyKioskDto AddNotification(string machineId, ProcessType processType, KioskStatus kioskStatus, string systemName, string groupName) { if (SettingsConfigurationSignalR.IS_PULSE_SERVER) { var events = new SignalREventHandlers(Context.QueryString["access_token"]); AsyncHelper.RunSync(() => events.TriggerUpdateStatusAsync(new KioskArgs { MachineId = machineId, kioskStatus = kioskStatus })); var document = AsyncHelper.RunSync(() => events.TriggerNofityAsync(new NotifyKioskArgs { MachineId = machineId, Name = systemName, GroupName = groupName, Status = Enum.GetName(typeof(KioskStatus), kioskStatus), Content = string.Format("Kiosk {0} {1} to Pulse Server.", systemName, Enum.GetName(typeof(ProcessType), processType)), CreateAt = DateTime.UtcNow })); return(document); } return(null); }
private void TriggerMongoKiosk(string machineId, string json) { var events = new SignalREventHandlers(Context.QueryString["access_token"]); AsyncHelper.RunAsync(() => events.TriggerMongoKioskAsync(new MongoKioskArgs { MachineId = machineId, Json = json })); }
public async Task <IHttpActionResult> Logout([FromBody] Dictionary <string, string> @param) { var user = await _userProfileService.FindByUserIdAsync(_userProfileService.CurrentUserId); var events = new SignalREventHandlers(@param["token"]); await events.TriggerUserActivitiesAsync(new UserActivitiesArgs { Action = ActionType.Logout, Name = user.FullName }); return(Content(System.Net.HttpStatusCode.OK, "Successful")); }
public async Task <IHttpActionResult> Post([FromBody] Dictionary <string, string> @param) { var result = await _proxyService.EnsureApiTokenAsync(@param["username"], @param["password"]); if (result.ContainsKey("fullName")) { var events = new SignalREventHandlers(result["access_token"]); await events.TriggerUserActivitiesAsync(new UserActivitiesArgs { Action = ActionType.Login, Name = result["fullName"], }); } return(Ok(result)); }
public void SendDeviceControl(string machineId, string controlType) { var userData = FindUserDataByMachineId(machineId); var events = new SignalREventHandlers(Context.QueryString["access_token"]); if (userData != null) { ProcessDevicesControlMessage(userData.ConnectionId, controlType); AsyncHelper.RunSync(() => events.TriggerSystemEventAsync(new SystemEventArgs { Action = controlType == "shutdown" ? ActionType.ShutDown : ActionType.Restart, Description = controlType == "shutdown" ? Enum.GetName(typeof(ActionType), 1) : Enum.GetName(typeof(ActionType), 0), MachineId = machineId, MachineName = userData.SystemName, Status = SystemEventStatus.Critical })); } }