Avatare zum Handy schicken

This commit is contained in:
staccatomamba
2016-11-21 11:25:24 +01:00
parent ef715ab7aa
commit 4f0667c48d
5 changed files with 131 additions and 22 deletions

View File

@@ -73,6 +73,14 @@ namespace BeWoPlanerAndroid
return LoginFailReason.Unknown.ToString();
}
[WebMethod(EnableSession = true)]
public string LoadImageForEmployee(long pEmployeePersonOid)
{
var employee = DAOFactory.SearchDAO.FindEmployeeWithPersonOid(pEmployeePersonOid);
return SerializeObject(employee.EmployeeThumbnail);
}
[WebMethod(EnableSession = true)]
public string TenantNochExistent()
{
@@ -143,7 +151,10 @@ namespace BeWoPlanerAndroid
var isEmployee = customer == null;
// mit den eigenen Klienten und allen anderen Mitarbeitern
var allPersons = DAOFactory.SearchDAO.FindAllChatAuthorizedPersonsForEmployee(employee.Oid.Value).Where(w => w.Key.Oid.Value != employee.Person.Oid.Value).Select(s => new ChatPerson(s.Key.Oid.Value, s.Key.FirstNameLastName, false, null, null, s.Key.Version.Value, s.Value)).ToList();
var allPersons = DAOFactory.SearchDAO.FindAllChatAuthorizedPersonsForEmployee(employee.Oid.Value).Where(w => w.Key.Oid.Value != employee.Person.Oid.Value);
var allChatPersons = allPersons
.Select(s => new ChatPerson(s.Key.Oid.Value, s.Key.FirstNameLastName, false, null, null, s.Key.Version.Value, s.Value)).ToList();
var teams = DAOFactory.SearchDAO.FindTeamsOfEmployee(employee.Oid.Value).Where(w => w.MemberList.Count > 1);
@@ -166,10 +177,10 @@ namespace BeWoPlanerAndroid
}
}
allPersons.Add(new ChatPerson(team.Oid.Value, team.Name, true, memberString, memberNames, team.Version.Value, false));
allChatPersons.Add(new ChatPerson(team.Oid.Value, team.Name, true, memberString, memberNames, team.Version.Value, false));
}
return SerializeObject(allPersons);
return SerializeObject(allChatPersons);
}
private static string SerializeObject(object obj)
@@ -211,6 +222,47 @@ namespace BeWoPlanerAndroid
return JsonConvert.SerializeObject(jsonMessages);
}
[WebMethod(EnableSession = true)]
public string LoadUserImages(long pPersonOid)
{
var images = new Dictionary<long, string>();
// employee oder customer laden
var employee = DAOFactory.SearchDAO.FindEmployeeWithPersonOid(pPersonOid);
var customer = DAOFactory.SearchDAO.FindCustomerWithPersonOid(pPersonOid);
var isEmployee = customer == null;
// mit den eigenen Klienten und allen anderen Mitarbeitern
if(isEmployee)
{
var byteImages = DAOFactory.SearchDAO.FindImagesForChatAuthorizedPersonsForEmployee(employee.Oid.Value);
foreach(var img in byteImages)
{
images.Add(img.Key, Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Array.ConvertAll(img.Value, b => unchecked((sbyte)b)).ToString())));
}
}
else
{
}
return SerializeObject(images);
}
public class ImageEntity
{
public long PersonOid { get; set; }
public sbyte[] Image { get; set; }
public ImageEntity(long pPersonOid, byte[] pImage)
{
Image = Array.ConvertAll(pImage, b => unchecked((sbyte)b));
}
}
public class ChatPerson
{
public long Oid { get; set; }
@@ -237,6 +289,11 @@ namespace BeWoPlanerAndroid
Version = pVersion;
IsEmployee = pIsEmployee;
}
//public void ConvertImageToSignedByteArray(byte[] image)
//{
// ImageThumbnail = Array.ConvertAll(image, b => unchecked((sbyte) b));
//}
}
public class ChatMessageForJson