diff --git a/Android/BewoMitarbeiterApp/app/app.iml b/Android/BewoMitarbeiterApp/app/app.iml
index 5c1f8f22c..7ec9dbda5 100644
--- a/Android/BewoMitarbeiterApp/app/app.iml
+++ b/Android/BewoMitarbeiterApp/app/app.iml
@@ -66,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -82,6 +74,14 @@
+
+
+
+
+
+
+
+
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
index 7a28e5d75..61e4a1607 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
@@ -38,37 +38,35 @@ public class DatabaseHandler extends SQLiteOpenHelper {
private static final String LOGTAG = "DATABASE_HANDLER";
//DataBase version
- private static final int DATABASE_VERSION = 10;
+ private static final int DATABASE_VERSION = 11;
//Database name
private static final String DATABASE_NAME = "Contacts_Manager";
//Table Name
- private static final String TABLE_CONTACTS = "Contactlist";
- private static final String TABLE_CHATMESSAGE = "ChatMessage";
+ private static final String TABLE_CONTACTS = "Contactlist";
+ private static final String TABLE_CHATMESSAGE = "ChatMessage";
private static final String TABLE_DATABASEOWNER = "DatabaseOwner";
+ private static final String TABLE_IMAGE2PERSON = "Image2Person";
//Table Columns name
- private static final String KEY_ID_OWNER = "id";
+ private static final String KEY_ID_OWNER = "id";
private static final String KEY_OWNER_PERSON_OID = "ownerpersonoid";
-
// Contacts-Tabelle
- private static final String KEY_ID ="id";
- private static final String KEY_KONTAKT_NAME = "kontaktname";
- private static final String KEY_PERSONOID = "personoid";
- private static final String KEY_PICTURE_BLOB = "bild";
- private static final String KEY_IS_TEAM = "isteam";
- private static final String KEY_TEAM_MEMBER_OIDS = "teammemberoids";
+ private static final String KEY_ID = "id";
+ private static final String KEY_KONTAKT_NAME = "kontaktname";
+ private static final String KEY_PERSONOID = "personoid";
+ private static final String KEY_IS_TEAM = "isteam";
+ private static final String KEY_TEAM_MEMBER_OIDS = "teammemberoids";
private static final String KEY_TEAM_MEMBER_NAMES = "teammembernames";
- private static final String KEY_VERSION = "version";
- private static final String KEY_IS_EMPLOYEE = "isemployee";
+ private static final String KEY_VERSION = "version";
+ private static final String KEY_IS_EMPLOYEE = "isemployee";
private static final String[] CONTACTS_COLUMNS = new String[] {
KEY_ID,
KEY_KONTAKT_NAME,
KEY_PERSONOID,
- KEY_PICTURE_BLOB,
KEY_IS_TEAM,
KEY_TEAM_MEMBER_OIDS,
KEY_TEAM_MEMBER_NAMES,
@@ -77,16 +75,16 @@ public class DatabaseHandler extends SQLiteOpenHelper {
};
// ChatMessage-Tabelle
- private static final String KEY_ID_CHATMESSAGE = "id";
- private static final String KEY_SENDER_PERSON_OID_CHATMESSAGE = "senderpersonoid";
+ private static final String KEY_ID_CHATMESSAGE = "id";
+ private static final String KEY_SENDER_PERSON_OID_CHATMESSAGE = "senderpersonoid";
private static final String KEY_RECIPIENT_PERSON_OID_CHATMESSAGE = "recipientpersonoid";
- private static final String KEY_INSTS_CHATMESSAGE = "insts";
- private static final String KEY_CHAT_TEXT_CHATMESSAGE = "chattext";
- private static final String KEY_IS_DELIVERED_CHATMESSAGE = "isdelivered";
- private static final String KEY_SERVERSEITIGE_OID_CHATMESSAGE = "serverseitigeoid";
- private static final String KEY_IS_TEAM_CHATMESSAGE = "isteam";
- private static final String KEY_MESSAGE_ID_CHATMESSAGE = "messageid";
- private static final String KEY_SENDDATE_CHATMESSAGE = "senddate";
+ private static final String KEY_INSTS_CHATMESSAGE = "insts";
+ private static final String KEY_CHAT_TEXT_CHATMESSAGE = "chattext";
+ private static final String KEY_IS_DELIVERED_CHATMESSAGE = "isdelivered";
+ private static final String KEY_SERVERSEITIGE_OID_CHATMESSAGE = "serverseitigeoid";
+ private static final String KEY_IS_TEAM_CHATMESSAGE = "isteam";
+ private static final String KEY_MESSAGE_ID_CHATMESSAGE = "messageid";
+ private static final String KEY_SENDDATE_CHATMESSAGE = "senddate";
private static final String[] CHAT_MESSAGE_COLUMNS = new String[] {
KEY_ID_CHATMESSAGE,
@@ -101,6 +99,20 @@ public class DatabaseHandler extends SQLiteOpenHelper {
KEY_SENDDATE_CHATMESSAGE
};
+
+ // Image2Person-Tabelle
+ private static final String KEY_ID_IMAGE2PERSON = "id";
+ private static final String KEY_IMAGE_IMAGE2PERSON = "image";
+ private static final String KEY_PERSONOID_IMAGE2PERSON = "personoid";
+ private static final String KEY_VERSION_IMAGE2PERSON = "version";
+
+ private static final String[] IMAGE2PERSON_COLUMNS = new String[] {
+ KEY_ID_IMAGE2PERSON,
+ KEY_IMAGE_IMAGE2PERSON,
+ KEY_PERSONOID_IMAGE2PERSON,
+ KEY_VERSION_IMAGE2PERSON
+ };
+
private static DatabaseHandler mInstance = null;
public static DatabaseHandler getInstance(Context context) {
@@ -126,6 +138,9 @@ public class DatabaseHandler extends SQLiteOpenHelper {
deleteQuery = "DELETE FROM " + TABLE_CONTACTS;
db.execSQL(deleteQuery);
+
+ deleteQuery = "DELETE FROM " + TABLE_IMAGE2PERSON;
+ db.execSQL(deleteQuery);
}
public void onCreate(SQLiteDatabase db) {
@@ -134,7 +149,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
KEY_ID + " INTEGER PRIMARY KEY," +
KEY_KONTAKT_NAME + " TEXT,"+
KEY_PERSONOID + " INTEGER," +
- KEY_PICTURE_BLOB + " BLOB, " +
KEY_IS_TEAM + " INTEGER, " +
KEY_TEAM_MEMBER_NAMES + " TEXT, " +
KEY_TEAM_MEMBER_OIDS + " TEXT, " +
@@ -164,6 +178,14 @@ public class DatabaseHandler extends SQLiteOpenHelper {
")";
db.execSQL(createOwnerTable);
+
+ String createImage2PersonTable = "CREATE TABLE " + TABLE_IMAGE2PERSON + " (" +
+ KEY_ID_IMAGE2PERSON + " INTEGER PRIMARY KEY," +
+ KEY_IMAGE_IMAGE2PERSON + " BLOB, " +
+ KEY_PERSONOID_IMAGE2PERSON + " INTEGER, " +
+ KEY_VERSION_IMAGE2PERSON + "INTEGER)";
+
+ db.execSQL(createImage2PersonTable);
}
public void insertOwnerOid(int ownerOid) {
@@ -309,6 +331,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CHATMESSAGE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_DATABASEOWNER);
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_IMAGE2PERSON);
onCreate(db);
}
@@ -319,7 +342,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
values.put(KEY_KONTAKT_NAME, contact.getChatName());
values.put(KEY_PERSONOID, contact.getPersonOid());
- values.put(KEY_PICTURE_BLOB, contact.getPicture());
values.put(KEY_IS_TEAM, contact.isTeam);
values.put(KEY_TEAM_MEMBER_NAMES, contact.teamMemberNames);
values.put(KEY_TEAM_MEMBER_OIDS, contact.teamMemberOids);
@@ -465,14 +487,13 @@ public class DatabaseHandler extends SQLiteOpenHelper {
int contactId = cursor.getInt(0);
String contactName = cursor.getString(1);
int contactPersonOid = cursor.getInt(2);
- byte[] contactPicture = cursor.getBlob(3);
- boolean contactIsTeam = cursor.getInt(4) == 1;
- String teamMemberOids = cursor.getString(5);
- String teamMemberNames = cursor.getString(6);
- int contactVersion = cursor.getInt(7);
- boolean isEmployee = cursor.getInt(8) == 1;
+ boolean contactIsTeam = cursor.getInt(3) == 1;
+ String teamMemberOids = cursor.getString(4);
+ String teamMemberNames = cursor.getString(5);
+ int contactVersion = cursor.getInt(6);
+ boolean isEmployee = cursor.getInt(7) == 1;
- ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
+ ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
cursor.close();
@@ -496,12 +517,11 @@ public class DatabaseHandler extends SQLiteOpenHelper {
contact.setId(cursor.getInt(0));
contact.setChatName(cursor.getString(1));
contact.setPersonOid(cursor.getInt(2));
- contact.setPicture(cursor.getBlob(3));
- contact.isTeam = cursor.getInt(4) == 1;
- contact.teamMemberNames = cursor.getString(5);
- contact.teamMemberOids = cursor.getString(6);
- contact.setVersion(cursor.getInt(7));
- contact.setIsEmployee(cursor.getInt(8) == 1);
+ contact.isTeam = cursor.getInt(3) == 1;
+ contact.teamMemberNames = cursor.getString(4);
+ contact.teamMemberOids = cursor.getString(5);
+ contact.setVersion(cursor.getInt(6));
+ contact.setIsEmployee(cursor.getInt(7) == 1);
contactList.add(contact);
} while (cursor.moveToNext());
@@ -555,7 +575,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
ContentValues values = new ContentValues();
values.put(KEY_KONTAKT_NAME, contact.getChatName());
values.put(KEY_PERSONOID, contact.getPersonOid());
- values.put(KEY_PICTURE_BLOB, contact.getPicture());
values.put(KEY_IS_TEAM, (contact.isTeam ? 1 : 0));
values.put(KEY_TEAM_MEMBER_NAMES, contact.teamMemberNames);
values.put(KEY_TEAM_MEMBER_OIDS, contact.teamMemberOids);
@@ -586,22 +605,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
return result;
}
- public byte[] getUserImage(Integer personOid) {
- SQLiteDatabase readableDatabase = this.getReadableDatabase();
-
- Cursor cursor = readableDatabase.query(TABLE_CONTACTS, new String[] {KEY_PICTURE_BLOB}, KEY_PERSONOID + " = " + personOid, null, null, null, null);
-
- byte[] picture = null;
-
- if(cursor != null && cursor.moveToFirst()) {
- picture = cursor.getBlob(0);
-
- cursor.close();
- }
-
- return picture;
- }
-
public ContactListItem getContactByPersonOid(int personOid, boolean isTeam) {
SQLiteDatabase readableDatabase = this.getReadableDatabase();
@@ -616,14 +619,13 @@ public class DatabaseHandler extends SQLiteOpenHelper {
int contactId = cursor.getInt(0);
String contactName = cursor.getString(1);
int contactPersonOid = cursor.getInt(2);
- byte[] contactPicture = cursor.getBlob(3);
- boolean contactIsTeam = cursor.getInt(4) == 1;
- String teamMemberOids = cursor.getString(5);
- String teamMemberNames = cursor.getString(6);
- int contactVersion = cursor.getInt(7);
- boolean isEmployee = cursor.getInt(8) == 1;
+ boolean contactIsTeam = cursor.getInt(3) == 1;
+ String teamMemberOids = cursor.getString(4);
+ String teamMemberNames = cursor.getString(5);
+ int contactVersion = cursor.getInt(6);
+ boolean isEmployee = cursor.getInt(7) == 1;
- ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
+ ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
cursor.close();
@@ -750,4 +752,69 @@ public class DatabaseHandler extends SQLiteOpenHelper {
return result;
}
+
+ private boolean isImageExistingForPerson(int personOid) {
+ SQLiteDatabase readableDatabase = this.getReadableDatabase();
+
+ Cursor cursor = readableDatabase.query(TABLE_IMAGE2PERSON,
+ IMAGE2PERSON_COLUMNS,
+ KEY_PERSONOID_IMAGE2PERSON + " = ?",
+ new String[] {String.valueOf(personOid)},
+ null, null, null, null);
+
+ boolean result = cursor != null && cursor.moveToFirst();
+
+ if(cursor != null) {
+ cursor.close();
+ }
+
+ return result;
+ }
+
+ public void deleteUserImage(int personOid) {
+ SQLiteDatabase writableDatabase = this.getWritableDatabase();
+ writableDatabase.delete(TABLE_IMAGE2PERSON, KEY_PERSONOID_IMAGE2PERSON + " = ?", new String[] {String.valueOf(personOid)});
+ }
+
+ public void insertUserImage(int personOid, byte[] image) {
+ SQLiteDatabase writableDatabase = this.getWritableDatabase();
+
+ ContentValues values = new ContentValues();
+ values.put(KEY_PERSONOID_IMAGE2PERSON, personOid);
+ values.put(KEY_IMAGE_IMAGE2PERSON, image);
+
+ // wenn personoid vorhanden, dann update, ansonsten insert
+ if(isImageExistingForPerson(personOid)) {
+ writableDatabase.update(TABLE_IMAGE2PERSON, values, KEY_PERSONOID_IMAGE2PERSON + " = ?", new String[] {String.valueOf(personOid)});
+ } else {
+ writableDatabase.insertOrThrow(TABLE_IMAGE2PERSON, null, values);
+ }
+ }
+
+ public void updateUserImage(int personOid, byte[] image) {
+ SQLiteDatabase writableDatabase = this.getWritableDatabase();
+
+ ContentValues values = new ContentValues();
+ values.put(KEY_PERSONOID_IMAGE2PERSON, personOid);
+ values.put(KEY_IMAGE_IMAGE2PERSON, image);
+
+ writableDatabase.update(TABLE_IMAGE2PERSON, values, KEY_PERSONOID_IMAGE2PERSON + " = ?", new String[] {String.valueOf(personOid)});
+ }
+
+ // TODO: Immer nur ein Bild pro Person
+ public byte[] getUserImage(Integer personOid) {
+ SQLiteDatabase readableDatabase = this.getReadableDatabase();
+
+ Cursor cursor = readableDatabase.query(TABLE_IMAGE2PERSON, new String[] {KEY_IMAGE_IMAGE2PERSON}, KEY_PERSONOID_IMAGE2PERSON + " = " + personOid, null, null, null, null);
+
+ byte[] picture = null;
+
+ if(cursor != null && cursor.moveToFirst()) {
+ picture = cursor.getBlob(0);
+
+ cursor.close();
+ }
+
+ return picture;
+ }
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java
index d0ed511e2..e0ac675b1 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java
@@ -242,6 +242,8 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
adapter.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged();
+ listView.setSelection(adapter.getCount() - 1);
+
if(!BeWoChatApplication.isActivityVisible()) {
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, chatPacket.IsEmployee, getApplicationContext());
}
@@ -482,6 +484,13 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
adapter.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged();
+ listView.post(new Runnable() {
+ @Override
+ public void run() {
+ listView.setSelection(adapter.getCount() - 1);
+ }
+ });
+
super.onResume();
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ContactListItem.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ContactListItem.java
index e429e603b..cb9a928b5 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ContactListItem.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ContactListItem.java
@@ -1,7 +1,5 @@
package beyondsoft.bewomitarbeiterapp;
-import android.util.Log;
-
import entities.ChatPerson;
/**
@@ -10,7 +8,6 @@ import entities.ChatPerson;
public class ContactListItem {
private int mId;
private String mChatName;
- private byte[] mPicture;
private int mPersonOid;
private int mVersion;
private boolean mIsEmployee;
@@ -25,11 +22,10 @@ public class ContactListItem {
public ContactListItem(){}
- public ContactListItem(int id, String kontaktname, int personOid, byte[] picture, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
+ public ContactListItem(int id, String kontaktname, int personOid, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
this.mId = id;
this.mChatName = kontaktname;
this.mPersonOid = personOid;
- this.mPicture = picture;
this.isTeam = isTeam;
this.teamMemberNames = teamMemberNames;
this.teamMemberOids = teamMemberOids;
@@ -37,10 +33,9 @@ public class ContactListItem {
this.mIsEmployee = isEmployee;
}
- ContactListItem(String kontaktname, int personOid, byte[] picture, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
+ ContactListItem(String kontaktname, int personOid, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
this.mChatName = kontaktname;
this.mPersonOid = personOid;
- this.mPicture = picture;
this.isTeam = isTeam;
this.teamMemberNames = teamMemberNames;
@@ -68,16 +63,6 @@ public class ContactListItem {
this.mChatName = mChatName;
}
- public byte[] getPicture(){
-
- return this.mPicture;
- }
-
- public void setPicture(byte[] mPicture){
-
- this.mPicture = mPicture;
- }
-
public int getPersonOid() {
return mPersonOid;
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktAdapter.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktAdapter.java
index 537a15530..a8c1e0d9d 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktAdapter.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktAdapter.java
@@ -67,29 +67,31 @@ public class KontaktAdapter extends ArrayAdapter {
}
Thread getPic;
- if(currentContact.getPicture() != null) {
- Log.i("Kontakt", "PersonOid hat Bild");
- byte[] imageAsByteArray = currentContact.getPicture();
- Bitmap i = BitmapFactory.decodeByteArray(imageAsByteArray, 0, imageAsByteArray.length);
-
- if(i == null) {
- int bildId = R.drawable.mitarbeiter_avatar;
-
- if(currentContact.isTeam) {
- bildId = R.drawable.mitarbeiter_team_avatar;
- } else if(!currentContact.getIsEmployee()) {
- bildId = R.drawable.klient_avatar;
- }
-
- Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), bildId, 100, 100);
-
- imageView.setImageBitmap(ImageConverter.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 2));
- }
-
- getPic = new Thread(new CircleBitmapCreator(i));
- getPic.start();
- } else {
+ // TODO: Datenbankaufruf
+// if(currentContact.getPicture() != null) {
+// Log.i("Kontakt", "PersonOid hat Bild");
+// byte[] imageAsByteArray = currentContact.getPicture();
+//
+// Bitmap i = BitmapFactory.decodeByteArray(imageAsByteArray, 0, imageAsByteArray.length);
+//
+// if(i == null) {
+// int bildId = R.drawable.mitarbeiter_avatar;
+//
+// if(currentContact.isTeam) {
+// bildId = R.drawable.mitarbeiter_team_avatar;
+// } else if(!currentContact.getIsEmployee()) {
+// bildId = R.drawable.klient_avatar;
+// }
+//
+// Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), bildId, 100, 100);
+//
+// imageView.setImageBitmap(ImageConverter.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 2));
+// }
+//
+// getPic = new Thread(new CircleBitmapCreator(i));
+// getPic.start();
+// } else {
int bildId = R.drawable.mitarbeiter_avatar;
if(currentContact.isTeam) {
@@ -101,7 +103,7 @@ public class KontaktAdapter extends ArrayAdapter {
Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), bildId, 100, 100);
imageView.setImageBitmap(ImageConverter.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 2));
- }
+// }
int resourceId;
if(currentContact.isTeam) {
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java
index 2cd7e2479..7e5f11ccc 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java
@@ -42,6 +42,7 @@ import Database.DatabaseHandler;
import entities.ChatEntity;
import entities.ChatMessage;
import entities.ChatPerson;
+import entities.ImageEntity;
import soapConnection.JsonSoapPrimitiveRequest;
import soapConnection.OnRequestSuccessCallback;
import soapConnection.Packet;
@@ -117,15 +118,16 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
Intent in = new Intent(getBaseContext(), ChatActivity.class);
in.putExtras(bundle);
- if(selectedValue.getPicture() == null) {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.mitarbeiter_avatar);
- a.compress(Bitmap.CompressFormat.JPEG,0,stream);
- byte[] x = stream.toByteArray();
- in.putExtra("Bild", x);
- } else {
- in.putExtra("Bild", selectedValue.getPicture());
- }
+ // TODO: durch Datebankaufruf ersetzen
+// if(selectedValue.getPicture() == null) {
+// ByteArrayOutputStream stream = new ByteArrayOutputStream();
+// Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.mitarbeiter_avatar);
+// a.compress(Bitmap.CompressFormat.JPEG,0,stream);
+// byte[] x = stream.toByteArray();
+// in.putExtra("Bild", x);
+// } else {
+// in.putExtra("Bild", selectedValue.getPicture());
+// }
startActivity(in);
}
@@ -726,8 +728,7 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
}
for(ChatPerson cp : result) {
- Log.i("KONTAKTE_VOM_SERVER", "(" + cp.Name + ") Größe des Bildes: " + (cp.ImageThumbnail != null ? "" + cp.ImageThumbnail.length : "Bild ist NULL"));
- ContactListItem contact = new ContactListItem(cp.Name, cp.Oid, cp.ImageThumbnail, cp.IsTeam, cp.TeamMemberOids, cp.TeamMemberNames, cp.Version, cp.IsEmployee);
+ ContactListItem contact = new ContactListItem(cp.Name, cp.Oid, cp.IsTeam, cp.TeamMemberOids, cp.TeamMemberNames, cp.Version, cp.IsEmployee);
ChatEntity cliEntity = new ChatEntity(cp.Oid, cp.IsTeam, cp.IsEmployee);
@@ -823,4 +824,82 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
}
}
}
+
+ private final class JsonSoapPrimitiveImageRequestListener implements RequestListener {
+
+ @Override
+ public void onRequestFailure(SpiceException spiceException) {
+ BeWoLog.writeToLogFile("Ein Fehler ist beim Laden der Bilder aufgetreten (JsonSoapPrimitiveImageRequestListener->onRequestFailure)");
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(KontaktChatActivity.this, "Ein Fehler ist beim laden der Bilder aufgetreten.", Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ @Override
+ public void onRequestSuccess(SoapPrimitive soapPrimitive) {
+ if(soapPrimitive == null) {
+ BeWoLog.writeToLogFile("Antwort vom Server war null. Ein erneuter Login erfolgt. (JsonSoapPrimitiveRequestListener->onRequestSuccess)");
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ swipeRefreshLayout.setRefreshing(false);
+ }
+ });
+
+ Log.e(LOGTAG, "Der vom Server zurückgelieferte Wert ist NULL! (Laden der Bilder)");
+
+ try {
+ ArrayList propertyInfos = new ArrayList<>();
+
+ SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
+ String savedTenant = settings.getString(Util.PREFS_TENANT_KEY, null);
+ String savedUsername = settings.getString(Util.PREFS_USERNAME_KEY, null);
+ String savedPassword = settings.getString(Util.PREFS_PASSWORD, null);
+
+ byte[] tenantByteArray = Base64.decode(savedTenant, Base64.DEFAULT);
+ ByteArrayInputStream tenantStream = new ByteArrayInputStream(tenantByteArray);
+
+ byte[] usernameByteArray = Base64.decode(savedUsername, Base64.DEFAULT);
+ ByteArrayInputStream usernameStream = new ByteArrayInputStream(usernameByteArray);
+
+ byte[] passwordByteArray = Base64.decode(savedPassword, Base64.DEFAULT);
+ ByteArrayInputStream passwordStream = new ByteArrayInputStream(passwordByteArray);
+
+ propertyInfos.add(SoapConnectionManager.BuildProperty("pTenant", SecurityUtils.decrypt(tenantStream).toString(), String.class));
+ propertyInfos.add(SoapConnectionManager.BuildProperty("pUsername", SecurityUtils.decrypt(usernameStream).toString(), String.class));
+ propertyInfos.add(SoapConnectionManager.BuildProperty("pPassword", SecurityUtils.decrypt(passwordStream).toString(), String.class));
+
+ JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.LOGIN_CALL, propertyInfos);
+
+ BeWoLog.writeToLogFile("Lade Bilder erneut herunter. (JsonSoapPrimitiveRequestListener->onRequestSuccess)");
+ spiceManager.execute(request, new KontaktChatActivity.JsonSoapPrimitiveReLoginRequestListener());
+ } catch(Exception e) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(getApplicationContext(), "Ein fataler Fehler ist aufgetreten. Bitte Loggen Sie sich erneut ein.", Toast.LENGTH_LONG).show();
+ }
+ });
+ }
+
+ return;
+ }
+
+ GsonBuilder builder = new GsonBuilder();
+ builder.registerTypeAdapter(ImageEntity.class, new ChatPersonDeserializer());
+
+ Gson gson = builder.create();
+
+ Type listType = new TypeToken>(){}.getType();
+
+ ArrayList result = gson.fromJson(soapPrimitive.toString(), listType);
+
+// List lc = databaseHandler.getAllContacts();
+ }
+ }
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/entities/ImageEntity.java b/Android/BewoMitarbeiterApp/app/src/main/java/entities/ImageEntity.java
index a0e27661e..1e0166076 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/entities/ImageEntity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/entities/ImageEntity.java
@@ -7,9 +7,11 @@ package entities;
public class ImageEntity {
public int PersonOid;
public byte[] Image;
+ public int Version;
- public ImageEntity(int personOid, byte[] image) {
+ public ImageEntity(int personOid, byte[] image, int version) {
PersonOid = personOid;
Image = image;
+ Version = version;
}
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/Packet.java b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/Packet.java
index cc36bb1e6..b8cd6b585 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/Packet.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/Packet.java
@@ -1,5 +1,6 @@
package soapConnection;
+import android.util.Base64;
import android.util.Log;
import java.io.UnsupportedEncodingException;
@@ -11,23 +12,27 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
+import util.BeWoLog;
+
/**
* Created by JettenM on 05.07.2016.
*/
public class Packet {
public DataIdentifier ChatDataIdentifier;
- public String ChatName;
- public int SenderPersonOid;
- public int RecipientPersonOid;
- public String ChatMessage;
- public Date MessageTimeStamp;
- public String Tenant;
- public boolean IsDelivered;
- public int ServerseitigeOid;
- public int ClientseitigeOid;
- public boolean IsEmployee;
- public String MessageId;
+ public String ChatName;
+ public int SenderPersonOid;
+ public int RecipientPersonOid;
+ public String ChatMessage;
+ public Date MessageTimeStamp;
+ public String Tenant;
+ public boolean IsDelivered;
+ public int ServerseitigeOid;
+ public int ClientseitigeOid;
+ public boolean IsEmployee;
+ public String MessageId;
+ public int MediaType;
+ public byte[] MediaFile;
public Packet() {
ChatDataIdentifier = DataIdentifier.NULL;
@@ -40,6 +45,7 @@ public class Packet {
MessageTimeStamp = Calendar.getInstance().getTime();
IsEmployee = SoapConnectionManager.getUser().getIsEmployee();
MessageId = "";
+ MediaType = 0;
}
private String getFormattedMessageTimeStamp() {
@@ -53,71 +59,97 @@ public class Packet {
//23;281;20;389;1;38;932;[Tenant];1; 9 Semikola
+
public Packet(String message) {
Log.i("PACKET_CONSTRUCTOR_MSG", message);
-
- String[] gesplittet = message.split(";");
-
- String senderPersonOidString = gesplittet[0];
- String recipientPersonOidString = gesplittet[1];
- String chatNameLengthString = gesplittet[2];
- String chatMessageLengthString = gesplittet[3];
- String chatIdentifierString = gesplittet[4];
- String serverseitigeOidString = gesplittet[5];
- String clientseitigeOidString = gesplittet[6];
- Tenant = gesplittet[7];
- String isEmployeeString = gesplittet[8];
- MessageId = gesplittet[9];
-
- SenderPersonOid = Integer.parseInt(senderPersonOidString);
- RecipientPersonOid = Integer.parseInt(recipientPersonOidString);
- ServerseitigeOid = Integer.parseInt(serverseitigeOidString);
- ClientseitigeOid = Integer.parseInt(clientseitigeOidString);
- IsEmployee = Integer.parseInt(isEmployeeString) == 1;
-
- ChatDataIdentifier = DataIdentifier.getEnumValue(Integer.parseInt(chatIdentifierString));
-
- int chatNameLength = Integer.parseInt(chatNameLengthString);
- int chatMessageLength = Integer.parseInt(chatMessageLengthString);
-
- int headerLength = senderPersonOidString.length() + recipientPersonOidString.length() + chatNameLengthString.length() + chatMessageLengthString.length() + chatIdentifierString.length() + Tenant.length() + serverseitigeOidString.length() + clientseitigeOidString.length() + MessageId.length() + 12;
- String actualMessage = message.substring(headerLength - 1);
-
- ChatName = actualMessage.substring(0, chatNameLength);
-
- ChatMessage = actualMessage.substring(chatNameLength, chatMessageLength + chatNameLength);
-
- String dateString = actualMessage.substring(chatMessageLength + chatNameLength, chatMessageLength + chatNameLength + 19);
+ //34;128;0;21.11.2016 13:58;0;1;2129;238;123e4567-e89b-12d3-a456-426655440000;0;;THluZG9uIEpldHRlbg==;RGFzIGlzdCBlaW5lIFRlc3RuYWNocmljaHQ=;ZGVtb2FwcDQ=
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMAN);
+ String[] gesplittet = message.split(";");
+
+ /*
+ SenderPersonOid 0 int
+ RecipientPersonOid 1 int
+ DataIdentifier 2 int -> enum (DataIdentifier)
+ MessageTimeStamp 3 String -> Date
+ IsDelivered 4 int -> Boolean
+ IsEmployee 5 int -> Boolean
+ ServerseitigeOid 6 int
+ ClientseitigeOid 7 int
+ MessageId 8 String
+ MediaTyp 9 int
+ MediaFile 10 Base64String -> byte[]
+ ClientName 11 Base64String -> String
+ ChatMessage 12 Base64String -> String
+ Tenant 13 Base64String -> String
+ */
+
+ SenderPersonOid = Integer.parseInt(gesplittet[0]);
+ RecipientPersonOid = Integer.parseInt(gesplittet[1]);
+ ChatDataIdentifier = DataIdentifier.getEnumValue(Integer.parseInt(gesplittet[2]));
+
try {
- MessageTimeStamp = df.parse(dateString);
+ MessageTimeStamp = df.parse(new String(Base64.decode(gesplittet[3], Base64.NO_WRAP)));
} catch (ParseException e) {
e.printStackTrace();
}
- IsDelivered = Integer.parseInt(actualMessage.substring(chatMessageLength + chatNameLength + 19, chatMessageLength + chatNameLength + 20)) != 0;
+ IsDelivered = Integer.parseInt(gesplittet[4]) == 1;
+ IsEmployee = Integer.parseInt(gesplittet[5]) == 1;
+ ServerseitigeOid = Integer.parseInt(gesplittet[6]);
+ ClientseitigeOid = Integer.parseInt(gesplittet[7]);
-// writeToLog("Konstruktor");
+ MessageId = gesplittet[8];
+ MediaType = Integer.parseInt(gesplittet[9]);
+
+ // TODO: FEHLER
+ MediaFile = gesplittet[10].length() == 0 ? null : Base64.decode(gesplittet[10], Base64.NO_WRAP);
+
+ ChatName = gesplittet[11].length() == 0 ? "" : new String(Base64.decode(gesplittet[11], Base64.NO_WRAP));
+ ChatMessage = gesplittet[12].length() == 0 ? "" : new String(Base64.decode(gesplittet[12], Base64.NO_WRAP));
+
+ // nicht immer ist ein : enthalten
+ String encodedTenant = gesplittet[13];
+ if(encodedTenant.contains(":")) {
+ encodedTenant = encodedTenant.substring(0, encodedTenant.length() - 1);
+ }
+
+ Tenant = gesplittet[13].length() == 0 ? "" : new String(Base64.decode(encodedTenant, Base64.NO_WRAP));
}
public byte[] getDataStream() {
- String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + (IsEmployee ? 1 : 0) + ";" + MessageId + ";";
-
- dataStreamAsString += ChatName + ChatMessage + getFormattedMessageTimeStamp() + "" + (IsDelivered ? 1 : 0);
-
- byte[] blaaah = new byte[dataStreamAsString.length()];
+ String dataStreamAsString = "";
try {
- blaaah = dataStreamAsString.getBytes("UTF8");
- } catch (UnsupportedEncodingException e) {
+ dataStreamAsString += SenderPersonOid + ";";
+ dataStreamAsString += RecipientPersonOid + ";";
+ dataStreamAsString += ChatDataIdentifier.getValue() + ";";
+ dataStreamAsString += Base64.encodeToString(getFormattedMessageTimeStamp().getBytes("UTF8"), Base64.NO_WRAP) + ";";
+ dataStreamAsString += (IsDelivered ? 1 : 0) + ";";
+ dataStreamAsString += (IsEmployee ? 1 : 0) + ";";
+ dataStreamAsString += ServerseitigeOid + ";";
+ dataStreamAsString += ClientseitigeOid + ";";
+ dataStreamAsString += MessageId + ";";
+ dataStreamAsString += MediaType + ";";
+ dataStreamAsString += (MediaFile != null ? Base64.encodeToString(MediaFile, Base64.NO_WRAP) : "") + ";";
+ dataStreamAsString += (ChatName != null ? Base64.encodeToString(ChatName.getBytes("UTF8"), Base64.NO_WRAP) : "") + ";"; // ChatName
+ dataStreamAsString += (ChatMessage != null ? Base64.encodeToString(ChatMessage.getBytes("UTF8"), Base64.NO_WRAP) : "") + ";"; // ChatMessage
+ dataStreamAsString += (Tenant != null ? Base64.encodeToString(Tenant.getBytes("UTF8"), Base64.NO_WRAP) : "") + ":"; // Tenant
+ } catch(UnsupportedEncodingException uee) {
+ BeWoLog.writeExceptionToLog(uee);
+ }
+
+ byte[] result = new byte[dataStreamAsString.length()];
+
+ try {
+ result = dataStreamAsString.getBytes("UTF8");
+ } catch(UnsupportedEncodingException e) {
+ BeWoLog.writeExceptionToLog(e);
Log.e("Packet.getDataStream", e.getMessage());
}
- writeToLog("getDataStream()");
-
- return blaaah;
+ return result;
}
private void writeToLog(String prefix) {
@@ -142,77 +174,13 @@ public class Packet {
// private static final String ANALYZERLOGTAG = "PACKET_ANALYZER";
public static ArrayList analyzePackets(String packetString) {
- int messagesCharCount = packetString.length();
ArrayList packets = new ArrayList<>();
- while (messagesCharCount > 0) {
-// Log.i(ANALYZERLOGTAG, "Packet Nr. " + (packetCount + 1));
- String[] gesplittet = packetString.split(";");
+ String[] messagesFromPacket = packetString.split(":");
-// Log.i(ANALYZERLOGTAG, "Zu analysierender String: " + packetString);
-
- int senderPersonOidLength = gesplittet[0].length();
- int recipientPersonOidLength = gesplittet[1].length();
- int chatNameLength = gesplittet[2].length();
- int chatMessageLength = gesplittet[3].length();
- int chatIdentifierLength = gesplittet[4].length();
- int serverseitigeOidLength = gesplittet[5].length();
- int clientseitigeOidLength = gesplittet[6].length();
- int tenantLength = gesplittet[7].length();
- int isEmployeeLength = gesplittet[8].length();
- int messageIdLength = gesplittet[9].length();
-
-// Log.i(ANALYZERLOGTAG, "SenderPersonOidLength: " + senderPersonOidLength + "\n" +
-// "recipientPersonOidLength: " + recipientPersonOidLength + "\n" +
-// "chatNameLength: " + chatNameLength + "\n" +
-// "chatMessageLength: " + chatMessageLength + "\n" +
-// "chatIdentifierLength: " + chatIdentifierLength + "\n" +
-// "serverseitigeOidLength: " + serverseitigeOidLength + "\n" +
-// "clientseitigeOidLength: " + clientseitigeOidLength + "\n" +
-// "tenantLength: " + tenantLength + "\n" +
-// "isEmployeeLength: " + isEmployeeLength + "\n" +
-// "messageIdLength: " + messageIdLength + "\n" +
-// "actualChatNameLength: " + Integer.parseInt(gesplittet[2]));
-
- int headerLength =
- 10 +
- senderPersonOidLength +
- recipientPersonOidLength +
- chatNameLength +
- chatMessageLength +
- chatIdentifierLength +
- serverseitigeOidLength +
- clientseitigeOidLength +
- tenantLength +
- isEmployeeLength +
- messageIdLength +
- Integer.parseInt(gesplittet[2]);
-
-// Log.i(ANALYZERLOGTAG, "Testausgabe: " + packetString.substring(0, headerLength));
-
- int actualChatMessageLength = Integer.parseInt(gesplittet[3]);
-
- int firstMessageLength = headerLength + actualChatMessageLength + 20;
-
-// Log.i(ANALYZERLOGTAG, "Header-Length: " + headerLength);
-// Log.i(ANALYZERLOGTAG, "Länge der ersten Nachricht: " + firstMessageLength);
-// Log.i(ANALYZERLOGTAG, "Länge des packetStrings: " + packetString.length());
-
- String firstMessage = packetString.substring(0, firstMessageLength);
-
-// Log.i(ANALYZERLOGTAG, "Eigentliche Nachricht: " + (actualChatMessageLength > 0 ? firstMessage.substring(headerLength, headerLength + actualChatMessageLength) : "<>"));
-// Log.i(ANALYZERLOGTAG, "Header: " + firstMessage.substring(0, headerLength));
-//
-// Log.i(ANALYZERLOGTAG, "Erste Nachricht: " + firstMessage);
-//
-// Log.i(ANALYZERLOGTAG, "Länge erste Nachricht: " + firstMessage.length() + ". Länge gesamter packetString: " + packetString.length());
-
- packets.add(new Packet(firstMessage));
-
- messagesCharCount -= firstMessage.length();
- packetString = packetString.substring(firstMessageLength);
-
-// Log.i(ANALYZERLOGTAG, "Reduzierter packetString: " + packetString);
+ for(int i = 0; i < messagesFromPacket.length; i++) {
+ Log.i("PACKETANALYZER", messagesFromPacket[i]);
+ packets.add(new Packet(messagesFromPacket[i] + ":"));
}
return packets;
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
index 73944fd67..d41a99c1d 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
@@ -16,25 +16,27 @@ public class SoapCalls {
public static String LOAD_CHATMESSAGES_CHUNKWISE = "LoadChatMessagesChunkwise";
+ public static String LOAD_USER_IMAGES = "LoadUserImages";
+
//TODO: "app4.bewoplaner.de";//
- public static String DESTINATION_ADDRESS = "app4.bewoplaner.de";
- public static int DESTINATION_PORT = 5000;
-
- public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token=";
-
- public static String WEB_DOKU_URL = "https://app1.bewoplaner.de/mobil/login/1234567890";
-
- public static String WSDL_TARGET_NAME = "bliblablubb.org/";
- public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
-
-
-// public static String DESTINATION_ADDRESS = "192.168.1.103";
+// public static String DESTINATION_ADDRESS = "app4.bewoplaner.de";
// public static int DESTINATION_PORT = 5000;
//
-// public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
+// public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token=";
//
-// public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo";
+// public static String WEB_DOKU_URL = "https://app1.bewoplaner.de/mobil/login/1234567890";
//
-// static String WSDL_TARGET_NAME = "bliblablubb.org/";
-// static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
+// public static String WSDL_TARGET_NAME = "bliblablubb.org/";
+// public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
+
+
+ public static String DESTINATION_ADDRESS = "192.168.1.103";
+ public static int DESTINATION_PORT = 5000;
+
+ public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
+
+ public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo";
+
+ static String WSDL_TARGET_NAME = "bliblablubb.org/";
+ static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/util/ChatPersonDeserializer.java b/Android/BewoMitarbeiterApp/app/src/main/java/util/ChatPersonDeserializer.java
index 148e8935b..a1aeed1dc 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/util/ChatPersonDeserializer.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/util/ChatPersonDeserializer.java
@@ -31,18 +31,6 @@ public class ChatPersonDeserializer implements JsonDeserializer {
int version = Long.valueOf(json.get("Version").getAsLong()).intValue();
boolean isEmployee = json.get("IsEmployee").getAsBoolean();
-// JsonArray originalValue = json.get("ImageThumbnail").getAsJsonArray();
-// String stringValue = originalValue.toString();
-// byte[] bytesValue = stringValue.getBytes();
-// byte[] image = null;//new byte[0];//isImageThumbnailNull ? new byte[0] : json.get("ImageThumbnail").getAsJsonArray().toString().getBytes();
-
-// String[] test = stringValue.substring(1, stringValue.length() - 1).split(",");
-// byte[] abcdef = new byte[test.length];
-// for(int i = 0; len = test.length; i < len; i++) {
-//
-// }
-
-
return new ChatPerson(oid, name, isTeam, teamMemberNames, teamMemberOids, version, isEmployee);
}
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/util/ImageEntityDeserializer.java b/Android/BewoMitarbeiterApp/app/src/main/java/util/ImageEntityDeserializer.java
index 307deb20a..f898d9ecb 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/util/ImageEntityDeserializer.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/util/ImageEntityDeserializer.java
@@ -20,8 +20,8 @@ public class ImageEntityDeserializer implements JsonDeserializer {
JsonObject json = (JsonObject) jsonElement;
- int oid = Long.valueOf(json.get("Oid").getAsLong()).intValue();
- String imgAsBase64 = json.get("").getAsString();
+ int oid = Long.valueOf(json.get("PersonOid").getAsLong()).intValue();
+ String imgAsBase64 = json.get("ImageBase64String").getAsString();
return null;
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml b/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml
index 8e0fc57a2..09a803a93 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml
+++ b/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml
@@ -18,7 +18,7 @@
android:listSelector="@android:color/transparent"
android:stackFromBottom="true"
android:background="@color/white"
- android:transcriptMode="disabled"
+ android:transcriptMode="normal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj
index b4eb35193..5da91386c 100644
--- a/BeWo/BeWo.csproj
+++ b/BeWo/BeWo.csproj
@@ -416,10 +416,6 @@
MSBuild:Compile
Designer
-
- MSBuild:Compile
- Designer
-
MSBuild:Compile
Designer
@@ -788,9 +784,6 @@
ChatEmojisView.xaml
-
- ChatProgressBarView.xaml
-
MiniChatView.xaml
diff --git a/BeWo/View/MiniChatView.xaml.cs b/BeWo/View/MiniChatView.xaml.cs
index b44613924..7f5081fcd 100644
--- a/BeWo/View/MiniChatView.xaml.cs
+++ b/BeWo/View/MiniChatView.xaml.cs
@@ -84,12 +84,18 @@ namespace BeWo.View
try
{
// DragMove();
- anzahlDS = 0;
- viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
-
- viewChat.Visibility = Visibility.Visible;
- myListDS.Clear();
- Visibility = Visibility.Collapsed;
+ if (viewChat != null && viewChat.Visibility != Visibility.Visible)
+ {
+ anzahlDS = 0;
+ viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
+
+ viewChat.Visibility = Visibility.Visible;
+ myListDS.Clear();
+ Visibility = Visibility.Collapsed;
+ }else
+ {
+ Visibility = Visibility.Collapsed;
+ }
}
@@ -205,16 +211,18 @@ namespace BeWo.View
{
try
{
- if (viewChat.Visibility != Visibility.Visible)
+
+ if (viewChat != null && viewChat.Visibility != Visibility.Visible)
{
anzahlDS = 0;
- viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
-
+ viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
+
viewChat.Visibility = Visibility.Visible;
myListDS.Clear();
Visibility = Visibility.Collapsed;
}
+
}
catch (Exception edf)
{
diff --git a/BeWoChatServer/Server.cs b/BeWoChatServer/Server.cs
index 083893813..588375068 100644
--- a/BeWoChatServer/Server.cs
+++ b/BeWoChatServer/Server.cs
@@ -303,6 +303,8 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in der Datenbank");
+
+ // TODO: MedienTyp unterscheiden 0 -> Text, 1 -> Bild, 2 -> Dokument
DAOFactory.GenericDAO.Insert(chatMessage);
if(chatMessage.Oid != null)
diff --git a/BeWoPlanerAndroid/AndroidSoapService.asmx.cs b/BeWoPlanerAndroid/AndroidSoapService.asmx.cs
index 83e64de74..e7c285fa2 100644
--- a/BeWoPlanerAndroid/AndroidSoapService.asmx.cs
+++ b/BeWoPlanerAndroid/AndroidSoapService.asmx.cs
@@ -225,7 +225,7 @@ namespace BeWoPlanerAndroid
[WebMethod(EnableSession = true)]
public string LoadUserImages(long pPersonOid)
{
- var images = new Dictionary();
+ var images = new List();
// employee oder customer laden
var employee = DAOFactory.SearchDAO.FindEmployeeWithPersonOid(pPersonOid);
@@ -234,14 +234,11 @@ namespace BeWoPlanerAndroid
var isEmployee = customer == null;
// mit den eigenen Klienten und allen anderen Mitarbeitern
- if(isEmployee)
+ 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())));
- }
+ images.AddRange(byteImages.Select(img => new ImageEntity(img.Key, img.Value)));
}
else
{
@@ -255,11 +252,14 @@ namespace BeWoPlanerAndroid
{
public long PersonOid { get; set; }
- public sbyte[] Image { get; set; }
+ public string ImageBase64String { get; set; }
+
+ public string CheckSum { get; set; }
public ImageEntity(long pPersonOid, byte[] pImage)
{
- Image = Array.ConvertAll(pImage, b => unchecked((sbyte)b));
+ PersonOid = pPersonOid;
+ ImageBase64String = Convert.ToBase64String(pImage);
}
}
@@ -289,11 +289,6 @@ namespace BeWoPlanerAndroid
Version = pVersion;
IsEmployee = pIsEmployee;
}
-
- //public void ConvertImageToSignedByteArray(byte[] image)
- //{
- // ImageThumbnail = Array.ConvertAll(image, b => unchecked((sbyte) b));
- //}
}
public class ChatMessageForJson
diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs
index d67e769da..2eefb7f63 100644
--- a/Data/Access/SearchDAO.cs
+++ b/Data/Access/SearchDAO.cs
@@ -1757,12 +1757,28 @@ namespace BeWo.Data.Access
foreach (var emp in employees.Where(w => w.EmployeeImage != null))
{
+ var cs = CalculateCheckSum(emp.EmployeeImage);
+
result.Add(emp.Oid.Value, emp.EmployeeImage);
}
return result;
}
+ private string CalculateCheckSum(byte[] pDataToCalculate)
+ {
+ var checkSum = 0;
+
+ foreach (var chData in pDataToCalculate)
+ {
+ checkSum += chData;
+ }
+
+ checkSum &= 0xff;
+
+ return checkSum.ToString("X2");
+ }
+
public IEnumerable FindUnreadChatMessagesForRecipient(long pRecipientOid)
{
var c = CreateCriteriaIsActive()
diff --git a/Model/Changes2_06_10_2016.txt b/Model/Changes2_06_10_2016.txt
index 8380ecbb5..fd27b637a 100644
--- a/Model/Changes2_06_10_2016.txt
+++ b/Model/Changes2_06_10_2016.txt
@@ -1,2 +1,2 @@
-ALTER TABLE `1234567890`.`contract`
+ALTER TABLE `contract`
ADD COLUMN `MonthlyTotalHours` DECIMAL(18,10) NULL DEFAULT NULL COMMENT '' AFTER `WeeklyDays`;
diff --git a/Model/Changes_16_11_2016.txt b/Model/Changes_16_11_2016.txt
index af633ca76..878f8740d 100644
--- a/Model/Changes_16_11_2016.txt
+++ b/Model/Changes_16_11_2016.txt
@@ -1,5 +1,5 @@
-CREATE TABLE `1234567890`.`chatmediamessage` (
- `Oid` BIGINT(19) NULL AUTO_INCREMENT COMMENT '',
+CREATE TABLE `chatmediamessage` (
+ `Oid` BIGINT(19) AUTO_INCREMENT COMMENT '',
`ChatMessageOid` BIGINT(19) NULL COMMENT '',
`Tid` INT(10) NULL COMMENT '',
@@ -19,8 +19,8 @@ CREATE TABLE `1234567890`.`chatmediamessage` (
PRIMARY KEY (`Oid`) COMMENT '');
-ALTER TABLE `1234567890`.`chatmediamessage`
+ALTER TABLE `chatmediamessage`
ADD INDEX `ChatMessage_IDX` (`ChatMessageOid` ASC) COMMENT '';
-ALTER TABLE `1234567890`.`chatmessages`
+ALTER TABLE `chatmessages`
DROP COLUMN `MediaDatei`;
diff --git a/Shared/Packet.cs b/Shared/Packet.cs
index a6333325a..1a29fa3ac 100644
--- a/Shared/Packet.cs
+++ b/Shared/Packet.cs
@@ -34,6 +34,9 @@ namespace BS.Shared
//[SenderOid];[RecipientOid];[ClientNameLength];[MessageLength];[ChatDataIdentifier];[ServerSeitigeOid];[ClientSeitigeOid];[Tenant];[IsEmployee]; 9 Semikola
+ // NEU:
+ // 34;128;0;21.11.2016 13:58;0;1;2129;238;123e4567-e89b-12d3-a456-426655440000;0;;THluZG9uIEpldHRlbg==;RGFzIGlzdCBlaW5lIFRlc3RuYWNocmljaHQ=;ZGVtb2FwcDQ=:
+
public Packet(Socket pSocket, string pClientName, long pSenderPersonOid, long pRecipientPersonOid, bool pIsEmployee)
{
Socket = pSocket;
@@ -58,6 +61,97 @@ namespace BS.Shared
}
public void GetData(string message)
+ {
+ /*
+ * 0 SenderPersonOid
+ * 1 RecipientPersonOid
+ * 2 DataIdentifier
+ * 3 MessageTimeStamp
+ * 4 IsDelivered
+ * 5 IsEmployee
+ * 6 ServerseitigeOid
+ * 7 ClientseitigeOid
+ * 8 MessageId
+ * 9 MediaTyp
+ * 10 MediaFile
+ * 11 ClientName
+ * 12 ChatMessage
+ * 13 Tenant
+ */
+
+ Debug.WriteLine("Erhaltene Nachricht: " + message);
+
+ try
+ {
+ var gesplittet = message.Split(';');
+
+ for (var i = 0; i < gesplittet.Length; i++)
+ {
+ Debug.WriteLine(i + ": " + gesplittet[i]);
+ }
+
+ SenderPersonOid = Convert.ToInt64(gesplittet[0]);
+ RecipientPersonOid = Convert.ToInt64(gesplittet[1]);
+ DataIdentifier = (DataIdentifier)Convert.ToInt32(gesplittet[2]);
+ MessageTimeStamp = DateTime.ParseExact(Encoding.UTF8.GetString(Convert.FromBase64String(gesplittet[3])), "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture);
+ IsDelivered = Convert.ToInt32(gesplittet[4]) == 1;
+ IsEmployee = Convert.ToInt32(gesplittet[5]) == 1;
+ ServerseitigeOid = Convert.ToInt64(gesplittet[6]);
+ ClientseitigeOid = Convert.ToInt64(gesplittet[7]);
+ MessageId = gesplittet[8];
+ MediaTyp = Convert.ToInt32(gesplittet[9]);
+
+ if (!gesplittet[10].IsNullOrEmpty())
+ {
+ MediaDatei = Convert.FromBase64String(gesplittet[10]);
+ }
+
+ if (!gesplittet[11].IsNullOrEmpty())
+ {
+ ClientName = Encoding.UTF8.GetString(Convert.FromBase64String(gesplittet[11]));
+ }
+
+ if (!gesplittet[12].IsNullOrEmpty())
+ {
+ ChatMessage = Encoding.UTF8.GetString(Convert.FromBase64String(gesplittet[12]));
+ }
+
+ if (!gesplittet[13].IsNullOrEmpty())
+ {
+ Tenant = Encoding.UTF8.GetString(Convert.FromBase64String(gesplittet[13].Substring(0, gesplittet[13].Length - 1)));
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.WriteLine("Error 1500: " + e.Message);
+ }
+ }
+
+ public byte[] GetDataStream()
+ {
+ var result = "";
+
+ result += SenderPersonOid + ";";
+ result += RecipientPersonOid + ";";
+ result += (int)DataIdentifier + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")), Base64FormattingOptions.None) + ";";
+ result += (IsDelivered ? 1 : 0) + ";";
+ result += (IsEmployee ? 1 : 0) + ";";
+ result += ServerseitigeOid + ";";
+ result += ClientseitigeOid + ";";
+ result += MessageId + ";";
+ result += MediaTyp + ";";
+ result += (MediaDatei != null ? Convert.ToBase64String(MediaDatei, Base64FormattingOptions.None) : "") + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientName ?? ""), Base64FormattingOptions.None) + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(ChatMessage ?? ""), Base64FormattingOptions.None) + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(Tenant ?? ""), Base64FormattingOptions.None) + ":";
+
+ Debug.WriteLine("Verschicke Paket: " + result);
+
+ return Encoding.UTF8.GetBytes(result);
+ }
+
+ public void GetData_ALT(string message)
{
Debug.WriteLine("Erhaltene Nachricht: " + message);
@@ -76,7 +170,7 @@ namespace BS.Shared
var isEmployeeString = gesplittet[8];
MessageId = gesplittet[9];
var mediatypString = gesplittet[10];
- var mediaDateiSring = gesplittet[11];
+ var mediaDateiString = gesplittet[11];
DataIdentifier = (DataIdentifier) Convert.ToInt32(chatIdentifierString);
@@ -95,9 +189,9 @@ namespace BS.Shared
MediaTyp = 0;
}
- if (!mediaDateiSring.IsNullOrEmpty())
+ if (!mediaDateiString.IsNullOrEmpty())
{
- MediaDatei = Convert.FromBase64String(mediaDateiSring);
+ MediaDatei = Convert.FromBase64String(mediaDateiString);
}
var chatNameLength = Convert.ToInt32(chatNameLengthString);
@@ -123,24 +217,37 @@ namespace BS.Shared
}
}
- public byte[] GetDataStream()
+ public byte[] GetDataStream_ALT()
{
var result = "";
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int)DataIdentifier + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + (IsEmployee ? 1 : 0) + ";" + MessageId + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
-
+
Debug.WriteLine("Verschicke Paket: " + result);
return Encoding.UTF8.GetBytes(result);
}
- public byte[] GetDataStream(long senderPersonOid, long empfaengerPersonoid, string clientName, string message, DataIdentifier dataIdentifier, string tenant, bool isDelivered, bool IsEmploye, string Messageid,int mediatyp,byte[]mediaDatei)
+ public byte[] GetDataStream(long pSenderPersonOid, long pRecipientPersonOid, string pClientName, string pMessage, DataIdentifier pDataIdentifier, string pTenant, bool pIsDelivered, bool pIsEmployee, string pMessageId, int pMediaType, byte[] pMediaFile)
{
//Bewo-Client spezialisiert
var result = "";
- result += senderPersonOid + ";" + empfaengerPersonoid + ";" + clientName.Length + ";" + message.Length + ";" + (int)dataIdentifier + ";" + 0 + ";" + 0 + ";" + tenant + ";" + (IsEmploye ? 1 : 0) + ";" + Messageid + ";" + clientName + message + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (isDelivered ? 1 : 0) + ";" + mediatyp + ";" + Convert.ToBase64String(mediaDatei);
+ result += pSenderPersonOid + ";";
+ result += pRecipientPersonOid + ";";
+ result += (int)pDataIdentifier + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")), Base64FormattingOptions.None) + ";";
+ result += (pIsDelivered ? 1 : 0) + ";";
+ result += (pIsEmployee ? 1 : 0) + ";";
+ result += 0 + ";";
+ result += 0 + ";";
+ result += pMessageId + ";";
+ result += pMediaType + ";";
+ result += (pMediaFile != null ? Convert.ToBase64String(pMediaFile, Base64FormattingOptions.None) : "") + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(pClientName ?? ""), Base64FormattingOptions.None) + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(pMessage ?? ""), Base64FormattingOptions.None) + ";";
+ result += Convert.ToBase64String(Encoding.UTF8.GetBytes(pTenant ?? ""), Base64FormattingOptions.None) + ":";
return Encoding.UTF8.GetBytes(result);
}