diff --git a/Android/BewoMitarbeiterApp/app/app.iml b/Android/BewoMitarbeiterApp/app/app.iml
index a8696e47b..842f7dc08 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/ic_launcher-web.png b/Android/BewoMitarbeiterApp/app/src/main/ic_launcher-web.png
index a65ac9142..3c7103bce 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/ic_launcher-web.png and b/Android/BewoMitarbeiterApp/app/src/main/ic_launcher-web.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
index d8546bc82..2a6f6c6b1 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java
@@ -253,6 +253,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
ByteArrayOutputStream chatMessageOutputStream = new ByteArrayOutputStream();
+ Log.i("SAVING_MESSAGE", "MessageId: " + message.MessageId);
+
try {
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)});
}
- public ArrayList getExistingChatMessageUUIDs() {
+ public ArrayList getExistingChatMessageUUIDs(int recipientPersonOid, int senderPersonOid) {
ArrayList result = new ArrayList<>();
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);
@@ -298,12 +300,14 @@ public class DatabaseHandler extends SQLiteOpenHelper {
return result;
}
- public ArrayList getExistingTeamChatMessageUUIDs() {
+ public ArrayList getExistingTeamChatMessageUUIDs(int recipientPersonOid, int senderPersonOid) {
ArrayList result = new ArrayList<>();
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);
@@ -810,7 +814,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
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();
@@ -828,8 +831,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
}
private class CircleBitmapCreator implements Runnable{
-
-
Bitmap bitmap;
CircleBitmapCreator(Bitmap _bitmap){
this.bitmap = _bitmap;
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 b2631b756..95f0a2e16 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java
@@ -219,6 +219,10 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
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.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged();
@@ -418,10 +422,12 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
}
};
- ArrayList test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs() : databaseHandler.getExistingChatMessageUUIDs();
+ // TODO: nur zur Konversation gehörende MessageIds laden
+ ArrayList test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs(recipientPersonOid, SoapConnectionManager.getUser().getPersonOid().intValue()) : databaseHandler.getExistingChatMessageUUIDs(recipientPersonOid, SoapConnectionManager.getUser().getPersonOid().intValue());
String pExceptions = "";
for(int i = 0; i < test.size(); i++) {
+ Log.i("EXISTING_MESSAGEIDS", test.get(i));
pExceptions += test.get(i);
if(i < test.size() - 1) {
@@ -673,6 +679,13 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
final ArrayList 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);
listView.post(new Runnable() {
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 ee724aeb5..777518c98 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/KontaktChatActivity.java
@@ -919,12 +919,21 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
BeWoLog.writeToLogFile("Es wurden " + result.size() + " Avatare heruntergeladen.");
for(ImageEntity imageEntity : result) {
+ Log.i("IMAGE_DOWNLOAD", "Bild für Person mit Oid " + imageEntity.PersonOid);
databaseHandler.insertUserImage(imageEntity.PersonOid, imageEntity.Image);
}
} else {
Log.i("IMAGES", "Es wurden keine Avatare geladen.");
BeWoLog.writeToLogFile("Es wurden keine Avatare heruntergeladen!");
}
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ KontaktAdapter adapter = (KontaktAdapter) listView.getAdapter();
+ adapter.notifyDataSetChanged();
+ }
+ });
}
}
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/LoginActivity.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/LoginActivity.java
index a86d278ae..156d7a951 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/LoginActivity.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/LoginActivity.java
@@ -413,6 +413,8 @@ public class LoginActivity extends ActionBarActivity {
}
});
+ BeWoChatApplication.sendUnsentMessages(LoginActivity.this);
+
Intent kontaktChatActivity = new Intent(LoginActivity.this, KontaktChatActivity.class);
LoginActivity.this.startActivity(kontaktChatActivity);
}
diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
index 32b48a0c9..d41a99c1d 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
+++ b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java
@@ -19,24 +19,24 @@ public class SoapCalls {
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/res/drawable/bslogo_korrektes_orange.png b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bslogo_korrektes_orange.png
new file mode 100644
index 000000000..a7b3bf739
Binary files /dev/null and b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bslogo_korrektes_orange.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_logo.png b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_logo.png
new file mode 100644
index 000000000..a863093b2
Binary files /dev/null and b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_logo.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_muschel.png b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_muschel.png
new file mode 100644
index 000000000..a15058e3b
Binary files /dev/null and b/Android/BewoMitarbeiterApp/app/src/main/res/drawable/bwp_muschel.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/layout/splashscreen.xml b/Android/BewoMitarbeiterApp/app/src/main/res/layout/splashscreen.xml
index c23737d3b..122a5a008 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/res/layout/splashscreen.xml
+++ b/Android/BewoMitarbeiterApp/app/src/main/res/layout/splashscreen.xml
@@ -1,18 +1,35 @@
+ android:layout_height="match_parent"
+ android:background="@color/white">
+ android:layout_alignParentStart="true"
+ android:contentDescription="@string/bwp_logo_description"/>
+
\ No newline at end of file
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-hdpi/ic_launcher.png
index e8147762f..e077592da 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-mdpi/ic_launcher.png
index a97178221..6f86b86be 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 484360eee..fdc1bd0f5 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index f37aee315..a2bb0f647 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index a6eeafee4..acd854482 100644
Binary files a/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/Android/BewoMitarbeiterApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/values/strings.xml b/Android/BewoMitarbeiterApp/app/src/main/res/values/strings.xml
index 1b90d6c44..4d3b7f615 100644
--- a/Android/BewoMitarbeiterApp/app/src/main/res/values/strings.xml
+++ b/Android/BewoMitarbeiterApp/app/src/main/res/values/strings.xml
@@ -1,5 +1,5 @@
- BewoMitarbeiterApp
+ BeWoPlaner-App
Bewo Klient Kontakte
Bewo Hauptmenü
Chat
@@ -37,4 +37,6 @@
Chat
Kontakte
+ BeWoPlaner
+ beyondsoft GmbH
diff --git a/BeWoChatServer/Server.cs b/BeWoChatServer/Server.cs
index 7b0694b3f..eee5588ff 100644
--- a/BeWoChatServer/Server.cs
+++ b/BeWoChatServer/Server.cs
@@ -305,6 +305,22 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in der Datenbank");
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.
if(dataPacket.MediaDatei != null)
@@ -419,6 +435,22 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Speichere Team-Nachricht in der Datenbank");
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);
if (chatMessage.Oid != null)
diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs
index b09746917..b74ac0586 100644
--- a/Data/Access/SearchDAO.cs
+++ b/Data/Access/SearchDAO.cs
@@ -6,8 +6,13 @@ using System.Text;
using BeWo.Data.Entities;
using BS.Shared.Extensions;
-
+using NHibernate;
using NHibernate.Criterion;
+using NHibernate.Engine;
+using NHibernate.Impl;
+using NHibernate.Loader;
+using NHibernate.Loader.Criteria;
+using NHibernate.Persister.Entity;
using NHibernate.SqlCommand;
using BS.Shared.Core;
@@ -1764,33 +1769,17 @@ namespace BeWo.Data.Access
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))
{
- var cs = CalculateCheckSum(emp.EmployeeImage);
-
- result.Add(emp.Oid.Value, emp.EmployeeImage);
+ result.Add(emp.Person.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()
@@ -1800,15 +1789,43 @@ namespace BeWo.Data.Access
return c.List();
}
- //TODO: Anpassen. Ist fehlerhaft.
public IEnumerable 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}",
- BeWoEntityBase.PropertyName_Oid, ChatMessage.PropertyName_EmpfaengerPersonOid, pRecipientPersonOid, ChatMessage.PropertyName_SenderPersonOid, "TeamOid", BeWoEntityBase.PropertyName_InsTs));
+ var blubb = FindTeamsOfEmployee(pRecipientPersonOid);
- var result = query2.List();
+ var c = CreateCriteria();
+ c.Add(Subqueries.PropertyIn("Oid",
+ DetachedCriteria.For()
- return result.Count > 0 ? DAOFactory.GenericDAO.LoadByIDs(result) : new List();
+ .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();
+ }
+
+ 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 FindChatMessageIds(List messageIds)
@@ -1845,15 +1862,22 @@ namespace BeWo.Data.Access
var c1 = CreateCriteriaIsActive()
.Add(Restrictions.Eq(ChatMessage.PropertyName_MessageId, pMessageId))
.AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs));
- var lastLoadedChatMessage = c1.List().First();
- c.Add(Restrictions.Not(Restrictions.In(ChatMessage.PropertyName_MessageId, pExceptions)));
- c.Add(Restrictions.Lt(BeWoEntityBase.PropertyName_InsTs, lastLoadedChatMessage.InsTs));
+ var list = c1.List();
+ if (list.Count > 0)
+ {
+ var lastLoadedChatMessage = c1.List().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.SetMaxResults(50);
+ var sql = ToSql(c);
+
return c.List();
}
@@ -1864,5 +1888,43 @@ namespace BeWo.Data.Access
return c.List();
}
+
+ public NewestChatMessage GetNewestChatMessageForConversation(long pRecipientPersonOid, long pSenderPersonOid, bool pIsTeam)
+ {
+ var teams = new List();
+
+ if (pIsTeam)
+ {
+ var employee = FindEmployeeWithPersonOid(pSenderPersonOid);
+ if (employee != null)
+ {
+ teams.AddRange(FindTeamsOfEmployee(employee.Oid.Value).Select(s => s.Oid.Value));
+ }
+ }
+
+ var c = CreateCriteria();
+
+ 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();
+ }
}
}
diff --git a/Data/Data.csproj b/Data/Data.csproj
index 5b4e15545..47701073e 100644
--- a/Data/Data.csproj
+++ b/Data/Data.csproj
@@ -159,6 +159,7 @@
+
@@ -639,6 +640,11 @@
Designer
+
+
+ Designer
+
+