From 740fd33a18b5f23532dee8fa135132875b0a0b6c Mon Sep 17 00:00:00 2001 From: lukeIam Date: Tue, 30 Dec 2014 19:16:34 +0100 Subject: [PATCH 1/5] [Server] Increased the timeout for image upload --- Vocaluxe/Website/js/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index 49aec6f1..11a1d96e 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -585,6 +585,7 @@ url: "sendPhoto", contentType: "application/json;charset=utf-8", type: "POST", + timeout: 40000, data: JSON.stringify({ Photo: { base64Data: imgData } }) }, 'Uploading photo...'); } From f815dfb2fdfa6e6374a4b421261dc5d6529c6788 Mon Sep 17 00:00:00 2001 From: lukeIam Date: Wed, 31 Dec 2014 13:24:08 +0100 Subject: [PATCH 2/5] Fix: saving a new created playlist could cause an exception --- Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 77fc2b06..fdddf0dc 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -43,7 +43,7 @@ namespace Vocaluxe.Lib.Playlist public void Save() { - if (File == "") + if (string.IsNullOrEmpty(File)) { string filename = string.Empty; // ReSharper disable LoopCanBeConvertedToQuery From dd470dcd66da81d3c457cd2f95669506e328ea41 Mon Sep 17 00:00:00 2001 From: lukeIam Date: Wed, 31 Dec 2014 13:26:28 +0100 Subject: [PATCH 3/5] Added comment with wcf tracing code --- Vocaluxe/app.config | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Vocaluxe/app.config b/Vocaluxe/app.config index 7fb031b0..c0dafe77 100644 --- a/Vocaluxe/app.config +++ b/Vocaluxe/app.config @@ -3,4 +3,32 @@ + From 83fee9dc06695b2e3543e5c16b4cbd61544dc6a9 Mon Sep 17 00:00:00 2001 From: lukeIam Date: Wed, 31 Dec 2014 13:26:53 +0100 Subject: [PATCH 4/5] [Server] small change on request() --- Vocaluxe/Website/js/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index 11a1d96e..b51c9841 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -46,6 +46,10 @@ data.timeout = 10000; //10 sec. timeout } + if ((typeof data.type) == "undefined") { + data.type = "GET"; + } + if (message != "noOverlay") { var message2 = message; if (i18n.t) { @@ -1227,7 +1231,7 @@ if (name != null && name.replace(" ", "") != "" && $('h2').filter(function () { return this.textContent == name; }).length == 0) { - request({ url: "addPlaylist?playlistName=" + name }, "Creating...").done(function () { + request({ url: "addPlaylist?playlistName=" + name, dataType: "json" }, "Creating...").done(function () { request({ url: "getPlaylists" }).done(function (data2) { From a0e1f6d558143d910dd0bcb325692ba52098f6fc Mon Sep 17 00:00:00 2001 From: lukeIam Date: Wed, 31 Dec 2014 13:39:18 +0100 Subject: [PATCH 5/5] [Server] Send better messages on failed playlist operations --- ServerLib/CWebservice.cs | 123 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 9 deletions(-) diff --git a/ServerLib/CWebservice.cs b/ServerLib/CWebservice.cs index 3a085350..1b2762f5 100644 --- a/ServerLib/CWebservice.cs +++ b/ServerLib/CWebservice.cs @@ -376,48 +376,153 @@ namespace ServerLib public SPlaylistData GetPlaylist(int playlistId) { - return CServer.GetPlaylist(playlistId); + try + { + return CServer.GetPlaylist(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return new SPlaylistData(); + } + } public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates) { - if (_CheckRight(EUserRights.AddSongToPlaylist)) + if (!_CheckRight(EUserRights.AddSongToPlaylist)) + return; + + try + { CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public void RemoveSongFromPlaylist(int position, int playlistId, int songId) { - if (_CheckRight(EUserRights.RemoveSongsFromPlaylists)) + if (!_CheckRight(EUserRights.RemoveSongsFromPlaylists)) + return; + + try + { CServer.RemoveSongFromPlaylist(position, playlistId, songId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public void MoveSongInPlaylist(int newPosition, int playlistId, int songId) { - if (_CheckRight(EUserRights.ReorderPlaylists)) + if (!_CheckRight(EUserRights.ReorderPlaylists)) + return; + + try + { CServer.MoveSongInPlaylist(newPosition, playlistId, songId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public bool PlaylistContainsSong(int songId, int playlistId) { - return CServer.PlaylistContainsSong(songId, playlistId); + try + { + return CServer.PlaylistContainsSong(songId, playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return false; + } } public SPlaylistSongInfo[] GetPlaylistSongs(int playlistId) { - return CServer.GetPlaylistSongs(playlistId); + try + { + return CServer.GetPlaylistSongs(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + return new SPlaylistSongInfo[0]; + } } public void RemovePlaylist(int playlistId) { - if (_CheckRight(EUserRights.DeletePlaylists)) + if (!_CheckRight(EUserRights.DeletePlaylists)) + return; + + try + { CServer.RemovePlaylist(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public int AddPlaylist(string playlistName) { - if (_CheckRight(EUserRights.CreatePlaylists)) - return CServer.AddPlaylist(playlistName); + if (!_CheckRight(EUserRights.CreatePlaylists)) return -1; + + try + { + return CServer.AddPlaylist(playlistName); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return -1; + } } #endregion