Android Client von Datei mit ChatNachrichten auf DB umgestellt
This commit is contained in:
@@ -64,14 +64,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
@@ -80,6 +72,14 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
|
||||
@@ -48,13 +48,16 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import entities.ChatMessage;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import util.SecurityUtils;
|
||||
import util.Util;
|
||||
|
||||
@@ -65,6 +68,8 @@ public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
private static final String LOG_TAG = "CHAT";
|
||||
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
//View Variablen
|
||||
protected TextView chat;
|
||||
protected EditText text;
|
||||
@@ -79,15 +84,15 @@ public class ChatActivity extends ActionBarActivity{
|
||||
//Design View
|
||||
protected ListView listView;
|
||||
protected boolean isMe = true;
|
||||
public static List<ChatMessageFormat> chatMessages;
|
||||
public static ArrayAdapter<ChatMessageFormat> adapter;
|
||||
public static List<ChatMessage> chatMessages;
|
||||
public static ArrayAdapter<ChatMessage> adapter;
|
||||
public static ChatMessageFormat chatMessage;
|
||||
|
||||
File file;
|
||||
File Unsendfile = null;
|
||||
File UnsentFile = null;
|
||||
|
||||
protected String name;
|
||||
protected int personOid;
|
||||
protected String recipientName;
|
||||
protected int recipientPersonOid;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -100,7 +105,7 @@ public class ChatActivity extends ActionBarActivity{
|
||||
action.setDisplayShowTitleEnabled(false);
|
||||
|
||||
LayoutInflater inflate = LayoutInflater.from(this);
|
||||
View mCustomView = inflate.inflate(R.layout.custom_menuebar,null);
|
||||
View mCustomView = inflate.inflate(R.layout.custom_menuebar, null);
|
||||
|
||||
|
||||
// Initialiesiere die Variablen
|
||||
@@ -109,8 +114,8 @@ public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
//get Daten aus vorheriger Activity
|
||||
Bundle zielkorb = getIntent().getExtras();
|
||||
name = zielkorb.getString("Name");
|
||||
personOid = zielkorb.getInt("RecipientOid");
|
||||
recipientName = zielkorb.getString("Name");
|
||||
recipientPersonOid = zielkorb.getInt("RecipientOid");
|
||||
|
||||
byte[] bildArray = zielkorb.getByteArray("Bild");
|
||||
Bitmap customerImage;
|
||||
@@ -121,18 +126,23 @@ public class ChatActivity extends ActionBarActivity{
|
||||
titlepic.setImageBitmap(GetCircleBitmap(customerImage));
|
||||
}
|
||||
|
||||
titlename.setText(name);
|
||||
titlename.setText(recipientName);
|
||||
|
||||
action.setCustomView(mCustomView);
|
||||
action.setDisplayShowCustomEnabled(true);
|
||||
|
||||
databaseHandler = new DatabaseHandler(this);
|
||||
|
||||
senden = (Button)findViewById(R.id.Sendebutton);
|
||||
|
||||
chatMessages = new ArrayList<>();
|
||||
|
||||
listView = (ListView)findViewById(R.id.list_msg);
|
||||
|
||||
adapter = new MessageAdapter(this, R.layout.item_chat_left,chatMessages);
|
||||
DatabaseHandler handler = new DatabaseHandler(this);
|
||||
chatMessages = databaseHandler.getMessagesForRecipient(recipientPersonOid);
|
||||
|
||||
adapter = new MessageAdapter(this, R.layout.item_chat_left, chatMessages);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
try {
|
||||
@@ -141,15 +151,11 @@ public class ChatActivity extends ActionBarActivity{
|
||||
MainActivityMitarbeiter.CloseMainActivitySocketListener();
|
||||
|
||||
socketOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
} catch(Exception e){
|
||||
Log.e("CHAT_ERROR", "Fehler bei der Socket-Erstellung: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
CreateFile();
|
||||
|
||||
ReadMessageToStorage();
|
||||
//ReadMessageToStorage();
|
||||
|
||||
text = (EditText)findViewById(R.id.editText);
|
||||
|
||||
@@ -165,13 +171,9 @@ public class ChatActivity extends ActionBarActivity{
|
||||
}
|
||||
});
|
||||
|
||||
//Erstelle einen immer horchenden Listener
|
||||
Thread t = new Thread(new SocketListener());
|
||||
t.start();
|
||||
|
||||
//MainActivityMitarbeiter.listen.sus
|
||||
//sharedpreferences = true;
|
||||
|
||||
SharedPreferences sp = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("IsInChatActivity", true);
|
||||
@@ -181,16 +183,12 @@ public class ChatActivity extends ActionBarActivity{
|
||||
public class MessageSender implements Runnable{
|
||||
public void run(){
|
||||
try{
|
||||
Log.i(LOG_TAG, "Sende Nachricht...");
|
||||
|
||||
if(socket != null ) {
|
||||
|
||||
Log.d(LOG_TAG, "Ist der Socket mit dem Server Verbunden: " + (socket.isConnected()));
|
||||
|
||||
Packet p = new Packet();
|
||||
p.ChatMessage = text.getText().toString();
|
||||
p.ChatDataIdentifier = DataIdentifier.MESSAGE;
|
||||
p.RecipientPersonOid = personOid;
|
||||
p.RecipientPersonOid = recipientPersonOid;
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
|
||||
@@ -211,18 +209,23 @@ public class ChatActivity extends ActionBarActivity{
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Log.i(LOG_TAG, "Führe GUI-Update durch...");
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date now = c.getTime();
|
||||
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
String formattedDate = df.format(now);
|
||||
|
||||
saveCompleteMessage = text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n";
|
||||
// saveCompleteMessage = text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n";
|
||||
//
|
||||
// WriteMessagesfromStorage(text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n");
|
||||
|
||||
WriteMessagesfromStorage(text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n");
|
||||
// TODO: In Datenbank speichern
|
||||
ChatMessage message = new ChatMessage(SoapConnectionManager.User.getPersonOid().intValue(), recipientPersonOid, now, text.getText().toString(), false);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessage = new ChatMessageFormat(text.getText().toString(), isMe, formattedDate);
|
||||
chatMessages.add(chatMessage);
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
text.setText("");
|
||||
@@ -272,16 +275,27 @@ public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
chatPacket = new Packet(total.toString());
|
||||
|
||||
if(!chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.i("CHAT_ACTIVITY", "Erhaltene Nachricht: " + chatPacket.ChatMessage);
|
||||
|
||||
listV.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
WriteMessagesfromStorage(chatPacket.ChatMessage + "/" + false + "%" + chatPacket.getFormattedMessageTimeStamp() + "\n");
|
||||
// TODO: Nachricht in Datenbank speichern
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date now = c.getTime();
|
||||
|
||||
ChatMessage message = new ChatMessage(SoapConnectionManager.User.getPersonOid().intValue(), recipientPersonOid, now, chatPacket.ChatMessage, false);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessage = new ChatMessageFormat(chatPacket.ChatMessage, false, chatPacket.getFormattedMessageTimeStamp());
|
||||
chatMessages.add(chatMessage);
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@@ -298,9 +312,9 @@ public class ChatActivity extends ActionBarActivity{
|
||||
}
|
||||
|
||||
public void SaveAfterLoseConnection(String UnsendMessage){
|
||||
CreateCustomFileForUnSendMessage();
|
||||
CreateCustomFileForUnsentMessage();
|
||||
try{
|
||||
FileOutputStream stream = new FileOutputStream(Unsendfile,true);
|
||||
FileOutputStream stream = new FileOutputStream(UnsentFile,true);
|
||||
|
||||
try{
|
||||
stream.write(UnsendMessage.getBytes());
|
||||
@@ -314,9 +328,9 @@ public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
public void SendAfterGetConnection(){
|
||||
//ist eine UnsendMessage File vorhanden
|
||||
if(Unsendfile != null && socket.isConnected()){
|
||||
if(UnsentFile != null && socket.isConnected()){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(Unsendfile);
|
||||
FileInputStream stream = new FileInputStream(UnsentFile);
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
|
||||
@@ -336,13 +350,13 @@ public class ChatActivity extends ActionBarActivity{
|
||||
final String datetime = ArtDate[1];
|
||||
|
||||
//für jede Gelesene Line Sende Nachricht
|
||||
new Thread(new SendUnsendMS(message)).start();
|
||||
new Thread(new SendUnsentMessage(message)).start();
|
||||
}
|
||||
line = readLn.readLine();
|
||||
}
|
||||
stream.close();
|
||||
in.close();
|
||||
Unsendfile.delete();
|
||||
UnsentFile.delete();
|
||||
}catch(Exception fe){
|
||||
Log.v("Status","Ein problem ist im BEreich Unsend Ms Aufgetreten");
|
||||
}
|
||||
@@ -350,11 +364,11 @@ public class ChatActivity extends ActionBarActivity{
|
||||
}
|
||||
}
|
||||
|
||||
public class SendUnsendMS implements Runnable{
|
||||
public class SendUnsentMessage implements Runnable{
|
||||
|
||||
String al;
|
||||
|
||||
SendUnsendMS(String unMS){
|
||||
SendUnsentMessage(String unMS){
|
||||
this.al = unMS;
|
||||
}
|
||||
|
||||
@@ -370,12 +384,12 @@ public class ChatActivity extends ActionBarActivity{
|
||||
socketOutputStream.flush();
|
||||
}
|
||||
}catch(Exception xs){
|
||||
|
||||
Log.e("SendUnsentMessage", xs.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateCustomFileForUnSendMessage(){
|
||||
public void CreateCustomFileForUnsentMessage(){
|
||||
try{
|
||||
File pfad = getBaseContext().getFilesDir();
|
||||
|
||||
@@ -383,7 +397,7 @@ public class ChatActivity extends ActionBarActivity{
|
||||
//File pfad = getBaseContext().getExternalFilesDir(null);
|
||||
|
||||
//Erstelle das File Objekt
|
||||
Unsendfile = new File(pfad,name+"_Unsend"+".txt");
|
||||
UnsentFile = new File(pfad,recipientName+"_Unsend"+".txt");
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler"," Das erstellen/öffnen einer Datei ist Derzeit nicht möglich");
|
||||
@@ -434,62 +448,7 @@ public class ChatActivity extends ActionBarActivity{
|
||||
mNotifyMgr.notify(1, mBuilder.build());
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
|
||||
|
||||
SharedPreferences sp = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("IsInChatActivity", true);
|
||||
editor.commit();
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void onStop(){
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
|
||||
SharedPreferences sp = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("IsInChatActivity", false);
|
||||
editor.commit();
|
||||
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void onDestroy(){
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
// currentlisten = null;
|
||||
SharedPreferences sp = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("IsInChatActivity", false);
|
||||
editor.commit();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void CreateFile(){
|
||||
|
||||
try{
|
||||
|
||||
File pfad = getBaseContext().getFilesDir();
|
||||
|
||||
//Für external Save
|
||||
//File pfad = getBaseContext().getExternalFilesDir(null);
|
||||
|
||||
//Erstelle das File Objekt
|
||||
//file = new File(pfad,name+".txt");
|
||||
|
||||
//vorläufig ##### für debug zwecke
|
||||
file = new File(pfad,"demo"+".txt");
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler"," Das erstellen/öffnen einer Datei ist Derzeit nicht möglich");
|
||||
}
|
||||
}
|
||||
|
||||
//Internal Storage
|
||||
// Internal Storage
|
||||
public void WriteMessagesfromStorage(String message){
|
||||
try{
|
||||
FileOutputStream stream = new FileOutputStream(file,true);
|
||||
@@ -510,8 +469,6 @@ public class ChatActivity extends ActionBarActivity{
|
||||
//Internal storage
|
||||
public void ReadMessageToStorage(){
|
||||
try{
|
||||
|
||||
// Log.v("Status","Verbindung steht 1");
|
||||
int lenght = (int) file.length();
|
||||
|
||||
byte[] bytes = new byte[lenght];
|
||||
@@ -525,33 +482,27 @@ public class ChatActivity extends ActionBarActivity{
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
|
||||
String line = readLn.readLine();
|
||||
String allLines="";
|
||||
String allLines = "";
|
||||
//Build a readLine konstrukt
|
||||
while (line != null) {
|
||||
allLines += line;
|
||||
|
||||
//Funktion für das korrekte anzeigen der Geladenen Nachrichten hier implementieren
|
||||
//---> <---//
|
||||
//String[] splitt = line.split("/");
|
||||
|
||||
// Log.v("Status",line);
|
||||
|
||||
String[] splitt = line.split("/");
|
||||
|
||||
if(splitt.length >1 ) {
|
||||
if(splitt.length > 1) {
|
||||
String[] ArtDate = splitt[1].split("%"); //<------------ im code sind als seperator ? gesetzt // lösung einfach alle löschen und neuen chat speichern !!
|
||||
|
||||
final String message = splitt[0];
|
||||
|
||||
final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
|
||||
final String datetime = ArtDate[1];
|
||||
|
||||
Log.i("NACHRICHT AUS DATEI", splitt[0]);
|
||||
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatMessage = new ChatMessageFormat(message, art, datetime);
|
||||
chatMessages.add(chatMessage);
|
||||
//chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@@ -562,9 +513,6 @@ public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
stream.close();
|
||||
in.close();
|
||||
|
||||
// Log.v("Local Storage",allLines);
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler 2 ",e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -6,8 +6,16 @@ import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import entities.ChatMessage;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
/**
|
||||
* Created by bib on 07.06.2016.
|
||||
@@ -20,6 +28,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
private static final String DATABASE_NAME = "Contacts_Manager";
|
||||
//Table Name
|
||||
private static final String TABLE_CONTACTS = "Contactlist";
|
||||
private static final String TABLE_CHATMESSAGE = "ChatMessage";
|
||||
|
||||
|
||||
//Table Columns name
|
||||
@@ -28,25 +37,73 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
private static final String KEY_PERSONOID = "personoid";
|
||||
private static final String KEY_Picture_BLOB = "bild";
|
||||
|
||||
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";
|
||||
|
||||
public DatabaseHandler(Context context){
|
||||
super(context,DATABASE_NAME,null,DATABASE_VERSION);
|
||||
super(context,DATABASE_NAME, null, DATABASE_VERSION);
|
||||
}
|
||||
|
||||
// Erstelle Tabelle | Tabellen construct
|
||||
public void onCreate(SQLiteDatabase db){
|
||||
String CREATE_CONTACTS_TABLE ="CREATE TABLE "+TABLE_CONTACTS +"("+
|
||||
KEY_ID +" INTEGER PRIMARY KEY,"+KEY_KontaktName+ " TEXT,"+
|
||||
KEY_PERSONOID +" INTEGER," + KEY_Picture_BLOB+ " BLOB"+")";
|
||||
KEY_PERSONOID +" INTEGER," + KEY_Picture_BLOB+ " BLOB)";
|
||||
|
||||
db.execSQL(CREATE_CONTACTS_TABLE);
|
||||
|
||||
String createChatMessageTable =
|
||||
"CREATE TABLE " + TABLE_CHATMESSAGE + "(" +
|
||||
KEY_ID_CHATMESSAGE + " INTEGER PRIMARY KEY," +
|
||||
KEY_SENDER_PERSON_OID_CHATMESSAGE + " INTEGER," +
|
||||
KEY_RECIPIENT_PERSON_OID_CHATMESSAGE + " INTEGER," +
|
||||
KEY_INSTS_CHATMESSAGE + " DATETIME DEFAULT CURRENT_TIMESTAMP," +
|
||||
KEY_CHAT_TEXT_CHATMESSAGE + " TEXT," +
|
||||
KEY_IS_DELIVERED_CHATMESSAGE + " INTEGER)";
|
||||
|
||||
db.execSQL(createChatMessageTable);
|
||||
}
|
||||
|
||||
void addChatMessage(ChatMessage message) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
values.put(KEY_SENDER_PERSON_OID_CHATMESSAGE, message.SenderPersonOid);
|
||||
values.put(KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, message.RecipientPersonOid);
|
||||
values.put(KEY_INSTS_CHATMESSAGE, getDateTimeString(message.InsTs));
|
||||
values.put(KEY_CHAT_TEXT_CHATMESSAGE, message.ChatText);
|
||||
values.put(KEY_IS_DELIVERED_CHATMESSAGE, (message.IsDelivered ? 1 : 0));
|
||||
|
||||
db.insert(TABLE_CHATMESSAGE, null, values);
|
||||
db.close();
|
||||
}
|
||||
|
||||
private String getDateTimeString(Date date) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
private Date getDateFromString(String dateString) {
|
||||
Date result = new Date();
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMAN);
|
||||
try {
|
||||
result = df.parse(dateString);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
|
||||
|
||||
//drop older Table if existed
|
||||
db.execSQL("DROP TABLE IF EXISTS "+ TABLE_CONTACTS);
|
||||
db.execSQL("DROP TABLE IF EXISTS "+ TABLE_CHATMESSAGE);
|
||||
|
||||
onCreate(db);
|
||||
}
|
||||
@@ -65,7 +122,56 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
db.close();
|
||||
}
|
||||
|
||||
//Hole ein Bestimten Contact
|
||||
public ChatMessage getChatMessageById(int id) {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
|
||||
Cursor cursor = db.query(
|
||||
TABLE_CHATMESSAGE,
|
||||
new String[] {KEY_ID_CHATMESSAGE, KEY_SENDER_PERSON_OID_CHATMESSAGE, KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, KEY_INSTS_CHATMESSAGE, KEY_CHAT_TEXT_CHATMESSAGE, KEY_IS_DELIVERED_CHATMESSAGE},
|
||||
KEY_ID_CHATMESSAGE + "=?",
|
||||
new String[]{String.valueOf(id)},
|
||||
null, null, null, null);
|
||||
|
||||
if(cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
}
|
||||
|
||||
ChatMessage message = new ChatMessage(cursor.getInt(0), cursor.getInt(1), cursor.getInt(2), getDateFromString(cursor.getString(3)), cursor.getString(4), cursor.getInt(5) != 0);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public ArrayList<ChatMessage> getMessagesForRecipient(int recipientOid) {
|
||||
ArrayList<ChatMessage> messages = new ArrayList<>();
|
||||
|
||||
SQLiteDatabase database = this.getWritableDatabase();
|
||||
|
||||
Cursor cursor = database.query(
|
||||
TABLE_CHATMESSAGE,
|
||||
new String[] {KEY_ID_CHATMESSAGE, KEY_SENDER_PERSON_OID_CHATMESSAGE, KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, KEY_INSTS_CHATMESSAGE, KEY_CHAT_TEXT_CHATMESSAGE, KEY_IS_DELIVERED_CHATMESSAGE},
|
||||
KEY_SENDER_PERSON_OID_CHATMESSAGE + "=? AND " + KEY_RECIPIENT_PERSON_OID_CHATMESSAGE + "=?",
|
||||
new String[] {String.valueOf(SoapConnectionManager.User.getPersonOid()), String.valueOf(recipientOid)},
|
||||
null, null, null, null);
|
||||
|
||||
if(cursor.moveToFirst()) {
|
||||
do{
|
||||
ChatMessage message = new ChatMessage(
|
||||
cursor.getInt(0),
|
||||
cursor.getInt(1),
|
||||
cursor.getInt(2),
|
||||
getDateFromString(cursor.getString(3)),
|
||||
cursor.getString(4),
|
||||
cursor.getInt(5) != 0
|
||||
);
|
||||
|
||||
messages.add(message);
|
||||
} while(cursor.moveToNext());
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
// Lade einen bestimmten Kontakt
|
||||
ContactListItem getContact(int id) {
|
||||
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
@@ -123,14 +229,14 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
//Delet single Contact
|
||||
public void deletContacts(ContactListItem contact){
|
||||
public void deleteContacts(ContactListItem contact){
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
db.delete(TABLE_CONTACTS, KEY_ID + " = ?", new String[] { String.valueOf(contact.getID()) });
|
||||
db.close();
|
||||
}
|
||||
|
||||
public int getContactsCount(){
|
||||
String countQuery = "SELECT * FROM " + TABLE_CONTACTS;
|
||||
String countQuery = "SELECT * FROM " + TABLE_CONTACTS;
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery(countQuery, null);
|
||||
cursor.close();
|
||||
|
||||
@@ -46,17 +46,10 @@ public class KontaktChatActivity extends ListActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//erstelle für Demo ein pic einmalig
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a =((BitmapDrawable)getResources().getDrawable(R.drawable.bslogo)).getBitmap();
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
|
||||
databaseHandler = new DatabaseHandler(this);
|
||||
|
||||
//Clear Database from Data
|
||||
//TODO: nicht löschen, sondern updaten
|
||||
databaseHandler.onUpgrade(databaseHandler.getReadableDatabase(),1,2);
|
||||
//databaseHandler.onUpgrade(databaseHandler.getReadableDatabase(), 1, 2);
|
||||
|
||||
ArrayList<PropertyInfo> propertyInfos = new ArrayList<>();
|
||||
propertyInfos.add(SoapConnectionManager.BuildProperty("pPersonOid", SoapConnectionManager.User.getPersonOid(), Long.class));
|
||||
@@ -97,7 +90,6 @@ public class KontaktChatActivity extends ListActivity {
|
||||
|
||||
korb.putString("Name", selectedValue.getKontaktName());
|
||||
korb.putInt("RecipientOid", selectedValue.get_personOid());
|
||||
Log.i("KontaktChatActivity", "EmpfängerOid: " + selectedValue.get_personOid());
|
||||
|
||||
Intent in = new Intent(getBaseContext(), ChatActivity.class);
|
||||
in.putExtras(korb);
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
@@ -24,8 +23,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -240,7 +237,7 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
chatPacket = new Packet(total.toString());
|
||||
|
||||
if(chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
SetNotify(chatPacket.ChatName, chatPacket.ChatMessage);
|
||||
SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid);
|
||||
}
|
||||
|
||||
Log.i("MAIN_ACTIVITY", "Erhaltene Nachricht: " + chatPacket.ChatMessage);
|
||||
@@ -434,7 +431,7 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
}
|
||||
|
||||
//setze Notification
|
||||
public void SetNotify(String Username, String message){
|
||||
public void SetNotify(String username, String message, int recipientOid){
|
||||
|
||||
//Convertiert in Pic Resource in ein Bitmap
|
||||
//BitmapFactory.decodeResource(getResources(), R.drawable.bslogo)
|
||||
@@ -442,7 +439,7 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.ic_stat_name)
|
||||
.setContentTitle(Username)
|
||||
.setContentTitle(username)
|
||||
.setContentText(message)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
@@ -450,7 +447,13 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
.setLights(Color.YELLOW, 3000, 3000) //Notification.Default_Lights
|
||||
.setOngoing(true);
|
||||
|
||||
Intent resultIntent = new Intent(this, MainActivityMitarbeiter.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("Name", username);
|
||||
bundle.putInt("RecipientOid", recipientOid);
|
||||
|
||||
Intent resultIntent = new Intent(this, ChatActivity.class);
|
||||
resultIntent.putExtras(bundle);
|
||||
|
||||
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
PendingIntent resultPendingIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT );
|
||||
|
||||
|
||||
@@ -10,15 +10,18 @@ import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import entities.ChatMessage;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
/**
|
||||
* Created by bib on 20.05.2016.
|
||||
*/
|
||||
public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
public class MessageAdapter extends ArrayAdapter<ChatMessage> {
|
||||
|
||||
private Activity activity;
|
||||
private List<ChatMessageFormat> messages;
|
||||
private List<ChatMessage> messages;
|
||||
|
||||
public MessageAdapter(Activity context, int resource, List<ChatMessageFormat> objects) {
|
||||
public MessageAdapter(Activity context, int resource, List<ChatMessage> objects) {
|
||||
super(context, resource, objects);
|
||||
this.activity = context;
|
||||
this.messages = objects;
|
||||
@@ -30,15 +33,10 @@ public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
ViewHolder holder;
|
||||
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
int layoutResource = 0; // determined by view type
|
||||
ChatMessageFormat chatMessage = getItem(position);
|
||||
int viewType = getItemViewType(position);
|
||||
int layoutResource;
|
||||
ChatMessage chatMessage = getItem(position);
|
||||
|
||||
//Splitt message um zu wissen ob from server oder nicht
|
||||
// String line = chatMessage.getMessage();
|
||||
|
||||
//Server nachricht kenntlich machen
|
||||
if (chatMessage.getIsME()) {
|
||||
if (chatMessage.SenderPersonOid == SoapConnectionManager.User.getPersonOid()) {
|
||||
layoutResource = R.layout.item_chat_right;
|
||||
// } else if(splitt[0].equals("Server")) {
|
||||
// layoutResource = R.layout.item_chat_sever_right;
|
||||
@@ -50,9 +48,7 @@ public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
|
||||
//set message content
|
||||
holder.msg.setText(chatMessage.getMessage());
|
||||
|
||||
holder.msg.setText(chatMessage.ChatText);
|
||||
|
||||
//TODO eine weitere option für Chatmessage hinzufügen zum abfragen wegen send Message
|
||||
|
||||
@@ -60,11 +56,10 @@ public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
holder.send_tick.setText(Html.fromHtml("✓") + "" + Html.fromHtml("✓"));
|
||||
}
|
||||
|
||||
|
||||
if(chatMessage.getIsME()){
|
||||
holder.dateIn.setText(chatMessage.getDatum());
|
||||
if(chatMessage.SenderPersonOid == SoapConnectionManager.User.getPersonOid()){
|
||||
holder.dateIn.setText(chatMessage.getInsTsAsString());
|
||||
}else {
|
||||
holder.dateOut.setText(chatMessage.getDatum());
|
||||
holder.dateOut.setText(chatMessage.getInsTsAsString());
|
||||
}
|
||||
|
||||
return convertView;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package entities;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 26.07.2016.
|
||||
*/
|
||||
public class ChatMessage {
|
||||
public int Id;
|
||||
public int SenderPersonOid;
|
||||
public int RecipientPersonOid;
|
||||
public Date InsTs;
|
||||
public String ChatText;
|
||||
public boolean IsDelivered;
|
||||
|
||||
public ChatMessage(int id, int senderPersonOid, int recipientPersonOid, Date insTs, String chatText, boolean isDelivered) {
|
||||
Id = id;
|
||||
SenderPersonOid = senderPersonOid;
|
||||
RecipientPersonOid = recipientPersonOid;
|
||||
InsTs = insTs;
|
||||
ChatText = chatText;
|
||||
IsDelivered = isDelivered;
|
||||
}
|
||||
|
||||
public ChatMessage(int senderPersonOid, int recipientPersonOid, Date insTs, String chatText, boolean isDelivered) {
|
||||
SenderPersonOid = senderPersonOid;
|
||||
RecipientPersonOid = recipientPersonOid;
|
||||
InsTs = insTs;
|
||||
ChatText = chatText;
|
||||
IsDelivered = isDelivered;
|
||||
}
|
||||
|
||||
public String getInsTsAsString() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMAN);
|
||||
return dateFormat.format(InsTs);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package soapConnection;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
@@ -10,7 +9,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,6 +22,9 @@ public class Packet {
|
||||
public String ChatMessage;
|
||||
public Date MessageTimeStamp;
|
||||
public String Tenant;
|
||||
public boolean IsDelivered;
|
||||
|
||||
// TODO: IsDelivered einbauen
|
||||
|
||||
public Packet() {
|
||||
ChatDataIdentifier = DataIdentifier.NULL;
|
||||
@@ -32,6 +33,7 @@ public class Packet {
|
||||
Tenant = "";
|
||||
SenderPersonOid = SoapConnectionManager.User.getPersonOid().intValue();
|
||||
RecipientPersonOid = 0;
|
||||
IsDelivered = false;
|
||||
|
||||
MessageTimeStamp = Calendar.getInstance().getTime();
|
||||
}
|
||||
@@ -81,13 +83,15 @@ public class Packet {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
IsDelivered = Integer.parseInt(actualMessage.substring(chatMessageLength + chatNameLength + 19, chatMessageLength + chatNameLength + 20)) != 0;
|
||||
}
|
||||
|
||||
public byte[] GetDataStream() {
|
||||
|
||||
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + Tenant + ";";
|
||||
|
||||
dataStreamAsString += ChatName + ChatMessage + getFormattedMessageTimeStamp();
|
||||
dataStreamAsString += ChatName + ChatMessage + getFormattedMessageTimeStamp() + (IsDelivered ? 1 : 0);
|
||||
|
||||
byte[] blaaah = new byte[dataStreamAsString.length()];
|
||||
|
||||
|
||||
@@ -4,16 +4,14 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:background="@drawable/out_message_bg"
|
||||
android:paddingBottom="4dp"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
<!-- in diesem bereich noch das datum anzeigen und uhrzeit -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -30,19 +28,6 @@
|
||||
android:maxWidth="250dp"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_msg_tick"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:padding="5dp"
|
||||
android:textColor="@android:color/holo_blue_light"/> -->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- padding 10 -->
|
||||
@@ -10,9 +10,7 @@
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/in_message_bg"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="4dp"
|
||||
>
|
||||
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@@ -21,36 +19,31 @@
|
||||
android:textSize="8dp"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_msg"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="250dp"
|
||||
android:padding="5dp"
|
||||
android:textColor="@android:color/black"/>
|
||||
|
||||
<!-- 5 dp-->
|
||||
<TextView
|
||||
android:id="@+id/txt_msg_tick"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end"
|
||||
android:padding="5dp"
|
||||
android:textColor="@android:color/holo_blue_light"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="250dp"
|
||||
android:padding="5dp"
|
||||
android:textColor="@android:color/black"/>
|
||||
|
||||
<!-- 5 dp-->
|
||||
<TextView
|
||||
android:id="@+id/txt_msg_tick"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end"
|
||||
android:padding="5dp"
|
||||
android:textColor="@android:color/holo_blue_light"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- -->
|
||||
@@ -128,6 +128,22 @@ namespace BeWoChatServer
|
||||
client.Key.Send(notificationPacket.GetDataStream());
|
||||
}
|
||||
|
||||
// Letzten X Nachrichten schicken
|
||||
|
||||
try
|
||||
{
|
||||
Monitor.Enter(_Lock);
|
||||
|
||||
DefaultHibernateSessionManager.CurrentTenant = dataPacket.Tenant;
|
||||
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(_Lock);
|
||||
}
|
||||
|
||||
break;
|
||||
case DataIdentifier.Message:
|
||||
if(responseByteCount == 0)
|
||||
@@ -172,9 +188,8 @@ namespace BeWoChatServer
|
||||
|
||||
break;
|
||||
case DataIdentifier.Logout:
|
||||
var endPointLogout = dataPacket.Socket.RemoteEndPoint;
|
||||
|
||||
var isRemoveSuccessful = clientList.Remove(dataPacket.Socket);
|
||||
clientList.Remove(dataPacket.Socket);
|
||||
|
||||
var notificationPacketLogout = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) {DataIdentifier = DataIdentifier.StatusNotificationLogout};
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1566,10 +1566,5 @@ namespace BeWo.Data.Access
|
||||
|
||||
return c.List<CustomerAPPCode>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace BeWoChatServer
|
||||
public string ChatMessage { get; set; }
|
||||
public DateTime MessageTimeStamp { get; set; }
|
||||
public string Tenant { get; set; }
|
||||
public bool IsDelivered { get; set; }
|
||||
|
||||
public byte[] DataBuffer = new byte[1024];
|
||||
|
||||
@@ -70,9 +71,11 @@ namespace BeWoChatServer
|
||||
ClientName = actualMessage.Substring(0, chatNameLength);
|
||||
ChatMessage = actualMessage.Substring(chatNameLength, chatMessageLength);
|
||||
|
||||
var dateString = actualMessage.Substring(chatMessageLength + chatNameLength);
|
||||
var dateString = actualMessage.Substring(chatMessageLength + chatNameLength, 19);
|
||||
|
||||
MessageTimeStamp = DateTime.ParseExact(dateString, "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
|
||||
IsDelivered = Convert.ToBoolean(Convert.ToInt32(actualMessage.Substring(chatMessageLength + chatNameLength + 19, 1)));
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
@@ -84,7 +87,7 @@ namespace BeWoChatServer
|
||||
{
|
||||
var result = "";
|
||||
|
||||
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int) DataIdentifier + ";" + Tenant + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss");
|
||||
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int) DataIdentifier + ";" + Tenant + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
|
||||
|
||||
return Encoding.UTF8.GetBytes(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user