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

No files matched your search

+6 -2
View File
@@ -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.
@@ -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
}
}
@@ -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 : "";
}
+14 -6
View File
@@ -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;
}
+2 -2
View File
@@ -1,7 +1,7 @@
#playerAvatar {
height: 75%;
max-width: 250px;
height: auto;
max-height: 250px;
width: auto;
}
#playerName {
+18 -9
View File
@@ -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) {
$('<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')
.click(handleProfileSelectLineClick);
}
@@ -169,18 +170,26 @@ function initMainPageHandler() {
$('#content').wrap('<div class="overlay" />');
$.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);