void control_RemoveClicked(object source, EventArgs args)
        {
            QueueSongControl control = source as QueueSongControl;

            SongRequest requestToRemove = new SongRequest();
            requestToRemove.songID = control.Song.ID;
            requestToRemove.user = this.QueueSinger.user;
            DJModel.Instance.RemoveSongRequest(requestToRemove);

            //Handle the case when we have only 1 item left
            if (songControlList.Count == 1 && control.IsEmpty == false)
            {
                songControlList[0].SetAsEmpty();
                return;
            }

            songControlList.Remove(control);

            //Animate the grid collapsing to fill the lost song
            DoubleAnimation animator = new DoubleAnimation();
            animator.From = HEADER_HEIGHT + ((songControlList.Count + 1) * LABEL_HEIGHT);
            animator.To = HEADER_HEIGHT + (songControlList.Count * LABEL_HEIGHT);
            animator.Duration = new Duration(TimeSpan.FromSeconds(.1));
            GridMain.BeginAnimation(Grid.HeightProperty, animator);
        }
Example #2
0
        public JsonResult GetSongForSongRequest(Guid clientId, string songId)
        {
            Contract.Requires(songId != null);

            var user = RavenDb.Query<User>().FirstOrDefault(u => u.ClientIdentifier == clientId);
            var userId = user != null ? user.Id : "0";
            var songRequest = new SongRequest
            {
                DateTime = DateTime.UtcNow,
                SongId = songId,
                UserId = userId
            };
            RavenDb.Store(songRequest);
            return GetSongById(clientId, songId);
        }
        void control_MoveUpClicked(object source, EventArgs args)
        {
            QueueSongControl control = source as QueueSongControl;

            int index = songControlList.IndexOf(control);

            //Check if this already the top one
            if (index == 0)
                return;

            SongRequest request = new SongRequest();
            request.songID = control.Song.ID;
            request.user = this.QueueSinger.user;
            DJModel.Instance.MoveSongRequest(request, index - 1);

            songControlList.Remove(control);
            songControlList.Insert(index - 1, control);
        }
Example #4
0
        private void RemoveSongRequest(SongRequest request, long djKey, object userState)
        {
            Response response = _client.DJRemoveSongRequest(request, djKey);

            if (RemoveSongRequestComplete != null)
            {
                RemoveSongRequestComplete(this, new ResponseArgs(response, userState));
            }
        }
        private async void ProcessSongRequest(SongRequest request, bool fromHistory = false)
        {
            await _downloadSemaphore.WaitAsync();

            try {
                if ((RequestManager.RequestSongs.Any() && !fromHistory) || (RequestManager.HistorySongs.Any() && fromHistory))
                {
                    if (!fromHistory)
                    {
                        this._bot.SetRequestStatus(request, RequestStatus.Played);
                        this._bot.DequeueRequest(request);
                    }

                    if (request == null)
                    {
                        return;
                    }
                    var songName  = request._song["songName"].Value;
                    var songIndex = Regex.Replace($"{request._song["id"].Value} ({request._song["songName"].Value} - {request._song["levelAuthor"].Value})", "[\\\\:*/?\"<>|]", "_");
                    songIndex = this.Normalize.RemoveDirectorySymbols(ref songIndex); // Remove invalid characters.

                    var currentSongDirectory = Path.Combine(Environment.CurrentDirectory, "Beat Saber_Data\\CustomLevels", songIndex);
                    var songHash             = request._song["hash"].Value.ToUpper();

                    if (Loader.GetLevelByHash(songHash) == null)
                    {
                        Utility.EmptyDirectory(".requestcache", false);

                        if (Directory.Exists(currentSongDirectory))
                        {
                            Utility.EmptyDirectory(currentSongDirectory, true);
                        }
                        var localPath = Path.Combine(Environment.CurrentDirectory, ".requestcache", $"{request._song["id"].Value}.zip");
#if UNRELEASED
                        // Direct download hack
                        var ext = Path.GetExtension(request.song["coverURL"].Value);
                        var k   = request.song["coverURL"].Value.Replace(ext, ".zip");

                        var songZip = await Plugin.WebClient.DownloadSong($"https://beatsaver.com{k}", System.Threading.CancellationToken.None);
#endif
                        var result = await WebClient.DownloadSong($"https://beatsaver.com{request._song["downloadURL"].Value}", System.Threading.CancellationToken.None, this.DownloadProgress);

                        if (result == null)
                        {
                            this.ChatManager.QueueChatMessage("BeatSaver is down now.");
                        }
                        using (var zipStream = new MemoryStream(result))
                            using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Read)) {
                                try {
                                    // open zip archive from memory stream
                                    archive.ExtractToDirectory(currentSongDirectory);
                                }
                                catch (Exception e) {
                                    Logger.Error($"Unable to extract ZIP! Exception");
                                    Logger.Error(e);
                                    return;
                                }
                                zipStream.Close();
                            }
                        Dispatcher.RunCoroutine(this.WaitForRefreshAndSchroll(request));
#if UNRELEASED
                        //if (!request.song.IsNull) // Experimental!
                        //{
                        //TwitchWebSocketClient.SendCommand("/marker "+ _textFactory.Create().AddUser(ref request.requestor).AddSong(request.song).Parse(NextSonglink.ToString()));
                        //}
#endif
                    }
                    else
                    {
                        Dispatcher.RunOnMainThread(() => this.BackButtonPressed());
                        Dispatcher.RunCoroutine(this.SongListUtils.ScrollToLevel(songHash, () =>
                        {
                            this._bot.UpdateRequestUI();
                        }));
                        if (!request._song.IsNull)
                        {
                            // Display next song message
                            this._textFactory.Create().AddUser(request._requestor).AddSong(request._song).QueueMessage(StringFormat.NextSonglink.ToString());
                        }
                    }
                }
            }
            catch (Exception e) {
                Logger.Error(e);
            }
            finally {
                _downloadSemaphore.Release();
            }
        }
Example #6
0
 public void RemoveSongRequestAsync(SongRequest request, long djKey, object userState)
 {
     ThreadPool.QueueUserWorkItem(lambda =>
     {
         RemoveSongRequest(request, djKey, userState);
     });
 }
Example #7
0
        private void ChangeSongRequest(SongRequest newRequest, SongRequest oldRequest, long djKey, object userState)
        {
            Response response = _client.DJChangeSongRequest(newRequest, oldRequest, djKey);

            if (ChangeSongRequestComplete != null)
            {
                ChangeSongRequestComplete(this, new ResponseArgs(response, userState));
            }
        }
Example #8
0
        private void AddSongRequest(SongRequest request, int queueIndex, long djKey, object userState)
        {
            Response response = _client.DJAddQueue(request, queueIndex, djKey);

            //Get the new queue while we're at it
            GetSingerQueue(djKey, null);

            if (AddSongRequestComplete != null)
            {
                AddSongRequestComplete(this, new ResponseArgs(response, userState));
            }
        }
Example #9
0
        private void RemoveSongRequest(SongRequest request, long djKey, object userState)
        {
            Response response = _client.DJRemoveSongRequest(request, djKey);

            //Get the new queue while we're at it
            GetSingerQueue(djKey, null);

            if (RemoveSongRequestComplete != null)
            {
                RemoveSongRequestComplete(this, new ResponseArgs(response, userState));
            }
        }
Example #10
0
        public void Initialize()
        {
            string date = DateTime.Now.ToString("dd-MM-yyyy");

            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();
            RedisDataProvider dbRedis = new RedisDataProvider();

            StreamReader stream;

            //Check is database initialized
            if (dbNeo4j.UserExists("admin", "admin"))
            {
                return;
            }

            DeleteAllData();
            dbRedis.ResetHashCounter();

            #region Create users

            User admin = new User();
            admin.name     = "admin";
            admin.email    = "admin";
            admin.password = "******";
            admin.admin    = true;
            admin.date     = date;
            dbNeo4j.UserCreate(admin);
            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(userFilePath));
                while (!stream.EndOfStream)
                {
                    User user = new User();
                    user.name     = stream.ReadLine();
                    user.email    = stream.ReadLine();
                    user.password = stream.ReadLine();
                    user.admin    = false;
                    user.date     = date;
                    stream.ReadLine();
                    dbNeo4j.UserCreate(user);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }

            #endregion

            #region Create genres

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(genresFilePath));
                while (!stream.EndOfStream)
                {
                    Genre genre = new Genre();
                    genre.name = stream.ReadLine();
                    stream.ReadLine();
                    dbNeo4j.GenreCreate(genre);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }

            #endregion

            #region Create artists

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(artistFilePath));
                while (!stream.EndOfStream)
                {
                    Artist artist = new Artist();
                    artist.name      = stream.ReadLine();
                    artist.biography = stream.ReadLine();
                    artist.website   = stream.ReadLine();

                    string        genresClean     = Regex.Replace(stream.ReadLine(), " *, *", ",");
                    List <string> genreNames      = genresClean.Split(',').ToList();
                    List <string> checkGenres     = dbNeo4j.GenreRead();
                    List <string> validGenreNames = genreNames.Intersect(checkGenres).ToList();
                    List <Genre>  validGenres     = new List <Genre>();
                    foreach (string genreName in validGenreNames)
                    {
                        Genre tmp = new Genre();
                        tmp.name = genreName;
                        validGenres.Add(tmp);
                    }
                    dbNeo4j.ArtistCreate(artist, validGenres);
                    stream.ReadLine();
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }
            #endregion

            #region Create songs

            string[] songPaths = Directory.GetFiles(HostingEnvironment.MapPath(songFolderPath));
            foreach (string songPath in songPaths)
            {
                try
                {
                    stream = new StreamReader(songPath);
                    Song song = new Song();
                    song.name = stream.ReadLine();
                    string artist = stream.ReadLine();
                    string user   = stream.ReadLine();
                    stream.ReadLine();
                    song.content = stream.ReadToEnd();
                    song.date    = date;
                    dbNeo4j.SongCreate(song, user, artist);
                    stream.Close();
                }
                catch (Exception e)
                {
                }
            }

            #endregion

            #region Create favorites

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(favoritesFilePath));
                while (!stream.EndOfStream)
                {
                    string song   = stream.ReadLine();
                    string artist = stream.ReadLine();
                    string user   = stream.ReadLine();
                    stream.ReadLine();
                    dbNeo4j.SongAddToFavorites(song, artist, user);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }

            #endregion

            #region Create Comments

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(commentsFilePath));
                while (!stream.EndOfStream)
                {
                    Comment comment = new Comment();
                    comment.title   = stream.ReadLine();
                    comment.content = stream.ReadLine();
                    comment.date    = date;
                    string song   = stream.ReadLine();
                    string artist = stream.ReadLine();
                    string user   = stream.ReadLine();
                    stream.ReadLine();
                    dbNeo4j.CommentCreate(comment, user, artist, song);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }

            #endregion

            #region Create requests

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(songRequestFilePath));
                while (!stream.EndOfStream)
                {
                    SongRequest songRequest = new SongRequest();
                    songRequest.author = stream.ReadLine();
                    songRequest.artist = stream.ReadLine();
                    songRequest.song   = stream.ReadLine();
                    songRequest.date   = date;
                    stream.ReadLine();
                    dbNeo4j.SongRequestCreate(songRequest);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }

            #endregion

            #region Create songdrafts

            string[] songDraftPaths = Directory.GetFiles(HostingEnvironment.MapPath(songDraftFolderPath));
            foreach (string songDraftPath in songDraftPaths)
            {
                try
                {
                    stream = new StreamReader(songDraftPath);
                    SongDraft songDraft = new SongDraft();
                    songDraft.name   = stream.ReadLine();
                    songDraft.artist = stream.ReadLine();
                    string user = stream.ReadLine();
                    songDraft.content = stream.ReadToEnd();
                    songDraft.date    = date;
                    dbNeo4j.SongDraftCreate(songDraft, user);
                    stream.Close();
                    dbRedis.AddAdminNotification();
                }
                catch (Exception e)
                {
                }
            }

            #endregion
        }
Example #11
0
 public void MoveSongRequestAsync(SongRequest request, int newIndex, long djKey, object userState)
 {
     ThreadPool.QueueUserWorkItem(lambda =>
     {
         MoveSongRequest(request, newIndex, djKey, userState);
     });
 }
Example #12
0
        static void Main(string[] args)
        {
            // User the proxy to communicate with server.
            DJClient proxy = new DJClient();

            // This is the DJKey that identifies the DJ. It is not set until a signin request is made.
            long DJKey = -1;

            Console.WriteLine("Remember to sign in before using commands that need a DJKey");
            for (; ; )
            {
                // Get user input for what to do.
                Console.WriteLine("Enter command or [help]");
                string command = Console.ReadLine();

                if (command.StartsWith("h")) //HELP
                {
                    Console.WriteLine("help<h>, quit<q>, insertDJ<id>, signinDJ<si>, signoutDJ <so>,");
                    Console.WriteLine("listDJS<ld>, addSong<as>, removeSong<rs>, listSongs<ls>, listQueue<lq>,");
                    Console.WriteLine("popQueue<pq>, getQR<gq>, generateNewQR<nq>, addRequest<ar>, removeRequest<rr>");
                    Console.WriteLine("changeRequest<cr>, moveUser<mu>, removeUser<ru>, createSession<cs>");
                    Console.WriteLine("newUserWaitTime<nw>, testQueueFill<tf>, moveSongRequest<mr>, mostPopular<mp>");
                    Console.WriteLine("BanUser<bu>, UnbanUser<uu>, ListBans<lb>, addAchievement<aa>,listAchievemts<la>");
                    Console.WriteLine("deleteAchivement<da>, evaluateAchievements<ea>, modifyAchievement<ma>");
                    Console.WriteLine("viewAchievementSql<vs>, GenerateSongHistory<gs>");
                }
                else if (command.StartsWith("x"))
                {
                    try
                    {
                        Random r = new Random();
                        Console.WriteLine(r.Next(1, 1));

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e.Message);
                    }

                }
                else if (command.StartsWith("gs"))
                {
                    Response r;
                    try
                    {
                        Console.WriteLine("Enter MobileID:");
                        int mobileID = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter number of songs per band");
                        int numberPerBand = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter artists (Comma separated)");
                        string rawBands = Console.ReadLine();
                        string[] bands = rawBands.Split(',');

                        r = proxy.InsertFauxSongHistory(DJKey, bands, numberPerBand, mobileID);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("vs"))
                {
                    Response r;
                    try
                    {
                        Console.WriteLine("Enter ID:");
                        int achievementID = int.Parse(Console.ReadLine());
                        r = proxy.ViewAchievementSql(DJKey, achievementID);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("ea"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJEvaluateAchievements(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("aa"))
                {
                    Response r;
                    Console.WriteLine("Achievement number");
                    int number = int.Parse(Console.ReadLine().Trim());
                    Achievement achievement;
                    if (number == 1)
                        achievement = createAchievement1();
                    else if (number == 2)
                        achievement = createAchievement2();
                    else if (number == 3)
                        achievement = createAchievement3();
                    else
                        achievement = createAchievement4();
                    try
                    {
                        r = proxy.DJAddAchievement(achievement, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("ma"))
                {
                    Response r;
                    Console.WriteLine("Enter old achievement ID");
                    int ID = int.Parse(Console.ReadLine());

                    Console.WriteLine("New achievement number");
                    int number = int.Parse(Console.ReadLine().Trim());
                    Achievement achievement;
                    if (number == 1)
                        achievement = createAchievement1();
                    else if (number == 2)
                        achievement = createAchievement2();
                    else if (number == 3)
                        achievement = createAchievement3();
                    else
                        achievement = createAchievement4();

                    achievement.ID = ID;
                    Console.WriteLine("Enter new name:");
                    achievement.name = Console.ReadLine();
                    try
                    {
                        r = proxy.DJModifyAchievement(achievement, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("da"))
                {
                    Response r;
                    try
                    {
                        Console.WriteLine("ID:");
                        int id = int.Parse(Console.ReadLine());
                        r = proxy.DJDeleteAchievement(id, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("la"))
                {
                    Response r;
                    Achievement[] achievements;
                    try
                    {
                        r = proxy.DJViewAchievements(out achievements, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        foreach (Achievement a in achievements)
                        {
                            Console.WriteLine(achievementString(a));
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("bu"))
                {
                    Console.WriteLine("Enter UserID to bad");
                    User u = new User();
                    u.userID = int.Parse(Console.ReadLine());
                    Response r;
                    try
                    {
                        r = proxy.DJBanUser(u, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("uu"))
                {
                    Response r;
                    try
                    {
                        Console.WriteLine("Enter UserID to unban");
                        User u = new User();
                        u.userID = int.Parse(Console.ReadLine());
                        r = proxy.DJUnbanUser(u, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("lb"))
                {
                    Response r;
                    User[] users;
                    try
                    {
                        r = proxy.DJGetBannedUsers(out users, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        foreach (User u in users)
                        {
                            Console.WriteLine(u.userID + " " + u.userName);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("mp"))
                {
                    Response r;
                    Song[] songs;
                    int[] counts;
                    bool limitToVenue;
                    Console.WriteLine("Do you wish to limit results to this venue? [0=no,1=yes]");
                    string input = Console.ReadLine();
                    if (input == "0")
                        limitToVenue = false;
                    else
                        limitToVenue = true;

                    Console.WriteLine("Starting index");
                    int start = int.Parse(Console.ReadLine());
                    Console.WriteLine("Count");
                    int count = int.Parse(Console.ReadLine());

                    try
                    {
                        r = proxy.DJGetMostPopularSongs(out songs, out counts, DJKey, limitToVenue, start, count);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        for (int i = 0; i < songs.Length; i++)
                        {
                            Console.WriteLine(songs[i].ID + " " + songs[i].title + " " + songs[i].artist + " " + counts[i]);
                        }

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("tf"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJTestQueueFill(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("nw"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJNewUserWaitTime(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("cs"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJCreateSession(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("gq"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJGetQRNumber(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("nq"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJGenerateNewQRNumber(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("q")) // QUIT
                {
                    return;
                }
                else if (command.StartsWith("ld")) // LIST DJS [This is a temporary function, not for release]
                {
                    Response r;
                    try
                    {
                        r = proxy.DJSignUp("list", String.Empty, new Venue(), String.Empty);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("id")) // INSERT DJ
                {
                    Response r;
                    string username, password, email;
                    Venue venue = new Venue();
                    Console.WriteLine("Username: "******"Password: "******"Email:");
                    email = Console.ReadLine();
                    Console.WriteLine("Venue Name:");
                    venue.venueName = Console.ReadLine();
                    Console.WriteLine("Venue Address:");
                    venue.venueAddress = Console.ReadLine();

                    try
                    {
                        r = proxy.DJSignUp(username, password, venue, email);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("si")) // Signin a DJ
                {
                    LogInResponse r;
                    string username, password;
                    Console.Write("Username: "******"Password: "******"Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        DJKey = r.userKey;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("so")) // Signout a DJ
                {
                    Response r;
                    try
                    {
                        r = proxy.DJSignOut(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("as")) // Add a song
                {
                    try
                    {
                        Response r;
                        string title, artist, pathOnDisk;
                        Console.WriteLine("Title: ");
                        title = Console.ReadLine();
                        Console.WriteLine("Artist: ");
                        artist = Console.ReadLine();
                        Console.WriteLine("Path on Disk: ");
                        pathOnDisk = Console.ReadLine();
                        Console.WriteLine("Duration: ");
                        int duration = int.Parse(Console.ReadLine());
                        Song s = new Song();
                        s.artist = artist;
                        s.title = title;
                        s.pathOnDisk = pathOnDisk;
                        s.duration = duration;
                        List<Song> songs = new List<Song>();
                        songs.Add(s);
                        r = proxy.DJAddSongs(songs.ToArray(), DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("rs")) // Remove a song
                {
                    Response r;
                    string title, artist, pathOnDisk;
                    Console.WriteLine("Title: ");
                    title = Console.ReadLine();
                    Console.WriteLine("Artist: ");
                    artist = Console.ReadLine();
                    Console.WriteLine("Path on Disk: ");
                    pathOnDisk = Console.ReadLine();
                    try
                    {
                        Song s = new Song();
                        s.artist = artist;
                        s.title = title;
                        s.pathOnDisk = pathOnDisk;
                        List<Song> songs = new List<Song>();
                        songs.Add(s);
                        r = proxy.DJRemoveSongs(songs.ToArray(), DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ls")) // List all Songs owned by the logged in DJ.
                {
                    try
                    {
                        Song[] songs;
                        Response r = proxy.DJListSongs(out songs, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        Console.WriteLine("Songs: ");
                        if (!r.error)
                            foreach (Song s in songs)
                                Console.WriteLine(s.ID + ", " + s.title + ", " + s.artist + ", " + s.pathOnDisk + ", " + s.duration);
                        Console.WriteLine("Result: " + r.result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("lq")) // List the song queue for the loggin in DJ.
                {
                    try
                    {
                        queueSinger[] queue;
                        Response r = proxy.DJGetQueue(out queue, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        Console.WriteLine("Queue: ");
                        if (!r.error)
                            foreach (queueSinger qs in queue)
                            {
                                string id = "ID: " + qs.user.userID + ", Name: " + qs.user.userName;

                                Console.WriteLine("\n" + id.Trim());
                                foreach (Song s in qs.songs)
                                {
                                    string s2 = s.ID + ", " + s.title + ", " + s.artist + ", " + s.pathOnDisk;
                                    Console.WriteLine("  " + s2.Trim());
                                }
                            }

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("pq")) // Pop the first song request off the queue for the loggin in DJ.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter clientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;

                        Response r = proxy.DJPopQueue(sr, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ar")) // Add a song request.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Type ClientID, or 0 to type in Client Name, or -1 to add a temp user.");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        if (u.userID == 0)
                        {
                            Console.WriteLine("Enter the client name:");
                            u.userName = Console.ReadLine().Trim();
                        }
                        if (u.userID == -1)
                        {
                            Console.WriteLine("Enter the temp client name:");
                            u.userName = Console.ReadLine().Trim();
                        }
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;
                        Console.WriteLine("enter index to insert client into:");
                        int index = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJAddQueue(sr, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("rr")) // Remove song request.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;

                        Response r = proxy.DJRemoveSongRequest(sr, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("cr")) // Change song request.
                {
                    try
                    {
                        SongRequest newSR = new SongRequest();
                        SongRequest oldSR = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter Old Song ID:");
                        oldSR.songID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter New Song ID:");
                        newSR.songID = int.Parse(Console.ReadLine().Trim());
                        oldSR.user = u;
                        newSR.user = u;

                        Response r = proxy.DJChangeSongRequest(newSR, oldSR, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("mr")) // Move a song request in the list of songs.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter song ID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter new index:");
                        int index = int.Parse(Console.ReadLine());
                        sr.user = u;
                        Response r = proxy.DJMoveSongRequest(sr, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("mu")) // Move user
                {
                    try
                    {
                        Console.WriteLine("Enter ClientID:");
                        int userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter new index:");
                        int index = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJMoveUser(userID, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ru")) // Remove user.
                {
                    try
                    {
                        Console.WriteLine("Enter ClientID:");
                        int userID = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJRemoveUser(userID, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Command!");
                }
            }
        }
        public (AddRequestResult, int) AddRequest(string username, string commandText, bool vipRequest = false)
        {
            var songIndex     = 0;
            var playlistState = this.GetPlaylistState();

            if (playlistState == PlaylistState.VeryClosed)
            {
                return(AddRequestResult.PlaylistVeryClosed, 0);
            }

            using (var context = _contextFactory.Create())
            {
                var request = new SongRequest
                {
                    RequestTime     = DateTime.UtcNow,
                    RequestText     = commandText,
                    RequestUsername = username,
                    Played          = false
                };

                if (!vipRequest)
                {
                    var playlistLength = context.SongRequests.Count(sr => !sr.Played);
                    var userSongCount  = context.SongRequests.Count(sr => !sr.Played && sr.RequestUsername == username && sr.VipRequestTime == null);
                    _logger.LogInformation($"Not a vip request: {playlistLength}, {userSongCount}");
                    if (playlistState == PlaylistState.Closed)
                    {
                        return(AddRequestResult.PlaylistClosed, 0);
                    }

                    if (userSongCount >= UserMaxSongCount)
                    {
                        return(AddRequestResult.MaximumRegularRequests, 0);
                    }
                }

                if (vipRequest)
                {
                    request.VipRequestTime = DateTime.UtcNow;
                }

                context.SongRequests.Add(request);
                context.SaveChanges();

                songIndex = context.SongRequests.Where(sr => !sr.Played).OrderRequests()
                            .FindIndex(sr => sr == request) + 1;

                if (_currentRequest == null)
                {
                    _currentRequest = new PlaylistItem
                    {
                        songRequestId   = request.SongRequestId,
                        songRequestText = request.RequestText,
                        songRequester   = request.RequestUsername,
                        isEvenIndex     = false,
                        isInChat        = true,
                        isVip           = vipRequest,
                        isSuperVip      = false,
                        isInDrive       = request.InDrive
                    };
                }
            }

            UpdatePlaylists();

            return(AddRequestResult.Success, songIndex);
        }
        public AddRequestResult AddWebRequest(RequestSongViewModel requestSongViewModel, string username)
        {
            try
            {
                if (string.IsNullOrEmpty(requestSongViewModel.Title) &&
                    string.IsNullOrWhiteSpace(requestSongViewModel.Artist))
                {
                    return(AddRequestResult.NoRequestEntered);
                }

                var playlistState = GetPlaylistState();

                switch (playlistState)
                {
                case PlaylistState.VeryClosed:
                    return(AddRequestResult.PlaylistVeryClosed);

                case PlaylistState.Closed when !requestSongViewModel.IsVip:
                    return(AddRequestResult.PlaylistClosed);
                }

                using (var context = _contextFactory.Create())
                {
                    if (!requestSongViewModel.IsVip && !requestSongViewModel.IsSuperVip)
                    {
                        var userSongCount = context.SongRequests.Count(sr =>
                                                                       !sr.Played && sr.RequestUsername == username && sr.VipRequestTime == null);

                        if (userSongCount >= UserMaxSongCount)
                        {
                            return(AddRequestResult.MaximumRegularRequests);
                        }
                    }

                    var request = new SongRequest
                    {
                        RequestTime = DateTime.UtcNow,
                        RequestText =
                            $"{requestSongViewModel.Artist} - {requestSongViewModel.Title} ({requestSongViewModel.SelectedInstrument})",
                        RequestUsername = username,
                        Played          = false
                    };

                    if (requestSongViewModel.IsSuperVip)
                    {
                        request.VipRequestTime      = DateTime.UtcNow;
                        request.SuperVipRequestTime = DateTime.UtcNow;

                        if (!_vipService.UseSuperVip(username))
                        {
                            return(AddRequestResult.UnSuccessful);
                        }
                    }
                    else if (requestSongViewModel.IsVip)
                    {
                        request.VipRequestTime = DateTime.UtcNow;
                        if (!_vipService.UseVip(username))
                        {
                            return(AddRequestResult.UnSuccessful);
                        }
                    }

                    context.SongRequests.Add(request);
                    context.SaveChanges();
                }

                UpdatePlaylists();
            }
            catch (Exception)
            {
                return(AddRequestResult.UnSuccessful);
            }

            return(AddRequestResult.Success);
        }
Example #15
0
 public void ChangeSongRequestAsync(SongRequest newRequest, SongRequest oldRequest, long djKey, object userState)
 {
     ThreadPool.QueueUserWorkItem(lambda =>
     {
         ChangeSongRequest(newRequest, oldRequest, djKey, userState);
     });
 }
Example #16
0
 //Adds a new song request to the singer queue
 public void AddSongRequest(SongRequest request, int indexInQueue)
 {
     serviceClient.AddSongRequestAsync(request, indexInQueue, this.DJKey, null);
 }
Example #17
0
 public void PopSingerQueueAsync(SongRequest request, long djKey, object userState)
 {
     ThreadPool.QueueUserWorkItem(lambda =>
     {
         PopSingerQueue(request, djKey, userState);
     });
 }
Example #18
0
 //Remove a song request from the singer queue
 public void RemoveSongRequest(SongRequest request)
 {
     serviceClient.RemoveSongRequestAsync(request, this.DJKey, null);
 }
Example #19
0
        private void AddSongRequest(SongRequest request, int queueIndex, long djKey, object userState)
        {
            Response response = _client.DJAddQueue(request, queueIndex, djKey);

            if (AddSongRequestComplete != null)
            {
                AddSongRequestComplete(this, new ResponseArgs(response, userState));
            }
        }
Example #20
0
        //Updates the singer queue by popping off the top user, removing their first song and adding them back to the bottom
        private void PopSongQueue()
        {
            queueSinger topSinger = this.SongRequestQueue[0];
            SongRequest requestToPop = new SongRequest();
            if (topSinger.songs.Length > 0)
            {
                requestToPop.songID = topSinger.songs[0].ID;
                requestToPop.user = topSinger.user;

                serviceClient.PopSingerQueueAsync(requestToPop, this.DJKey, null);
            }
        }
Example #21
0
        private void PopSingerQueue(SongRequest request, long djKey, object userState)
        {
            Response response;

            if (request != null)
            {
                try
                {
                    response = _client.DJPopQueue(request, djKey);
                }
                catch
                {
                    response = new Response();
                    response.error = true;
                    response.message = "There are no more song requests in the queue.";
                }
            }
            else
            {
                response = new Response();
                response.error = true;
                response.message = "There are no more song requests in the queue.";
            }

            if (PopQueueComplete != null)
            {
                PopQueueComplete(this, new ResponseArgs(response, userState));
            }
        }
        //Song was double clicked so add the selection to the queue
        private void ListBoxResults_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SongSearchResult songSearchResult = ((ListView)sender).SelectedItem as SongSearchResult;

            //Check if no user name was entered
            if (TextBoxUserName.Text.Trim().Equals(""))
            {
                //Animate the text box to flash red
                ColorAnimation animation = new ColorAnimation();
                animation.From = Colors.White;
                animation.To = Color.FromArgb(255, 255, 125, 125);
                animation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
                animation.AutoReverse = true;

                Storyboard s = new Storyboard();
                s.Duration = new Duration(new TimeSpan(0, 0, 1));
                s.Children.Add(animation);

                Storyboard.SetTarget(animation, TextBoxUserName);
                Storyboard.SetTargetProperty(animation, new PropertyPath("Background.Color"));

                s.Begin();

                return;
            }

            string userName = TextBoxUserName.Text.Trim();

            //Let's check if this is already a current user
            User user = null;
            foreach (QueueControl control in this.QueueControlList)
            {
                if (control.QueueSinger.user.userName.ToLower().Equals(userName.ToLower()))
                {
                    user = control.QueueSinger.user;
                    break;
                }
            }

            SongRequest request = new SongRequest();

            //No matching user found so let's just make a new one
            if (user == null)
            {
                user = new User();
                user.userID = userID--;
                user.userName = userName;
            }

            request.user = user;
            request.songID = songSearchResult.Song.ID;

            DJModel.Instance.AddSongRequest(request, DJModel.Instance.SongRequestQueue.Count + 1, user.userID);
            CloseControl();
        }
Example #23
0
 public void AddSongRequestAsync(SongRequest request, int queueIndex, long djKey, object userState)
 {
     ThreadPool.QueueUserWorkItem(lambda =>
     {
         AddSongRequest(request, queueIndex, djKey, userState);
     });
 }
Example #24
0
        static void Main(string[] args)
        {
            // User the proxy to communicate with server.
            DJClient proxy = new DJClient();

            // This is the DJKey that identifies the DJ. It is not set until a signin request is made.
            long DJKey = -1;

            Console.WriteLine("Remember to sign in before using commands that need a DJKey");
            for (; ; )
            {
                // Get user input for what to do.
                Console.WriteLine("Enter command or [help]");
                string command = Console.ReadLine();

                if (command.StartsWith("h")) //HELP
                {
                    Console.WriteLine("help<h>, quit<q>, insertDJ<id>, signinDJ<si>, signoutDJ <so>,");
                    Console.WriteLine("listDJS<ld>, addSong<as>, removeSong<rs>, listSongs<ls>, listQueue<lq>,");
                    Console.WriteLine("popQueue<pq>, getQR<gq>, generateNewQR<nq>, addRequest<ar>, removeRequest(rr)");
                    Console.WriteLine("changeRequest<cr>, moveUser<mu>, removeUser<ru>, createSession<cs>");
                    Console.WriteLine("newUserWaitTime<nw>, testQueueFill<tf>, moveSongRequest<mr>");
                }
                else if (command.StartsWith("tf"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJTestQueueFill(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("nw"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJNewUserWaitTime(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("cs"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJCreateSession(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("gq"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJGetQRNumber(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("nq"))
                {
                    Response r;
                    try
                    {
                        r = proxy.DJGenerateNewQRNumber(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("x"))
                {
                    try
                    {
                        Console.WriteLine("password");
                        string plainPassword = Console.ReadLine().Trim();
                        RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
                        byte[] buf = new byte[16];
                        rng.GetBytes(buf);
                        string salt = Convert.ToBase64String(buf);
                        Console.WriteLine(salt);

                        HashAlgorithm algorithm = new SHA256Managed();
                        string preHash = plainPassword + salt;

                        byte[] postHash = algorithm.ComputeHash(System.Text.Encoding.UTF8.GetBytes(preHash));
                        Console.WriteLine(Convert.ToBase64String(postHash));

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e.Message);
                    }

                }
                else if (command.StartsWith("q")) // QUIT
                {
                    return;
                }
                else if (command.StartsWith("ld")) // LIST DJS [This is a temporary function, not for release]
                {
                    Response r;
                    try
                    {
                        r = proxy.DJSignUp("list", String.Empty, new Venue(), String.Empty);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("id")) // INSERT DJ
                {
                    Response r;
                    string username, password, email;
                    Venue venue = new Venue();
                    Console.WriteLine("Username: "******"Password: "******"Email:");
                    email = Console.ReadLine();
                    Console.WriteLine("Venue Name:");
                    venue.venueName = Console.ReadLine();
                    Console.WriteLine("Venue Address:");
                    venue.venueAddress = Console.ReadLine();

                    try
                    {
                        r = proxy.DJSignUp(username, password, venue, email);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("si")) // Signin a DJ
                {
                    LogInResponse r;
                    string username, password;
                    Console.Write("Username: "******"Password: "******"Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        DJKey = r.userKey;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("so")) // Signout a DJ
                {
                    Response r;
                    try
                    {
                        r = proxy.DJSignOut(DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message);
                    }
                }
                else if (command.StartsWith("as")) // Add a song
                {
                    try
                    {
                        Response r;
                        string title, artist, pathOnDisk;
                        Console.WriteLine("Title: ");
                        title = Console.ReadLine();
                        Console.WriteLine("Artist: ");
                        artist = Console.ReadLine();
                        Console.WriteLine("Path on Disk: ");
                        pathOnDisk = Console.ReadLine();
                        Console.WriteLine("Duration: ");
                        int duration = int.Parse(Console.ReadLine());
                        Song s = new Song();
                        s.artist = artist;
                        s.title = title;
                        s.pathOnDisk = pathOnDisk;
                        s.duration = duration;
                        List<Song> songs = new List<Song>();
                        songs.Add(s);
                        r = proxy.DJAddSongs(songs.ToArray(), DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("rs")) // Remove a song
                {
                    Response r;
                    string title, artist, pathOnDisk;
                    Console.WriteLine("Title: ");
                    title = Console.ReadLine();
                    Console.WriteLine("Artist: ");
                    artist = Console.ReadLine();
                    Console.WriteLine("Path on Disk: ");
                    pathOnDisk = Console.ReadLine();
                    try
                    {
                        Song s = new Song();
                        s.artist = artist;
                        s.title = title;
                        s.pathOnDisk = pathOnDisk;
                        List<Song> songs = new List<Song>();
                        songs.Add(s);
                        r = proxy.DJRemoveSongs(songs.ToArray(), DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ls")) // List all Songs owned by the logged in DJ.
                {
                    try
                    {
                        Song[] songs;
                        Response r = proxy.DJListSongs(out songs, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        Console.WriteLine("Songs: ");
                        if (!r.error)
                            foreach (Song s in songs)
                                Console.WriteLine(s.ID + ", " + s.title + ", " + s.artist + ", " + s.pathOnDisk + ", " + s.duration);
                        Console.WriteLine("Result: " + r.result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("lq")) // List the song queue for the loggin in DJ.
                {
                    try
                    {
                        queueSinger[] queue;
                        Response r = proxy.DJGetQueue(out queue, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                        Console.WriteLine("Queue: ");
                        if (!r.error)
                            foreach (queueSinger qs in queue)
                            {
                                string id = "ID: " + qs.user.userID + ", Name: " + qs.user.userName;

                                Console.WriteLine("\n" + id.Trim());
                                foreach (Song s in qs.songs)
                                {
                                    string s2 = s.ID + ", " + s.title + ", " + s.artist + ", " + s.pathOnDisk;
                                    Console.WriteLine("  " + s2.Trim());
                                }
                            }

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("pq")) // Pop the first song request off the queue for the loggin in DJ.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter clientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;

                        Response r = proxy.DJPopQueue(sr, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ar")) // Add a song request.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Type ClientID, or 0 to type in Client Name, or -1 to add a temp user.");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        if (u.userID == 0)
                        {
                            Console.WriteLine("Enter the client name:");
                            u.userName = Console.ReadLine().Trim();
                        }
                        if (u.userID == -1)
                        {
                            Console.WriteLine("Enter the temp client name:");
                            u.userName = Console.ReadLine().Trim();
                        }
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;
                        Console.WriteLine("enter index to insert client into:");
                        int index = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJAddQueue(sr, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("rr")) // Remove song request.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter SongID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        sr.user = u;

                        Response r = proxy.DJRemoveSongRequest(sr, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("cr")) // Change song request.
                {
                    try
                    {
                        SongRequest newSR = new SongRequest();
                        SongRequest oldSR = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter Old Song ID:");
                        oldSR.songID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter New Song ID:");
                        newSR.songID = int.Parse(Console.ReadLine().Trim());
                        oldSR.user = u;
                        newSR.user = u;

                        Response r = proxy.DJChangeSongRequest(newSR, oldSR, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("mr")) // Move a song request in the list of songs.
                {
                    try
                    {
                        SongRequest sr = new SongRequest();
                        User u = new User();
                        Console.WriteLine("Enter ClientID:");
                        u.userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter song ID:");
                        sr.songID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter new index:");
                        int index = int.Parse(Console.ReadLine());
                        sr.user = u;
                        Response r = proxy.DJMoveSongRequest(sr, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("mu")) // Move user
                {
                    try
                    {
                        Console.WriteLine("Enter ClientID:");
                        int userID = int.Parse(Console.ReadLine().Trim());
                        Console.WriteLine("Enter new index:");
                        int index = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJMoveUser(userID, index, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else if (command.StartsWith("ru")) // Remove user.
                {
                    try
                    {
                        Console.WriteLine("Enter ClientID:");
                        int userID = int.Parse(Console.ReadLine().Trim());

                        Response r = proxy.DJRemoveUser(userID, DJKey);
                        Console.WriteLine("Error: " + r.error);
                        Console.WriteLine("Result: " + r.result);
                        Console.WriteLine("Message:\n" + r.message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: " + e.Message + "\n" + e.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Command!");
                }
            }
        }