Design angepasst

Korrekte Anzeige der neuesten Nachrichten
This commit is contained in:
staccatomamba
2016-11-30 13:42:50 +01:00
parent 667854b6f0
commit 337b1859a1
24 changed files with 322 additions and 65 deletions

View File

@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <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/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" 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/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" 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" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <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/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" 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/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 201 KiB

View File

@@ -253,6 +253,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
ByteArrayOutputStream chatMessageOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream chatMessageOutputStream = new ByteArrayOutputStream();
Log.i("SAVING_MESSAGE", "MessageId: " + message.MessageId);
try { try {
SecurityUtils.encrypt(message.ChatText, chatMessageOutputStream); SecurityUtils.encrypt(message.ChatText, chatMessageOutputStream);
@@ -278,12 +280,12 @@ public class DatabaseHandler extends SQLiteOpenHelper {
return writableDatabase.update(TABLE_CHATMESSAGE, fillValuesForChatMessage(message), KEY_ID_CHATMESSAGE + " = ?", new String[] { String.valueOf(message.Id)}); return writableDatabase.update(TABLE_CHATMESSAGE, fillValuesForChatMessage(message), KEY_ID_CHATMESSAGE + " = ?", new String[] { String.valueOf(message.Id)});
} }
public ArrayList<String> getExistingChatMessageUUIDs() { public ArrayList<String> getExistingChatMessageUUIDs(int recipientPersonOid, int senderPersonOid) {
ArrayList<String> result = new ArrayList<>(); ArrayList<String> result = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
String selectQuery = "SELECT "+ KEY_MESSAGE_ID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE " + KEY_MESSAGE_ID_CHATMESSAGE + " IS NOT NULL ORDER BY " + KEY_INSTS_CHATMESSAGE + " DESC"; String selectQuery = "SELECT "+ KEY_MESSAGE_ID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE (" + KEY_RECIPIENT_PERSON_OID_CHATMESSAGE + " = " + recipientPersonOid + " AND " + KEY_SENDER_PERSON_OID_CHATMESSAGE + " = " + senderPersonOid + " OR " + KEY_RECIPIENT_PERSON_OID_CHATMESSAGE + " = " + senderPersonOid + " AND " + KEY_SENDER_PERSON_OID_CHATMESSAGE + " = " + recipientPersonOid + ") AND " + KEY_MESSAGE_ID_CHATMESSAGE + " IS NOT NULL AND " + KEY_IS_TEAM_CHATMESSAGE + " = 0 ORDER BY " + KEY_INSTS_CHATMESSAGE + " DESC";
Cursor cursor = db.rawQuery(selectQuery, null); Cursor cursor = db.rawQuery(selectQuery, null);
@@ -298,12 +300,14 @@ public class DatabaseHandler extends SQLiteOpenHelper {
return result; return result;
} }
public ArrayList<String> getExistingTeamChatMessageUUIDs() { public ArrayList<String> getExistingTeamChatMessageUUIDs(int recipientPersonOid, int senderPersonOid) {
ArrayList<String> result = new ArrayList<>(); ArrayList<String> result = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
String selectQuery = "SELECT " + KEY_MESSAGE_ID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE " + KEY_MESSAGE_ID_CHATMESSAGE + " IS NOT NULL AND " + KEY_IS_TEAM_CHATMESSAGE + " = 1 ORDER BY " + KEY_INSTS_CHATMESSAGE + " DESC"; String selectQuery = "SELECT " + KEY_MESSAGE_ID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE " + KEY_RECIPIENT_PERSON_OID_CHATMESSAGE + " = " + recipientPersonOid + " AND " + KEY_MESSAGE_ID_CHATMESSAGE + " IS NOT NULL AND " + KEY_IS_TEAM_CHATMESSAGE + " = 1 ORDER BY " + KEY_INSTS_CHATMESSAGE + " DESC";
Log.i("SELECT", selectQuery);
Cursor cursor = db.rawQuery(selectQuery, null); Cursor cursor = db.rawQuery(selectQuery, null);
@@ -810,7 +814,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
writableDatabase.update(TABLE_IMAGE2PERSON, values, KEY_PERSONOID_IMAGE2PERSON + " = ?", new String[] {String.valueOf(personOid)}); 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) { public byte[] getUserImage(Integer personOid) {
SQLiteDatabase readableDatabase = this.getReadableDatabase(); SQLiteDatabase readableDatabase = this.getReadableDatabase();
@@ -828,8 +831,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
} }
private class CircleBitmapCreator implements Runnable{ private class CircleBitmapCreator implements Runnable{
Bitmap bitmap; Bitmap bitmap;
CircleBitmapCreator(Bitmap _bitmap){ CircleBitmapCreator(Bitmap _bitmap){
this.bitmap = _bitmap; this.bitmap = _bitmap;

View File

@@ -219,6 +219,10 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
chatMessages = isTeam ? databaseHandler.getMessagesForTeam(recipientPersonOid) : databaseHandler.getMessagesForRecipient(recipientPersonOid); chatMessages = isTeam ? databaseHandler.getMessagesForTeam(recipientPersonOid) : databaseHandler.getMessagesForRecipient(recipientPersonOid);
for(ChatMessage cm : chatMessages) {
Log.i("NACHRICHTEN", "" + cm.ChatText + "; MessageId: " + cm.MessageId);
}
adapter = new MessageAdapter(this, R.layout.item_chat_left, chatMessages); adapter = new MessageAdapter(this, R.layout.item_chat_left, chatMessages);
adapter.sort(DATE_COMPARATOR); adapter.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
@@ -418,10 +422,12 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
} }
}; };
ArrayList<String> test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs() : databaseHandler.getExistingChatMessageUUIDs(); // TODO: nur zur Konversation gehörende MessageIds laden
ArrayList<String> test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs(recipientPersonOid, SoapConnectionManager.getUser().getPersonOid().intValue()) : databaseHandler.getExistingChatMessageUUIDs(recipientPersonOid, SoapConnectionManager.getUser().getPersonOid().intValue());
String pExceptions = ""; String pExceptions = "";
for(int i = 0; i < test.size(); i++) { for(int i = 0; i < test.size(); i++) {
Log.i("EXISTING_MESSAGEIDS", test.get(i));
pExceptions += test.get(i); pExceptions += test.get(i);
if(i < test.size() - 1) { if(i < test.size() - 1) {
@@ -673,6 +679,13 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
final ArrayList<ChatMessage> result = gson.fromJson(soapPrimitive.toString(), listType); final ArrayList<ChatMessage> result = gson.fromJson(soapPrimitive.toString(), listType);
Log.i("SOAPCALL", "Erhalte Nachrichten vom Server beim Öffnen des Chats: " + result.size());
if(result.size() > 0) {
for(ChatMessage cm : result) {
Log.i("CHATMESSAGE: ", cm.MessageId + ": " + cm.ChatText);
}
}
databaseHandler.addChatMessages(result); databaseHandler.addChatMessages(result);
listView.post(new Runnable() { listView.post(new Runnable() {

View File

@@ -919,12 +919,21 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
BeWoLog.writeToLogFile("Es wurden " + result.size() + " Avatare heruntergeladen."); BeWoLog.writeToLogFile("Es wurden " + result.size() + " Avatare heruntergeladen.");
for(ImageEntity imageEntity : result) { for(ImageEntity imageEntity : result) {
Log.i("IMAGE_DOWNLOAD", "Bild für Person mit Oid " + imageEntity.PersonOid);
databaseHandler.insertUserImage(imageEntity.PersonOid, imageEntity.Image); databaseHandler.insertUserImage(imageEntity.PersonOid, imageEntity.Image);
} }
} else { } else {
Log.i("IMAGES", "Es wurden keine Avatare geladen."); Log.i("IMAGES", "Es wurden keine Avatare geladen.");
BeWoLog.writeToLogFile("Es wurden keine Avatare heruntergeladen!"); BeWoLog.writeToLogFile("Es wurden keine Avatare heruntergeladen!");
} }
runOnUiThread(new Runnable() {
@Override
public void run() {
KontaktAdapter adapter = (KontaktAdapter) listView.getAdapter();
adapter.notifyDataSetChanged();
}
});
} }
} }
} }

View File

@@ -413,6 +413,8 @@ public class LoginActivity extends ActionBarActivity {
} }
}); });
BeWoChatApplication.sendUnsentMessages(LoginActivity.this);
Intent kontaktChatActivity = new Intent(LoginActivity.this, KontaktChatActivity.class); Intent kontaktChatActivity = new Intent(LoginActivity.this, KontaktChatActivity.class);
LoginActivity.this.startActivity(kontaktChatActivity); LoginActivity.this.startActivity(kontaktChatActivity);
} }

View File

@@ -19,24 +19,24 @@ public class SoapCalls {
public static String LOAD_USER_IMAGES = "LoadUserImages"; public static String LOAD_USER_IMAGES = "LoadUserImages";
//TODO: "app4.bewoplaner.de";// //TODO: "app4.bewoplaner.de";//
public static String DESTINATION_ADDRESS = "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 int DESTINATION_PORT = 5000; // 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/"; // public static String WSDL_TARGET_NAME = "bliblablubb.org/";
// static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx"; // 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";
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View File

@@ -1,18 +1,35 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="@color/white">
<ImageView <ImageView
android:background="#ffffffff" android:background="#ffffffff"
android:id="@+id/imageView1" android:id="@+id/imageView1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:src="@drawable/bslogo" android:src="@drawable/bwp_logo"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="20dp"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/> android:layout_alignParentStart="true"
android:contentDescription="@string/bwp_logo_description"/>
<ImageView
android:background="#ffffffff"
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/bslogo_korrektes_orange"
android:scaleX=".5"
android:scaleY=".5"
android:scaleType="fitCenter"
android:layout_alignParentBottom="true"
android:contentDescription="@string/bs_logo_description"
/>
</RelativeLayout> </RelativeLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -1,5 +1,5 @@
<resources> <resources>
<string name="app_name">BewoMitarbeiterApp</string> <string name="app_name">BeWoPlaner-App</string>
<string name="app_name_kontakt">Bewo Klient Kontakte</string> <string name="app_name_kontakt">Bewo Klient Kontakte</string>
<string name="app_name_haupt">Bewo Hauptmenü</string> <string name="app_name_haupt">Bewo Hauptmenü</string>
<string name="app_name_chat">Chat</string> <string name="app_name_chat">Chat</string>
@@ -37,4 +37,6 @@
<string name="chat">Chat</string> <string name="chat">Chat</string>
<string name="contact_list_activity_name">Kontakte</string> <string name="contact_list_activity_name">Kontakte</string>
<string name="bwp_logo_description">BeWoPlaner</string>
<string name="bs_logo_description">beyondsoft GmbH</string>
</resources> </resources>

View File

@@ -305,6 +305,22 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in der Datenbank"); Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in der Datenbank");
DAOFactory.GenericDAO.Insert(chatMessage); DAOFactory.GenericDAO.Insert(chatMessage);
var newestMessage = DAOFactory.SearchDAO.GetNewestChatMessageForConversation(dataPacket.RecipientPersonOid, dataPacket.SenderPersonOid, false);
var newestChatMessage = new NewestChatMessage()
{
ChatMessageOid = chatMessage.Oid,
IsTeam = false,
RecipientPersonOid = dataPacket.RecipientPersonOid,
SenderPersonOid = dataPacket.SenderPersonOid
};
if (newestMessage != null)
{
DAOFactory.GenericDAO.Delete(newestMessage);
}
DAOFactory.GenericDAO.Insert(newestChatMessage);
//Media Bereich mit Bild und Dok. //Media Bereich mit Bild und Dok.
if(dataPacket.MediaDatei != null) if(dataPacket.MediaDatei != null)
@@ -419,6 +435,22 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Speichere Team-Nachricht in der Datenbank"); Console.WriteLine(DateTime.Now + ": Speichere Team-Nachricht in der Datenbank");
DAOFactory.GenericDAO.Insert(chatMessage); DAOFactory.GenericDAO.Insert(chatMessage);
var newestMessage = DAOFactory.SearchDAO.GetNewestChatMessageForConversation(dataPacket.RecipientPersonOid, dataPacket.SenderPersonOid, true);
var newestChatMessage = new NewestChatMessage()
{
ChatMessageOid = chatMessage.Oid,
IsTeam = true,
RecipientPersonOid = dataPacket.RecipientPersonOid,
SenderPersonOid = dataPacket.SenderPersonOid
};
if (newestMessage != null)
{
DAOFactory.GenericDAO.Delete(newestMessage);
}
DAOFactory.GenericDAO.Insert(newestChatMessage);
var personOids = team.MemberList.Select(s => s.Person.Oid.Value); var personOids = team.MemberList.Select(s => s.Person.Oid.Value);
if (chatMessage.Oid != null) if (chatMessage.Oid != null)

View File

@@ -6,8 +6,13 @@ using System.Text;
using BeWo.Data.Entities; using BeWo.Data.Entities;
using BS.Shared.Extensions; using BS.Shared.Extensions;
using NHibernate;
using NHibernate.Criterion; using NHibernate.Criterion;
using NHibernate.Engine;
using NHibernate.Impl;
using NHibernate.Loader;
using NHibernate.Loader.Criteria;
using NHibernate.Persister.Entity;
using NHibernate.SqlCommand; using NHibernate.SqlCommand;
using BS.Shared.Core; using BS.Shared.Core;
@@ -1764,33 +1769,17 @@ namespace BeWo.Data.Access
foreach (var customer in customers.Where(w => w.CustomerImage != null)) foreach (var customer in customers.Where(w => w.CustomerImage != null))
{ {
result.Add(customer.Oid.Value, customer.CustomerImage); result.Add(customer.Person.Oid.Value, customer.CustomerImage);
} }
foreach (var emp in employees.Where(w => w.EmployeeImage != null)) foreach (var emp in employees.Where(w => w.EmployeeImage != null))
{ {
var cs = CalculateCheckSum(emp.EmployeeImage); result.Add(emp.Person.Oid.Value, emp.EmployeeImage);
result.Add(emp.Oid.Value, emp.EmployeeImage);
} }
return result; 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<ChatMessage> FindUnreadChatMessagesForRecipient(long pRecipientOid) public IEnumerable<ChatMessage> FindUnreadChatMessagesForRecipient(long pRecipientOid)
{ {
var c = CreateCriteriaIsActive<ChatMessage>() var c = CreateCriteriaIsActive<ChatMessage>()
@@ -1800,15 +1789,43 @@ namespace BeWo.Data.Access
return c.List<ChatMessage>(); return c.List<ChatMessage>();
} }
//TODO: Anpassen. Ist fehlerhaft.
public IEnumerable<ChatMessage> FindNewestChatMessages(long pRecipientPersonOid) public IEnumerable<ChatMessage> FindNewestChatMessages(long pRecipientPersonOid)
{ {
var query2 = Session.CreateSQLQuery(string.Format("SELECT MAX({0}) FROM chatmessages WHERE ({1} = {2} OR {3} = {2}) AND {4} IS NULL OR {4} IS NOT NULL AND {1} IN (SELECT t.{0} FROM Team t JOIN employee2team e ON e.{4} = t.{0}) GROUP BY {1}, {3}", var blubb = FindTeamsOfEmployee(pRecipientPersonOid);
BeWoEntityBase.PropertyName_Oid, ChatMessage.PropertyName_EmpfaengerPersonOid, pRecipientPersonOid, ChatMessage.PropertyName_SenderPersonOid, "TeamOid", BeWoEntityBase.PropertyName_InsTs));
var result = query2.List<long>(); var c = CreateCriteria<ChatMessage>();
c.Add(Subqueries.PropertyIn("Oid",
DetachedCriteria.For<NewestChatMessage>()
return result.Count > 0 ? DAOFactory.GenericDAO.LoadByIDs<ChatMessage>(result) : new List<ChatMessage>(); .Add(
Restrictions.Or(
Restrictions.And(
Restrictions.Or(
Restrictions.Eq(NewestChatMessage.PropertyName_RecipientPersonOid, pRecipientPersonOid),
Restrictions.Eq(NewestChatMessage.PropertyName_SenderPersonOid, pRecipientPersonOid)),
Restrictions.Eq(NewestChatMessage.PropertyName_IsTeam, false)),
Restrictions.And(Restrictions.Eq(NewestChatMessage.PropertyName_IsTeam, true), Restrictions.In(NewestChatMessage.PropertyName_RecipientPersonOid, blubb.Select(s => s.Oid.Value).ToArray())))
)
.SetProjection(Projections.Property("ChatMessageOid"))));
return c.List<ChatMessage>();
}
public string ToSql(ICriteria criteria)
{
var c = (CriteriaImpl)criteria;
var s = (SessionImpl)c.Session;
var factory = (ISessionFactoryImplementor)s.SessionFactory;
var implementors = factory.GetImplementors(c.EntityOrClassName);
var loader = new CriteriaLoader(
(IOuterJoinLoadable)factory.GetEntityPersister(implementors[0]),
factory,
c,
implementors[0],
s.EnabledFilters);
return loader.SqlString.ToString();
} }
public IEnumerable<string> FindChatMessageIds(List<string> messageIds) public IEnumerable<string> FindChatMessageIds(List<string> messageIds)
@@ -1845,15 +1862,22 @@ namespace BeWo.Data.Access
var c1 = CreateCriteriaIsActive<ChatMessage>() var c1 = CreateCriteriaIsActive<ChatMessage>()
.Add(Restrictions.Eq(ChatMessage.PropertyName_MessageId, pMessageId)) .Add(Restrictions.Eq(ChatMessage.PropertyName_MessageId, pMessageId))
.AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs)); .AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs));
var lastLoadedChatMessage = c1.List<ChatMessage>().First();
c.Add(Restrictions.Not(Restrictions.In(ChatMessage.PropertyName_MessageId, pExceptions))); var list = c1.List<ChatMessage>();
c.Add(Restrictions.Lt(BeWoEntityBase.PropertyName_InsTs, lastLoadedChatMessage.InsTs)); if (list.Count > 0)
{
var lastLoadedChatMessage = c1.List<ChatMessage>().First(); // Was ist bei einer leeren Liste?
c.Add(Restrictions.Not(Restrictions.In(ChatMessage.PropertyName_MessageId, pExceptions)));
c.Add(Restrictions.Lt(BeWoEntityBase.PropertyName_InsTs, lastLoadedChatMessage.InsTs));
}
} }
c.AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs)); c.AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs));
c.SetMaxResults(50); c.SetMaxResults(50);
var sql = ToSql(c);
return c.List<ChatMessage>(); return c.List<ChatMessage>();
} }
@@ -1864,5 +1888,43 @@ namespace BeWo.Data.Access
return c.List<ChatMediaMessage>(); return c.List<ChatMediaMessage>();
} }
public NewestChatMessage GetNewestChatMessageForConversation(long pRecipientPersonOid, long pSenderPersonOid, bool pIsTeam)
{
var teams = new List<long>();
if (pIsTeam)
{
var employee = FindEmployeeWithPersonOid(pSenderPersonOid);
if (employee != null)
{
teams.AddRange(FindTeamsOfEmployee(employee.Oid.Value).Select(s => s.Oid.Value));
}
}
var c = CreateCriteria<NewestChatMessage>();
if (pIsTeam)
{
c.Add(Restrictions.And(Restrictions.Eq(NewestChatMessage.PropertyName_IsTeam, true),
Restrictions.In(NewestChatMessage.PropertyName_RecipientPersonOid, teams.ToArray())));
}
else
{
c.Add(
Restrictions.And(
Restrictions.Or(
Restrictions.And(
Restrictions.Eq(NewestChatMessage.PropertyName_RecipientPersonOid, pRecipientPersonOid),
Restrictions.Eq(NewestChatMessage.PropertyName_SenderPersonOid, pSenderPersonOid)),
Restrictions.And(
Restrictions.Eq(NewestChatMessage.PropertyName_RecipientPersonOid, pSenderPersonOid),
Restrictions.Eq(NewestChatMessage.PropertyName_SenderPersonOid, pRecipientPersonOid))),
Restrictions.Eq(NewestChatMessage.PropertyName_IsTeam, false)));
}
return c.UniqueResult<NewestChatMessage>();
}
} }
} }

View File

@@ -159,6 +159,7 @@
<Compile Include="Entities\ChatMessage.cs" /> <Compile Include="Entities\ChatMessage.cs" />
<Compile Include="Entities\ChatMediaMessage.cs" /> <Compile Include="Entities\ChatMediaMessage.cs" />
<Compile Include="Entities\MedRecord.cs" /> <Compile Include="Entities\MedRecord.cs" />
<Compile Include="Entities\NewestChatMessage.cs" />
<Compile Include="Entities\SupportConceptApprovalPeriod2Employee.cs" /> <Compile Include="Entities\SupportConceptApprovalPeriod2Employee.cs" />
<Compile Include="Entities\Wohnheimbuchung2Employee.cs" /> <Compile Include="Entities\Wohnheimbuchung2Employee.cs" />
<Compile Include="Entities\FamilyData.cs" /> <Compile Include="Entities\FamilyData.cs" />
@@ -639,6 +640,11 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Mappings\NewestChatMessage.hbm.xml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,62 @@
using BS.Shared;
namespace BeWo.Data.Entities
{
public class NewestChatMessage : BeWoEntityBase
{
public static string PropertyName_RecipientPersonOid = "RecipientPersonOid";
public static string PropertyName_SenderPersonOid = "SenderPersonOid";
public static string PropertyName_ChatMessageOid = "ChatMessageOid";
public static string PropertyName_IsTeam = "IsTeam";
private long? _RecipientPersonOid;
private long? _SenderPersonOid;
private long? _ChatMessageOid;
public NewestChatMessage()
{
_Tid = TableID.NewestChatMessage;
}
public virtual long? RecipientPersonOid
{
get { return _RecipientPersonOid; }
set
{
if (AreDifferent(_RecipientPersonOid, value))
{
_RecipientPersonOid = value;
}
}
}
public virtual long? SenderPersonOid
{
get { return _SenderPersonOid; }
set
{
if (AreDifferent(_SenderPersonOid, value))
{
_SenderPersonOid = value;
}
}
}
public virtual long? ChatMessageOid
{
get { return _ChatMessageOid; }
set
{
if (AreDifferent(_ChatMessageOid, value))
{
_ChatMessageOid = value;
}
}
}
public virtual bool IsTeam { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="BeWo.Data.Entities.NewestChatMessage, BeWo.Data" table="NewestChatMessage">
<id name="Oid" column="Oid" type="Int64" unsaved-value="null">
<generator class="identity" />
</id>
<version type="Int64" column="Version" name="Version" />
<property column="Tid" type="BS.Shared.TableID, BS.Shared" name="_Tid" access="field" />
<property column="Notice" type="String" name="Notice" length="1024" />
<property column="InsTs" type="DateTime" name="InsTs" />
<property column="InsUser" type="String" name="InsUser" length="256" />
<property column="UdpUser" type="String" name="UdpUser" length="256" />
<property column="IsActive" type="BS.Shared.ActivationTypeId, BS.Shared" name="IsActive" />
<property column="SystemEntryID" type="BS.Shared.SystemEntryID, BS.Shared" name="SystemEntryID" />
<property column="IsTeam" type="Boolean" name="IsTeam" />
<property name="RecipientPersonOid" column="RecipientPersonOid" type="Int64" />
<property name="SenderPersonOid" column="SenderPersonOid" type="Int64" />
<property name="ChatMessageOid" column="ChatMessageOid" type="Int64" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,25 @@
CREATE TABLE `newestchatmessage` (
`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
`Tid` INT(10) DEFAULT NULL,
`IsActive` TINYINT(1) DEFAULT NULL,
`Notice` VARCHAR(1024) DEFAULT NULL,
`InsTs` DATETIME DEFAULT NULL,
`InsUser` VARCHAR(256) DEFAULT NULL,
`Version` BIGINT(19) DEFAULT NULL,
`UdpUser` VARCHAR(256) DEFAULT NULL,
`SystemEntryID` INT(10) DEFAULT NULL,
`RecipientPersonOid` BIGINT(19) DEFAULT NULL,
`SenderPersonOid` BIGINT(19) DEFAULT NULL,
`ChatMessageOid` BIGINT(19) DEFAULT NULL,
`IsTeam` TINYINT(1) DEFAULT NULL,
PRIMARY KEY (`Oid`),
KEY `NEWESTCHATMESSAGE_RECIPIENT_FK` (`RecipientPersonOid`),
CONSTRAINT `FK_NEWESTCHATMESSAGE_RECIPIENT` FOREIGN KEY (`RecipientPersonOid`) REFERENCES `Person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
KEY `NEWESTCHATMESSAGE_SENDER_FK` (`SenderPersonOid`),
CONSTRAINT `FK_NEWESTCHATMESSAGE_SENDER` FOREIGN KEY (`SenderPersonOid`) REFERENCES `Person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
KEY `NEWESTCHATMESSAGE_CHATMESSAGE_FK` (`ChatMessageOid`),
CONSTRAINT `FK_NEWESTCHATMESSAGE_CHATMESSAGE` FOREIGN KEY (`ChatMessageOid`) REFERENCES `ChatMessages` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

View File

@@ -121,7 +121,8 @@ namespace BS.Shared
Bargeldkasse = 114, Bargeldkasse = 114,
MedRecord = 115, MedRecord = 115,
ChatMessage = 116, ChatMessage = 116,
ChatMediaMessage = 117 ChatMediaMessage = 117,
NewestChatMessage = 118
} }
public enum SystemEntryID public enum SystemEntryID