3340 lines
130 KiB
C#
3340 lines
130 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.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Linq.Expressions;
|
|
using System.Media;
|
|
using System.Net;
|
|
using System.Security.Permissions;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using BeWo.View.Detail;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using DevExpress.Xpf.Core;
|
|
using DevExpress.Xpf.Docking;
|
|
using DevExpress.XtraEditors.Senders;
|
|
using DevExpress.XtraPrinting.Native;
|
|
using DevExpress.XtraPrinting.XamlExport;
|
|
using Microsoft.Office.Interop.Word;
|
|
//using NAudio.Wave;
|
|
using Brush = System.Windows.Media.Brush;
|
|
using Button = System.Windows.Forms.Button;
|
|
using Color = System.Drawing.Color;
|
|
using ContextMenu = System.Windows.Controls.ContextMenu;
|
|
using DataFormats = System.Windows.Forms.DataFormats;
|
|
using DragEventArgs = System.Windows.DragEventArgs;
|
|
using GiveFeedbackEventArgs = System.Windows.GiveFeedbackEventArgs;
|
|
using GroupBox = System.Windows.Forms.GroupBox;
|
|
using IDataObject = System.Windows.Forms.IDataObject;
|
|
using Image = System.Windows.Controls.Image;
|
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
|
using MenuItem = System.Windows.Controls.MenuItem;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
using Panel = System.Windows.Forms.Panel;
|
|
using Point = System.Windows.Point;
|
|
using SelectionMode = System.Windows.Controls.SelectionMode;
|
|
using Size = System.Windows.Size;
|
|
|
|
|
|
namespace BeWo.View
|
|
{
|
|
public partial class ChatView
|
|
{
|
|
public UserVM ViewModel { get; set; }
|
|
public int abr = 0;
|
|
|
|
private TcpClient tcpClient;
|
|
|
|
private CollectionView view;
|
|
|
|
private ChatEmojisView emojiView = null;
|
|
|
|
private List<KontaktlistBuilder> ita = new List<KontaktlistBuilder>();
|
|
private List<long> oidspeicher = new List<long>();
|
|
private List<string> teamdc = new List<string>();
|
|
private PropertyGroupDescription groupDescription;
|
|
private bool isOnFocus = false;
|
|
|
|
private bool SendtoServerFailes = false;
|
|
//Neu Sound und Datei Versende gedöns usw...
|
|
//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;
|
|
|
|
//Itemgrenze für anzeige
|
|
private int itemGrenze = 10;
|
|
private List<string> aktuelleChatMessageIDListe = new List<string>();
|
|
private List<string> aktuelleChatMessageIDListeforTeam = new List<string>();
|
|
|
|
private bool WeitereNachrichtSchalter = false;
|
|
|
|
|
|
public Dictionary<string, string> Speicherpfad = new Dictionary<string, string>();
|
|
|
|
private bool sortLabelSwitch = false;
|
|
|
|
private ContextMenu context;
|
|
|
|
public ChatView(String nameinf, String Chatinf, TcpClient tcpClient)
|
|
{
|
|
InitializeComponent();
|
|
|
|
rootGroupBox.Header = nameinf;
|
|
|
|
this.tcpClient = tcpClient;
|
|
|
|
CloseWindow();
|
|
LoadallChatKontakts();
|
|
ErstelleContextMenue();
|
|
|
|
Width = System.Windows.SystemParameters.PrimaryScreenWidth /2;
|
|
Height = System.Windows.SystemParameters.PrimaryScreenWidth / 2;
|
|
}
|
|
|
|
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;
|
|
|
|
if (emojiView != null && emojiView.Visibility == Visibility.Visible)
|
|
{
|
|
emojiView.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
Visibility = Visibility.Collapsed;
|
|
}));
|
|
}
|
|
|
|
public void SetText(String text, String nameclient, long personoid,int mediaart, byte[] media,string messageid)
|
|
{
|
|
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 = "";
|
|
|
|
if (mediaart == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(nameclient, text, DateTime.Now.ToString(), personoid,
|
|
false, false, null));
|
|
}
|
|
else
|
|
{
|
|
switch (mediaart)
|
|
{
|
|
case 1:
|
|
var bild = DecodeBild(media);
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(
|
|
BeWoApp.LoggedOnUser.Employee.FirstName, text,
|
|
DateTime.Now.ToString(), personoid, false, false, true, false, bild,
|
|
null, null, false, null, 0));
|
|
|
|
break;
|
|
case 2:
|
|
object[] x = new object[2];
|
|
|
|
x[0] = text;
|
|
x[1] = media;
|
|
x[2] = 0;
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, text,
|
|
DateTime.Now.ToString(), personoid, false, false, false, true, null,
|
|
text, null, false, x,0));
|
|
|
|
break;
|
|
case 3:
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
text, DateTime.Now.ToString(), curItem.EmpfaengerOid, true, true, false, false, null, null, null, false, null, 0));
|
|
break;
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
|
|
ServiceFacade.DoCustomerServiceSync(s => s.UpdateIstGelesenForOne(BeWoApp.LoggedOnUser.Employee.EmployeeOid, personoid, true,messageid));
|
|
}
|
|
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 SetAnzahlErhalteneNachricht(long personoid)
|
|
{
|
|
try
|
|
{
|
|
foreach (var abc in ita)
|
|
{
|
|
|
|
if (abc.EmpfaengerOid == personoid && abc.TypeChat != ChatType.Team)
|
|
{
|
|
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, BuildImgList(mitarbeiter.Images,ChatType.Mitarbeiter), 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;
|
|
|
|
if (variable.TypeChat == ChatType.Team)
|
|
{
|
|
foreach (var zug in zugehorigkeit)
|
|
{
|
|
if (zug.SimpleDescription.Equals(variable.Name))
|
|
{
|
|
variable.StatusTyp = StatusType.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, BuildImgList(klienten.Images,ChatType.Klienten), personoid, ChatType.Klienten, customerCompact);//"Online"
|
|
|
|
foreach (var variable in ita)
|
|
{
|
|
if (konbuild.Name.Equals(variable.Name))
|
|
variable.StatusTyp = StatusType.Online;
|
|
}
|
|
view.Refresh();
|
|
}
|
|
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
if (curItem.EmpfaengerOid == personoid)
|
|
{
|
|
curItem.StatusTyp = StatusType.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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
oidspeicher.Add(teamprof.EmpfaengerOid);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (oidspeicher.Count == 0)
|
|
{
|
|
foreach (var tt in ita)
|
|
{
|
|
if (tt.TypeChat == ChatType.Team)
|
|
{
|
|
tt.StatusTyp = StatusType.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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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; //Ungenutzt
|
|
}
|
|
|
|
private void SendButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals("") && isOnFocus)
|
|
{
|
|
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);
|
|
isOnFocus = false;
|
|
}
|
|
}
|
|
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);
|
|
isOnFocus = false;
|
|
}
|
|
}
|
|
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);
|
|
isOnFocus = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
|
|
foreach (var team in employeeteamoids)
|
|
{
|
|
Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null, ChatType.Team), 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, StatusType.Offline,
|
|
BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeThumbnail(list.EmployeeOid)),ChatType.Mitarbeiter),
|
|
list.PersonOid, ChatType.Mitarbeiter));
|
|
}
|
|
}
|
|
foreach (var list in offklienten)
|
|
{
|
|
|
|
Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, StatusType.Offline,
|
|
BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerThumbnail(list.CustomerOid)), ChatType.Klienten),
|
|
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);
|
|
view.SortDescriptions.Add(new SortDescription("Receivems", ListSortDirection.Descending));
|
|
// view.SortDescriptions.Add(new SortDescription("StatusType", ListSortDirection.Descending));
|
|
view.Filter = UserFilter;
|
|
|
|
if (sortLabelSwitch == true)
|
|
{
|
|
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(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
|
|
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,ChatType.Team), var.TeamOid, ChatType.Team));
|
|
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,
|
|
BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeThumbnail(var.EmployeeOid)),ChatType.Mitarbeiter),
|
|
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,
|
|
BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerThumbnail(var.CustomerOid)), ChatType.Klienten),
|
|
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();
|
|
}
|
|
|
|
if (sortLabelSwitch == true)
|
|
{
|
|
view.GroupDescriptions.Clear();
|
|
groupDescription = new PropertyGroupDescription("TypeChat");
|
|
view.GroupDescriptions.Add(groupDescription);
|
|
view.Refresh();
|
|
}
|
|
else
|
|
{
|
|
view.GroupDescriptions.Clear();
|
|
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;
|
|
}
|
|
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;
|
|
else if (type == DataIdentifier.StatusNotificationOnline)
|
|
list.StatusTyp = StatusType.Online;
|
|
else if (type == DataIdentifier.StatusNotificationOffline)
|
|
list.StatusTyp = StatusType.Offline;
|
|
}
|
|
}
|
|
view.Refresh();
|
|
}
|
|
|
|
|
|
private void ErstelleContextMenue()
|
|
{
|
|
try
|
|
{
|
|
context = new ContextMenu();
|
|
|
|
MenuItem item1 = new MenuItem();
|
|
MenuItem item2 = new MenuItem();
|
|
MenuItem item3 = new MenuItem();
|
|
|
|
context.Items.Add(item1);
|
|
context.Items.Add(item2);
|
|
context.Items.Add(item3);
|
|
|
|
item1.Header = "Dokumentieren";
|
|
item1.Visibility = Visibility.Visible;
|
|
item1.Click += OnChatRightClickMenue;
|
|
|
|
item2.Header = "Speichern unter";
|
|
item2.Visibility = Visibility.Visible;
|
|
item2.Click += onChatRightClickItem2;
|
|
|
|
item3.Header = "Einfügen";
|
|
item3.Visibility = Visibility.Visible;
|
|
item3.Click += onChatRightClickItem3;
|
|
|
|
Image icon = new Image();
|
|
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 eines neuen Chat Contextes ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2380 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void onChatRightClickItem3(object sender, RoutedEventArgs e)
|
|
{
|
|
var item = context.Items[2] as MenuItem;
|
|
|
|
item.Visibility = Visibility.Collapsed;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
|
|
var d = System.Windows.Forms.Clipboard.GetDataObject();
|
|
|
|
if (d.GetDataPresent(DataFormats.FileDrop))
|
|
{
|
|
string[] files = (String[])d.GetData(DataFormats.FileDrop);
|
|
|
|
string imgFileString = files[0];
|
|
|
|
|
|
if (isAnImage(imgFileString))
|
|
{
|
|
ZeigeProgressWärendUpload(1, imgFileString);
|
|
}
|
|
else
|
|
{
|
|
ZeigeProgressWärendUpload(2, imgFileString);
|
|
}
|
|
|
|
System.Windows.Forms.Clipboard.Clear();
|
|
}
|
|
else
|
|
{
|
|
if (d.GetDataPresent(DataFormats.Text))
|
|
{
|
|
string files = (String)d.GetData(DataFormats.Text);
|
|
|
|
string imgFileString = files;
|
|
|
|
try
|
|
{
|
|
byte[] data;
|
|
using (WebClient client = new WebClient())
|
|
{
|
|
data = client.DownloadData(imgFileString);
|
|
}
|
|
|
|
string filename = Path.GetFileName(imgFileString);
|
|
|
|
string isloaded = LoadDokumentFromInet(data, filename);
|
|
|
|
if (!isloaded.IsNullOrEmpty() && isAnImage(isloaded))
|
|
{
|
|
ZeigeProgressWärendUpload(1, isloaded);
|
|
}
|
|
else
|
|
{
|
|
ZeigeProgressWärendUpload(2, isloaded);
|
|
}
|
|
|
|
System.Windows.Forms.Clipboard.Clear();
|
|
}
|
|
catch (Exception s)
|
|
{
|
|
MessageBox.Show("Der Chat kann den Zwischen-Speicher nicht verarbeiten.", "Fehler", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (d.GetDataPresent(DataFormats.Bitmap))
|
|
{
|
|
Bitmap pic = (Bitmap)d.GetData(DataFormats.Bitmap);
|
|
|
|
var bildname = GeneriereZuffalsNamen() + ".jpg";
|
|
|
|
System.Drawing.Image img = pic;
|
|
|
|
var data = Utils.CreateByteArrayFromImage(img);
|
|
|
|
string isloaded = LoadDokumentFromInet(data, bildname);
|
|
|
|
if (!isloaded.IsNullOrEmpty() && isAnImage(isloaded))
|
|
{
|
|
ZeigeProgressWärendUpload(1, isloaded);
|
|
}
|
|
else
|
|
{
|
|
ZeigeProgressWärendUpload(2, isloaded);
|
|
}
|
|
|
|
System.Windows.Forms.Clipboard.Clear();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Der Chat kann den Zwischen-Speicher nicht verarbeiten.", "Fehler", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private string GeneriereZuffalsNamen()
|
|
{
|
|
int lenght = 6;
|
|
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
|
"abcdefghijklmnopqrstuvwxyz" +
|
|
"0123456789";
|
|
var random = new Random();
|
|
String Code = new string(Enumerable.Repeat(chars, lenght)
|
|
.Select(s => s[random.Next(s.Length)]).ToArray());
|
|
|
|
return Code;
|
|
}
|
|
|
|
|
|
public void onChatRightClickItem2(object sender, RoutedEventArgs e)
|
|
{
|
|
KontakMessageBuilder Item2;
|
|
|
|
if (Chat.SelectedItems.Count > 0 && Chat.SelectedItems.Count < 2 )
|
|
{
|
|
foreach (Object selecteditem in Chat.SelectedItems)
|
|
{
|
|
Item2 = selecteditem as KontakMessageBuilder;
|
|
|
|
if (Item2.PictureVisibility == Visibility.Visible)
|
|
{
|
|
if (Item2.ChatMessageOid.Value != 0)
|
|
{
|
|
SpeichernUnter(1,null, Item2.UserMessage,
|
|
Item2.ChatMessageOid.Value);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie besitzen bereits dieses Bild.", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
if (Item2.DokumentVisibility == Visibility.Visible)
|
|
{
|
|
if(Item2.ChatMessageOid.Value != 0){
|
|
SpeichernUnter(2, null, Item2.UserMessage, Item2.ChatMessageOid.Value);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie besitzen bereits dieses Dokument.", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
if (Item2.SoundVisibility == Visibility.Visible)
|
|
{
|
|
if (Item2.ChatMessageOid.Value != 0)
|
|
{
|
|
SpeichernUnter(3,null, Item2.UserMessage,
|
|
Item2.ChatMessageOid.Value);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie besitzen bereits dieses SoundFile.", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
if (Item2.SoundVisibility == Visibility.Collapsed && Item2.DokumentVisibility == Visibility.Collapsed && Item2.PictureVisibility == Visibility.Collapsed)
|
|
{
|
|
MessageBox.Show("Sie können keine normalen Chat Nachrichten Speichern.", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Um eine Datei Speichern zu können, dürfen sie nur eine Chat Nachricht auswählen","Info",MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void SpeichernUnter(int filterTyp, byte[] datensatz,string dateiname,long chatmessageoid)
|
|
{
|
|
try
|
|
{
|
|
datensatz = ServiceFacade.DoCustomerServiceSync(r => r.GetChatMedia(chatmessageoid));
|
|
|
|
if (datensatz != null)
|
|
{
|
|
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
|
|
|
saveFileDialog1.FileName = dateiname;
|
|
|
|
if (filterTyp == 1) // Bilder
|
|
{
|
|
saveFileDialog1.Filter = "Bilder |*.jpg;*.png;*.jpeg;*.jpe;*.gif;*.bmp";
|
|
saveFileDialog1.Title = "Bild Speichern";
|
|
saveFileDialog1.ShowDialog();
|
|
}
|
|
|
|
if (filterTyp == 2) //Office
|
|
{
|
|
saveFileDialog1.Filter = "Office Dokumente |*.doc;*.xls;*.ppt;*.txt";
|
|
saveFileDialog1.Title = "Dokument Speichern";
|
|
saveFileDialog1.ShowDialog();
|
|
}
|
|
|
|
if (filterTyp == 3) // Audio
|
|
{
|
|
saveFileDialog1.Filter = "Audio Datei|*.wav;*.mp3;*.wma;*.aac;*.ogg;";
|
|
saveFileDialog1.Title = "Audio Speichern";
|
|
saveFileDialog1.ShowDialog();
|
|
}
|
|
|
|
if (saveFileDialog1.FileName != "")
|
|
{
|
|
FileStream fs = (FileStream) saveFileDialog1.OpenFile();
|
|
|
|
fs.Write(datensatz, 0, datensatz.Length);
|
|
|
|
fs.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Die Datei wurde nicht gefunden.", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Beim Speichern der Datei ist ein Fehler aufgetreten."+e.Message+" \n" +e.StackTrace, "Fehler: 2395", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
}
|
|
|
|
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.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, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (RadioButtonOnline.IsChecked.Value)
|
|
{
|
|
if (tcpClient == null)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationOnline);
|
|
}
|
|
}
|
|
|
|
if (RadioButtonOffline.IsChecked.Value)
|
|
{
|
|
if (tcpClient == null)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationOffline);
|
|
}
|
|
}
|
|
|
|
if (RadioButtonBeschaeftigt.IsChecked.Value)
|
|
{
|
|
if (tcpClient == null)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else if (!tcpClient.Connected)
|
|
{
|
|
RadioButtonOffline.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
SendUserStatus(DataIdentifier.StatusNotificationBeschäftigt);
|
|
}
|
|
}
|
|
}
|
|
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();
|
|
|
|
var guid = Guid.NewGuid();
|
|
|
|
byte[] outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, 0,
|
|
BeWoApp.LoggedOnUser.LoginName, abc, identi, BeWoApp.Tenant, false, true, guid.ToString(),0,null);
|
|
|
|
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;
|
|
|
|
var item = context.Items[0] as MenuItem;
|
|
item.Visibility = Visibility.Visible;
|
|
|
|
Chat.SelectionMode = SelectionMode.Extended;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
context.Visibility = Visibility.Visible;
|
|
|
|
var item = context.Items[0] as MenuItem;
|
|
item.Visibility = Visibility.Collapsed;
|
|
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
}
|
|
}
|
|
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, EventArgs e)
|
|
{
|
|
KontaktlistBuilder curItem;
|
|
try
|
|
{
|
|
context.IsOpen = false;
|
|
|
|
if (!Clientlist.Items.IsEmpty)
|
|
{
|
|
curItem = (KontaktlistBuilder)Clientlist.SelectedItem;
|
|
|
|
Chat.Items.Clear();
|
|
|
|
AktChatUser.Items.Clear();
|
|
|
|
if(curItem != null){
|
|
|
|
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);
|
|
|
|
Suche.Text = "";
|
|
|
|
view.Refresh();
|
|
|
|
if (curItem.TypeChat == ChatType.Klienten)
|
|
{
|
|
context.Visibility = Visibility.Visible;
|
|
|
|
var item = context.Items[0] as MenuItem;
|
|
item.Visibility = Visibility.Visible;
|
|
|
|
Chat.SelectionMode = SelectionMode.Extended;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
context.Visibility = Visibility.Visible;
|
|
|
|
var item = context.Items[0] as MenuItem;
|
|
|
|
item.Visibility = Visibility.Collapsed;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
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 BuildImgList(List<Byte[]> images, ChatType x)
|
|
{
|
|
if (images != null && images.Count > 0)
|
|
{
|
|
return BuildImg(images[0], x);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public ImageSource BuildImg(Byte[] image, ChatType x)
|
|
{
|
|
try
|
|
{
|
|
if (image != null)
|
|
{
|
|
var biImg = new BitmapImage();
|
|
|
|
using (var ms = new MemoryStream(image))
|
|
{
|
|
biImg.BeginInit();
|
|
biImg.StreamSource = ms;
|
|
biImg.CacheOption = BitmapCacheOption.OnLoad;
|
|
biImg.EndInit();
|
|
|
|
}
|
|
return biImg;
|
|
}
|
|
else
|
|
{
|
|
if (x == ChatType.Klienten)
|
|
{
|
|
BitmapImage bix = new BitmapImage();
|
|
bix.BeginInit();
|
|
bix.UriSource = new Uri("pack://application:,,,/Ressources/icons/klient-avatar.png");
|
|
bix.EndInit();
|
|
return bix;
|
|
}else
|
|
if (x == ChatType.Mitarbeiter)
|
|
{
|
|
BitmapImage biy = new BitmapImage();
|
|
biy.BeginInit();
|
|
biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/mitarbeiter-avatar.png");
|
|
biy.EndInit();
|
|
return biy;
|
|
}else
|
|
if (x == ChatType.Team)
|
|
{
|
|
BitmapImage biz = new BitmapImage();
|
|
biz.BeginInit();
|
|
biz.UriSource = new Uri("pack://application:,,,/Ressources/icons/mitarbeiter-team-avatar.png");
|
|
biz.EndInit();
|
|
return biz;
|
|
}
|
|
else
|
|
{
|
|
BitmapImage bi = new BitmapImage();
|
|
bi.BeginInit();
|
|
bi.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png");
|
|
bi.EndInit();
|
|
return bi;
|
|
}
|
|
}
|
|
}
|
|
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,false,null));
|
|
|
|
if (tcpClient.Connected)
|
|
{
|
|
NetworkStream serverStream = tcpClient.GetStream();
|
|
|
|
Packet a = new Packet();
|
|
|
|
var guid = Guid.NewGuid();
|
|
|
|
byte[] outStream;
|
|
|
|
if (type == ChatType.Team)
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.Employee.FirstName + " " + BeWoApp.LoggedOnUser.Employee.LastName, msg, DataIdentifier.Team, BeWoApp.Tenant, false, true, guid.ToString(), 0, null);
|
|
}
|
|
else
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.Employee.FirstName + " " + BeWoApp.LoggedOnUser.Employee.LastName, msg, 0, BeWoApp.Tenant, false, true, guid.ToString(), 0, null);
|
|
}
|
|
|
|
serverStream.Write(outStream, 0, outStream.Length);
|
|
serverStream.Flush();
|
|
}
|
|
else
|
|
{
|
|
if (!SendtoServerFailes)
|
|
{
|
|
MessageBox.Show("Der Server steht zurzeit nicht zur verfügung. \nDie Nachrichten werden dennoch zur Datenbank übermittelt.", "Info", MessageBoxButton.OK);
|
|
SendtoServerFailes = true;
|
|
}
|
|
SaveChatMessageinDB(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, msg, false, type);
|
|
}
|
|
}
|
|
catch (Exception xe)
|
|
{
|
|
if (tcpClient.Connected)
|
|
{
|
|
MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + xe.Message + "\n" + xe.StackTrace,
|
|
"Fehler: 2300 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SaveChatMessageinDB(long senderoid, long empfangid, string message, bool istZugestellt, ChatType type)
|
|
{
|
|
try
|
|
{
|
|
var guid = Guid.NewGuid();
|
|
|
|
if (type == ChatType.Team)
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(
|
|
s =>
|
|
s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, empfangid,
|
|
guid.ToString()));
|
|
|
|
aktuelleChatMessageIDListeforTeam.Add(guid.ToString());
|
|
}
|
|
else
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(
|
|
s =>
|
|
s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, 0,
|
|
guid.ToString()));
|
|
aktuelleChatMessageIDListe.Add(guid.ToString());
|
|
}
|
|
}
|
|
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
|
|
{
|
|
aktuelleChatMessageIDListe.Clear();
|
|
aktuelleChatMessageIDListeforTeam.Clear();
|
|
|
|
if (Curitem.TypeChat == ChatType.Team)
|
|
{
|
|
var allTeamItems =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s => s.FindAllChatMessagesFromTeam(senderoid, empfaengerOid,itemGrenze));
|
|
|
|
ShowTeamMessageInChat(allTeamItems,true,0);
|
|
|
|
foreach (var item in allTeamItems)
|
|
{
|
|
aktuelleChatMessageIDListeforTeam.Add(item.MessageId);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var allitems2 =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s => s.FindAllChatMessages(senderoid, empfaengerOid, itemGrenze));
|
|
|
|
ShowMessageInChat(allitems2, true, senderoid, empfaengerOid,0);
|
|
|
|
foreach (var item in allitems2)
|
|
{
|
|
aktuelleChatMessageIDListe.Add(item.MessageId);
|
|
}
|
|
}
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
|
|
private void OnFocus(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (Chatbox.Text.Equals("Nachricht schreiben"))
|
|
{
|
|
Chatbox.Text = "";
|
|
Chatbox.Foreground = new SolidColorBrush(Colors.Black);
|
|
isOnFocus = true;
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void OnRightClickEvent(object sender, RoutedEventArgs e)
|
|
{
|
|
//################ Kopie und Paste gedönse ##########################
|
|
var d = System.Windows.Forms.Clipboard.GetDataObject();
|
|
|
|
var item = context.Items[2] as MenuItem;
|
|
|
|
|
|
//Daraus Switch case bastelln
|
|
if (d.GetDataPresent(DataFormats.FileDrop))
|
|
{
|
|
item.Visibility = Visibility.Visible;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
if (d.GetDataPresent(DataFormats.Text))
|
|
{
|
|
item.Visibility = Visibility.Visible;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
if (d.GetDataPresent(DataFormats.Bitmap))
|
|
{
|
|
item.Visibility = Visibility.Visible;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
else
|
|
{
|
|
item.Visibility = Visibility.Collapsed;
|
|
Chat.SelectionMode = SelectionMode.Single;
|
|
Chat.Focusable = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
//##############################################
|
|
|
|
|
|
e.Handled = true;
|
|
}
|
|
|
|
private bool isAnImage(string file)
|
|
{
|
|
try
|
|
{
|
|
System.Drawing.Image newImage = System.Drawing.Image.FromFile(file);
|
|
}
|
|
catch (OutOfMemoryException ex)
|
|
{
|
|
// Ist kein Image
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void SmileyButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (emojiView == null)
|
|
{
|
|
emojiView = new ChatEmojisView();
|
|
|
|
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.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
emojiView.Visibility = Visibility.Visible;
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void PruefeInDbObNeueNachrichtenVerfügbar()
|
|
{
|
|
try
|
|
{
|
|
|
|
ServiceFacade.DoOperationsServiceAsync(
|
|
s => s.FindUnreadChatMessagesForRecipient(BeWoApp.LoggedOnEmployee.PersonOid.Value),
|
|
m =>
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
foreach (var ChatMessage in m)
|
|
{
|
|
foreach (var aktChatPersons in ita)
|
|
{
|
|
if (aktChatPersons.EmpfaengerOid == ChatMessage.SenderPersonOid &&
|
|
aktChatPersons.TypeChat != ChatType.Team)
|
|
{
|
|
int aktc;
|
|
bool wasdrin = int.TryParse(aktChatPersons.Receivems, out aktc);
|
|
|
|
if (wasdrin)
|
|
{
|
|
aktc++;
|
|
aktChatPersons.Receivems = aktc.ToString();
|
|
|
|
}
|
|
else
|
|
aktChatPersons.Receivems = 1.ToString();
|
|
|
|
}
|
|
else if (aktChatPersons.EmpfaengerOid == ChatMessage.TeamOid && ChatMessage.SenderPersonOid != aktChatPersons.EmpfaengerOid)
|
|
{
|
|
int aktt;
|
|
bool wasdrin = int.TryParse(aktChatPersons.Receivems, out aktt);
|
|
|
|
if (wasdrin)
|
|
{
|
|
aktt++;
|
|
aktChatPersons.Receivems = aktt.ToString();
|
|
|
|
}
|
|
else
|
|
aktChatPersons.Receivems = 1.ToString();
|
|
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Fehler :" + e.Message + "\n" + e.StackTrace, "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
private void Suche_OnKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Return)
|
|
{
|
|
Suche.Text = "";
|
|
}
|
|
}
|
|
|
|
private void Suche_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
CollectionViewSource.GetDefaultView(Clientlist.ItemsSource).Refresh();
|
|
}
|
|
|
|
private bool UserFilter(object item)
|
|
{
|
|
if (String.IsNullOrEmpty(Suche.Text))
|
|
return true;
|
|
else
|
|
return ((item as KontaktlistBuilder).Name.IndexOf(Suche.Text, StringComparison.OrdinalIgnoreCase) >= 0);
|
|
}
|
|
|
|
private void Suche_OnLostFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
// Suche.Text = "";
|
|
}
|
|
|
|
|
|
private void ButtonSortLabel_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
if (sortLabelSwitch == false)
|
|
{
|
|
BitmapImage biy = new BitmapImage();
|
|
biy.BeginInit();
|
|
biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/sortiert.png");
|
|
biy.EndInit();
|
|
|
|
SortLabel.Source = biy;
|
|
|
|
sortLabelSwitch = true;
|
|
AktualisiereChatKontakt();
|
|
|
|
}
|
|
else
|
|
{
|
|
BitmapImage biy = new BitmapImage();
|
|
biy.BeginInit();
|
|
biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/unsortiert.png");
|
|
biy.EndInit();
|
|
|
|
SortLabel.Source = biy;
|
|
sortLabelSwitch = false;
|
|
AktualisiereChatKontakt();
|
|
|
|
}
|
|
}
|
|
|
|
private void AktChatUser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var offmitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact());
|
|
var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
|
|
using (Form form = new Form())
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
|
|
Image imgg = new Image();
|
|
|
|
|
|
if (curItem.TypeChat == ChatType.Mitarbeiter)
|
|
{
|
|
foreach (var list in offmitarbeiter)
|
|
{
|
|
if (list.PersonOid == curItem.EmpfaengerOid)
|
|
{
|
|
imgg.Source = BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(list.EmployeeOid)), curItem.TypeChat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (curItem.TypeChat == ChatType.Klienten)
|
|
{
|
|
|
|
foreach (var list in offklienten)
|
|
{
|
|
if (list.PersonOid == curItem.EmpfaengerOid)
|
|
{
|
|
imgg.Source = BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(list.CustomerOid)), curItem.TypeChat);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (curItem.TypeChat == ChatType.Team)
|
|
{
|
|
imgg.Source = BuildImg(null, curItem.TypeChat);
|
|
}
|
|
|
|
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
|
|
MemoryStream ms = new MemoryStream();
|
|
encoder.Frames.Add(BitmapFrame.Create((BitmapSource)imgg.Source));
|
|
encoder.Save(ms);
|
|
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
|
|
|
Bitmap imgbit = new Bitmap(img);
|
|
|
|
form.StartPosition = FormStartPosition.CenterScreen;
|
|
form.Size = imgbit.Size;
|
|
form.FormBorderStyle = FormBorderStyle.Sizable;
|
|
|
|
PictureBox pb = new PictureBox();
|
|
pb.Dock = DockStyle.Fill;
|
|
pb.Image = imgbit;
|
|
|
|
pb.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
|
|
form.Controls.Add(pb);
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Unbekannter Fehler: " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2392 ", MessageBoxButton.OK);
|
|
}
|
|
|
|
}
|
|
|
|
//################# Umbauen in ein Stream programm zum videochatten. #####################################################
|
|
private void ButtonVideoChat_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Code zum Abspielen von Sounds
|
|
private void PlayAufnahme_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
var btn = sender as System.Windows.Controls.Button;
|
|
|
|
var soundArray = btn.Tag;
|
|
|
|
//Verarbeite den SoundArray
|
|
//byte array
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Abspielen Aufnahme");
|
|
|
|
|
|
|
|
|
|
//Image img = FindChildControl<Image>(this, "image") as Image;
|
|
//img.Source = new BitmapImage(new Uri(@"..\..\Ressources\Icons\ClipboardDisabled.png", UriKind.Relative));
|
|
|
|
|
|
//btn.Image = new Bitmap("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png");
|
|
|
|
// if (mediaPlayer == null/*waveOutDevice == null*/)
|
|
// {
|
|
//simpleSound = new SoundPlayer(@"C:\Temp\WOMBO.mp3"); // Lade hier den Zwischenspeicher der noch erstellt werden soll und den Pfad der wav datei enthält
|
|
//simpleSound.Play();
|
|
|
|
/*waveOutDevice = new WaveOut();
|
|
audioFileReader = new AudioFileReader(@"C:\Temp\WOMBO.mp3");
|
|
|
|
waveOutDevice.Init(audioFileReader);
|
|
waveOutDevice.Play();
|
|
*/
|
|
// InitialiseMediaPlayer();
|
|
// }
|
|
// else
|
|
// {
|
|
//simpleSound.Stop();
|
|
//simpleSound = null;
|
|
|
|
// mediaPlayer.Stop();
|
|
// mediaPlayerTimer.Stop();
|
|
// mediaPlayer = null;
|
|
// mediaPlayerTimer = null;
|
|
/*waveOutDevice.Stop();
|
|
audioFileReader.Dispose();
|
|
waveOutDevice.Dispose();
|
|
waveOutDevice = null;
|
|
audioFileReader = null;*/
|
|
// }
|
|
|
|
Console.WriteLine("Abspielen Beendet");
|
|
}
|
|
|
|
|
|
//######################## Test phasen für Sound Datei ##########################
|
|
/* MediaPlayer mediaPlayer = null;
|
|
DispatcherTimer mediaPlayerTimer = null;
|
|
KontakSliderBuilder newSlide = new KontakSliderBuilder();
|
|
private void InitialiseMediaPlayer()
|
|
{
|
|
mediaPlayer = new MediaPlayer();
|
|
mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;
|
|
mediaPlayer.Open(new Uri(@"C:\Temp\WOMBO.mp3", UriKind.Absolute));
|
|
}
|
|
|
|
private void MediaPlayer_MediaOpened(object sender, EventArgs e)
|
|
{
|
|
if (mediaPlayer.NaturalDuration.HasTimeSpan)
|
|
{
|
|
newSlide.sliderMaximum = mediaPlayer.NaturalDuration.TimeSpan.TotalSeconds;
|
|
mediaPlayerTimer = new DispatcherTimer();
|
|
mediaPlayerTimer.Interval = TimeSpan.FromMilliseconds(1000);
|
|
mediaPlayerTimer.Tick += MediaPlayerTimer_Tick;
|
|
mediaPlayerTimer.Start();
|
|
mediaPlayer.Play();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void MediaPlayerTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
if (mediaPlayer != null)
|
|
{
|
|
newSlide.position = mediaPlayer.Position.TotalSeconds;
|
|
newSlide.time = mediaPlayer.Position;
|
|
}
|
|
}*/
|
|
//##################################################################################
|
|
|
|
private void Sound_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
/* if (WaveIn.DeviceCount != 0)
|
|
{
|
|
try
|
|
{
|
|
WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(0);
|
|
Console.WriteLine("Device {0}: {1}, {2} channels", WaveIn.DeviceCount, deviceInfo.ProductName,
|
|
deviceInfo.Channels);
|
|
|
|
waveSource = new WaveIn();
|
|
waveSource.WaveFormat = new WaveFormat(441000, 2);
|
|
// waveSource.DeviceNumber = 1;
|
|
waveSource.DataAvailable += waveSource_DataAvailable;
|
|
waveSource.RecordingStopped += waveSource_RecordingStopped;
|
|
|
|
// waveFile = new WaveFileWriter(@"C:\Temp\Ich_Hau_Dich.wav", waveSource.WaveFormat); // <---- Muss abgesprochen werden
|
|
|
|
|
|
waveSource.StartRecording(); //<---- Da gibt es zurzeit probleme, der grund könnte mit dem mic zusammen hängen.
|
|
}
|
|
catch (Exception f)
|
|
{
|
|
|
|
MessageBox.Show("Unbekannter Fehler: " + f.Message + "\n" + f.StackTrace, "Fehler: 2393 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// MessageBox.Show("Bitte Schließen sie ein Microfon an, um diese Funktion nutzen zu können.", "Kein Microfon vorhanden.",MessageBoxButton.OK);
|
|
}*/
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte Wählen sie einen Chat Partner aus", "Info", MessageBoxButton.OK);
|
|
}
|
|
|
|
}
|
|
|
|
private void Sound_OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
/*if (WaveIn.DeviceCount != 0)
|
|
{
|
|
waveSource.StopRecording();
|
|
}*/
|
|
//übergebe gespeicherte aufnahme an prozess zum senden/speichern WOMBO.mp3
|
|
// ZeigeProgressWärendUpload(3, @"C:\Temp\WOMBO.mp3");
|
|
}
|
|
|
|
}
|
|
|
|
//testen
|
|
/* private void waveSource_DataAvailable(object sender, WaveInEventArgs e)
|
|
{
|
|
if (waveFile != null)
|
|
{
|
|
waveFile.Write(e.Buffer, 0, e.BytesRecorded);
|
|
waveFile.Flush();
|
|
}
|
|
}
|
|
|
|
////testen
|
|
private void waveSource_RecordingStopped(object sender, StoppedEventArgs e)
|
|
{
|
|
if (waveSource != null)
|
|
{
|
|
waveSource.Dispose();
|
|
waveSource = null;
|
|
}
|
|
|
|
if (waveFile != null)
|
|
{
|
|
waveFile.Dispose();
|
|
waveFile = null;
|
|
}
|
|
}
|
|
*/
|
|
|
|
//fertig | design aber noch nicht
|
|
private void MediaBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (AktChatUser.Items.Count != 0)
|
|
{
|
|
using ( form1 = new Form())
|
|
{
|
|
|
|
form1.StartPosition = FormStartPosition.CenterParent;
|
|
form1.Size = new System.Drawing.Size(260, 80);
|
|
form1.FormBorderStyle = FormBorderStyle.FixedSingle;
|
|
form1.Text = "Media";
|
|
|
|
Button btnPic = new Button();
|
|
btnPic.Text = "Bild";
|
|
btnPic.Name = "Pic";
|
|
btnPic.Size = new System.Drawing.Size(120, 45);
|
|
btnPic.Margin = new Padding(2,2,2,2);
|
|
btnPic.TextAlign = ContentAlignment.MiddleCenter;
|
|
btnPic.Click += buttonMedia_Click;
|
|
|
|
|
|
Button btnDok = new Button();
|
|
btnDok.Text = "Dokument";
|
|
btnDok.Name = "Dok";
|
|
btnDok.Size = new System.Drawing.Size(120, 45);
|
|
btnDok.Margin = new Padding(2,2,2,2);
|
|
btnDok.Location = new System.Drawing.Point(125,0);
|
|
btnDok.TextAlign = ContentAlignment.MiddleCenter;
|
|
btnDok.Click += buttonMedia_Click;
|
|
|
|
form1.Controls.Add(btnPic);
|
|
form1.Controls.Add(btnDok);
|
|
|
|
|
|
form1.ShowDialog();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte Wählen sie einen Chat Partner aus", "Info", MessageBoxButton.OK);
|
|
}
|
|
|
|
}
|
|
|
|
//fertig
|
|
public void buttonMedia_Click(object s,EventArgs x)
|
|
{
|
|
try
|
|
{
|
|
Button btn = (Button) s;
|
|
int typ = 0;
|
|
|
|
if (btn.Name.Equals("Pic"))
|
|
typ = 1;
|
|
else
|
|
typ = 2;
|
|
|
|
OpenFileDialog openFileDialog1 = new OpenFileDialog();
|
|
|
|
if(typ == 1)
|
|
openFileDialog1.Filter = "Bilder |*.jpg;*.png;*.jpeg;*.jpe;*.gif;*.bmp";
|
|
else
|
|
openFileDialog1.Filter = "Office Dokumente |*.doc;*.xls;*.ppt;*.txt";
|
|
|
|
DialogResult result = openFileDialog1.ShowDialog();
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
ZeigeProgressWärendUpload(typ,openFileDialog1.FileName);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Unbekannter Fehler: " + e.Message + "\n" + e.StackTrace, "Fehler: 2394 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
private void ZeigeProgressWärendUpload(int mediaart, string file)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0];
|
|
string filename = "";
|
|
|
|
try
|
|
{
|
|
filename = Path.GetFileName(file);
|
|
|
|
Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Background,
|
|
(Action)(() =>
|
|
{
|
|
progressView = new ChatProgressBarView("Upload");
|
|
progressView.Show();
|
|
|
|
var upload = new ProgressStream(File.OpenRead(file));
|
|
|
|
upload.ProgressChanged += (s, e) => Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Normal,
|
|
(Action)(() =>
|
|
{
|
|
progressView.progressBar.Value = e.Data * 100;
|
|
}));
|
|
|
|
SendSpeziallToServer(curItem.EmpfaengerOid, curItem.TypeChat, filename, upload, mediaart);
|
|
|
|
}));
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Es ist ein Fehler beim speichern der Datei aufgetreten. \n" + edf.Message + "\n" + edf.StackTrace, "Fehler", MessageBoxButton.OK);
|
|
}
|
|
|
|
try
|
|
{
|
|
switch (mediaart)
|
|
{
|
|
case 1:
|
|
ImageSource imageSource = new BitmapImage(new Uri(file));
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
filename, DateTime.Now.ToString(), curItem.EmpfaengerOid, true, false, true, false,
|
|
imageSource,null,null,false,null,0));
|
|
break;
|
|
case 2:
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
filename, DateTime.Now.ToString(), curItem.EmpfaengerOid, true, false, false, true, null, file, null, false, null,0));
|
|
break;
|
|
case 3:
|
|
Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
filename, DateTime.Now.ToString(), curItem.EmpfaengerOid, true, true, false, false, null, null, null, false, null,0));
|
|
break;
|
|
}
|
|
Chat.Items.MoveCurrentToLast();
|
|
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
|
}
|
|
catch (Exception edfx)
|
|
{
|
|
MessageBox.Show("Bitte wählen sie das richtige Dateiformat aus. \n" + edfx.Message + "\n" + edfx.StackTrace, "Fehler: Falsches Dateiformat", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
private void SendSpeziallToServer(long empfängeroid, ChatType type, string filename, Stream istream,int mediatyp)
|
|
{
|
|
if (tcpClient.Connected)
|
|
{
|
|
NetworkStream serverStream = tcpClient.GetStream();
|
|
|
|
Packet a = new Packet();
|
|
|
|
byte[] outStream;
|
|
|
|
byte[] mdatei = Utils.ReadFully(istream);
|
|
|
|
var guid = Guid.NewGuid();
|
|
|
|
if (type == ChatType.Team)
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.Employee.FirstName + " " + BeWoApp.LoggedOnUser.Employee.LastName, filename, DataIdentifier.Team, BeWoApp.Tenant, false, true, guid.ToString(), mediatyp, mdatei);
|
|
}
|
|
else
|
|
{
|
|
outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.Employee.FirstName + " " + BeWoApp.LoggedOnUser.Employee.LastName, filename, 0, BeWoApp.Tenant, false, true, guid.ToString(), mediatyp, mdatei);
|
|
}
|
|
|
|
serverStream.Write(outStream, 0, outStream.Length);
|
|
|
|
serverStream.Flush();
|
|
|
|
|
|
if (form1 != null)
|
|
{
|
|
form1.Close();
|
|
}
|
|
progressView.Close();
|
|
istream.Dispose();
|
|
}
|
|
else
|
|
{
|
|
SaveChatSpeziallMessageinDB(type, BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, filename, false,mediatyp,istream);
|
|
}
|
|
}
|
|
|
|
|
|
private void SaveChatSpeziallMessageinDB(ChatType type, long senderoid, long empfangid, string message, bool istZugestellt, int mediatype, Stream upload)
|
|
{
|
|
UploadChatPackage chatpack;
|
|
var guid = Guid.NewGuid();
|
|
|
|
if (type == ChatType.Team)
|
|
{
|
|
chatpack = new UploadChatPackage(empfangid, istZugestellt, mediatype, message,guid.ToString() ,senderoid, empfangid, upload);
|
|
aktuelleChatMessageIDListeforTeam.Add(guid.ToString());
|
|
}
|
|
else
|
|
{
|
|
chatpack = new UploadChatPackage(empfangid, istZugestellt, mediatype, message,guid.ToString(), senderoid, 0, upload);
|
|
aktuelleChatMessageIDListe.Add(guid.ToString());
|
|
}
|
|
|
|
try
|
|
{
|
|
ServiceFacade.DoStreamingServiceAsync(s => s.CreateNewSpeziallStreamChatMessagesDC(chatpack),
|
|
r => this.Dispatch(
|
|
delegate
|
|
{
|
|
if (form1 != null)
|
|
{
|
|
form1.Close();
|
|
}
|
|
progressView.Close();
|
|
upload.Dispose();
|
|
}),
|
|
() => this.Dispatch(
|
|
delegate
|
|
{
|
|
if (form1 != null)
|
|
{
|
|
form1.Close();
|
|
}
|
|
progressView.Close();
|
|
upload.Dispose();
|
|
}));
|
|
}
|
|
catch (Exception edfg)
|
|
{
|
|
MessageBox.Show("Ups, Da ging was schief. \nBitte Versuchen sie es Erneut. \nFehler: "+edfg.Message,"Fehler",MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
private ImageSource DecodeBild(byte[] byteVal)
|
|
{
|
|
try
|
|
{
|
|
var image = new BitmapImage();
|
|
using (var mem = new MemoryStream(byteVal))
|
|
{
|
|
mem.Position = 0;
|
|
image.BeginInit();
|
|
image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
|
|
image.CacheOption = BitmapCacheOption.OnLoad;
|
|
image.UriSource = null;
|
|
image.StreamSource = mem;
|
|
image.EndInit();
|
|
}
|
|
return image;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenDokument_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var btn = sender as System.Windows.Controls.Button;
|
|
|
|
if (btn.Tag != null)
|
|
{
|
|
var filename = btn.Tag;
|
|
|
|
var fileType = filename.GetType();
|
|
|
|
|
|
if (fileType == typeof (String))
|
|
{
|
|
Process.Start(filename.ToString());
|
|
|
|
if (!Speicherpfad.ContainsKey(filename.ToString()))
|
|
Speicherpfad.Add(filename.ToString(), filename.ToString());
|
|
}
|
|
else if (fileType == typeof (object[]))
|
|
{
|
|
var dokarray = (object[]) btn.Tag;
|
|
|
|
string file = dokarray[0].ToString();
|
|
byte[] dokByte = (byte[]) dokarray[1];
|
|
long? chatMessageOid = (long?) dokarray[2];
|
|
|
|
byte[] dokBytes;
|
|
|
|
if (dokByte == null)
|
|
{
|
|
dokBytes = ServiceFacade.DoCustomerServiceSync(r => r.GetChatMedia(chatMessageOid.Value));
|
|
LoadDokument(dokBytes, file);
|
|
}
|
|
else
|
|
{
|
|
LoadDokument(dokByte, file);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void LoadDokument(byte[] dokBytes, String file)
|
|
{
|
|
if (dokBytes != null)
|
|
{
|
|
string path = @"c:\temp\" + file;
|
|
|
|
if (File.Exists(path))
|
|
{
|
|
try
|
|
{
|
|
File.Delete(path);
|
|
|
|
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
|
{
|
|
SourceStream.Seek(0, SeekOrigin.End);
|
|
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
|
{
|
|
SourceStream.Seek(0, SeekOrigin.End);
|
|
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
|
}
|
|
}
|
|
|
|
|
|
Process.Start(path);
|
|
|
|
if (!Speicherpfad.ContainsKey(file))
|
|
Speicherpfad.Add(file, path);
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Die Datei wurde nicht Gefunden", "Info", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
private string LoadDokumentFromInet(byte[] dokBytes, String file)
|
|
{
|
|
if (dokBytes != null)
|
|
{
|
|
string path = @"c:\temp\" + file;
|
|
|
|
if (File.Exists(path))
|
|
{
|
|
try
|
|
{
|
|
File.Delete(path);
|
|
|
|
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
|
{
|
|
SourceStream.Seek(0, SeekOrigin.End);
|
|
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
|
{
|
|
SourceStream.Seek(0, SeekOrigin.End);
|
|
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
|
}
|
|
}
|
|
|
|
if (!Speicherpfad.ContainsKey(file))
|
|
Speicherpfad.Add(file, path);
|
|
|
|
return path;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Die Datei wurde nicht Gefunden", "Info", MessageBoxButton.OK);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
//private void myProcess_Exited(object sender, EventArgs e)
|
|
//{
|
|
// var x = (Process)sender;
|
|
|
|
// try
|
|
// {
|
|
// if (File.Exists(x.StartInfo.FileName))
|
|
// {
|
|
// File.Delete(x.StartInfo.FileName);
|
|
// MessageBox.Show("File wurde erfolgreich deletet/ ID: " + x.Id, "File Deletet Info", MessageBoxButton.OK);
|
|
// }
|
|
// }
|
|
// catch (Exception)
|
|
// {
|
|
// MessageBox.Show("File Wurde bereits gelöscht / ID: " + x.Id + " / Filename: " + x.StartInfo.FileName, "File Deletet Info", MessageBoxButton.OK);
|
|
// }
|
|
//}
|
|
|
|
private void ChatView_OnStateChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
this.WindowState = WindowState.Normal;
|
|
}
|
|
}
|
|
|
|
//VerunVolständigt
|
|
//private void AudioSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
|
//{
|
|
|
|
// var slider = sender as Slider;
|
|
|
|
// slider.Minimum = 0;
|
|
// slider.Maximum = audioFileReader.Length;
|
|
// slider.Value = (int)audioFileReader.Position;
|
|
//}
|
|
|
|
//Lade Media Daten aus der Datenbank
|
|
private void DatenRunterladen_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
System.Windows.Controls.Button x = (System.Windows.Controls.Button)sender;
|
|
|
|
object[] array = (object[])x.Tag;
|
|
|
|
ChatMessageDC messagedc = (ChatMessageDC) array[0];
|
|
|
|
KontakMessageBuilder kontaktmessage = (KontakMessageBuilder) array[1];
|
|
|
|
var index = Chat.Items.IndexOf(kontaktmessage);
|
|
|
|
if(messagedc.MediaTyp == 1)
|
|
kontaktmessage.PictureVisibility = Visibility.Visible;
|
|
else if(messagedc.MediaTyp == 2)
|
|
kontaktmessage.DokumentVisibility = Visibility.Visible;
|
|
|
|
kontaktmessage.Herunterladen = Visibility.Collapsed;
|
|
|
|
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;
|
|
System.Windows.Controls.Image x = (System.Windows.Controls.Image)sender;
|
|
|
|
List<ChatMessageDC> chatlist = (List<ChatMessageDC>)x.Tag;
|
|
|
|
senderoid = chatlist[0].SenderPersonOid ?? 0;
|
|
empfaengeroid = chatlist[0].EmpfängerPersonOid ?? 0;
|
|
|
|
List<ChatMessageDC> newitems;
|
|
|
|
if (chatlist[0].TeamOid == 0 || chatlist[0].TeamOid == null)
|
|
{
|
|
newitems =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s =>
|
|
s.GetNextChatMessages(senderoid, empfaengeroid, false, aktuelleChatMessageIDListe,
|
|
itemGrenze));
|
|
}
|
|
else
|
|
{
|
|
newitems =
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s =>
|
|
s.GetNextChatMessages(senderoid, empfaengeroid, true, aktuelleChatMessageIDListeforTeam,
|
|
itemGrenze));
|
|
}
|
|
|
|
|
|
if(newitems.Count > 0){
|
|
|
|
if (chatlist[0].TeamOid != null)
|
|
{
|
|
foreach (var item in newitems)
|
|
{
|
|
if (!aktuelleChatMessageIDListeforTeam.Contains(item.MessageId))
|
|
aktuelleChatMessageIDListeforTeam.Add(item.MessageId);
|
|
}
|
|
|
|
var zahl = ServiceFacade.DoCustomerServiceSync(
|
|
s =>
|
|
s.CountChatMessages(aktuelleChatMessageIDListeforTeam.Count,senderoid,empfaengeroid,true));
|
|
|
|
if (zahl == 0)
|
|
WeitereNachrichtSchalter = true;
|
|
|
|
ShowTeamMessageInChat(newitems,false,1);
|
|
}
|
|
else{
|
|
|
|
foreach (var item in newitems)
|
|
{
|
|
if (!aktuelleChatMessageIDListe.Contains(item.MessageId))
|
|
aktuelleChatMessageIDListe.Add(item.MessageId);
|
|
}
|
|
|
|
var zahl = ServiceFacade.DoCustomerServiceSync(
|
|
s =>
|
|
s.CountChatMessages(aktuelleChatMessageIDListe.Count, senderoid, empfaengeroid,false));
|
|
|
|
|
|
if (zahl == 0)
|
|
WeitereNachrichtSchalter = true;
|
|
|
|
ShowMessageInChat(newitems, false,chatlist[0].SenderPersonOid,chatlist[0].EmpfängerPersonOid,1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var itemprop = (KontakMessageBuilder)Chat.Items[0];
|
|
|
|
if(itemprop.MessagePersonOid == 0)
|
|
Chat.Items.RemoveAt(0);
|
|
}
|
|
|
|
if (WeitereNachrichtSchalter)
|
|
{
|
|
var itemprop = (KontakMessageBuilder)Chat.Items[0];
|
|
|
|
if (itemprop.MessagePersonOid == 0)
|
|
Chat.Items.RemoveAt(0);
|
|
|
|
WeitereNachrichtSchalter = false;
|
|
}
|
|
|
|
}
|
|
|
|
#region ChatMessagebuilder
|
|
private void ShowMessageInChat(List<ChatMessageDC> allitems2, bool firstTime, long? sendoid, long? empfangOid, int i)
|
|
{
|
|
try
|
|
{
|
|
var allitems = allitems2.OrderBy(dc => dc.Uhrzeit).ToList();
|
|
|
|
long senderoid = sendoid ?? 0;
|
|
long empfaengerOid = empfangOid ?? 0;
|
|
|
|
if (firstTime)
|
|
{
|
|
if (allitems.Count == itemGrenze)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("","------------------------ Mehr Nachrichten Vorhanden ---------------------------------","", 0, false, true, allitems));
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
object[] datenmengen = new object[2];
|
|
datenmengen[0] = list;
|
|
|
|
if (list.IstGelesen == 1 && (list.TeamOid == null || list.TeamOid == 0))
|
|
{
|
|
if (list.SenderPersonOid == senderoid)
|
|
{
|
|
if (list.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid, true, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (list.MediaTyp == 1)
|
|
{
|
|
|
|
var bild = DecodeBild(list.ImageThumpNail);
|
|
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid, true, false, true, false, bild, null,
|
|
null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
|
|
//if (list.MediaTyp == 3)
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(list.ChatText))
|
|
// SoundZwischenSpeicher.Add(list.ChatText,list.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText, list.Uhrzeit.ToString(), senderoid, true, true, false, false, null,null,null));
|
|
//}
|
|
|
|
if (list.MediaTyp == 2)
|
|
{
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid, true, false, false, true, null,
|
|
list.ChatText, null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (list.MediaTyp == 1)
|
|
{
|
|
var bild = DecodeBild(list.ImageThumpNail);
|
|
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, true, false, bild,
|
|
null, null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
|
|
//if (list.MediaTyp == 3)
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(list.ChatText))
|
|
// SoundZwischenSpeicher.Add(list.ChatText, list.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText, list.Uhrzeit.ToString(), empfaengerOid, true, true, false, false, null,null,null));
|
|
//}
|
|
|
|
if (list.MediaTyp == 2)
|
|
{
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, false, true, null,
|
|
list.ChatText, null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list.TeamOid == null || list.TeamOid == 0)
|
|
{
|
|
if (list.SenderPersonOid == senderoid)
|
|
{
|
|
if (list.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), senderoid, true, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (list.MediaTyp == 1)
|
|
{
|
|
|
|
var bild = DecodeBild(list.ImageThumpNail);
|
|
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
list.ChatText, list.Uhrzeit.ToString(), senderoid, true, false, true,
|
|
false, bild, null, null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
|
|
//if (list.Mediatyp == 3 )
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(list.ChatText))
|
|
// SoundZwischenSpeicher.Add(list.ChatText, list.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText, list.Uhrzeit.ToString(), senderoid, true, true, false, false, null,null,null));
|
|
//}
|
|
|
|
if ( list.MediaTyp == 2)
|
|
{
|
|
KontakMessageBuilder builder =
|
|
new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
list.ChatText, list.Uhrzeit.ToString(), senderoid, true, false, false,
|
|
true, null, list.ChatText, null, false, datenmengen, list.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (i == 0 && list.IstGelesen == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("",
|
|
"------------------------ Ungelesene Nachrichten -----------------------", "", 0,
|
|
false, false, null));
|
|
i++;
|
|
}
|
|
|
|
if (list.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (list.MediaTyp == 1)
|
|
{
|
|
|
|
var bild = DecodeBild(list.ImageThumpNail);
|
|
|
|
Chat.Items.Add(new KontakMessageBuilder(
|
|
BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, true, false, bild,
|
|
null, null, false, datenmengen, list.ChatMessagesOid));
|
|
}
|
|
|
|
//if (list.Mediatyp == 3 )
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(list.ChatText))
|
|
// SoundZwischenSpeicher.Add(list.ChatText, list.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText, list.Uhrzeit.ToString(), empfaengerOid, true, true, false, false, null,null,null));
|
|
//}
|
|
|
|
if (list.MediaTyp == 2)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(
|
|
BeWoApp.LoggedOnUser.Employee.FirstName, list.ChatText,
|
|
list.Uhrzeit.ToString(), empfaengerOid, false, false, false, true, null,
|
|
list.ChatText, null, false, datenmengen,list.ChatMessagesOid));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ServiceFacade.DoCustomerServiceSync(s => s.UpdateIstGelesen(empfaengerOid, senderoid, true));
|
|
|
|
var lisadst = Chat.Items.Cast<KontakMessageBuilder>().OrderBy(item => item.SendTime).ToList();
|
|
|
|
Chat.Items.Clear();
|
|
foreach (KontakMessageBuilder listItem in lisadst)
|
|
{
|
|
Chat.Items.Add(listItem);
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Laden der Nachricht aus der Datenbank ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2320 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ChatTeamMessageBuilder
|
|
|
|
private void ShowTeamMessageInChat(List<ChatMessageDC> allTeamItems2,bool firstTime, int sx)
|
|
{
|
|
try
|
|
{
|
|
// int sx = 0;
|
|
|
|
var allTeamItems = allTeamItems2.OrderBy(dc => dc.Uhrzeit).ToList();
|
|
|
|
if (firstTime)
|
|
{
|
|
if (allTeamItems.Count == itemGrenze)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("",
|
|
"------------------------ Mehr Nachrichten Vorhanden ----------------------------------",
|
|
"", 0, false, true, allTeamItems));
|
|
}
|
|
}
|
|
|
|
|
|
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))
|
|
{
|
|
object[] datenmengen = new object[2];
|
|
datenmengen[0] = anzeige;
|
|
|
|
if (anzeige.SenderPersonOid.Value == BeWoApp.LoggedOnUser.Employee.PersonOid)
|
|
{
|
|
int zahl = (int) x.IndexOf(anzeige.SenderPersonOid.Value);
|
|
|
|
|
|
if (anzeige.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,
|
|
anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, true, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (anzeige.MediaTyp == 1)
|
|
{
|
|
|
|
var bild = DecodeBild(anzeige.ImageThumpNail);
|
|
|
|
KontakMessageBuilder builder = new KontakMessageBuilder(person[zahl].FirstName,
|
|
anzeige.ChatText, anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value,
|
|
true, false, true, false, bild, null, null, false, datenmengen, anzeige.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
|
|
//if (anzeige.MediaTyp == 3)
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(anzeige.ChatText))
|
|
// SoundZwischenSpeicher.Add(anzeige.ChatText, anzeige.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, true, true, false,false, null,null,null));
|
|
//}
|
|
|
|
if (anzeige.MediaTyp == 2)
|
|
{
|
|
KontakMessageBuilder builder = new KontakMessageBuilder(person[zahl].FirstName,
|
|
anzeige.ChatText, anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value,
|
|
true, false, false, true, null, anzeige.ChatText, null, false,
|
|
datenmengen,anzeige.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (sx == 0 && anzeige.IstGelesen != 1)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder("",
|
|
"------------------------ Ungelesene Nachrichten -----------------------", "", 0,
|
|
false, false, null));
|
|
sx++;
|
|
}
|
|
|
|
int zahl = (int) x.IndexOf(anzeige.SenderPersonOid.Value);
|
|
|
|
|
|
if (anzeige.MediaTyp == 0)
|
|
{
|
|
Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,
|
|
anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, false, false, null));
|
|
}
|
|
else
|
|
{
|
|
if (anzeige.MediaTyp == 1)
|
|
{
|
|
|
|
var bild = DecodeBild(anzeige.ImageThumpNail);
|
|
|
|
KontakMessageBuilder builder = new KontakMessageBuilder(person[zahl].FirstName,
|
|
anzeige.ChatText, anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value,
|
|
false, false, true, false, bild, null, null, false, datenmengen,anzeige.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
|
|
//if (anzeige.MediaTyp == 3)
|
|
//{
|
|
// if (!SoundZwischenSpeicher.ContainsKey(anzeige.ChatText))
|
|
// SoundZwischenSpeicher.Add(anzeige.ChatText, anzeige.SoundDatei);
|
|
|
|
// Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText,anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, false, true, false,false, null,null,null));
|
|
//}
|
|
|
|
if (anzeige.MediaTyp == 2)
|
|
{
|
|
KontakMessageBuilder builder = new KontakMessageBuilder(person[zahl].FirstName,
|
|
anzeige.ChatText, anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value,
|
|
false, false, false, true, null, anzeige.ChatText, null, false,
|
|
datenmengen,anzeige.ChatMessagesOid);
|
|
|
|
datenmengen[1] = builder;
|
|
|
|
Chat.Items.Add(builder);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (anzeige.IstGelesen != 1)
|
|
{
|
|
ServiceFacade.DoCustomerServiceSync(
|
|
s =>
|
|
s.UpdateIstGelesen(anzeige.EmpfängerPersonOid.Value,
|
|
anzeige.SenderPersonOid.Value, true));
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
var lisadst = Chat.Items.Cast<KontakMessageBuilder>().OrderBy(item => item.SendTime).ToList();
|
|
|
|
Chat.Items.Clear();
|
|
foreach (KontakMessageBuilder listItem in lisadst)
|
|
{
|
|
Chat.Items.Add(listItem);
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Es ist ein Fehler aufgetreten ", "Fehler", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region KontaklistBuilder
|
|
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 BrushConverter().ConvertFromString("#00ae00") as SolidColorBrush;
|
|
}
|
|
else if (statustyp == StatusType.Offline)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Orange);
|
|
}
|
|
|
|
if (typeChat == ChatType.Team)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.DarkViolet);
|
|
}
|
|
else if (typeChat == ChatType.Klienten)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Blue);
|
|
}
|
|
else
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Green);
|
|
}
|
|
}
|
|
|
|
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 BrushConverter().ConvertFromString("#00ae00") as SolidColorBrush;
|
|
}
|
|
else if (statustyp == StatusType.Offline)
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
this.Color = new SolidColorBrush(Colors.Orange);
|
|
}
|
|
|
|
if (typeChat == ChatType.Team)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.DarkViolet);
|
|
}
|
|
else if (typeChat == ChatType.Klienten)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Blue);
|
|
}
|
|
else
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Green);
|
|
}
|
|
}
|
|
|
|
public string Name { get; private set; }
|
|
|
|
private StatusType _statustyp;
|
|
public StatusType StatusTyp { get { return _statustyp; } set { _statustyp = value;
|
|
|
|
if (_statustyp == StatusType.Online)
|
|
{
|
|
_color = new BrushConverter().ConvertFromString("#00ae00") as SolidColorBrush;
|
|
}
|
|
else if (_statustyp == StatusType.Offline)
|
|
{
|
|
_color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Orange);
|
|
}
|
|
|
|
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 BrushConverter().ConvertFromString("#00ae00") as SolidColorBrush;
|
|
}
|
|
else if (StatusTyp == StatusType.Offline)
|
|
{
|
|
_color = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Orange);
|
|
}
|
|
|
|
OnPropertyChanged("Color"); }
|
|
}
|
|
|
|
private Brush _colorType;
|
|
public Brush ColorType
|
|
{
|
|
get
|
|
{
|
|
return _colorType;
|
|
}
|
|
set
|
|
{
|
|
if (TypeChat == ChatType.Team)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.DarkViolet);
|
|
}
|
|
else if (TypeChat == ChatType.Klienten)
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Blue);
|
|
}
|
|
else
|
|
{
|
|
_colorType = new SolidColorBrush(Colors.Green);
|
|
}
|
|
|
|
OnPropertyChanged("ColorType");
|
|
}
|
|
}
|
|
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));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region KontaktMessageBuilder
|
|
public class KontakMessageBuilder
|
|
{
|
|
public KontakMessageBuilder(string username, string message, string sendtime, long messagePersonOid, bool isme, bool loadnext, object loadObject)
|
|
{
|
|
Username = username;
|
|
UserMessage = message;
|
|
SendTime = sendtime;
|
|
MessagePersonOid = messagePersonOid;
|
|
|
|
if (messagePersonOid == 0 && !loadnext)
|
|
{
|
|
ChatColor = new SolidColorBrush(Colors.AliceBlue); //CornflowerBlue
|
|
Posi = "Center";
|
|
}else
|
|
if (isme)
|
|
{
|
|
ChatColor = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
|
|
Posi = "Right";
|
|
}
|
|
else
|
|
{
|
|
ChatColor = new BrushConverter().ConvertFromString("#cccccc") as SolidColorBrush;
|
|
Posi = "Left";
|
|
}
|
|
|
|
|
|
if (loadnext)
|
|
{
|
|
Posi = "Right";
|
|
LoadNextVisibility = Visibility.Visible;
|
|
ChatVisibility = Visibility.Collapsed;
|
|
LoadObject = loadObject;
|
|
MainVisibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
LoadNextVisibility = Visibility.Collapsed;
|
|
ChatVisibility = Visibility.Visible;
|
|
LoadObject = null;
|
|
MainVisibility = Visibility.Visible;
|
|
}
|
|
|
|
|
|
SoundVisibility = Visibility.Collapsed;
|
|
_pictureVisibility = Visibility.Collapsed;
|
|
DokumentVisibility = Visibility.Collapsed;
|
|
_herunterladen = Visibility.Collapsed;
|
|
|
|
}
|
|
|
|
public KontakMessageBuilder(string username, string message, string sendtime, long messagePersonOid, bool isme,
|
|
bool isSoundDatei, bool isPicDatei, bool isDokument, ImageSource source, string fulldokpfad, byte[] dokarray,bool isHerunterladen,object[] herunterladbares,long? chatMessageOid)
|
|
{
|
|
Username = username;
|
|
UserMessage = message;
|
|
SendTime = sendtime;
|
|
MessagePersonOid = messagePersonOid;
|
|
ChatMessageOid = chatMessageOid;
|
|
|
|
|
|
if (isme && messagePersonOid == 0)
|
|
{
|
|
ChatColor = new SolidColorBrush(Colors.CornflowerBlue);
|
|
Posi = "Center";
|
|
}
|
|
else if (isme)
|
|
{
|
|
|
|
ChatColor = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
|
|
Posi = "Right";
|
|
}
|
|
else
|
|
{
|
|
|
|
ChatColor = new BrushConverter().ConvertFromString("#cccccc") as SolidColorBrush;
|
|
Posi = "Left";
|
|
}
|
|
|
|
if (isSoundDatei)
|
|
{
|
|
ChatVisibility = Visibility.Collapsed;
|
|
SoundVisibility = Visibility.Visible;
|
|
_pictureVisibility = Visibility.Collapsed;
|
|
DokumentVisibility = Visibility.Collapsed;
|
|
_herunterladen = Visibility.Collapsed;
|
|
|
|
}
|
|
else if (isDokument)
|
|
{
|
|
ChatVisibility = Visibility.Collapsed;
|
|
SoundVisibility = Visibility.Collapsed;
|
|
_pictureVisibility = Visibility.Collapsed;
|
|
DokumentVisibility = Visibility.Visible;
|
|
_herunterladen = Visibility.Collapsed;
|
|
|
|
}
|
|
else if (isPicDatei && source != null)
|
|
{
|
|
ChatVisibility = Visibility.Collapsed;
|
|
SoundVisibility = Visibility.Collapsed;
|
|
_pictureVisibility = Visibility.Visible;
|
|
DokumentVisibility = Visibility.Collapsed;
|
|
_herunterladen = Visibility.Collapsed;
|
|
}
|
|
else if (isHerunterladen)
|
|
{
|
|
_herunterladen = Visibility.Visible;
|
|
ChatVisibility = Visibility.Collapsed;
|
|
SoundVisibility = Visibility.Collapsed;
|
|
_pictureVisibility = Visibility.Collapsed;
|
|
DokumentVisibility = Visibility.Collapsed;
|
|
|
|
}
|
|
else
|
|
{
|
|
ChatVisibility = Visibility.Visible;
|
|
SoundVisibility = Visibility.Collapsed;
|
|
_pictureVisibility = Visibility.Collapsed;
|
|
DokumentVisibility = Visibility.Collapsed;
|
|
_herunterladen = Visibility.Collapsed;
|
|
|
|
}
|
|
|
|
|
|
if (source != null)
|
|
{
|
|
ImageSources = source;
|
|
}
|
|
|
|
|
|
//Dokument
|
|
object[] array1 = new object[3];
|
|
|
|
if (fulldokpfad != null && chatMessageOid == 0)
|
|
{
|
|
Dokpfad = fulldokpfad;
|
|
}
|
|
else if (chatMessageOid > 0 && fulldokpfad != null)
|
|
{
|
|
array1[0] = fulldokpfad;
|
|
array1[1] = dokarray;
|
|
array1[2] = chatMessageOid;
|
|
|
|
Dokpfad = array1;
|
|
}
|
|
|
|
|
|
if (herunterladbares != null)
|
|
{
|
|
Herunterladbares = herunterladbares;
|
|
}
|
|
|
|
//array übergabe für Sound ermöglichen
|
|
SoundArray = null;
|
|
LoadNextVisibility = Visibility.Collapsed;
|
|
MainVisibility = Visibility.Visible;
|
|
}
|
|
|
|
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; }
|
|
|
|
public Visibility MainVisibility { get; set; }
|
|
public Visibility ChatVisibility { get; set; }
|
|
|
|
public Visibility LoadNextVisibility { get; set; }
|
|
public object LoadObject { get; set; }
|
|
|
|
public Visibility SoundVisibility { get; set; }
|
|
|
|
private Visibility _pictureVisibility;
|
|
public Visibility PictureVisibility { get { return _pictureVisibility; } set { _pictureVisibility = value; OnPropertyChanged("PictureVisibility"); } }
|
|
|
|
public Visibility DokumentVisibility { get; set; }
|
|
public ImageSource ImageSources { get; private set; }
|
|
public object Dokpfad { get; private set; }
|
|
public byte[] SoundArray { get; private set; }
|
|
|
|
public long? ChatMessageOid { get; private set; }
|
|
|
|
private Visibility _herunterladen;
|
|
public Visibility Herunterladen
|
|
{
|
|
get { return _herunterladen; }
|
|
set { _herunterladen = value; OnPropertyChanged("Herunterladen"); }
|
|
}
|
|
|
|
public object[] Herunterladbares { get; private set; }
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
var handler = PropertyChanged;
|
|
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|