예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
 /// <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);
 }
예제 #4
0
 /// <summary>
 /// Sends client info to all connected clients.
 /// </summary>
 /// <param name="message">The message.</param>
 public void ClientInfoResponse(ClientInfo message)
 {
     Clients.All.ClientInfoResponse(message);
 }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
 /// <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;
 }
예제 #8
0
 /// <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);
 }
예제 #9
0
 /// <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;
 }
예제 #10
0
        /// <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);
        }
예제 #11
0
 /// <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);
 }