diff --git a/ClientServerLib/ClientServerLib/CServer.cs b/ClientServerLib/ClientServerLib/CServer.cs index 47f0cd9d..d52929f0 100644 --- a/ClientServerLib/ClientServerLib/CServer.cs +++ b/ClientServerLib/ClientServerLib/CServer.cs @@ -74,6 +74,10 @@ namespace ClientServerLib WebHttpBinding wb = new WebHttpBinding(); wb.MaxReceivedMessageSize = 10485760; wb.MaxBufferSize = 10485760; + wb.MaxBufferPoolSize = 10485760; + wb.ReaderQuotas.MaxStringContentLength = 10485760; + wb.ReaderQuotas.MaxArrayLength = 10485760; + wb.ReaderQuotas.MaxBytesPerRead = 10485760; host.AddServiceEndpoint(typeof(ICWebservice), wb, ""); } @@ -83,8 +87,8 @@ namespace ClientServerLib { // Step 4 Enable metadata exchange. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); - smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; - smb.HttpGetEnabled = true; + //smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; + //smb.HttpGetEnabled = true; host.Description.Behaviors.Add(smb); // Step 5 Start the service. diff --git a/ClientServerLib/ClientServerLib/CWebservice.cs b/ClientServerLib/ClientServerLib/CWebservice.cs index 7a0be49d..3dea559f 100644 --- a/ClientServerLib/ClientServerLib/CWebservice.cs +++ b/ClientServerLib/ClientServerLib/CWebservice.cs @@ -44,6 +44,7 @@ namespace ClientServerLib [OperationContract] [WebInvoke(Method = "POST", + RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/sendPhoto")] bool sendPhoto(PhotoData photo); @@ -124,7 +125,7 @@ namespace ClientServerLib { if (CServer.GetProfileList == null) { - return new ProfileData[]{}; + return new ProfileData[] { }; } return CServer.GetProfileList(); } @@ -134,7 +135,7 @@ namespace ClientServerLib #region photo public bool sendPhoto(PhotoData photo) - { + { return CServer.SendPhoto(photo); } @@ -234,6 +235,6 @@ namespace ClientServerLib } } - #endregion + #endregion } } diff --git a/ClientServerLib/ClientServerLib/DataStructs.cs b/ClientServerLib/ClientServerLib/DataStructs.cs index a5a97d2e..e5d5f5b4 100644 --- a/ClientServerLib/ClientServerLib/DataStructs.cs +++ b/ClientServerLib/ClientServerLib/DataStructs.cs @@ -74,7 +74,8 @@ namespace ClientServerLib public Image getImage() { - byte[] imageData = Convert.FromBase64String(base64Data); + string onlyBase64Data = base64Data.Substring(base64Data.IndexOf(";base64,") + (";base64,").Length); + byte[] imageData = Convert.FromBase64String(onlyBase64Data); MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length); ms.Write(imageData, 0, imageData.Length); Image image = Image.FromStream(ms, true); @@ -84,7 +85,7 @@ namespace ClientServerLib public string getImageType() { Match match = Regex.Match(base64Data, "(?<=data:image/)[a-zA-Z]+(?=;base64)"); - return match.Success ? match.Groups[1].Value : ""; + return match.Success ? match.Groups[0].Value : ""; } diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 3d077a4c..991a3139 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -250,7 +250,7 @@ namespace Vocaluxe.Base.Server if (File.Exists(avatar.FileName)) { Image avatarImage = Image.FromFile(avatar.FileName); - //TODO: Convert??? and Compress? + //TODO: Convert??? and Resize? profileData.Avatar = new Base64Image(avatarImage, avatarImage.RawFormat); } } @@ -292,7 +292,7 @@ namespace Vocaluxe.Base.Server return false; } - string name = DateTime.Now.ToString("yyyy-MM-DD-hh-mm-ss"); + string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"); string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos); return (filePath != null && filePath != ""); @@ -330,12 +330,20 @@ namespace Vocaluxe.Base.Server string extension = imageDate.getImageType(); string filename = Path.Combine(folder, name); - int i = 0; - while (File.Exists(filename + "_" + i + "." + extension)) + if (File.Exists(filename + "." + extension)) { - i++; + int i = 0; + while (File.Exists(filename + "_" + i + "." + extension)) + { + i++; + } + filename = filename + "_" + i + "." + extension; } - filename = filename + "_" + i + "." + extension; + else + { + filename = filename + "." + extension; + } + avatarImage.Save(filename); return filename; } diff --git a/Vocaluxe/Website/css/style.css b/Vocaluxe/Website/css/style.css index 71a4eb3c..b6af6570 100644 --- a/Vocaluxe/Website/css/style.css +++ b/Vocaluxe/Website/css/style.css @@ -1,7 +1,7 @@ #playerAvatar { height: 75%; - max-width: 250px; - height: auto; + max-height: 250px; + width: auto; } #playerName { diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index f7b54f65..b71c3c6d 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -1,3 +1,4 @@ +var ownProfileId = 1; var profileIdRequest = 1; $(document).ready(function () { @@ -30,7 +31,7 @@ function initPageLoadHandler() { var promise = $.ajax({ url: "getProfile?profileId=" + profileIdRequest }).done(function (result) { - $('#playerName').text(result.PlayerName) + $('#playerName').attr("value", result.PlayerName); if (result.Avatar && result.Avatar.base64Data) { $('#playerAvatar').attr("src", result.Avatar.base64Data); } @@ -79,12 +80,12 @@ function initPageLoadHandler() { $('#selectProfileList').children().remove(); function handleProfileSelectLineClick(e) { - profileIdRequest = parseInt(e.target.id.replace("ProfileSelectLine_", "")); + profileIdRequest = parseInt(e.currentTarget.id.replace("ProfileSelectLine_", "")); $.mobile.changePage("#displayProfile", { transition: "slidefade" }); } for (var profile in data) { - $('
  • ' + data[profile].PlayerName + '

    Click here to show the profile of ' + data[profile].PlayerName + '

  • ') + $('
  • ' + data[profile].PlayerName + '

    Click here to show the profile of ' + data[profile].PlayerName + '

  • ') .appendTo('#selectProfileList') .click(handleProfileSelectLineClick); } @@ -169,18 +170,26 @@ function initMainPageHandler() { $('#content').wrap('
    '); $.mobile.loading('show', { text: 'Uploading photo...', - textVisible: true + textVisible: true }); var file = eventData.target.files[0]; var reader = new FileReader(); reader.onloadend = function (e) { - $.post("sendPhoto", { Photo: { base64Data: e.target.result } }) - .always(function () { - $.mobile.loading('hide'); - $('#content').unwrap(); - }); + $.ajax({ + url: "sendPhoto", + dataType: "json", + contentType: "application/json;charset=utf-8", + type: "POST", + data: JSON.stringify({ Photo: { base64Data: e.target.result } }), + success: function (msg) { + + } + }).always(function () { + $.mobile.loading('hide'); + $('#content').unwrap(); + }); }; reader.readAsDataURL(file);