/// <summary>
        /// Gets the total time spended on TS3 for specified clients.
        /// </summary>
        /// <param name="clientDatabaseIds">The client database ids.</param>
        /// <param name="fromTime">From time.</param>
        /// <param name="toTime">To time.</param>
        /// <returns></returns>
        public Dictionary<uint, double> GetTime(IEnumerable<uint> clientDatabaseIds, DateTime? fromTime, DateTime? toTime)
        {
            lock (Container.lockTimeClientList)
            {
                lock (Repository.Container.lockDatabase)
                {
                    var times = new List<TimeClientEntity>();
                    using (var command = new SQLiteCommand(this.Container.DatabaseConnection))
                    {
                        command.CommandText = string.Format("SELECT ClientDatabaseId, Joined, Disconnected, TotalMinutes FROM Time WHERE ClientDatabaseId IN ({0})", string.Join(", ", clientDatabaseIds));
                        if (fromTime.HasValue) command.CommandText += string.Format(" AND Disconnected > {0}", fromTime.Value.ToTimeStamp());
                        if (toTime.HasValue) command.CommandText += string.Format(" AND Joined < {0}", toTime.Value.ToTimeStamp());

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.HasRows && reader.Read())
                            {
                                times.Add(new TimeClientEntity
                                {
                                    User = (uint)reader.GetInt32(0),
                                    Joined = reader.GetInt32(1).ToDateTime(),
                                    Disconnected = reader.GetInt32(2).ToDateTime(),
                                    TotalMinutes = reader.GetInt32(3)
                                });
                            }
                        }
                    }

                    return times.GroupBy(m => m.User).ToDictionary(g => (uint)g.Key, g => g.Sum(m => m.GetTime(fromTime, toTime)));
                }
            }
        }