248 lines
7.6 KiB
C#
248 lines
7.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Animation;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using BeWo.Core.Config;
|
|
using BeWo.ServiceProxy;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using ChatController.ChatKlassen;
|
|
using ChatController.Klassen;
|
|
using DevExpress.Xpf.Core;
|
|
using Button = System.Windows.Controls.Button;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für ChatService.xaml
|
|
/// </summary>
|
|
public partial class ChatView : Window
|
|
{
|
|
|
|
public ChatEmojiView _emojiView;
|
|
|
|
public ChatView(ChatDatenUebergabe chatDaten)
|
|
{
|
|
InitializeComponent();
|
|
CloseWindow();
|
|
|
|
ChatMainControl.InitMitChatdaten(chatDaten);
|
|
ChatMainControl.AddContextMenu("In Dokumentation übernehmen", ChatMainControl_OnClickContextMenuItem);
|
|
|
|
LadeMessageInfoAusDatenBank();
|
|
|
|
Thread newThread = new Thread(ChatMainControl.SynchronisationVeranlassen);
|
|
newThread.IsBackground = true;
|
|
newThread.Start();
|
|
|
|
}
|
|
|
|
private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DragMove();
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
private void CloseWindow()
|
|
{
|
|
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) =>
|
|
{
|
|
Visibility = Visibility.Hidden;
|
|
|
|
if (_emojiView != null)
|
|
{
|
|
_emojiView.Close(); // hidden
|
|
|
|
}
|
|
|
|
|
|
SpeichereMessageInfosInDatenBank();
|
|
|
|
}));
|
|
}
|
|
|
|
private void ChatMainControl_OnOnEmoji(Button emojiButton)
|
|
{
|
|
if (_emojiView == null)
|
|
{
|
|
_emojiView = new ChatEmojiView(ChatMainControl);
|
|
|
|
var x = emojiButton.PointToScreen(new Point(0, 0));
|
|
PresentationSource source = PresentationSource.FromVisual(emojiButton);
|
|
|
|
_emojiView.Top = (x.Y / source.CompositionTarget.TransformToDevice.M22) - _emojiView.Height - 5;
|
|
_emojiView.Left = x.X / source.CompositionTarget.TransformToDevice.M11;
|
|
|
|
|
|
_emojiView.Show();
|
|
}
|
|
else
|
|
{
|
|
|
|
//if (_emojiView.Visibility == Visibility.Visible)
|
|
//{
|
|
// _emojiView.Visibility = Visibility.Hidden; // hidden
|
|
//}
|
|
//else
|
|
//{
|
|
_emojiView.Close();
|
|
_emojiView = null;
|
|
|
|
_emojiView = new ChatEmojiView(ChatMainControl);
|
|
var x = emojiButton.PointToScreen(new Point(0, 0));
|
|
PresentationSource source = PresentationSource.FromVisual(emojiButton);
|
|
|
|
_emojiView.Top = (x.Y / source.CompositionTarget.TransformToDevice.M22) - _emojiView.Height - 5;
|
|
_emojiView.Left = x.X / source.CompositionTarget.TransformToDevice.M11;
|
|
|
|
_emojiView.Show();
|
|
//}
|
|
}
|
|
}
|
|
|
|
private void ChatMainControl_OnClickContextMenuItem(String menuItem)
|
|
{
|
|
var aktuellerKontakt = ChatMainControl.GetAktuellenKontakt();
|
|
|
|
if (aktuellerKontakt != null)
|
|
{
|
|
var itemListe = ChatMainControl.GetSelectedMessages();
|
|
|
|
if (itemListe != null)
|
|
{
|
|
List<long> sdf = new List<long>();
|
|
|
|
//hier die Customer Oid hinzufügen
|
|
sdf.Add(1);
|
|
|
|
var compactCustomerlist = ServiceFacade.DoCustomerServiceSync(s => s.GetCompactCustomersById(sdf));
|
|
|
|
CompactCustomerDC compactCustomer = null;
|
|
|
|
foreach (var cc in compactCustomerlist)
|
|
{
|
|
compactCustomer = cc;
|
|
}
|
|
|
|
ChatDokumentationsView newView = new ChatDokumentationsView(itemListe,
|
|
BeWoApp.LoggedOnUser.Employee.PersonOid, compactCustomer);
|
|
|
|
newView.ShowDialog();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte Nachrichten auswählen");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Dokumentiert werden kann nur im Chat der Klienten");
|
|
}
|
|
}
|
|
|
|
#region Fenster Größen verstellung
|
|
internal void Normal()
|
|
{
|
|
this.WindowState = (WindowState) FormWindowState.Normal;
|
|
}
|
|
|
|
internal void Maximize()
|
|
{
|
|
this.WindowState = (WindowState)FormWindowState.Maximized;
|
|
}
|
|
|
|
internal void Minimize()
|
|
{
|
|
this.WindowState = (WindowState)FormWindowState.Minimized;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Close chat / wird nicht benutzt
|
|
private void MainWindow_OnClosed(object sender, EventArgs e)
|
|
{
|
|
//_emojiView = null;
|
|
//ChatMainControl.SpeichereMessageInfoInDatei();
|
|
|
|
//this.Dispatch(delegate
|
|
//{
|
|
// BeWoApp.MainControl.HomeView.ServiceChatView.Close();
|
|
// BeWoApp.MainControl.HomeView.ServiceChatView = null;
|
|
//});
|
|
}
|
|
|
|
private void ChatMainControl_OnOnClose()
|
|
{
|
|
//ChatMainControl.SpeichereMessageInfoInDatei();
|
|
//_emojiView = null;
|
|
|
|
|
|
//this.Dispatch(delegate
|
|
//{
|
|
// BeWoApp.MainControl.HomeView.ServiceChatView.Close();
|
|
// BeWoApp.MainControl.HomeView.ServiceChatView = null;
|
|
//});
|
|
}
|
|
#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<long,DateTime> aa = new Dictionary<long, DateTime>();
|
|
|
|
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
|
|
|
|
}
|
|
}
|