/// <summary> /// Executes the SeenModerator message. /// </summary> /// <param name="message">The message.</param> private void Execute(SeenModeratorMessage message) { if (message.ErrorMessage != null) { Log(LogLevel.Warning, message.ErrorMessage); return; } var server = Repository.Server.GetCurrentServer(); var serverGroup = Repository.Server.GetServerGroup(message.ServerGroup); var context = new MessageContext { ServerId = server.Id, ServerName = server.Name, ServerPort = server.Port, ServerGroupId = serverGroup.Id, ServerGroupName = serverGroup.Name }; QueryRunner.SendTextMessage(Repository.Settings.Control.SeenModerator.Target, Repository.Settings.Control.SeenModerator.TargetId > 0 ? Repository.Settings.Control.SeenModerator.TargetId : message.SenderClientId, Repository.Settings.Control.SeenModerator.TextMessage.ToMessage(context)); for (int index = 0; index < message.ClientDatabaseIds.Count; index++) { var clientDatabaseId = message.ClientDatabaseIds[index]; var client = Repository.Client.GetClientDataBaseInfo(clientDatabaseId); if (client != null) { var lastSeen = Repository.Client.GetLastSeen(clientDatabaseId); var joinedGroup = Repository.Client.GetServerGroupJoined(clientDatabaseId, message.ServerGroup); var messageContext = new MessageContext { Index = index + 1, ServerName = server.Name, ServerId = server.Id, ServerPort = server.Port, ServerGroupId = serverGroup.Id, ServerGroupName = serverGroup.Name, ServerGroupJoined = joinedGroup > DateTime.MinValue ? joinedGroup.ToLocalTime().ToString(Repository.Static.DateTimeFormat) : "Never", ClientDatabaseId = client.DatabaseId, ClientNickname = client.NickName, ClientLastLogin = client.LastConnected.ToLocalTime().ToString(Repository.Static.DateTimeFormat), ClientLastSeen = lastSeen != default(DateTime) && lastSeen > DateTime.MinValue ? lastSeen.ToLocalTime().ToString(Repository.Static.DateTimeFormat) : client.LastConnected.ToLocalTime().ToString(Repository.Static.DateTimeFormat) }; QueryRunner.SendTextMessage(Repository.Settings.Control.SeenModerator.Target, Repository.Settings.Control.SeenModerator.TargetId > 0 ? Repository.Settings.Control.SeenModerator.TargetId : message.SenderClientId, Repository.Settings.Control.SeenModerator.MessagePerClient.ToMessage(messageContext)); } } var senderClientEntry = Repository.Client.GetClientInfo(message.SenderClientId); Log(Repository.Settings.Control.SeenModerator, string.Format("Client '{1}'(id:{2}) used {0}.", Repository.Settings.Control.SeenModerator.Command, senderClientEntry.Nickname, senderClientEntry.DatabaseId)); }