diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 11b0db6f4..bfbe8d1a6 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -672,6 +672,7 @@ + diff --git a/BeWo/ServiceProxy/Generated.cs b/BeWo/ServiceProxy/Generated.cs index 74ec02cd4..ba5cc0050 100644 --- a/BeWo/ServiceProxy/Generated.cs +++ b/BeWo/ServiceProxy/Generated.cs @@ -174,6 +174,15 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEmployeeService/GetEmployeebyFullNameBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] BS.Shared.DataContracts.EmployeeDC GetEmployeebyFullName(string fullName); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEmployeeService/CreateOrUpdateChatBewoMessageSync", ReplyAction="http://tempuri.org/IEmployeeService/CreateOrUpdateChatBewoMessageSyncResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEmployeeService/CreateOrUpdateChatBewoMessageSyncBeWoFaultFau" + + "lt", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void CreateOrUpdateChatBewoMessageSync(System.Nullable eOid, string text); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEmployeeService/GetChatBewoMessageSync", ReplyAction="http://tempuri.org/IEmployeeService/GetChatBewoMessageSyncResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEmployeeService/GetChatBewoMessageSyncBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.Shared.DataContracts.ChatBewoMessageSyncDC GetChatBewoMessageSync(System.Nullable eOid); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEmployeeService/ArchiveEmployee", ReplyAction="http://tempuri.org/IEmployeeService/ArchiveEmployeeResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEmployeeService/ArchiveEmployeeBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] void ArchiveEmployee(long pOid, long pVersion); @@ -581,6 +590,16 @@ namespace BeWo.ServiceProxy return base.Channel.GetEmployeebyFullName(fullName); } + public void CreateOrUpdateChatBewoMessageSync(System.Nullable eOid, string text) + { + base.Channel.CreateOrUpdateChatBewoMessageSync(eOid, text); + } + + public BS.Shared.DataContracts.ChatBewoMessageSyncDC GetChatBewoMessageSync(System.Nullable eOid) + { + return base.Channel.GetChatBewoMessageSync(eOid); + } + public void ArchiveEmployee(long pOid, long pVersion) { base.Channel.ArchiveEmployee(pOid, pVersion); @@ -1325,7 +1344,6 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICustomerService/GetPersonWithCustomerOid", ReplyAction="http://tempuri.org/ICustomerService/GetPersonWithCustomerOidResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/ICustomerService/GetPersonWithCustomerOidBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CustomerDC))] - [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.WohnheimDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.EmployeeDC))] BS.Shared.DataContracts.PersonDC GetPersonWithCustomerOid(long oid); @@ -1596,7 +1614,6 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICustomerService/InsertNewPerson", ReplyAction="http://tempuri.org/ICustomerService/InsertNewPersonResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/ICustomerService/InsertNewPersonBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CustomerDC))] - [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.WohnheimDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.EmployeeDC))] long InsertNewPerson(BS.Shared.DataContracts.PersonDC pPersonDC); @@ -1619,7 +1636,6 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICustomerService/LoadPerson", ReplyAction="http://tempuri.org/ICustomerService/LoadPersonResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/ICustomerService/LoadPersonBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CustomerDC))] - [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.WohnheimDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.EmployeeDC))] BS.Shared.DataContracts.PersonDC LoadPerson(long pPersonOid); @@ -1662,7 +1678,6 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICustomerService/UpdatePerson", ReplyAction="http://tempuri.org/ICustomerService/UpdatePersonResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/ICustomerService/UpdatePersonBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CustomerDC))] - [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.WohnheimDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.EmployeeDC))] long UpdatePerson(BS.Shared.DataContracts.PersonDC pPersonDC); @@ -4247,7 +4262,7 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/CreateNewCustomerAPPCodeDC", ReplyAction="http://tempuri.org/IOperationsService/CreateNewCustomerAPPCodeDCResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/CreateNewCustomerAPPCodeDCBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey, long userOid); + BS.Shared.DataContracts.CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/CreateNewChatMessagesDC", ReplyAction="http://tempuri.org/IOperationsService/CreateNewChatMessagesDCResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/CreateNewChatMessagesDCBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] @@ -4271,7 +4286,7 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/CreateNewEmployeeAPPCodeDC", ReplyAction="http://tempuri.org/IOperationsService/CreateNewEmployeeAPPCodeDCResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/CreateNewEmployeeAPPCodeDCBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey, long userOid); + BS.Shared.DataContracts.EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/UpdateIsChatActiveEmployeeAPPCodeDC", ReplyAction="http://tempuri.org/IOperationsService/UpdateIsChatActiveEmployeeAPPCodeDCResponse" + "")] @@ -4421,17 +4436,13 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/GetLastVertreterBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] System.Collections.Generic.List GetLastVertreter(System.Nullable klientenOid); - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/GetHandOutPdfForChat", ReplyAction="http://tempuri.org/IOperationsService/GetHandOutPdfForChatResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/GetHandOutPdfForChatBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.PdfChatHandoutDC GetHandOutPdfForChat(string customerId, string apikey); - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/DeletEmloyeeChatCode", ReplyAction="http://tempuri.org/IOperationsService/DeletEmloyeeChatCodeResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/DeletEmloyeeChatCodeBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - bool DeletEmloyeeChatCode(string apikey, string kundennummer, long userOid); + bool DeletEmloyeeChatCode(string apikey, string kundennummer, long employeeoid); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/DeletCustomerChatCode", ReplyAction="http://tempuri.org/IOperationsService/DeletCustomerChatCodeResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/DeletCustomerChatCodeBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - bool DeletCustomerChatCode(string apikey, string kundennummer, long userOid); + bool DeletCustomerChatCode(string apikey, string kundennummer, long customeroid); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/GetTranslationDictionary", ReplyAction="http://tempuri.org/IOperationsService/GetTranslationDictionaryResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsService/GetTranslationDictionaryBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] @@ -5057,9 +5068,9 @@ namespace BeWo.ServiceProxy return base.Channel.InsertSignature(sig); } - public BS.Shared.DataContracts.CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey, long userOid) + public BS.Shared.DataContracts.CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey) { - return base.Channel.CreateNewCustomerAPPCodeDC(customerOid, kundennummer, apikey, userOid); + return base.Channel.CreateNewCustomerAPPCodeDC(customerOid, kundennummer, apikey); } public BS.Shared.DataContracts.ChatMessageDC CreateNewChatMessagesDC(long senderOid, long empfängerOid, string message, bool isDeliverd, long teamid, string messageid) @@ -5082,9 +5093,9 @@ namespace BeWo.ServiceProxy return base.Channel.FindUnreadChatMessagesForRecipient(personOid); } - public BS.Shared.DataContracts.EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey, long userOid) + public BS.Shared.DataContracts.EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey) { - return base.Channel.CreateNewEmployeeAPPCodeDC(employeeOid, kundennummer, apikey, userOid); + return base.Channel.CreateNewEmployeeAPPCodeDC(employeeOid, kundennummer, apikey); } public void UpdateIsChatActiveEmployeeAPPCodeDC(long employeeOid, int activeType) @@ -5252,19 +5263,14 @@ namespace BeWo.ServiceProxy return base.Channel.GetLastVertreter(klientenOid); } - public BS.Shared.DataContracts.PdfChatHandoutDC GetHandOutPdfForChat(string customerId, string apikey) + public bool DeletEmloyeeChatCode(string apikey, string kundennummer, long employeeoid) { - return base.Channel.GetHandOutPdfForChat(customerId, apikey); + return base.Channel.DeletEmloyeeChatCode(apikey, kundennummer, employeeoid); } - public bool DeletEmloyeeChatCode(string apikey, string kundennummer, long userOid) + public bool DeletCustomerChatCode(string apikey, string kundennummer, long customeroid) { - return base.Channel.DeletEmloyeeChatCode(apikey, kundennummer, userOid); - } - - public bool DeletCustomerChatCode(string apikey, string kundennummer, long userOid) - { - return base.Channel.DeletCustomerChatCode(apikey, kundennummer, userOid); + return base.Channel.DeletCustomerChatCode(apikey, kundennummer, customeroid); } public System.Collections.Generic.Dictionary GetTranslationDictionary() diff --git a/BeWo/View/ChatServiceCustomer.xaml.cs b/BeWo/View/ChatServiceCustomer.xaml.cs index 1a4ee72b2..9d249f3c2 100644 --- a/BeWo/View/ChatServiceCustomer.xaml.cs +++ b/BeWo/View/ChatServiceCustomer.xaml.cs @@ -141,7 +141,7 @@ namespace BeWo.View { StartWaiting(); var result = - ServiceFacade.DoOperationsServiceSync(s => s.CreateNewCustomerAPPCodeDC(customerOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey,personOid.Value)); + ServiceFacade.DoOperationsServiceSync(s => s.CreateNewCustomerAPPCodeDC(customerOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey)); EndWaiting(); if(result != null){ @@ -158,7 +158,7 @@ namespace BeWo.View else if (BeWoApp.Tenant != null && BeWoApp.Mandator.Apikey != null) { StartWaiting(); - var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewCustomerAPPCodeDC(customerOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey, personOid.Value)); + var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewCustomerAPPCodeDC(customerOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey)); EndWaiting(); if(result != null){ @@ -316,7 +316,7 @@ namespace BeWo.View { if (MessageBox.Show("Wollen Sie den Chat-Code wirklich löschen?\nAlle Daten werden gelöscht.", "Achtung", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { StartWaiting(); - var isdeletet = ServiceFacade.DoOperationsServiceSync(r => r.DeletCustomerChatCode(BeWoApp.Mandator.Apikey, BeWoApp.Tenant, personOid.Value)); + var isdeletet = ServiceFacade.DoOperationsServiceSync(r => r.DeletCustomerChatCode(BeWoApp.Mandator.Apikey, BeWoApp.Tenant, customerOid.Value)); EndWaiting(); if (isdeletet) diff --git a/BeWo/View/ChatServiceEmployee.xaml.cs b/BeWo/View/ChatServiceEmployee.xaml.cs index 953cd0063..6bc7c64d9 100644 --- a/BeWo/View/ChatServiceEmployee.xaml.cs +++ b/BeWo/View/ChatServiceEmployee.xaml.cs @@ -88,7 +88,7 @@ namespace BeWo.View MessageBoxImage.Question) == MessageBoxResult.Yes) { StartWaiting(); - var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewEmployeeAPPCodeDC(employeeOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey, personOid.Value)); + var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewEmployeeAPPCodeDC(employeeOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey)); EndWaiting(); if(result != null){ @@ -109,8 +109,8 @@ namespace BeWo.View var result = ServiceFacade.DoOperationsServiceSync( s => - s.CreateNewEmployeeAPPCodeDC(employeeOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey, - personOid.Value)); + s.CreateNewEmployeeAPPCodeDC(employeeOid.Value, BeWoApp.Tenant, BeWoApp.Mandator.Apikey)); + EndWaiting(); //GeneratetTexfield.Text = result.EmployeeCode; @@ -212,9 +212,7 @@ namespace BeWo.View private void ZeigePDF_OnClick(object sender, RoutedEventArgs e) { StartWaiting(); - - //var handout = ServiceFacade.DoOperationsServiceSync(r => r.GetHandOutPdfForChat("5473568546", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"/*BeWoApp.Tenant, BeWoApp.Mandator.Apikey*/)); - + List parameter = new List(); parameter.Add(BeWoApp.Tenant); parameter.Add(BeWoApp.Mandator.Apikey); @@ -469,7 +467,7 @@ namespace BeWo.View { StartWaiting(); - var isdeletet = ServiceFacade.DoOperationsServiceSync(r => r.DeletEmloyeeChatCode(BeWoApp.Mandator.Apikey, BeWoApp.Tenant, personOid.Value)); + var isdeletet = ServiceFacade.DoOperationsServiceSync(r => r.DeletEmloyeeChatCode(BeWoApp.Mandator.Apikey, BeWoApp.Tenant, employeeOid.Value)); EndWaiting(); diff --git a/BeWo/View/ChatView.xaml.cs b/BeWo/View/ChatView.xaml.cs index 021f1765a..97e488fbf 100644 --- a/BeWo/View/ChatView.xaml.cs +++ b/BeWo/View/ChatView.xaml.cs @@ -41,8 +41,8 @@ namespace BeWo.View ChatMainControl.InitMitChatdaten(chatDaten); ChatMainControl.AddContextMenu("In Dokumentation übernehmen", ChatMainControl_OnClickContextMenuItem); - - //in einem thread auslagern + LadeMessageInfoAusDatenBank(); + Thread newThread = new Thread(ChatMainControl.SynchronisationVeranlassen); newThread.IsBackground = true; newThread.Start(); @@ -61,8 +61,7 @@ namespace BeWo.View private void CloseWindow() { CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => - { - //Close(); + { Visibility = Visibility.Hidden; if (_emojiView != null) @@ -71,7 +70,8 @@ namespace BeWo.View } - ChatMainControl.SpeichereMessageInfoInDatei(); + + SpeichereMessageInfosInDatenBank(); })); } @@ -173,11 +173,9 @@ namespace BeWo.View #endregion - - - #region Close chat + #region Close chat / wird nicht benutzt private void MainWindow_OnClosed(object sender, EventArgs e) - { + { //_emojiView = null; //ChatMainControl.SpeichereMessageInfoInDatei(); @@ -202,5 +200,48 @@ namespace BeWo.View } #endregion + #region Speichere/Lade MessageSync In DB + + private void SpeichereMessageInfosInDatenBank() + { + var liste = ChatMainControl.UebergebeMessageInfoDatenFuerDb(); + + if (liste.Count != 0) + { + string text=""; + foreach (var item in liste) + { + text += item.GroupId + ";" + item.TimeStamp + ";"+"&"; + } + + ServiceFacade.DoEmployeeServiceSync(r => r.CreateOrUpdateChatBewoMessageSync(BeWoApp.LoggedOnUser.Employee.EmployeeOid,text)); + } + } + + private void LadeMessageInfoAusDatenBank() + { + var item = ServiceFacade.DoEmployeeServiceSync(r => r.GetChatBewoMessageSync(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + + if (item != null) + { + string[] messageSynctext = item.MessageSyncText.Split('&'); + + Dictionary aa = new Dictionary(); + + foreach (var text in messageSynctext) + { + if (!text.Equals("")) { + string[] splitten = text.Split(';'); + + aa.Add(Convert.ToInt64(splitten[0]), DateTime.Parse(splitten[1])); + } + } + + ChatMainControl.ErhalteMessageInfoVonDb(aa); + } + } + + #endregion + } } diff --git a/BeWo/ViewModel/ChatBewoMessageSyncVM.cs b/BeWo/ViewModel/ChatBewoMessageSyncVM.cs new file mode 100644 index 000000000..2a125c5c4 --- /dev/null +++ b/BeWo/ViewModel/ChatBewoMessageSyncVM.cs @@ -0,0 +1,46 @@ +using BS.Shared; +using BS.Shared.DataContracts; +using System; + +namespace BeWo.ViewModel +{ + public class ChatBewoMessageSyncVM : AbstractDCMapperVM + { + public static string PropertyName_MessageSyncText = "MessageSyncText"; + + private string _MessageSyncText; + + public ChatBewoMessageSyncVM(ChatBewoMessageSyncDC pDC) + : base(pDC, true) + { + } + + public string MessageSyncText + { + get { return this._MessageSyncText; } + + set + { + if (this.AreDifferent(this._MessageSyncText, value)) + { + this._MessageSyncText = value; + this.StoreDirtyInformation(this.AreDifferent(this.DataContract.MessageSyncText, value), PropertyName_MessageSyncText); + this.FirePropertyChanged(PropertyName_MessageSyncText); + } + } + } + + protected override void InitByDataContract(ChatBewoMessageSyncDC pDataContract) + { + this._MessageSyncText = pDataContract.MessageSyncText; + + } + + protected override ChatBewoMessageSyncDC MapToDataContract(ChatBewoMessageSyncDC pDataContract, bool doCommit) + { + pDataContract.MessageSyncText = _MessageSyncText; + + return pDataContract; + } + } +} \ No newline at end of file diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index 442f83077..242705b1d 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -2187,5 +2187,13 @@ namespace BeWo.Data.Access return criteria.List(); } + + public IEnumerable FindEmployeeChatBewoMessageSync(long oid) + { + var c = CreateCriteriaIsActive() + .Add(Restrictions.Eq(ChatBewoMessageSync.PropertyName_EmployeeOid, oid)); + + return c.List(); + } } } diff --git a/Data/Data.csproj b/Data/Data.csproj index 961453770..032deca3d 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -168,6 +168,7 @@ + @@ -569,6 +570,9 @@ + + Designer + Designer diff --git a/Data/Entities/ChatBewoMessageSync.cs b/Data/Entities/ChatBewoMessageSync.cs new file mode 100644 index 000000000..cfeceee3d --- /dev/null +++ b/Data/Entities/ChatBewoMessageSync.cs @@ -0,0 +1,54 @@ +using BS.Shared; +using System; +using System.Collections.Generic; + +namespace BeWo.Data.Entities +{ + public class ChatBewoMessageSync : BeWoEntityBase + { + public static string PropertyName_EmployeeOid = "EmployeeOid"; + + public static string PropertyName_MessageSyncText = "MessageSyncText"; + + private long? _EmployeeOid; + + private string _MessageSyncText; + + public ChatBewoMessageSync() + { + this._Tid = TableID.ChatBewoMessageSync; + } + + public virtual string MessageSyncText + { + get + { + return this._MessageSyncText; + } + + set + { + if (this.AreDifferent(this._MessageSyncText, value)) + { + this._MessageSyncText = value; + } + } + } + + public virtual long? EmployeeOid + { + get + { + return _EmployeeOid; + } + set + { + if (AreDifferent(_EmployeeOid, value)) + { + _EmployeeOid = value; + } + } + } + + } +} \ No newline at end of file diff --git a/Data/Mappings/ChatBewoMessageSync.hbm.xml b/Data/Mappings/ChatBewoMessageSync.hbm.xml new file mode 100644 index 000000000..3c0df85fe --- /dev/null +++ b/Data/Mappings/ChatBewoMessageSync.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Model/Changes_2017_11_08.txt b/Model/Changes_2017_11_08.txt new file mode 100644 index 000000000..6c558b28d --- /dev/null +++ b/Model/Changes_2017_11_08.txt @@ -0,0 +1,24 @@ +CREATE TABLE `1234567890`.`chatbewomessagesync` ( + `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '', + + `EmployeeOid` 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 '', + + `MessageSyncText` VARCHAR(1024) NULL COMMENT '', + + PRIMARY KEY (`Oid`) COMMENT ''); diff --git a/Service/DCEntityMapper/ChatBewoMessageSyncDC_ChatBewoMessageSync.cs b/Service/DCEntityMapper/ChatBewoMessageSyncDC_ChatBewoMessageSync.cs new file mode 100644 index 000000000..6abb35cd6 --- /dev/null +++ b/Service/DCEntityMapper/ChatBewoMessageSyncDC_ChatBewoMessageSync.cs @@ -0,0 +1,37 @@ +using System.IO; +using BeWo.Data.Entities; +using BS.Shared; +using BS.Shared.DataContracts; + +namespace BeWo.Service.DCEntityMapper +{ + public class ChatBewoMessageSyncDC_ChatBewoMessageSync : AbstractIDCEntityMapper + { + public override ChatBewoMessageSyncDC MergeWithDC(ChatBewoMessageSync pEntity, ChatBewoMessageSyncDC pDataContract) + { + pDataContract.EmployeeOid = pEntity.EmployeeOid; + pDataContract.MessageSyncText = pEntity.MessageSyncText; + + return pDataContract; + } + + public override ChatBewoMessageSync MergeWithEntity(ChatBewoMessageSyncDC pDataContract, ChatBewoMessageSync pEntity) + { + pEntity.EmployeeOid = pDataContract.EmployeeOid; + pEntity.MessageSyncText = pDataContract.MessageSyncText; + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(ChatBewoMessageSyncDC pDC, ChatBewoMessageSync pEntity) + { + + if (pDC.ChatBewoMessageSyncOid == null) + { + return false; + } + + return pDC.ChatBewoMessageSyncOid == pEntity.Oid; + } + } +} \ No newline at end of file diff --git a/Service/DCEntityMapper/MapperFactory.cs b/Service/DCEntityMapper/MapperFactory.cs index 3d1b31271..00b3c404a 100644 --- a/Service/DCEntityMapper/MapperFactory.cs +++ b/Service/DCEntityMapper/MapperFactory.cs @@ -47,6 +47,8 @@ namespace BeWo.Service.DCEntityMapper private static VertretungDC_Vertretung _VertretungDC_Vertretung; + private static ChatBewoMessageSyncDC_ChatBewoMessageSync _ChatBewoMessageSyncDC_ChatBewoMessageSync; + private static TokenDC_Token _TokenDC_Token; private static QuittierungsCheckDC_QuittierungsCheck _QuittierungsCheckDC_QuittierungsCheck; @@ -552,6 +554,14 @@ namespace BeWo.Service.DCEntityMapper } } + public static ChatBewoMessageSyncDC_ChatBewoMessageSync ChatBewoMessageSyncDC_ChatBewoMessageSync + { + get + { + return _ChatBewoMessageSyncDC_ChatBewoMessageSync ?? (_ChatBewoMessageSyncDC_ChatBewoMessageSync = new ChatBewoMessageSyncDC_ChatBewoMessageSync()); + } + } + public static TokenDC_Token TokenDC_Token { get diff --git a/Service/Service.csproj b/Service/Service.csproj index 814a00894..c03464ec6 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -230,6 +230,7 @@ + diff --git a/Service/ServiceContracts/IEmployeeService.cs b/Service/ServiceContracts/IEmployeeService.cs index a55f529bf..f0fb31ef1 100644 --- a/Service/ServiceContracts/IEmployeeService.cs +++ b/Service/ServiceContracts/IEmployeeService.cs @@ -359,5 +359,13 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] EmployeeDC GetEmployeebyFullName(string fullName); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + void CreateOrUpdateChatBewoMessageSync(long? eOid, string text); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + ChatBewoMessageSyncDC GetChatBewoMessageSync(long? eOid); } } \ No newline at end of file diff --git a/Service/ServiceContracts/IOperationsService.cs b/Service/ServiceContracts/IOperationsService.cs index 475caa60a..2fd7c4d5f 100644 --- a/Service/ServiceContracts/IOperationsService.cs +++ b/Service/ServiceContracts/IOperationsService.cs @@ -524,7 +524,7 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] - CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey, long userOid); + CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey); [FaultContract(typeof (BeWoFault))] [OperationContract] @@ -544,7 +544,7 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] - EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey, long userOid); + EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey); [FaultContract(typeof (BeWoFault))] [OperationContract] @@ -698,15 +698,11 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] - PdfChatHandoutDC GetHandOutPdfForChat(string customerId, string apikey); + bool DeletEmloyeeChatCode(string apikey, string kundennummer, long employeeoid); [FaultContract(typeof(BeWoFault))] [OperationContract] - bool DeletEmloyeeChatCode(string apikey, string kundennummer, long userOid); - - [FaultContract(typeof(BeWoFault))] - [OperationContract] - bool DeletCustomerChatCode(string apikey, string kundennummer, long userOid); + bool DeletCustomerChatCode(string apikey, string kundennummer, long customeroid); [FaultContract(typeof(BeWoFault))] [OperationContract] diff --git a/Service/ServiceImplementations/EmployeeServiceImp.cs b/Service/ServiceImplementations/EmployeeServiceImp.cs index 2e9d59890..0420f408e 100644 --- a/Service/ServiceImplementations/EmployeeServiceImp.cs +++ b/Service/ServiceImplementations/EmployeeServiceImp.cs @@ -1352,6 +1352,68 @@ namespace BeWo.Service.ServiceImplementations } } + public void CreateOrUpdateChatBewoMessageSync(long? eOid, string text) + { + try + { + + var chatMessageSync = DAOFactory.SearchDAO.FindEmployeeChatBewoMessageSync(eOid.Value); + + int count = chatMessageSync.Count(); + if(count > 0) { + + foreach (var item in chatMessageSync) + { + item.MessageSyncText = text; + } + + DAOFactory.GenericDAO.Update(chatMessageSync); + } + else { + ChatBewoMessageSyncDC cms = new ChatBewoMessageSyncDC(); + + cms.EmployeeOid = eOid; + cms.MessageSyncText = text; + + var x = MapperFactory.ChatBewoMessageSyncDC_ChatBewoMessageSync.MapToNewEntity(cms); + DAOFactory.GenericDAO.Insert(x); + } + } + catch (Exception e) + { + throw Utils.CreateBeWoFaultException(e); + } + } + + public ChatBewoMessageSyncDC GetChatBewoMessageSync(long? eOid) + { + try + { + var chatMessageSync = DAOFactory.GenericDAO.GetAllActive(); + + ChatBewoMessageSync cms = null; + foreach (var item in chatMessageSync) + { + if (eOid == item.EmployeeOid) + { + cms = item; + } + } + + if (cms != null) + { + var x = MapperFactory.ChatBewoMessageSyncDC_ChatBewoMessageSync.MapToNewDC(cms); + + return x; + } + + return null; + } + catch (Exception e) + { + throw Utils.CreateBeWoFaultException(e); + } + } } } \ No newline at end of file diff --git a/Service/ServiceImplementations/OperationsServiceImp.cs b/Service/ServiceImplementations/OperationsServiceImp.cs index fcfa536b7..4e267682e 100644 --- a/Service/ServiceImplementations/OperationsServiceImp.cs +++ b/Service/ServiceImplementations/OperationsServiceImp.cs @@ -3164,14 +3164,14 @@ namespace BeWo.Service.ServiceImplementations } } - public EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid,string kundennummer,string apikey ,long userOid) + public EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid,string kundennummer,string apikey) { try { - DeletZufallsCode(apikey, kundennummer, "E" + userOid); + DeletZufallsCode(apikey, kundennummer, "E" + employeeOid); EmployeeAPPCode newCode = new EmployeeAPPCode(); - string zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "E" + userOid); + string zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "E" + employeeOid); if (zufallscode != null) { newCode.EmployeeCode = zufallscode; @@ -3253,7 +3253,7 @@ namespace BeWo.Service.ServiceImplementations } } - public CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid,string kundennummer, string apikey, long userOid) + public CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid,string kundennummer, string apikey) { try { @@ -3262,12 +3262,12 @@ namespace BeWo.Service.ServiceImplementations apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"; #endif //TODO Abfragen erweitern - DeletZufallsCode(apikey, kundennummer, "C" + userOid); + DeletZufallsCode(apikey, kundennummer, "C" + customerOid); //abfangeritis starten - string zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "C" + userOid); + string zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "C" + customerOid); if (zufallscode != null) { @@ -4545,8 +4545,6 @@ namespace BeWo.Service.ServiceImplementations return lResult.OrderBy(s => s.Description).ToList(); } - - public void CreateNewPerson2OrganisationRelation(long organi, ValueListEntryDC value, long personOid, string mail, string fax, string tele, string notice) { try @@ -4575,210 +4573,13 @@ namespace BeWo.Service.ServiceImplementations } } - public PdfChatHandoutDC GetHandOutPdfForChat(string customerId,string apikey) + public bool DeletCustomerChatCode(string apikey,string kundennummer,long customeroid) { try { - var handout = new PdfChatHandoutDC(); - - string serverUrl = ErmittleServerURL(customerId); - - if (serverUrl == null) - { - handout.Result = 11; - - return handout; - } - else if (serverUrl.Equals("")) - { - handout.Result = 11; - - return handout; - } - - var endurl = serverUrl + "/api/ownchat/createpdfmanual/" + apikey + "/" + customerId; - - - // Post Gedönse mit übergeben - #region neuer nicht funktionsfähiger bereich - - - #region TestBereich Multipart - //Bereich zum Testen Multiform Test gedönse - //using (MultipartFormDataContent multiPartContent = new MultipartFormDataContent()) - //{ - // Uri requestUri = new Uri(ChatDaten.ServerUrl + "/api/ownchat/createpdfmanual/"); - - // Links Content / Rechts name - // multiPartContent.Add(new StringContent(chatcode + ""), "chatcode"); - // multiPartContent.Add(new StringContent(login + ""), "login"); - // multiPartContent.Add(new StringContent(password + ""), "password"); - // multiPartContent.Add(new StringContent("https://support.bewoplaner.de/bewoplaner_logo_big.png"), "custom_logo_url"); - - // httpRequest = new HttpRequestMessage(); - // httpRequest.Method = HttpMethod.Post; - // httpRequest.RequestUri = requestUri; - // httpRequest.Content = multiPartContent; - - // httpRequest.Headers.Add("Token", apikey); - // httpRequest.Headers.Add("CustomerID", customerId); - - - // HttpResponseMessage httpResponse = null; - - // HttpClient httpClient = new HttpClient(); - - // httpResponse = await httpClient.SendAsync(httpRequest, CancellationToken.None).ConfigureAwait(false); - - - // string antwortResponse = await httpResponse.Content.ReadAsStringAsync(); - - // var jsonDatentyp = JsonConvert.DeserializeObject(antwortResponse); - - // return jsonDatentyp; - //} - - #endregion - - #region TestBereich Normal Post - //neu post bereich - //Dictionary dic = new Dictionary(); - - //dic.Add("chatcode", "Hier ChatCode"); - //dic.Add("login", "hier benutzername"); - //dic.Add("password", "hier passwort"); - //dic.Add("custom_logo_url", "https://support.bewoplaner.de/bewoplaner_logo_big.png"); - - //string postdaten = ""; - //foreach (var key in dic.Keys) - //{ - // postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(dic[key]) + "&"; - //} - - //WebRequest requesten = WebRequest.Create(endurl); - //requesten.Method = "POST"; - //requesten.ContentType = "application/x-www-form-urlencoded"; - ////requesten.Headers["Token"] = "hier ggf. token hin "; - //requesten.Headers["CustomerID"] = customerId; - - //byte[] daten = Encoding.ASCII.GetBytes(postdaten); - - //requesten.ContentLength = daten.Length; - - //Stream requestStream = requesten.GetRequestStream(); - - //requestStream.Write(daten, 0, daten.Length); - - //requestStream.Close(); - - - //neu ende - #endregion - - #endregion - - - //############################ - Dictionary postparameter = new Dictionary(); - - postparameter.Add("username", "HAns"); - postparameter.Add("password", "Dito"); - - //neu | hinzufügen laut document - postparameter.Add("chatcode", "yyAbrams"); - - string postdaten = ""; - int i = 0; - foreach (var key in postparameter.Keys) - { - //hier noch chatcode übergeben - postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(postparameter[key]) + "&"; - - } - - WebRequest requesten = WebRequest.Create(endurl); - - requesten.Method = "POST"; - requesten.ContentType = "application/x-www-form-urlencoded"; - - byte[] daten = Encoding.ASCII.GetBytes(postdaten); - - requesten.ContentLength = daten.Length; - - try - { - Stream requestStream = requesten.GetRequestStream(); - - requestStream.Write(daten, 0, daten.Length); - - requestStream.Close(); - - } - catch (Exception e) - { - MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK); - - } - - //response bereich | Verarbeiten - HttpWebResponse response = (HttpWebResponse)requesten.GetResponse(); - //response.ContentType = "application/pdf"; - - //###################################################################### - - //alt get bereich - //WebRequest request = WebRequest.Create(endurl); - - //request.Method = WebRequestMethods.Http.Post; - - //request.Credentials = CredentialCache.DefaultCredentials; - //request.Proxy = null; - - //WebResponse response = request.GetResponse(); - - using (Stream stream = response.GetResponseStream()) - { - byte[] buffer = new byte[stream.Length]; - stream.Read(buffer, 0, buffer.Length); - File.WriteAllBytes("foo.pdf", buffer); - } - - string responseFromServer = ReadStreamForChatCode(response); - - if (responseFromServer.Contains("PDF")) - { - PdfChatHandoutDC hd = new PdfChatHandoutDC(); - hd.File = responseFromServer; - hd.Result = 0; - //hd.TestStream = dataStream; - - return hd; - } - else - { - var jsonDatentyp = JsonConvert.DeserializeObject(responseFromServer); - - return jsonDatentyp; - } - } - catch (Exception e) - { - //throw Utils.CreateBeWoFaultException(e); - var handout = new PdfChatHandoutDC(); - handout.Result = 60; - handout.File = e.Message; - - return handout; - } - } - - public bool DeletCustomerChatCode(string apikey,string kundennummer,long userOid) - { - try - { - DeletZufallsCode(apikey, kundennummer, "C" + userOid); + DeletZufallsCode(apikey, kundennummer, "C" + customeroid); - var customerappcode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(userOid); + var customerappcode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customeroid); var anzahl = customerappcode.Count(); @@ -4806,13 +4607,13 @@ namespace BeWo.Service.ServiceImplementations } } - public bool DeletEmloyeeChatCode(string apikey, string kundennummer, long userOid) + public bool DeletEmloyeeChatCode(string apikey, string kundennummer,long employeeoid) { try { - DeletZufallsCode(apikey, kundennummer, "E" + userOid); + DeletZufallsCode(apikey, kundennummer, "E" + employeeoid); - var employeeappcode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(userOid); + var employeeappcode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeoid); var anzahl = employeeappcode.Count(); diff --git a/Shared/BeWoEntityEnums.cs b/Shared/BeWoEntityEnums.cs index d03941aa0..d5b9cd3ff 100644 --- a/Shared/BeWoEntityEnums.cs +++ b/Shared/BeWoEntityEnums.cs @@ -128,8 +128,9 @@ namespace BS.Shared Vertretung = 121, Employee2Token = 122, QuittierungsCheck = 123, - CustomerTeam = 124 - } + CustomerTeam = 124, + ChatBewoMessageSync = 125 + } public enum SystemEntryID { diff --git a/Shared/DataContracts/ChatBewoMessageSyncDC.cs b/Shared/DataContracts/ChatBewoMessageSyncDC.cs new file mode 100644 index 000000000..ec08fec62 --- /dev/null +++ b/Shared/DataContracts/ChatBewoMessageSyncDC.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace BS.Shared.DataContracts +{ + [DataContract] + public class ChatBewoMessageSyncDC : IDataContract + { + [DataMember] + public long? ChatBewoMessageSyncOid { get; set; } + + [DataMember] + public long? EmployeeOid { get; set; } + + [DataMember] + public string MessageSyncText { get; set; } + + } +} \ No newline at end of file diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 3f7d021ed..14885db06 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -186,6 +186,7 @@ +