1420 lines
53 KiB
C#
1420 lines
53 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.ViewModel;
|
|
|
|
using BS.Shared.Extensions;
|
|
using System.Windows.Controls;
|
|
using System.Net.Sockets;
|
|
using System.Threading;
|
|
using System.Windows.Threading;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Media.Imaging;
|
|
using BeWo.View.Detail;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using DevExpress.Xpf.Core;
|
|
using DevExpress.Xpf.Docking;
|
|
using DevExpress.XtraPrinting.Native;
|
|
using DevExpress.XtraPrinting.XamlExport;
|
|
using Microsoft.Office.Interop.Word;
|
|
using Brush = System.Windows.Media.Brush;
|
|
using Color = System.Drawing.Color;
|
|
using Image = System.Windows.Controls.Image;
|
|
using Point = System.Windows.Point;
|
|
using Size = System.Windows.Size;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
public partial class ChatView
|
|
{
|
|
public UserVM ViewModel { get; set; }
|
|
public int abr = 0;
|
|
|
|
protected TcpClient tcpClient;
|
|
|
|
protected CollectionView view;
|
|
|
|
protected ChatEmojisView emojiView = null;
|
|
|
|
protected List<KontaktlistBuilder> ita = new List<KontaktlistBuilder>();
|
|
protected List<long> oidspeicher = new List<long>();
|
|
protected List<string> teamdc = new List<string>();
|
|
protected PropertyGroupDescription groupDescription;
|
|
|
|
protected ContextMenu context;
|
|
|
|
public ChatView(String nameinf, String Chatinf, TcpClient tcpClient)
|
|
{
|
|
InitializeComponent();
|
|
|
|
rootGroupBox.Header = nameinf;
|
|
|
|
this.tcpClient = tcpClient;
|
|
|
|
CloseWindow();
|
|
LoadallChatKontakts();
|
|
ErstelleContextMenue();
|
|
SetChatSetting();
|
|
|
|
}
|
|
|
|
private void SetChatSetting()
|
|
{
|
|
try
|
|
{
|
|
List<string> data = new List<string>();
|
|
data.Add("Online");
|
|
data.Add("Offline");
|
|
data.Add("Beschäftigt");
|
|
|
|
StatusSetting.ItemsSource = data;
|
|
// StatusSetting.SelectedIndex = 0;
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Das Aufbauen der Chat-Settings ist fehlgeschlagen. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2200 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void UpdateTcp(TcpClient tcpClient)
|
|
{
|
|
this.tcpClient = tcpClient;
|
|
}
|
|
|
|
|
|
private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DragMove();
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) =>
|
|
{
|
|
abr = 1;
|
|
|
|
//Close();
|
|
|
|
if (emojiView != null && emojiView.Visibility == Visibility.Visible)
|
|
{
|
|
emojiView.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
Visibility = Visibility.Collapsed;
|
|
}));
|
|
}
|
|
|
|
public void SetText(String text, String nameclient, long personoid)
|
|
{
|
|
try
|
|
{
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
if (curItem.EmpfaengerOid == personoid)
|
|
{
|
|
foreach (var collection in ita)
|
|
{
|
|
if (collection.EmpfaengerOid == personoid)
|
|
collection.Receivems = "";
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
curItem.Receivems = "";
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(nameclient, text, DateTime.Now.ToString(), personoid,false));
|
|
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var abc in ita)
|
|
{
|
|
if (abc.EmpfaengerOid == personoid)
|
|
{
|
|
int x;
|
|
bool wasdrin = int.TryParse(abc.Receivems, out x);
|
|
|
|
if (wasdrin)
|
|
abc.Receivems = x++.ToString();
|
|
else
|
|
abc.Receivems = 1.ToString();
|
|
}
|
|
}
|
|
|
|
view.Refresh();
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim verarbeiten der Nachricht ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2220 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void SetTeamAnzahlErhalteneNachricht(long personoid, ChatType type)
|
|
{
|
|
try
|
|
{
|
|
foreach (var abc in ita)
|
|
{
|
|
|
|
if (abc.EmpfaengerOid == personoid && abc.TypeChat == type)
|
|
{
|
|
int x;
|
|
bool wasdrin = int.TryParse(abc.Receivems, out x);
|
|
|
|
if (wasdrin)
|
|
{
|
|
x++;
|
|
abc.Receivems = x.ToString();
|
|
|
|
}
|
|
else
|
|
abc.Receivems = 1.ToString();
|
|
}
|
|
}
|
|
view.Refresh();
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Setzen der Anzahl angekommender Nachrichten ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler 2391", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void RefreshViewModel()
|
|
{
|
|
view.Refresh();
|
|
}
|
|
|
|
|
|
public void SetList(String clientname, long personoid)
|
|
{
|
|
try
|
|
{
|
|
List<long> x = new List<long>();
|
|
x.Add(personoid);
|
|
|
|
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
|
|
|
var a = person[0].Type;
|
|
|
|
if (a == PersonType.Employee)
|
|
{
|
|
var mitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeWithPersonOid(personoid));
|
|
|
|
KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname,StatusType.Online, BuildImg(mitarbeiter.EmployeeImage), personoid, ChatType.Mitarbeiter);//"Online"
|
|
|
|
var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(personoid));
|
|
|
|
foreach (var variable in ita)
|
|
{
|
|
if (konbuild.Name.Equals(variable.Name))
|
|
variable.StatusTyp = StatusType.Online;// "Online";
|
|
|
|
if (variable.TypeChat == ChatType.Team)
|
|
{
|
|
foreach (var zug in zugehorigkeit)
|
|
{
|
|
if (zug.SimpleDescription.Equals(variable.Name))
|
|
{
|
|
variable.StatusTyp = StatusType.Online;// "Online";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
view.Refresh();
|
|
}
|
|
else if (a == PersonType.Customer)
|
|
{
|
|
|
|
var klienten = ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerWithPersonOid(personoid));
|
|
|
|
CompactCustomerDC customerCompact = new CompactCustomerDC();
|
|
customerCompact = new CompactCustomerDC();
|
|
customerCompact.CustomerOid = klienten.CustomerOid.Value;
|
|
customerCompact.PersonOid = klienten.PersonOid.Value;
|
|
customerCompact.FirstName = klienten.FirstName;
|
|
customerCompact.LastName = klienten.LastName;
|
|
customerCompact.DateOfBirth = klienten.DateOfBirth;
|
|
|
|
KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(klienten.CustomerImage), personoid, ChatType.Klienten, customerCompact);//"Online"
|
|
|
|
foreach (var variable in ita)
|
|
{
|
|
if (konbuild.Name.Equals(variable.Name))
|
|
variable.StatusTyp = StatusType.Online; //"Online";
|
|
}
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
if (curItem.EmpfaengerOid == personoid)
|
|
{
|
|
curItem.StatusTyp = StatusType.Online;// "Online";
|
|
view.Refresh();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Erweitern der 'Gerade Online' liste ist ein fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2230 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
public void RemoveListItem(long clientid)
|
|
{
|
|
try
|
|
{
|
|
foreach (var abc in ita)
|
|
{
|
|
if (abc.EmpfaengerOid == clientid)
|
|
{
|
|
abc.StatusTyp = StatusType.Offline;// "Offline";
|
|
}
|
|
}
|
|
|
|
PruefeTeamsObOnline();
|
|
|
|
teamdc.Clear();
|
|
oidspeicher.Clear();
|
|
|
|
if (AktChatUser.Items.Count > 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
if (curItem.EmpfaengerOid.Equals(clientid))
|
|
{
|
|
curItem.StatusTyp = StatusType.Offline;// "Offline";
|
|
}
|
|
}
|
|
|
|
view.Refresh();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Beim Entfernen eines Users von der 'Gerade Online' liste ist ein Fehler aufgetreten. " + e.Message + "\n" + e.StackTrace, "Fehler: 2240 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void PruefeTeamsObOnline()
|
|
{
|
|
try
|
|
{
|
|
foreach (var teamprof in ita)
|
|
{
|
|
if (teamprof.TypeChat == ChatType.Mitarbeiter)
|
|
{
|
|
if (teamprof.StatusTyp == StatusType.Online) //("Online")
|
|
{
|
|
oidspeicher.Add(teamprof.EmpfaengerOid);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (oidspeicher.Count == 0)
|
|
{
|
|
foreach (var tt in ita)
|
|
{
|
|
if (tt.TypeChat == ChatType.Team)
|
|
{
|
|
tt.StatusTyp = StatusType.Offline; //"Offline";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var oid in oidspeicher)
|
|
{
|
|
var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(oid));
|
|
|
|
foreach (var dc in zugehorigkeit)
|
|
{
|
|
if (!teamdc.Contains(dc.SimpleDescription))
|
|
teamdc.Add(dc.SimpleDescription);
|
|
}
|
|
}
|
|
|
|
foreach (var tt in ita)
|
|
{
|
|
if (tt.TypeChat == ChatType.Team && !teamdc.Contains(tt.Name))
|
|
{
|
|
tt.StatusTyp = StatusType.Offline;//"Offline";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Es ist ein Fehler Aufgetreten. Bitte Ruhe Bewahren. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2390 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Boolean CompareWithListItem(long personid)
|
|
{
|
|
try
|
|
{
|
|
foreach (var abc in ita)
|
|
{
|
|
if (abc.EmpfaengerOid == personid)
|
|
{
|
|
if (abc.StatusTyp == StatusType.Online)
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Das Vergleichen mit der User-Liste ist nicht möglich. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2350 ",
|
|
MessageBoxButton.OK);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void SetServerStats(String servstats)
|
|
{
|
|
ServerStats.Text = servstats;
|
|
}
|
|
|
|
private void SendButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals("") && !Chatbox.Text.Equals("Nachricht schreiben"))
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
SendMessage(curItem.EmpfaengerOid, curItem.TypeChat);
|
|
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
|
|
Chatbox.Text = "";
|
|
|
|
if (Chatbox.Text.Equals(""))
|
|
{
|
|
Chatbox.Text = "Nachricht schreiben";
|
|
Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (AktChatUser.Items.IsEmpty)
|
|
{
|
|
MessageBox.Show("Bitte wählen Sie einen Chatpartner aus.", "Fehler", MessageBoxButton.OK);
|
|
if (Chatbox.Text.Equals(""))
|
|
{
|
|
Chatbox.Text = "Nachricht schreiben";
|
|
Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray);
|
|
}
|
|
}
|
|
else if (Chatbox.Text.Equals(""))
|
|
{
|
|
MessageBox.Show("Sie können keine lehre Nachricht verschicken.", "Fehler", MessageBoxButton.OK);
|
|
if (Chatbox.Text.Equals(""))
|
|
{
|
|
Chatbox.Text = "Nachricht schreiben";
|
|
Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception sf)
|
|
{
|
|
MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + sf.Message + "\n" + sf.StackTrace, "Fehler: 2250 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
private void OnKeyDownHandler(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Key == Key.Return)
|
|
{
|
|
if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals(""))
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
SendMessage(curItem.EmpfaengerOid, curItem.TypeChat);
|
|
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
|
|
Chatbox.Text = "";
|
|
}
|
|
else
|
|
{
|
|
if (AktChatUser.Items.IsEmpty)
|
|
{
|
|
MessageBox.Show("Bitte wählen Sie einen Chatpartner aus.", "Fehler", MessageBoxButton.OK);
|
|
}
|
|
else if (Chatbox.Text.Equals(""))
|
|
{
|
|
MessageBox.Show("Sie können keine lehre Nachricht verschicken.", "Fehler", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ed)
|
|
{
|
|
MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + ed.Message + "\n" + ed.StackTrace, "Fehler: 2260 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
public void LoadallChatKontakts()
|
|
{
|
|
try
|
|
{
|
|
var employeeteamoids = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
var offmitarbeiter =
|
|
ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact());
|
|
var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact());
|
|
|
|
/* var employee = ServiceFacade.DoEmployeeServiceSync(
|
|
s => s.GetEmployeeWithPersonOid(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
|
|
employee.Employee2CustomerList.Select(s => s.CustomerOid.Value);*/
|
|
|
|
StatusType Goff = StatusType.Offline;//"Offline";
|
|
|
|
foreach (var team in employeeteamoids)
|
|
{
|
|
Clientlist.Items.Add(new KontaktlistBuilder(team.Name, Goff, BuildImg(null), team.TeamOid, ChatType.Team));
|
|
}
|
|
|
|
foreach (var list in offmitarbeiter)
|
|
{
|
|
if(list.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid){
|
|
Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, Goff,
|
|
BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(list.EmployeeOid))),
|
|
list.PersonOid, ChatType.Mitarbeiter));
|
|
}
|
|
}
|
|
foreach (var list in offklienten)
|
|
{
|
|
|
|
Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, Goff,
|
|
BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(list.CustomerOid))),
|
|
list.PersonOid, ChatType.Klienten,list));
|
|
}
|
|
|
|
|
|
foreach (var a in Clientlist.Items)
|
|
{
|
|
KontaktlistBuilder cl = (KontaktlistBuilder)a;
|
|
|
|
ita.Add(cl);
|
|
}
|
|
|
|
Clientlist.Items.Clear();
|
|
Clientlist.ItemsSource = ita;
|
|
|
|
view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
|
|
groupDescription = new PropertyGroupDescription("TypeChat");
|
|
view.GroupDescriptions.Add(groupDescription);
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Setzen einer Neuen Chat Einstellung ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2270 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void AktualisiereChatKontakt()
|
|
{
|
|
try
|
|
{
|
|
var employeeteamoids = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
var offmitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact());
|
|
var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact());
|
|
|
|
List<long> idMitarbeitspeicher = new List<long>();
|
|
List<long> idteamspeicher = new List<long>();
|
|
List<long> idKlientspeicher = new List<long>();
|
|
|
|
foreach (var teamprof in ita)
|
|
{
|
|
if (teamprof.TypeChat == ChatType.Klienten)
|
|
{
|
|
idKlientspeicher.Add(teamprof.EmpfaengerOid);
|
|
}
|
|
if (teamprof.TypeChat == ChatType.Team)
|
|
{
|
|
idteamspeicher.Add(teamprof.EmpfaengerOid);
|
|
}
|
|
if (teamprof.TypeChat == ChatType.Mitarbeiter)
|
|
{
|
|
idMitarbeitspeicher.Add(teamprof.EmpfaengerOid);
|
|
}
|
|
}
|
|
|
|
foreach (var var in employeeteamoids)
|
|
{
|
|
if (!idteamspeicher.Contains(var.TeamOid) && idteamspeicher.Count <= employeeteamoids.Count)
|
|
{
|
|
ita.Add(new KontaktlistBuilder(var.Name,StatusType.Offline, BuildImg(null), var.TeamOid, ChatType.Team)); // "Offline"
|
|
view.Refresh();
|
|
}
|
|
|
|
if (idteamspeicher.Contains(var.TeamOid))
|
|
idteamspeicher.Remove(var.TeamOid);
|
|
}
|
|
|
|
foreach (var var in offmitarbeiter)
|
|
{
|
|
if (!idMitarbeitspeicher.Contains(var.PersonOid) && idMitarbeitspeicher.Count <= offmitarbeiter.Count && var.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid)
|
|
{
|
|
ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName,StatusType.Offline,// "Offline",
|
|
BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(var.EmployeeOid))),
|
|
var.PersonOid, ChatType.Mitarbeiter));
|
|
view.Refresh();
|
|
}
|
|
|
|
if (idMitarbeitspeicher.Contains(var.PersonOid))
|
|
idMitarbeitspeicher.Remove(var.PersonOid);
|
|
}
|
|
|
|
foreach (var var in offklienten)
|
|
{
|
|
if (!idKlientspeicher.Contains(var.PersonOid) && idKlientspeicher.Count <= offklienten.Count)
|
|
{
|
|
ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName, StatusType.Offline,//"Offline",
|
|
BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(var.CustomerOid))),
|
|
var.PersonOid, ChatType.Klienten,var));
|
|
view.Refresh();
|
|
}
|
|
|
|
if (idKlientspeicher.Contains(var.PersonOid))
|
|
idKlientspeicher.Remove(var.PersonOid);
|
|
}
|
|
|
|
if (idKlientspeicher.Count != 0)
|
|
{
|
|
var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idKlientspeicher[0] && r.TypeChat == ChatType.Klienten);
|
|
|
|
if (itemToRemove != null)
|
|
ita.Remove(itemToRemove);
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
if (idMitarbeitspeicher.Count != 0)
|
|
{
|
|
var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idMitarbeitspeicher[0] && r.TypeChat == ChatType.Mitarbeiter);
|
|
|
|
if (itemToRemove != null)
|
|
ita.Remove(itemToRemove);
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
if (idteamspeicher.Count != 0)
|
|
{
|
|
var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idteamspeicher[0] && r.TypeChat == ChatType.Team);
|
|
|
|
if (itemToRemove != null)
|
|
ita.Remove(itemToRemove);
|
|
|
|
view.Refresh();
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Aktualisieren der Kontakt Liste ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2210 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void SetAllUserOfflineIfNoInet()
|
|
{
|
|
foreach (var list in ita)
|
|
{
|
|
list.StatusTyp = StatusType.Offline;// "Offline";
|
|
}
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
public void SetUserBeschäftigt(long oid, DataIdentifier type)
|
|
{
|
|
foreach (var list in ita)
|
|
{
|
|
if (oid == list.EmpfaengerOid)
|
|
{
|
|
if (type == DataIdentifier.StatusNotificationBeschäftigt)
|
|
list.StatusTyp = StatusType.Beschäftigt;// "Beschäftigt";
|
|
else if (type == DataIdentifier.StatusNotificationOnline)
|
|
list.StatusTyp = StatusType.Online;// "Online";
|
|
else if (type == DataIdentifier.StatusNotificationOffline)
|
|
list.StatusTyp = StatusType.Offline; //"Offline"; //<--- testen
|
|
}
|
|
|
|
}
|
|
|
|
view.Refresh();
|
|
}
|
|
|
|
|
|
private void ErstelleContextMenue()
|
|
{
|
|
try
|
|
{
|
|
context = new ContextMenu();
|
|
|
|
MenuItem item1 = new MenuItem();
|
|
|
|
context.Items.Add(item1);
|
|
|
|
item1.Header = "Dokumentieren";
|
|
item1.Visibility = Visibility.Visible;
|
|
item1.Click += new RoutedEventHandler(OnChatRightClickMenue);
|
|
|
|
Image icon = new Image();
|
|
//icon.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png");
|
|
icon.Source = new BitmapImage(new Uri(@"..\..\Ressources\Icons\ClipboardDisabled.png", UriKind.Relative));
|
|
icon.SetSize(new Size(16, 16));
|
|
item1.Icon = icon;
|
|
|
|
|
|
Chat.ContextMenu = context;
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Setzen einer Neuen Chat Einstellung ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2380 ", MessageBoxButton.OK);
|
|
}
|
|
|
|
}
|
|
|
|
private void OnChatRightClickMenue(object sender, RoutedEventArgs e)
|
|
{
|
|
List<KontakMessageBuilder> itemListe = new List<KontakMessageBuilder>();
|
|
|
|
|
|
KontakMessageBuilder Item;
|
|
foreach (Object selecteditem in Chat.SelectedItems)
|
|
{
|
|
Item = selecteditem as KontakMessageBuilder;
|
|
|
|
if (Item.MessagePersonOid != 0)
|
|
{
|
|
itemListe.Add(Item);
|
|
}
|
|
|
|
}
|
|
|
|
if(itemListe.Count !=0){
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
if (curItem.TypeChat != ChatType.Team && curItem.TypeChat != ChatType.Mitarbeiter)
|
|
{
|
|
ChatDokumentationsView newView = new ChatDokumentationsView(itemListe, BeWoApp.LoggedOnUser.Employee.PersonOid, curItem.EmpfaengerOid,curItem.Customer);
|
|
|
|
|
|
//newView.Activate();
|
|
newView.ShowDialog();
|
|
|
|
Chat.SelectedIndex = -1;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie können nur Klienten Nachrichten Dokumentieren.", "Info", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie müssen für diese art von Dokumentation Chat-Nachrichten auswählen.", "Info", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
itemListe.Clear();
|
|
}
|
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
switch (StatusSetting.SelectedIndex)
|
|
{
|
|
case 0:
|
|
if (tcpClient == null)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationOnline);
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
if (tcpClient == null)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationOffline);
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
if (tcpClient == null)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
StatusSetting.SelectedIndex = 1;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationBeschäftigt);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Setzen eines neuen Statuses ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2270 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void SendUserStatus(DataIdentifier identi)
|
|
{
|
|
try
|
|
{
|
|
NetworkStream serverStream = tcpClient.GetStream();
|
|
|
|
String abc = "";
|
|
|
|
Packet a = new Packet();
|
|
|
|
byte[] outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, 0,
|
|
BeWoApp.LoggedOnUser.LoginName, abc, identi, BeWoApp.Tenant, false);
|
|
|
|
serverStream.Write(outStream, 0, outStream.Length);
|
|
serverStream.Flush();
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
Console.WriteLine(edf.StackTrace);
|
|
}
|
|
}
|
|
|
|
public void SetListBoxSelection(long personoid, ChatType type)
|
|
{
|
|
try
|
|
{
|
|
context.IsOpen = false;
|
|
|
|
foreach (var blub in ita)
|
|
{
|
|
if (blub.EmpfaengerOid == personoid && blub.TypeChat == type)
|
|
{
|
|
AktChatUser.Items.Clear();
|
|
Chat.Items.Clear();
|
|
blub.Receivems = "";
|
|
|
|
if (blub.TypeChat == ChatType.Klienten)
|
|
{
|
|
AktChatUser.Items.Add(new KontaktlistBuilder(blub.Name, blub.StatusTyp, blub.Image, blub.EmpfaengerOid, blub.TypeChat, blub.Customer));
|
|
}
|
|
else
|
|
{
|
|
AktChatUser.Items.Add(new KontaktlistBuilder(blub.Name, blub.StatusTyp, blub.Image, blub.EmpfaengerOid, blub.TypeChat));
|
|
}
|
|
|
|
LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, blub.EmpfaengerOid, blub);
|
|
|
|
|
|
if (blub.TypeChat == ChatType.Klienten)
|
|
{
|
|
context.Visibility = Visibility.Visible;
|
|
Chat.SelectionMode = SelectionMode.Extended;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
context.Visibility = Visibility.Collapsed;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler siehe Fehlercode. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2370", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
private void ListBoxSelectedIndexChanged(object sender, System.EventArgs e)
|
|
{
|
|
KontaktlistBuilder curItem;
|
|
try
|
|
{
|
|
context.IsOpen = false;
|
|
|
|
if (!Clientlist.Items.IsEmpty)
|
|
{
|
|
curItem = (KontaktlistBuilder)Clientlist.SelectedItem;
|
|
|
|
Chat.Items.Clear();
|
|
|
|
AktChatUser.Items.Clear();
|
|
|
|
if (!curItem.Receivems.Equals(""))
|
|
{
|
|
curItem.Receivems = "";
|
|
}
|
|
|
|
if (curItem.TypeChat == ChatType.Klienten)
|
|
{
|
|
AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat, curItem.Customer));
|
|
}
|
|
else
|
|
{
|
|
AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat));
|
|
}
|
|
|
|
|
|
LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, curItem.EmpfaengerOid, curItem);
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
view.Refresh();
|
|
|
|
|
|
if (curItem.TypeChat == ChatType.Klienten)
|
|
{
|
|
context.Visibility = Visibility.Visible;
|
|
Chat.SelectionMode = SelectionMode.Extended;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
context.Visibility = Visibility.Collapsed;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception s)
|
|
{
|
|
curItem = null;
|
|
MessageBox.Show("Beim Auswählen eines Users ist ein Fehler aufgetreten. " + s.Message + "\n" + s.StackTrace, "Fehler: 2280 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public ImageSource BuildImg(Byte[] c)
|
|
{
|
|
try
|
|
{
|
|
if (c != null)
|
|
{
|
|
var biImg = new BitmapImage();
|
|
|
|
using (var ms = new MemoryStream(c))
|
|
{
|
|
biImg.BeginInit();
|
|
biImg.StreamSource = ms;
|
|
biImg.CacheOption = BitmapCacheOption.OnLoad;
|
|
biImg.EndInit();
|
|
|
|
}
|
|
return biImg;
|
|
}
|
|
else
|
|
{
|
|
//return null;
|
|
//return new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative));
|
|
BitmapImage bi = new BitmapImage();
|
|
bi.BeginInit();
|
|
bi.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png");
|
|
bi.EndInit();
|
|
return bi;
|
|
|
|
//return new ImageSource new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative));
|
|
|
|
//(ImageSource)
|
|
// new ImageSourceConverter().ConvertFromString(
|
|
// "../../Ressources/Icons/UserHomeBoyDisabled.png");
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Aufbauen der Profilbilder ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2290 ", MessageBoxButton.OK);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void setConnectionLostIcon()
|
|
{
|
|
System.Drawing.Icon icon = System.Drawing.SystemIcons.Warning;
|
|
BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
|
AlarmLabel.Source = bs;
|
|
|
|
ButtonAlarmLabel.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
public void SendMessage(long empfängeroid, ChatType type)
|
|
{
|
|
try
|
|
{
|
|
string msg = Chatbox.Text;
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, msg, DateTime.Now.ToString(), BeWoApp.LoggedOnUser.Employee.PersonOid,true));
|
|
|
|
|
|
if (tcpClient.Connected)
|
|
{
|
|
NetworkStream serverStream = tcpClient.GetStream();
|
|
|
|
Packet a = new Packet();
|
|
|
|
byte[] outStream;
|
|
|
|
if (type == ChatType.Team)
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.LoginName, msg, DataIdentifier.Team, BeWoApp.Tenant, false);
|
|
}
|
|
else
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.LoginName, msg, 0, BeWoApp.Tenant, false);
|
|
}
|
|
|
|
|
|
serverStream.Write(outStream, 0, outStream.Length);
|
|
serverStream.Flush();
|
|
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart)delegate { ServerStats.Text = "Nachricht erfolgreich gesendet"; });
|
|
}
|
|
else
|
|
{
|
|
SaveChatMessageinDB(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, msg, false, type);
|
|
}
|
|
}
|
|
catch (Exception xe)
|
|
{
|
|
if (tcpClient.Connected)
|
|
{
|
|
MessageBox.Show("Beim Senden einer Nachricht zum Server ist ein Fehler aufgetreten. " + xe.Message + "\n" + xe.StackTrace,
|
|
"Fehler: 2300 ", MessageBoxButton.OK);
|
|
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) // <--- Muss dass nicht Weg
|
|
delegate { ServerStats.Text = "Fehler: Die Nachricht konnte nicht gesendet werden."; });
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SaveChatMessageinDB(long senderoid, long empfangid, string message, bool istZugestellt, ChatType type)
|
|
{
|
|
try
|
|
{
|
|
if (type == ChatType.Team)
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(s => s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, empfangid));
|
|
}
|
|
else
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(s => s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, 0));
|
|
}
|
|
}
|
|
catch (InvalidOperationException e)
|
|
{
|
|
MessageBox.Show("Beim Speichern einer Nachricht in die Datenbank ist ein Fehler aufgetreten. " + e.Message + "\n" + e.StackTrace, "Fehler: 2310 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void LoadChatMessagefromDB(long senderoid, long empfaengerOid, KontaktlistBuilder Curitem)
|
|
{
|
|
try
|
|
{
|
|
if (Curitem.TypeChat == ChatType.Team)
|
|
{
|
|
int sx = 0;
|
|
|
|
var allTeamItems =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s => s.FindAllChatMessagesFromTeam(senderoid, empfaengerOid));
|
|
|
|
List<long> x = new List<long>();
|
|
|
|
foreach (var team in allTeamItems)
|
|
{
|
|
if (!x.Contains(team.SenderPersonOid.Value))
|
|
x.Add(team.SenderPersonOid.Value);
|
|
}
|
|
|
|
x.Sort();
|
|
|
|
|
|
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
|
|
|
foreach (var anzeige in allTeamItems)
|
|
{
|
|
|
|
if (x.Contains(anzeige.SenderPersonOid.Value))
|
|
{
|
|
|
|
/* if (sx == 0) // Muss noch getestet werden !!! bzw. muss noch angepast werden.
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("", "------------------------ Ungelesene Nachrichten -----------------------", "", 0));
|
|
sx++;
|
|
}*/
|
|
if (anzeige.SenderPersonOid.Value == BeWoApp.LoggedOnUser.Employee.PersonOid)
|
|
{
|
|
int zahl = (int)x.IndexOf(anzeige.SenderPersonOid.Value);
|
|
Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,
|
|
anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value,true));
|
|
|
|
}
|
|
else
|
|
{
|
|
int zahl = (int)x.IndexOf(anzeige.SenderPersonOid.Value);
|
|
Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,
|
|
anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, false));
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
var allitems =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s => s.FindAllChatMessages(senderoid, empfaengerOid));
|
|
|
|
List<long> x = new List<long>();
|
|
x.Add(senderoid);
|
|
x.Add(empfaengerOid);
|
|
|
|
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
|
|
|
int i = 0;
|
|
|
|
foreach (var list in allitems)
|
|
{
|
|
if (list.IstGelesen == 1 && (list.TeamOid == null || list.TeamOid == 0))
|
|
{
|
|
if (list.SenderPersonOid == senderoid)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid,true));
|
|
}
|
|
else
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid,false));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list.TeamOid == null || list.TeamOid == 0)
|
|
{
|
|
/* if (i == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("", "------------------------ Ungelesene Nachrichten -----------------------", "", 0));
|
|
i++;
|
|
}*/
|
|
|
|
if (list.SenderPersonOid == senderoid)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid,true));
|
|
}
|
|
else
|
|
{
|
|
if (i == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("", "------------------------ Ungelesene Nachrichten -----------------------", "", 0,false));
|
|
i++;
|
|
}
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid,false));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ServiceFacade.DoCustomerServiceSync(s => s.UpdateIstGelesen(empfaengerOid, senderoid, true));
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Laden einer Nachricht aus der Datenbank ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2320 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
//placeholder
|
|
private void OnFocus(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (Chatbox.Text.Equals("Nachricht schreiben")) // ----> Es muss geschaut werden, was man möchte
|
|
{
|
|
Chatbox.Text = "";
|
|
Chatbox.Foreground = new SolidColorBrush(Colors.Black);
|
|
}
|
|
|
|
|
|
|
|
if (emojiView != null)
|
|
{
|
|
if (emojiView.Visibility == Visibility.Visible)
|
|
{
|
|
emojiView.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler beim Fokusieren der Nachrichten Leiste. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2330 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
//Rechte Maus Taste an dem Chat
|
|
public void OnRightClickEvent(object sender, RoutedEventArgs e)
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
|
|
|
|
public void SmileyButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (emojiView == null)
|
|
{
|
|
emojiView = new ChatEmojisView();
|
|
|
|
var x = EmojiButton.PointToScreen(new Point(0, 0));
|
|
|
|
emojiView.Left = x.X;
|
|
emojiView.Top = x.Y - emojiView.Height - 5;
|
|
|
|
emojiView.Show();
|
|
}
|
|
else
|
|
{
|
|
if (emojiView.Visibility == Visibility.Visible)
|
|
{
|
|
emojiView.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
emojiView.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public class KontaktlistBuilder : INotifyPropertyChanged
|
|
{
|
|
public KontaktlistBuilder(string name, StatusType statustyp, ImageSource image, long empfaengerid, ChatType typeChat)
|
|
{
|
|
this.Name = name;
|
|
this.StatusTyp = statustyp;
|
|
this.Image = image;
|
|
this.EmpfaengerOid = empfaengerid;
|
|
|
|
Receivems = "";
|
|
TypeChat = typeChat;
|
|
|
|
if (statustyp == StatusType.Online)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.LightGreen);
|
|
//Color.Opacity = 0.5;
|
|
}
|
|
else if (statustyp == StatusType.Offline)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Orange); //"Beschäftigt"
|
|
}
|
|
}
|
|
|
|
public KontaktlistBuilder(string name, StatusType statustyp, ImageSource image, long empfaengerid, ChatType typeChat, CompactCustomerDC customer)
|
|
{
|
|
this.Customer = customer;
|
|
this.Name = name;
|
|
this.StatusTyp = statustyp;
|
|
this.Image = image;
|
|
this.EmpfaengerOid = empfaengerid;
|
|
|
|
Receivems = "";
|
|
TypeChat = typeChat;
|
|
|
|
if (statustyp == StatusType.Online)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.LightGreen);
|
|
}
|
|
else if (statustyp == StatusType.Offline)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Orange); //"Beschäftigt"
|
|
}
|
|
}
|
|
|
|
public string Name { get; private set; }
|
|
|
|
private StatusType _statustyp;
|
|
public StatusType StatusTyp { get { return _statustyp; } set { _statustyp = value;
|
|
|
|
if (_statustyp == StatusType.Online)
|
|
{
|
|
_color = new SolidColorBrush(Colors.LightGreen);
|
|
}
|
|
else if (_statustyp == StatusType.Offline)
|
|
{
|
|
_color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Orange); //"Beschäftigt"
|
|
}
|
|
|
|
OnPropertyChanged("Lastms"); } }
|
|
|
|
public ImageSource Image { get; private set; }
|
|
|
|
public long EmpfaengerOid { get; private set; }
|
|
|
|
private string _receivems;
|
|
public string Receivems { get { return _receivems; } set { _receivems = value; OnPropertyChanged("Receivems"); } }
|
|
|
|
public ChatType TypeChat { get; set; }
|
|
|
|
private Brush _color;
|
|
public Brush Color
|
|
{
|
|
get
|
|
{
|
|
return _color;}
|
|
set
|
|
{
|
|
if (StatusTyp == StatusType.Online)
|
|
{
|
|
_color = new SolidColorBrush(Colors.LightGreen);
|
|
}
|
|
else if (StatusTyp == StatusType.Offline)
|
|
{
|
|
_color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Orange); //"Beschäftigt"
|
|
}
|
|
|
|
//_color = value;
|
|
OnPropertyChanged("Color"); }
|
|
}
|
|
|
|
public CompactCustomerDC Customer { get; set; }
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
var handler = PropertyChanged;
|
|
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
|
|
public class KontakMessageBuilder
|
|
{
|
|
public KontakMessageBuilder(string username, string message, string sendtime, long messagePersonOid, bool isme)
|
|
{
|
|
Username = username;
|
|
UserMessage = message;
|
|
SendTime = sendtime;
|
|
MessagePersonOid = messagePersonOid;
|
|
|
|
if (isme)
|
|
{
|
|
ChatColor = new SolidColorBrush(Colors.Orange);
|
|
Posi = "Right";
|
|
}
|
|
else
|
|
{
|
|
ChatColor = new SolidColorBrush(Colors.LightGray);
|
|
Posi = "Left";
|
|
}
|
|
|
|
}
|
|
|
|
public string Username { get; private set; }
|
|
public string UserMessage { get; private set; }
|
|
public string SendTime { get; private set; }
|
|
public long MessagePersonOid { get; private set; }
|
|
public Brush ChatColor { get; private set; }
|
|
public int ChatPosition { get; private set; }
|
|
public string Posi { get; private set; }
|
|
}
|
|
}
|
|
|
|
|
|
|