/// <summary> /// Updates the connected client. /// </summary> /// <param name="message">The message.</param> private void UpdateConnectedClient(ClientInfo message) { // do not handle our own info if (message.Id == CommunicationService.SessionId) { return; } var foundVm = ActiveClients.FirstOrDefault(ci => ci.Id == message.Id); if (message.IsDisconnected) { if (foundVm != null) { ActiveClients.Remove(foundVm); } } else { if (foundVm == null) { foundVm = new ClientInfoViewModel(message); ActiveClients.Add(foundVm); } else { foundVm.UpdateFrom(message); } } }
/// <summary> /// Gets the client information. /// </summary> /// <returns>ClientInfo.</returns> public ClientInfo GetClientInfo() { var result = new ClientInfo { Id = CommunicationService.SessionId, Login = ApplicationContext.User.Identity.Name, ActiveSince = CommunicationService.SessionStartedTime.ToString(CultureInfo.InvariantCulture), Ip = InitParams.UserIPParamName, ComputerName = InitParams.UserComputerNameParam, OpenWindows = MainViewModel.Windows.Select(w => w.Title), LicenseType = ApplicationContext.User.Identity.IsAuthenticated ? ((IMQ1Identity)ApplicationContext.User.Identity).LicenseType : LicenseTypes.Viewonly, AccountId = ApplicationContext.User.Identity.IsAuthenticated ? ((IMQ1Identity)ApplicationContext.User.Identity).AccountId : 0 }; return result; }
/// <summary> /// Clients the connected. /// </summary> /// <param name="info">The information.</param> public void ClientConnected(ClientInfo info) { if (_hubConnection.State == ConnectionState.Connected) _hubProxy.Invoke(CommunicationConstants.ClientConnectedEventName, info); }
/// <summary> /// Sends client info to all connected clients. /// </summary> /// <param name="message">The message.</param> public void ClientInfoResponse(ClientInfo message) { Clients.All.ClientInfoResponse(message); }
/// <summary> /// The client disconnected. /// </summary> /// <param name="info">Client info.</param> public void ClientDisconnected(ClientInfo info) { var clientInfo = LoggedInClients.FirstOrDefault(x => x.Id == info.Id); if (clientInfo != null) { LogAuthorizationDataCommand.CreateLogouAuditRecord(clientInfo.AccountId, clientInfo.Login); lock (LoggedInClients) LoggedInClients.Remove(clientInfo); } Clients.Others.ClientDisconnected(info); }
/// <summary> /// The client connected. /// </summary> /// <param name="info">Client info.</param> public void ClientConnected(ClientInfo info) { lock (LoggedInClients) if (info != null && (!string.IsNullOrEmpty(info.Login) && !LoggedInClients.Contains(info))) LoggedInClients.Add(info); Clients.Others.ClientConnected(info); }
/// <summary> /// Updates from. /// </summary> /// <param name="message">The message.</param> public void UpdateFrom(ClientInfo message) { Login = message.Login; ActiveSince = message.ActiveSince; OpenWindows = message.OpenWindows; Ip = message.Ip; }
/// <summary> /// Initializes a new instance of the <see cref="ClientInfoViewModel"/> class. /// </summary> /// <param name="message">The message.</param> public ClientInfoViewModel(ClientInfo message) { Id = message.Id; UpdateFrom(message); }
/// <summary> /// Updates from. /// </summary> /// <param name="message">The message.</param> public void UpdateFrom(ClientInfo message) { Login = message.Login; ActiveSince = message.ActiveSince; LicenseType = message.LicenseType; ClientIP = message.Ip; }
/// <summary> /// Updates the connected client. /// </summary> /// <param name="message">The message.</param> private void UpdateConnectedClient(ClientInfo message) { // do not handle our own info and not logged in users if (message.Id == CommunicationService.SessionId || string.IsNullOrEmpty(message.Login)) { return; } var foundVm = ActiveClients.FirstOrDefault(ci => ci.Id == message.Id); if (message.IsDisconnected) { if (foundVm != null) { ActiveClients.Remove(foundVm); } } else { if (foundVm == null) { foundVm = new ClientInfoViewModel(message); if (!ActiveClients.Any(x => x.ClientIP.Equals(foundVm.ClientIP) && x.Login.Equals(foundVm.Login))) ActiveClients.Add(foundVm); } else { foundVm.UpdateFrom(message); } } RaisePropertyChanged(() => ActiveConcurrentUsersCount); RaisePropertyChanged(() => ActiveNamedUsersCount); RaisePropertyChanged(() => ActiveViewonlyUsersCount); }
/// <summary> /// Check if Client Info equals. /// </summary> /// <param name="obj">Input Client Info.</param> /// <returns>True if equals.</returns> public bool Equals(ClientInfo obj) { return obj != null && Id.Equals(obj.Id); }