/// <summary> /// Initializes the message /// </summary> /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param> /// <param name="parameters">The parameters.</param> public override void Initialize(MessageReceivedEventArgs e, string[] parameters) { SenderClientId = e.InvokerClientId; string nickname = null; if (parameters.Length > 1) { TimeSpanEntity timeSpanEntity; if (TimeSpanEntity.TryParse(parameters[1], out timeSpanEntity)) { this.TimeSpan = timeSpanEntity; if (parameters.Length > 2) { nickname = string.Join(" ", parameters, 2, parameters.Length - 2); } } else if (parameters.Length > 2 && TimeSpanEntity.TryParse(parameters[parameters.Length - 1], out timeSpanEntity)) { this.TimeSpan = timeSpanEntity; nickname = string.Join(" ", parameters, 1, parameters.Length - 2); } else { nickname = string.Join(" ", parameters, 1, parameters.Length - 1); } } if (nickname != null) { AllClients = false; uint clientDatabaseId; if (uint.TryParse(nickname, out clientDatabaseId)) { ClientDatabaseIds.Add(clientDatabaseId); } else { var clientIds = Repository.Client.GetClientsFromDatabase().Values .Where(m => m.NickName.ToLower().Contains(nickname.ToLower())) .Select(m => m.DatabaseId).ToList(); if (clientIds.Any()) { ClientDatabaseIds = clientIds; } else { ErrorMessage = string.Format("Could not find nickname or database id '{0}'", nickname); } } } }
/// <summary> /// Initializes a new instance of the <see cref="HoursMessage"/> class. /// </summary> public HoursMessage() { TimeSpan = new TimeSpanEntity(); ClientDatabaseIds = new List <uint>(); AllClients = true; }
/// <summary> /// Initializes the message /// </summary> /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param> /// <param name="parameters">The parameters.</param> public override void Initialize(MessageReceivedEventArgs e, string[] parameters) { SenderClientId = e.InvokerClientId; this.TimeSpan = TimeSpanEntity.Parse(parameters.Length > 1 ? parameters[1] : null); }
/// <summary> /// Initializes a new instance of the <see cref="ModeratorMessage"/> class. /// </summary> public ModeratorMessage() { TimeSpan = new TimeSpanEntity(); }
/// <summary> /// Initializes a new instance of the <see cref="HoursMessage"/> class. /// </summary> public HoursMessage() { TimeSpan = new TimeSpanEntity(); ClientDatabaseIds = new List<uint>(); AllClients = true; }
/// <summary> /// Initializes a new instance of the <see cref="ModeratorMessage"/> class. /// </summary> public ModeratorMessage() { TimeSpan = new TimeSpanEntity(); }