This commit is contained in:
lukeIam committed 2013-12-13 17:35:03 +01:00
1 parent 00e3729485
commit d0ebe70ae4
6 files changed
+44 -21

No files matched your search

+6 -2
View File
@@ -74,6 +74,10 @@ namespace ClientServerLib
WebHttpBinding wb = new WebHttpBinding(); WebHttpBinding wb = new WebHttpBinding();
wb.MaxReceivedMessageSize = 10485760; wb.MaxReceivedMessageSize = 10485760;
wb.MaxBufferSize = 10485760; wb.MaxBufferSize = 10485760;
wb.MaxBufferPoolSize = 10485760;
wb.ReaderQuotas.MaxStringContentLength = 10485760;
wb.ReaderQuotas.MaxArrayLength = 10485760;
wb.ReaderQuotas.MaxBytesPerRead = 10485760;
host.AddServiceEndpoint(typeof(ICWebservice), wb, ""); host.AddServiceEndpoint(typeof(ICWebservice), wb, "");
} }
@@ -83,8 +87,8 @@ namespace ClientServerLib
{ {
// Step 4 Enable metadata exchange. // Step 4 Enable metadata exchange.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; //smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
smb.HttpGetEnabled = true; //smb.HttpGetEnabled = true;
host.Description.Behaviors.Add(smb); host.Description.Behaviors.Add(smb);
// Step 5 Start the service. // Step 5 Start the service.
@@ -44,6 +44,7 @@ namespace ClientServerLib
[OperationContract] [OperationContract]
[WebInvoke(Method = "POST", [WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendPhoto")] UriTemplate = "/sendPhoto")]
bool sendPhoto(PhotoData photo); bool sendPhoto(PhotoData photo);
@@ -124,7 +125,7 @@ namespace ClientServerLib
{ {
if (CServer.GetProfileList == null) if (CServer.GetProfileList == null)
{ {
return new ProfileData[]{}; return new ProfileData[] { };
} }
return CServer.GetProfileList(); return CServer.GetProfileList();
} }
@@ -74,7 +74,8 @@ namespace ClientServerLib
public Image getImage() 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); MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length);
ms.Write(imageData, 0, imageData.Length); ms.Write(imageData, 0, imageData.Length);
Image image = Image.FromStream(ms, true); Image image = Image.FromStream(ms, true);
@@ -84,7 +85,7 @@ namespace ClientServerLib
public string getImageType() public string getImageType()
{ {
Match match = Regex.Match(base64Data, "(?<=data:image/)[a-zA-Z]+(?=;base64)"); 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 : "";
} }
+14 -6
View File
@@ -250,7 +250,7 @@ namespace Vocaluxe.Base.Server
if (File.Exists(avatar.FileName)) if (File.Exists(avatar.FileName))
{ {
Image avatarImage = Image.FromFile(avatar.FileName); Image avatarImage = Image.FromFile(avatar.FileName);
//TODO: Convert??? and Compress? //TODO: Convert??? and Resize?
profileData.Avatar = new Base64Image(avatarImage, avatarImage.RawFormat); profileData.Avatar = new Base64Image(avatarImage, avatarImage.RawFormat);
} }
} }
@@ -292,7 +292,7 @@ namespace Vocaluxe.Base.Server
return false; 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); string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
return (filePath != null && filePath != ""); return (filePath != null && filePath != "");
@@ -330,12 +330,20 @@ namespace Vocaluxe.Base.Server
string extension = imageDate.getImageType(); string extension = imageDate.getImageType();
string filename = Path.Combine(folder, name); string filename = Path.Combine(folder, name);
int i = 0; if (File.Exists(filename + "." + extension))
while (File.Exists(filename + "_" + i + "." + 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); avatarImage.Save(filename);
return filename; return filename;
} }
+2 -2
View File
@@ -1,7 +1,7 @@
#playerAvatar { #playerAvatar {
height: 75%; height: 75%;
max-width: 250px; max-height: 250px;
height: auto; width: auto;
} }
#playerName { #playerName {
+17 -8
View File
@@ -1,3 +1,4 @@
var ownProfileId = 1;
var profileIdRequest = 1; var profileIdRequest = 1;
$(document).ready(function () { $(document).ready(function () {
@@ -30,7 +31,7 @@ function initPageLoadHandler() {
var promise = $.ajax({ var promise = $.ajax({
url: "getProfile?profileId=" + profileIdRequest url: "getProfile?profileId=" + profileIdRequest
}).done(function (result) { }).done(function (result) {
$('#playerName').text(result.PlayerName) $('#playerName').attr("value", result.PlayerName);
if (result.Avatar && result.Avatar.base64Data) { if (result.Avatar && result.Avatar.base64Data) {
$('#playerAvatar').attr("src", result.Avatar.base64Data); $('#playerAvatar').attr("src", result.Avatar.base64Data);
} }
@@ -79,12 +80,12 @@ function initPageLoadHandler() {
$('#selectProfileList').children().remove(); $('#selectProfileList').children().remove();
function handleProfileSelectLineClick(e) { function handleProfileSelectLineClick(e) {
profileIdRequest = parseInt(e.target.id.replace("ProfileSelectLine_", "")); profileIdRequest = parseInt(e.currentTarget.id.replace("ProfileSelectLine_", ""));
$.mobile.changePage("#displayProfile", { transition: "slidefade" }); $.mobile.changePage("#displayProfile", { transition: "slidefade" });
} }
for (var profile in data) { for (var profile in data) {
$('<li id="ProfileSelectLine_' + data[profile].ProfileId + '"> <a href="#"> <img src="' + ((data[profile].Avatar & data[profile].Avatar.base64Data) ? data[profile].Avatar.base64Data : "img/profile.png") + '"> <h2>' + data[profile].PlayerName + '</h2> <p>Click here to show the profile of ' + data[profile].PlayerName + '</p> </a> </li>') $('<li id="ProfileSelectLine_' + data[profile].ProfileId + '"> <a href="#"> <img src="' + ((data[profile].Avatar && data[profile].Avatar.base64Data) ? data[profile].Avatar.base64Data : "img/profile.png") + '"> <h2>' + data[profile].PlayerName + '</h2> <p>Click here to show the profile of ' + data[profile].PlayerName + '</p> </a> </li>')
.appendTo('#selectProfileList') .appendTo('#selectProfileList')
.click(handleProfileSelectLineClick); .click(handleProfileSelectLineClick);
} }
@@ -176,11 +177,19 @@ function initMainPageHandler() {
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = function (e) { reader.onloadend = function (e) {
$.post("sendPhoto", { Photo: { base64Data: e.target.result } }) $.ajax({
.always(function () { url: "sendPhoto",
$.mobile.loading('hide'); dataType: "json",
$('#content').unwrap(); 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); reader.readAsDataURL(file);