diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 3f6eb74dc..382ae443c 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -592,6 +592,7 @@ + diff --git a/BeWo/View/ChatView.xaml.cs b/BeWo/View/ChatView.xaml.cs index 7417f35b1..cd52c76e1 100644 --- a/BeWo/View/ChatView.xaml.cs +++ b/BeWo/View/ChatView.xaml.cs @@ -65,45 +65,45 @@ namespace BeWo.View public UserVM ViewModel { get; set; } public int abr = 0; - protected TcpClient tcpClient; + private TcpClient tcpClient; - protected CollectionView view; + private CollectionView view; - protected ChatEmojisView emojiView = null; + private ChatEmojisView emojiView = null; - protected List ita = new List(); - protected List oidspeicher = new List(); - protected List teamdc = new List(); - protected PropertyGroupDescription groupDescription; - protected bool isOnFocus = false; + private List ita = new List(); + private List oidspeicher = new List(); + private List teamdc = new List(); + private PropertyGroupDescription groupDescription; + private bool isOnFocus = false; private bool SendtoServerFailes = false; //Neu Sound und Datei Versende gedöns usw... - //protected WaveIn waveSource = null; - //protected WaveFileWriter waveFile = null; - protected SoundPlayer simpleSound = null; - protected Form form1 = null; - protected ChatProgressBarView progressView = null; + //private WaveIn waveSource = null; + //private WaveFileWriter waveFile = null; + private SoundPlayer simpleSound = null; + private Form form1 = null; + private ChatProgressBarView progressView = null; //protected IWavePlayer waveOutDevice = null; //protected AudioFileReader audioFileReader = null; //Für anzeige MEhr Anzeigen wen mehr als 20 items Vorhanden - protected int itemGrenze = 5; - protected List aktuelleChatMessageIDListe = new List(); - protected List aktuelleChatMessageIDListeforTeam = new List(); + private int itemGrenze = 10; + private List aktuelleChatMessageIDListe = new List(); + private List aktuelleChatMessageIDListeforTeam = new List(); private bool WeitereNachrichtSchalter = false; //versuch oder | probieren geht über studieren - protected Dictionary SoundZwischenSpeicher = new Dictionary(); - protected Dictionary BildZwischenSpeicher = new Dictionary(); - protected Dictionary DokumentZwischenSpeicher = new Dictionary(); + private Dictionary SoundZwischenSpeicher = new Dictionary(); + private Dictionary BildZwischenSpeicher = new Dictionary(); + private Dictionary DokumentZwischenSpeicher = new Dictionary(); public Dictionary Speicherpfad = new Dictionary(); - protected bool sortLabelSwitch = false; + private bool sortLabelSwitch = false; - protected ContextMenu context; + private ContextMenu context; public ChatView(String nameinf, String Chatinf, TcpClient tcpClient) { @@ -1246,8 +1246,7 @@ namespace BeWo.View s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, empfangid, guid.ToString())); - aktuelleChatMessageIDListeforTeam.Add(guid.ToString()); - + aktuelleChatMessageIDListeforTeam.Add(guid.ToString()); } else { @@ -1257,8 +1256,6 @@ namespace BeWo.View guid.ToString())); aktuelleChatMessageIDListe.Add(guid.ToString()); } - - } catch (InvalidOperationException e) { @@ -2035,7 +2032,6 @@ namespace BeWo.View { } - } else { @@ -2131,16 +2127,17 @@ namespace BeWo.View Chat.Items[index] = kontaktmessage; - - //Von der Datenbank aus die Daten Rausholen. + + //messagedc.ChatMessagesOid, sender und empfänger oid + + + Chat.Items.Refresh(); } - - private void WeitereNachrichten_OnMouse(object sender, MouseButtonEventArgs e) { long senderoid, empfaengeroid; diff --git a/BeWo/ViewModel/ChatMediaMessageVM.cs b/BeWo/ViewModel/ChatMediaMessageVM.cs new file mode 100644 index 000000000..ec810db2b --- /dev/null +++ b/BeWo/ViewModel/ChatMediaMessageVM.cs @@ -0,0 +1,85 @@ +using BS.Shared.DataContracts; +using System; + +namespace BeWo.ViewModel +{ + public class ChatMediaMessageVM : AbstractDCMapperVM + { + //public static string PropertyName_ChatMessageOid = "ChatMessageOid"; + + public static string PropertyName_Media = "Media"; + + public static string PropertyName_ImageThumpNail = "ImageThumpNail"; + + private byte[] _media; + + private byte[] _imageThumpNail; + + private long? _chatMessageOid; + + public ChatMediaMessageVM(ChatMediaMessageDC pDC) + : base(pDC, true) + { + } + + + public virtual byte[] Media + { + get { return _media; } + + set + { + if (AreDifferent(_media, value)) + { + _media = value; + } + } + } + + public virtual byte[] ImageThumpNail + { + get { return _imageThumpNail; } + + set + { + if (AreDifferent(_imageThumpNail, value)) + { + _imageThumpNail = value; + } + } + } + + public virtual long? ChatMessageOid + { + get + { + return this._chatMessageOid; + } + + set + { + if (AreDifferent(_chatMessageOid, value)) + { + _chatMessageOid = value; + } + } + } + + + protected override void InitByDataContract(ChatMediaMessageDC pDataContract) + { + _chatMessageOid = pDataContract.ChatMessageOid; + _imageThumpNail = pDataContract.ImageThumpNail; + _media = pDataContract.Media; + } + + protected override ChatMediaMessageDC MapToDataContract(ChatMediaMessageDC pDataContract, bool doCommit) + { + pDataContract.ChatMessageOid = _chatMessageOid; + pDataContract.ImageThumpNail = _imageThumpNail; + pDataContract.Media = _media; + + return pDataContract; + } + } +} \ No newline at end of file diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index f096475f5..e81f986b4 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -1794,5 +1794,13 @@ namespace BeWo.Data.Access return c.List(); } - } + + public IList GetChatMediaMessagesForChatMessage(long chatMessageOid) + { + var c = CreateCriteriaIsActive() + .Add(Restrictions.Eq(ChatMediaMessage.PropertyName_ChatMessageOid, chatMessageOid)); + + return c.List(); + } + } } diff --git a/Data/Data.csproj b/Data/Data.csproj index 883fb792b..5b4e15545 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -157,6 +157,7 @@ + @@ -550,6 +551,9 @@ PreserveNewest + + Designer + Designer diff --git a/Data/Entities/ChatMediaMessage.cs b/Data/Entities/ChatMediaMessage.cs new file mode 100644 index 000000000..dd27be268 --- /dev/null +++ b/Data/Entities/ChatMediaMessage.cs @@ -0,0 +1,66 @@ +using System; +using BS.Shared; + +namespace BeWo.Data.Entities +{ + public class ChatMediaMessage : BeWoEntityBase + { + public static string PropertyName_ChatMessageOid = "ChatMessageOid"; + + public static string PropertyName_Media = "Media"; + + public static string PropertyName_ImageThumpNail = "ImageThumpNail"; + + private byte[] _Media; + + private byte[] _ImageThumpNail; + + private long? _ChatMessageOid; + + + public ChatMediaMessage() + { + _Tid = TableID.ChatMediaMessage; + } + + public virtual byte[] Media + { + get { return _Media; } + + set + { + if (AreDifferent(_Media, value)) + { + _Media = value; + } + } + } + + public virtual byte[] ImageThumpNail + { + get { return _ImageThumpNail; } + + set + { + if (AreDifferent(_ImageThumpNail, value)) + { + _ImageThumpNail = value; + } + } + } + + public virtual long? ChatMessageOid + { + get { return _ChatMessageOid; } + + set + { + if (AreDifferent(_ChatMessageOid, value)) + { + _ChatMessageOid = value; + } + } + } + + } +} \ No newline at end of file diff --git a/Data/Entities/ChatMessage.cs b/Data/Entities/ChatMessage.cs index e54c0411a..470856867 100644 --- a/Data/Entities/ChatMessage.cs +++ b/Data/Entities/ChatMessage.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using BS.Shared; namespace BeWo.Data.Entities @@ -21,14 +22,10 @@ namespace BeWo.Data.Entities public static string PropertyName_MessageId = "MessageId"; - public static string PropertyName_MediaDatei = "MediaDatei"; - public static string PropertyName_MediaTyp = "MediaTyp"; private byte[] _ChatText; - private byte[] _MediaDatei; - private int _MediaTyp; private long? _EmpfaengerPersonOid; @@ -75,18 +72,6 @@ namespace BeWo.Data.Entities } } - public virtual byte[] MediaDatei - { - get { return _MediaDatei; } - - set - { - if (AreDifferent(_MediaDatei, value)) - { - _MediaDatei = value; - } - } - } public virtual DateTime Uhrzeit { @@ -178,5 +163,6 @@ namespace BeWo.Data.Entities } } } + } } \ No newline at end of file diff --git a/Data/Mappings/ChatMessage.hbm.xml b/Data/Mappings/ChatMessage.hbm.xml index 442319b6b..1a4aa55a4 100644 --- a/Data/Mappings/ChatMessage.hbm.xml +++ b/Data/Mappings/ChatMessage.hbm.xml @@ -21,8 +21,7 @@ - - + \ No newline at end of file diff --git a/Model/Changes_16_11_2016.txt b/Model/Changes_16_11_2016.txt new file mode 100644 index 000000000..af633ca76 --- /dev/null +++ b/Model/Changes_16_11_2016.txt @@ -0,0 +1,26 @@ +CREATE TABLE `1234567890`.`chatmediamessage` ( + `Oid` BIGINT(19) NULL AUTO_INCREMENT COMMENT '', + + `ChatMessageOid` BIGINT(19) NULL COMMENT '', + `Tid` INT(10) NULL COMMENT '', + `Notice` VARCHAR(1024) NULL COMMENT '', + + `InsTs` DATETIME NULL COMMENT '', + `InsUser` VARCHAR(1024) NULL COMMENT '', + `Version` BIGINT(19) NULL COMMENT '', + + `UdpUser` VARCHAR(256) NULL COMMENT '', + `isActive` TINYINT(4) NULL COMMENT '', + `SystemEntryID` INT(10) NULL COMMENT '', + + `Media` LONGBLOB NULL DEFAULT NULL COMMENT '', + +`ImageThumpNail` LONGBLOB NULL DEFAULT NULL COMMENT '', + + PRIMARY KEY (`Oid`) COMMENT ''); + +ALTER TABLE `1234567890`.`chatmediamessage` +ADD INDEX `ChatMessage_IDX` (`ChatMessageOid` ASC) COMMENT ''; + +ALTER TABLE `1234567890`.`chatmessages` +DROP COLUMN `MediaDatei`; diff --git a/Service/DCEntityMapper/ChatMediaMessageDC_ChatMediaMessage.cs b/Service/DCEntityMapper/ChatMediaMessageDC_ChatMediaMessage.cs new file mode 100644 index 000000000..012d13186 --- /dev/null +++ b/Service/DCEntityMapper/ChatMediaMessageDC_ChatMediaMessage.cs @@ -0,0 +1,39 @@ +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BS.Shared.Core; +using BS.Shared.DataContracts; + +namespace BeWo.Service.DCEntityMapper +{ + public class ChatMediaMessageDC_ChatMediaMessage : AbstractIDCEntityMapper + { + public override ChatMediaMessageDC MergeWithDC(ChatMediaMessage pEntity, ChatMediaMessageDC pDataContract) + { + pDataContract.ChatMessageOid = pEntity.ChatMessageOid; + pDataContract.ImageThumpNail = pEntity.ImageThumpNail; + pDataContract.Media = pEntity.Media; + + + return pDataContract; + } + + public override ChatMediaMessage MergeWithEntity(ChatMediaMessageDC pDataContract, ChatMediaMessage pEntity) + { + pEntity.ChatMessageOid = pDataContract.ChatMessageOid; + pEntity.Media = pDataContract.Media; + pEntity.ImageThumpNail = Utils.ErstelleThumbnail(pDataContract.ImageThumpNail, 200, 200); + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(ChatMediaMessageDC pDC, ChatMediaMessage pEntity) + { + if (pDC.ChatMediaMessageOid == null ) + { + return false; + } + + return pDC.ChatMediaMessageOid == pEntity.Oid; + } + } +} \ No newline at end of file diff --git a/Service/DCEntityMapper/ChatMessageDC_ChatMessage.cs b/Service/DCEntityMapper/ChatMessageDC_ChatMessage.cs index fcba0aeae..90ebf0420 100644 --- a/Service/DCEntityMapper/ChatMessageDC_ChatMessage.cs +++ b/Service/DCEntityMapper/ChatMessageDC_ChatMessage.cs @@ -15,10 +15,9 @@ namespace BeWo.Service.DCEntityMapper pDataContract.IsDelivered = pEntity.IsDelivered; pDataContract.IstGelesen = pEntity.IstGelesen; pDataContract.TeamOid = pEntity.TeamOid; - pDataContract.MessageId = pEntity.MessageId; - pDataContract.MediaDatei = pEntity.MediaDatei; + pDataContract.MessageId = pEntity.MessageId; pDataContract.MediaTyp = pEntity.MediaTyp; - + pDataContract.ChatMessagesOid = pEntity.Oid; return pDataContract; } @@ -32,9 +31,10 @@ namespace BeWo.Service.DCEntityMapper pEntity.ChatText = System.Text.Encoding.Default.GetBytes(pDataContract.ChatText); pEntity.IstGelesen = pDataContract.IstGelesen; pEntity.TeamOid = pDataContract.TeamOid; - pEntity.MessageId = pDataContract.MessageId; - pEntity.MediaDatei = pDataContract.MediaDatei; + pEntity.MessageId = pDataContract.MessageId; pEntity.MediaTyp = pDataContract.MediaTyp; + pEntity.Oid = pDataContract.ChatMessagesOid; + return pEntity; } diff --git a/Service/DCEntityMapper/MapperFactory.cs b/Service/DCEntityMapper/MapperFactory.cs index 17e1edf24..cb0b6da94 100644 --- a/Service/DCEntityMapper/MapperFactory.cs +++ b/Service/DCEntityMapper/MapperFactory.cs @@ -47,6 +47,8 @@ namespace BeWo.Service.DCEntityMapper private static ChatMessageDC_ChatMessage _ChatMessageDC_ChatMessage; + private static ChatMediaMessageDC_ChatMediaMessage _ChatMediaMessageDC_ChatMediaMessage; + private static CompactOrganisationDC_Organisation _CompactOrganisationDC_Organisation; private static CompactPersonDC_Person _CompactPersonDC_Person; @@ -527,6 +529,14 @@ namespace BeWo.Service.DCEntityMapper } } + public static ChatMediaMessageDC_ChatMediaMessage ChatMediaMessagesDC_ChatMediaMessages + { + get + { + return _ChatMediaMessageDC_ChatMediaMessage ?? (_ChatMediaMessageDC_ChatMediaMessage = new ChatMediaMessageDC_ChatMediaMessage()); + } + } + public static EmployeeAPPCodeDC_EmployeeAPPCode EmployeeAPPCodeDC_EmployeeAPPCode { get diff --git a/Service/Service.csproj b/Service/Service.csproj index d8bf10d2d..8b1fec752 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -212,6 +212,7 @@ + diff --git a/Service/ServiceImplementations/CustomerServiceImp.cs b/Service/ServiceImplementations/CustomerServiceImp.cs index f4ffa3a2b..3eeb30810 100644 --- a/Service/ServiceImplementations/CustomerServiceImp.cs +++ b/Service/ServiceImplementations/CustomerServiceImp.cs @@ -3182,7 +3182,19 @@ namespace BeWo.Service.ServiceImplementations { var messages = DAOFactory.SearchDAO.FindAllChatMessages(senderOid, empfaengerOid, maxNachricht); - return MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + var dcList = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + + foreach (var msg in dcList) + { + var cmm = DAOFactory.SearchDAO.GetChatMediaMessagesForChatMessage(msg.ChatMessagesOid.Value); + + if (cmm.Count > 0) + { + msg.MediaDatei = cmm[0].ImageThumpNail; + } + } + + return dcList; } catch (Exception e) { @@ -3196,7 +3208,19 @@ namespace BeWo.Service.ServiceImplementations { var messages = DAOFactory.SearchDAO.FindAllChatMessagesFromTeam(senderOid, teamEmpfangOid,maxNachrichten); - return MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + var dcList = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + + foreach (var msg in dcList) + { + var cmm = DAOFactory.SearchDAO.GetChatMediaMessagesForChatMessage(msg.ChatMessagesOid.Value); + + if (cmm.Count > 0) + { + msg.MediaDatei = cmm[0].ImageThumpNail; + } + } + + return dcList; } catch (Exception e) { @@ -3220,13 +3244,37 @@ namespace BeWo.Service.ServiceImplementations //empfangoid == teamempfang oid var messages = DAOFactory.SearchDAO.FindNextChatMessages(senderOid, EmpfangOid ,maxMessage,messageIds,true); - return MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + var dcList = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + + foreach (var msg in dcList) + { + var cmm = DAOFactory.SearchDAO.GetChatMediaMessagesForChatMessage(msg.ChatMessagesOid.Value); + + if (cmm.Count > 0) + { + msg.MediaDatei = cmm[0].ImageThumpNail; + } + } + + return dcList; } else { var messages = DAOFactory.SearchDAO.FindNextChatMessages(senderOid, EmpfangOid, maxMessage,messageIds,false); - return MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + var dcList = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(messages); + + foreach (var msg in dcList) + { + var cmm = DAOFactory.SearchDAO.GetChatMediaMessagesForChatMessage(msg.ChatMessagesOid.Value); + + if (cmm.Count > 0) + { + msg.MediaDatei = cmm[0].ImageThumpNail; + } + } + + return dcList; } } catch (Exception e) diff --git a/Service/ServiceImplementations/StreamingServiceImp.cs b/Service/ServiceImplementations/StreamingServiceImp.cs index 16010d881..1fca2bc57 100644 --- a/Service/ServiceImplementations/StreamingServiceImp.cs +++ b/Service/ServiceImplementations/StreamingServiceImp.cs @@ -182,15 +182,14 @@ namespace BeWo.Service.ServiceImplementations SenderPersonOid = istream.senderOid, Uhrzeit = DateTime.Now, IsDelivered = istream.isDeliverd, - ChatText = Encoding.UTF8.GetBytes(istream.message), - MediaDatei = BS.Shared.Core.Utils.ReadFully(istream.Stream), + ChatText = Encoding.UTF8.GetBytes(istream.message), MediaTyp = istream.mediatype, IstGelesen = 0, MessageId = istream.messageid }; - istream.Stream.Close(); - istream.Stream.Dispose(); + + if (istream.teamid != 0) { @@ -203,6 +202,23 @@ namespace BeWo.Service.ServiceImplementations DAOFactory.GenericDAO.Insert(chatMessage); + byte[] ThImage = null; + if (istream.mediatype == 1) + { + ThImage = BS.Shared.Core.Utils.ReadFully(istream.Stream); + } + + var chatMediaMessage = new ChatMediaMessage + { + Media = BS.Shared.Core.Utils.ReadFully(istream.Stream), + ImageThumpNail = ThImage, + ChatMessageOid = chatMessage.Oid + }; + + DAOFactory.GenericDAO.Insert(chatMediaMessage); + + istream.Stream.Close(); + istream.Stream.Dispose(); var result = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDC(chatMessage); result.MediaDatei = null; diff --git a/Shared/BeWoEntityEnums.cs b/Shared/BeWoEntityEnums.cs index 1574814b0..3d03708c5 100644 --- a/Shared/BeWoEntityEnums.cs +++ b/Shared/BeWoEntityEnums.cs @@ -120,7 +120,8 @@ namespace BS.Shared FinanzDokumente = 113, Bargeldkasse = 114, MedRecord = 115, - ChatMessage = 116 + ChatMessage = 116, + ChatMediaMessage = 117 } public enum SystemEntryID diff --git a/Shared/DataContracts/ChatMediaMessageDC.cs b/Shared/DataContracts/ChatMediaMessageDC.cs new file mode 100644 index 000000000..e652bf300 --- /dev/null +++ b/Shared/DataContracts/ChatMediaMessageDC.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.Serialization; + +namespace BS.Shared.DataContracts +{ + [DataContract] + public class ChatMediaMessageDC : IDataContract + { + [DataMember] + public long? ChatMediaMessageOid { get; set; } + + [DataMember] + public long? ChatMessageOid { get; set; } + + [DataMember] + public byte[] Media { get; set; } + + [DataMember] + public byte[] ImageThumpNail { get; set; } + + } +} \ No newline at end of file diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index f6c5bd9ee..e1b1115df 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -169,6 +169,7 @@ +