Beispiel #1
0
        /// <summary>
        /// List the banned users of this venue.
        /// </summary>
        /// <param name="DJKey">The DJKey for the venue.</param>
        /// <param name="users">Out list of banned users.</param>
        /// <returns>The outcome of the operation.</returns>
        public Response DJGetBannedUsers(long DJKey, out List<User> users)
        {
            int DJID = -1;
            users = new List<User>();
            using (DatabaseConnectivity db = new DatabaseConnectivity())
            {
                // Try to establish a database connection
                Response r = db.OpenConnection();
                if (r.error)
                    return r;
                // Attempt to convert DJKey to DJID
                r = DJKeyToID(DJKey, out DJID, db);
                if (r.error)
                    return r;

                r = db.DJGetBannedUsers(DJID, out users);
                if (r.error)
                    return r;

                for (int i = 0; i < users.Count; i++)
                {
                    r = db.MobileIDtoUsername(users[i].userID);
                    if (r.error)
                        return r;
                    users[i].userName = r.message.Trim();
                }

                return r;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Convert the database representation of a queue to the object representation. Fill all fields except for path on disk.
        /// </summary>
        /// <param name="raw">The database representation.</param>
        /// <param name="queue">The out parameter to store the queue in.</param>
        /// <param name="DJID">The ID of the venue.</param>
        /// <param name="mobileID">The ID of the client.</param>
        /// <param name="db">The databse conenctivity to use.</param>
        /// <returns>The outcome of the operation.</returns>
        private Response DBToNearlyFullList(string raw, out List<queueSinger> queue, int DJID, int mobileID, DatabaseConnectivity db)
        {
            queue = new List<queueSinger>();
            Response r = new Response();
            int count = 0;

            string[] clientRequests = raw.Split('`');
            for (int i = 0; i < clientRequests.Length; i++)
            {
                string[] parts = clientRequests[i].Split('~');
                if (parts.Length == 0)
                {
                    r.error = true;
                    r.message = "Error in DBtoList 1";
                    return r;
                }

                queueSinger qs = new queueSinger();
                qs.songs = new List<Song>();
                User u = new User();
                u.userID = int.Parse(parts[0]);

                if (u.userID < 0)
                    r = db.DJGetTempUserName(u.userID, DJID);
                else
                    r = db.MobileIDtoUsername(u.userID);

                if (r.error)
                    return r;
                if (r.message.Trim().Length == 0)
                {
                    r.error = true;
                    r.message = "DB Username lookup exception in DJGetQueue!";
                    return r;
                }

                u.userName = r.message.Trim();
                qs.user = u;

                for (int j = 1; j < parts.Length; j++)
                {
                    Song song;
                    r = Common.GetSongInformation(int.Parse(parts[j]), DJID, mobileID, out song, db);
                    if (r.error)
                        return r;
                    qs.songs.Add(song);

                }
                queue.Add(qs);
                count++;
            }
            return r;
        }