Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/Chat
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<Grid >
|
||||
<!--Background="{StaticResource ObjectEditBackgroundBrush}"-->
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.7*" />
|
||||
<ColumnDefinition Width="2.7*" MaxWidth="250" />
|
||||
<ColumnDefinition Width="7.2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -271,7 +271,7 @@
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Image Stretch="Uniform" MaxHeight="200" MaxWidth="300" Source="{Binding ImageSources}" RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
|
||||
<!--<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Center"/>-->
|
||||
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
#region Style setter für ownChatDesktop Version
|
||||
public void SetzteStyleAufNull()
|
||||
{
|
||||
EmojiButton.Style = null;
|
||||
@@ -138,7 +139,9 @@ namespace ChatController
|
||||
ReloadGruppen.Visibility = Visibility.Visible;
|
||||
_isDesktopVersion = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Synconisation Veranlassen für Bewoplaner
|
||||
public void SynchronisationVeranlassen()
|
||||
{
|
||||
try
|
||||
@@ -149,7 +152,7 @@ namespace ChatController
|
||||
{
|
||||
doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
|
||||
if (true || doSync)
|
||||
if (doSync)
|
||||
{
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
@@ -161,13 +164,10 @@ namespace ChatController
|
||||
DispatcherPriority.Normal,
|
||||
(Action) delegate
|
||||
{
|
||||
//CollectionViewSource.GetDefaultView(Clientlist.Items).Refresh();
|
||||
Clientlist.Items.Refresh();
|
||||
});
|
||||
//this.Dispatch(delegate // hä ??
|
||||
//{
|
||||
// Clientlist.Items.Refresh();
|
||||
//});
|
||||
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMinutes(5));
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ namespace ChatController
|
||||
MessageBox.Show("Ein Fehler bei der Synchronisation ist aufgetreten.\nFehler:\n" + e.Message, "Fehler",MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Lade KontaktDaten und Lade sie in den Chat
|
||||
private void AktChatUser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
@@ -286,7 +287,7 @@ namespace ChatController
|
||||
private void Item3OnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
var kontakt = (AktuellerKontakt)AktChatUser.Items[0];
|
||||
_chat.Einfuegen(kontakt.GroupId);
|
||||
_chat.Einfuegen(kontakt.GroupId,this);
|
||||
}
|
||||
|
||||
private void Item4OnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
@@ -417,14 +418,19 @@ namespace ChatController
|
||||
if (AktChatUser.Items.Count > 0)
|
||||
{
|
||||
var kontakt = (AktuellerKontakt) AktChatUser.Items[0];
|
||||
|
||||
var medium = _chat.HoleMedium();
|
||||
|
||||
_chat.HoleUndSendeMediumAnKontakt(kontakt);
|
||||
if(medium != null) {
|
||||
_chat.AddeMediumDerNachrichtView(medium);
|
||||
|
||||
Chat.ItemsSource = null;
|
||||
Chat.ItemsSource = _chat.LadeChatNachrichtenVomKontakt(kontakt);
|
||||
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
_chat.SendeMediumAnKontakt(kontakt,medium);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,19 +447,19 @@ namespace ChatController
|
||||
if (!Chatbox.Text.Equals(""))
|
||||
{
|
||||
var kontakt = (AktuellerKontakt)AktChatUser.Items[0];
|
||||
|
||||
var text = Chatbox.Text;
|
||||
|
||||
_chat.AddeNachrichtDerView(Chatbox.Text);
|
||||
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
_chat.SendMessage(Chatbox.Text, kontakt.GroupId);
|
||||
|
||||
|
||||
//UebergebeNachrichtAnKontaktList(Chatbox.Text);
|
||||
Chatbox.Text = "";
|
||||
|
||||
//Lade Nachrichten nach
|
||||
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
|
||||
if (Chatbox.Text.Equals(""))
|
||||
{
|
||||
Chatbox.Text = "Nachricht schreiben";
|
||||
@@ -485,7 +491,6 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Chatbox_OnGotFocus(object sender, RoutedEventArgs e)
|
||||
@@ -511,16 +516,19 @@ namespace ChatController
|
||||
if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals(""))
|
||||
{
|
||||
var kontakt = (AktuellerKontakt)AktChatUser.Items[0];
|
||||
|
||||
var text = Chatbox.Text;
|
||||
|
||||
_chat.AddeNachrichtDerView(Chatbox.Text);
|
||||
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
_chat.SendMessage(Chatbox.Text, kontakt.GroupId);
|
||||
|
||||
//UebergebeNachrichtAnKontaktList(Chatbox.Text);
|
||||
|
||||
Chatbox.Text = "";
|
||||
|
||||
|
||||
//lade Nachrichten nach
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,6 +548,37 @@ namespace ChatController
|
||||
MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + ed.Message + "\n" + ed.StackTrace, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private void UebergebeNachrichtAnKontaktList(string nachricht)
|
||||
{
|
||||
try
|
||||
{
|
||||
var aktuellerKontakt = (AktuellerKontakt)AktChatUser.Items[0];
|
||||
|
||||
foreach (var liste in _kontaktlist)
|
||||
{
|
||||
if (liste.GroupId == aktuellerKontakt.GroupId)
|
||||
{
|
||||
liste.ReceiveMs = nachricht;
|
||||
|
||||
//var clientZone = TimeZoneInfo.Local;
|
||||
|
||||
var x = DateTime.Now;
|
||||
|
||||
//var timeformated = TimeZoneInfo.ConvertTimeToUtc(x);
|
||||
|
||||
liste.TimeStamp = x;
|
||||
|
||||
liste.SetzeGelesen = 0;
|
||||
}
|
||||
}
|
||||
CollectionViewSource.GetDefaultView(Clientlist.Items).Refresh();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//einfach ignorieren
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Add Emoji To ChatBox
|
||||
@@ -684,43 +723,14 @@ namespace ChatController
|
||||
(Action)delegate
|
||||
{
|
||||
if(kontakt != null) {
|
||||
|
||||
//neuer Aufruf villeicht nur von
|
||||
//Cursor = Cursors.Wait;
|
||||
|
||||
Chat.ItemsSource = null;
|
||||
|
||||
//Wichtig Verbessern
|
||||
|
||||
var x = _chat.LadeChatNachrichtenVomKontakt(kontakt);
|
||||
|
||||
//foreach (var liste in _Orderedmessagelist)
|
||||
//{
|
||||
// foreach (var neu in alist)
|
||||
// {
|
||||
|
||||
// if (liste.ChatMessageOid == neu.ChatMessageOid)
|
||||
// {
|
||||
// //_Orderedmessagelist.CreateOrderedEnumerable(neu,,true);
|
||||
|
||||
// //if (!liste.ReceiveMs.Equals(neu.ReceiveMs))
|
||||
// //{
|
||||
// // liste.ReceiveMs = neu.ReceiveMs;
|
||||
// // liste.SetzeGelesen = 1;
|
||||
// // //Vorher noch abfragen ob die id gleich den chat ist und dann nur wenn nicht zutrifft dann auf 1 setzen
|
||||
// //}
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
Chat.ItemsSource = x;
|
||||
|
||||
//Cursor = Cursors.Arrow;
|
||||
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -733,8 +743,8 @@ namespace ChatController
|
||||
break;
|
||||
}
|
||||
|
||||
Task.Delay(2000);
|
||||
//Thread.Sleep(2000);
|
||||
//Task.Delay(2000);
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -752,15 +762,10 @@ namespace ChatController
|
||||
private void DoWorkAlleNachrichten()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var x = _chat.SchaueNachAllenMessageCounts();
|
||||
{
|
||||
var x = _chat.SchaueNachAllenMessageCounts();
|
||||
|
||||
if (AlleNachrichtenCount == null)
|
||||
{
|
||||
AlleNachrichtenCount = x;
|
||||
}
|
||||
|
||||
if (x > AlleNachrichtenCount)
|
||||
if (x > 0)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Background,
|
||||
@@ -768,45 +773,50 @@ namespace ChatController
|
||||
{
|
||||
var alist = _chat.NeueGroupklassenKontakte();
|
||||
|
||||
var aktuellerKontakt =(AktuellerKontakt)AktChatUser.Items[0];
|
||||
AktuellerKontakt aktuellerKontakt = null;
|
||||
|
||||
if (AktChatUser.HasItems)
|
||||
{
|
||||
aktuellerKontakt = (AktuellerKontakt) AktChatUser.Items[0];
|
||||
}
|
||||
|
||||
foreach (var liste in _kontaktlist)
|
||||
{
|
||||
foreach (var neu in alist)
|
||||
{
|
||||
if (liste.GroupId == neu.GroupId)
|
||||
foreach (var neu in alist)
|
||||
{
|
||||
if (!liste.ReceiveMs.Equals(neu.ReceiveMs)) {
|
||||
if (liste.GroupId == neu.GroupId)
|
||||
{
|
||||
if (!liste.ReceiveMs.Equals(neu.ReceiveMs)) {
|
||||
|
||||
liste.ReceiveMs = neu.ReceiveMs;
|
||||
liste.ReceiveMs = neu.ReceiveMs;
|
||||
liste.TimeStamp = neu.TimeStamp;
|
||||
|
||||
if (neu.GroupId == aktuellerKontakt.GroupId)
|
||||
{
|
||||
liste.SetzeGelesen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
liste.SetzeGelesen = 1;
|
||||
if (aktuellerKontakt != null && neu.GroupId == aktuellerKontakt.GroupId)
|
||||
{
|
||||
liste.SetzeGelesen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
liste.SetzeGelesen = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
});
|
||||
|
||||
AlleNachrichtenCount = x;
|
||||
|
||||
}
|
||||
|
||||
if (AlleNachrichtenThreadBool == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Task.Delay(5000);
|
||||
}
|
||||
|
||||
//Thread.Sleep(5000);
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,21 +843,32 @@ namespace ChatController
|
||||
|
||||
private void Chat_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
StartWaiting();
|
||||
var chatItems = Chat.SelectedItems;
|
||||
|
||||
if (chatItems.Count > 0) {
|
||||
if (chatItems.Count > 0)
|
||||
{
|
||||
foreach (var items in chatItems)
|
||||
{
|
||||
var item = items as KontaktMessageBuilder;
|
||||
|
||||
if (item != null && item.ImageSources != null)
|
||||
{
|
||||
|
||||
|
||||
_chat.ShowPicture(item);
|
||||
|
||||
EndWaiting();
|
||||
Cursor = Cursors.Arrow;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EndWaiting();
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -941,10 +962,7 @@ namespace ChatController
|
||||
|
||||
#region ReloadGruppen (For Stand Alone version)
|
||||
private void ButtonReloadGruppen_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Thread newThread = new Thread(DoSynchro);
|
||||
//newThread.IsBackground = true;
|
||||
//newThread.Start();
|
||||
{
|
||||
DoSynchro();
|
||||
}
|
||||
|
||||
@@ -954,45 +972,19 @@ namespace ChatController
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
//StartWaiting();
|
||||
//if (_isDesktopVersion)
|
||||
//{
|
||||
// var doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
SpeichereMessageInfoInDatei();
|
||||
|
||||
// if (doSync)
|
||||
// {
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
|
||||
_kontaktlist = x;
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Cursor = Cursors.Arrow;
|
||||
// // EndWaiting();
|
||||
// if (OnClose != null)
|
||||
// {
|
||||
// OnClose();
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
// var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
|
||||
// _kontaktlist = x;
|
||||
|
||||
// Clientlist.Items.Refresh();
|
||||
|
||||
// Cursor = Cursors.Arrow;
|
||||
//}
|
||||
_kontaktlist = x;
|
||||
|
||||
LeseMessageInfoAusDatei();
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1001,7 +993,7 @@ namespace ChatController
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region speichern sowie lesen der MessageSyncDatei / stylezwecke
|
||||
public void SpeichereMessageInfoInDatei()
|
||||
{
|
||||
|
||||
@@ -1,34 +1,27 @@
|
||||
using System;
|
||||
using ChatController.ChatKlassen;
|
||||
using ChatController.Klassen;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using ChatController.ChatKlassen;
|
||||
using ChatController.Klassen;
|
||||
using Newtonsoft.Json;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using Clipboard = System.Windows.Forms.Clipboard;
|
||||
using ContextMenu = System.Windows.Controls.ContextMenu;
|
||||
using Cursor = System.Windows.Input.Cursor;
|
||||
using DataFormats = System.Windows.Forms.DataFormats;
|
||||
using Image = System.Windows.Controls.Image;
|
||||
using MenuItem = System.Windows.Forms.MenuItem;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Size = System.Drawing.Size;
|
||||
|
||||
@@ -50,6 +43,7 @@ namespace ChatController.HauptKlassen
|
||||
public static readonly List<string> ImageExtensions = new List<string> { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG", ".JPEG" };
|
||||
public static readonly List<string> DokumentExtension = new List<string> { ".TXT", ".PPT", ".XLS", ".DOC" };
|
||||
|
||||
private long lastTimeStamp=0;
|
||||
|
||||
public Chat(ChatDatenUebergabe chatDaten)
|
||||
{
|
||||
@@ -59,42 +53,55 @@ namespace ChatController.HauptKlassen
|
||||
#region Gruppen In Kontaktliste Wandler
|
||||
public IOrderedEnumerable<KontaktlistBuilder> GroupklassenInChatKontakteUmwandler()
|
||||
{
|
||||
foreach (var kontakt in ChatDaten.Groupconect.Response)
|
||||
foreach (var kontakt in ChatDaten.Groupconect.Response)
|
||||
{
|
||||
foreach (var value in kontakt.Value)
|
||||
{
|
||||
foreach (var value in kontakt.Value)
|
||||
string message = "";
|
||||
DateTime timestamp = new DateTime();
|
||||
|
||||
var lastMS = value.LastMessage;
|
||||
|
||||
DateTime timeformated = new DateTime();
|
||||
|
||||
|
||||
if (lastMS != null)
|
||||
{
|
||||
string message = "";
|
||||
DateTime timestamp = new DateTime();
|
||||
|
||||
var lastMS = value.LastMessage;
|
||||
|
||||
|
||||
if (lastMS != null)
|
||||
if (lastMS.Text != null)
|
||||
{
|
||||
if (lastMS.Text != null)
|
||||
{
|
||||
message = lastMS.Text;
|
||||
timestamp = DateTime.Parse(lastMS.Timestamp.Date);
|
||||
}
|
||||
}
|
||||
message = lastMS.Text;
|
||||
|
||||
if (message.Equals("") && value.LastMessage != null && !value.LastMessage.File.Equals(""))
|
||||
timestamp = DateTime.Parse(lastMS.Timestamp.Date);
|
||||
|
||||
var clientZone = TimeZoneInfo.Local;
|
||||
timeformated = TimeZoneInfo.ConvertTimeFromUtc(timestamp, clientZone);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.Equals("") && value.LastMessage != null && !value.LastMessage.File.Equals(""))
|
||||
{
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
|
||||
//null steht für employee
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar),
|
||||
message, timeformated, value.Oid, null));
|
||||
|
||||
if(lastMS != null && lastMS.Timestamp != null && lastMS.Timestamp.Date != null) {
|
||||
TimeSpan span = (DateTime.Parse(lastMS.Timestamp.Date) - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
long unixTime = System.Convert.ToInt64(span.TotalSeconds);
|
||||
|
||||
if (lastTimeStamp < unixTime)
|
||||
{
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
lastTimeStamp = unixTime;
|
||||
}
|
||||
|
||||
//null steht für employee
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar),
|
||||
message, timestamp, value.Oid, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sortedKontaktliste = Kontaktliste.OrderByDescending(r => r.TimeStamp);
|
||||
|
||||
var sortedKontaktliste = Kontaktliste.OrderByDescending(r => r.TimeStamp);
|
||||
|
||||
return sortedKontaktliste;
|
||||
|
||||
|
||||
return sortedKontaktliste;
|
||||
//Search Bereich
|
||||
//CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
|
||||
//view.SortDescriptions.Add(new SortDescription("TimeStamp", ListSortDirection.Descending));
|
||||
@@ -526,11 +533,13 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
TimeSpan lastTs = DateTime.UtcNow.TimeOfDay;
|
||||
|
||||
double timespan = lastTs.TotalSeconds;
|
||||
TimeSpan span = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
long timespan = System.Convert.ToInt64(span.TotalSeconds);
|
||||
//long timespan = //lastTs.TotalSeconds;
|
||||
|
||||
if (_userMessages != null && _userMessages.Response.Messages.Length > 0)
|
||||
{
|
||||
timespan = _userMessages.Response.Messages.First().CreatetdAt;
|
||||
timespan = _userMessages.Response.Messages.First().Created_At;
|
||||
}
|
||||
|
||||
if (kontakt != null)
|
||||
@@ -558,7 +567,7 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
private double? SendeTimestamp(long groupId,double lastStamp)
|
||||
private double? SendeTimestamp(long groupId,long lastStamp)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -596,22 +605,20 @@ namespace ChatController.HauptKlassen
|
||||
#region Prüfe für alle ob neue Nachrichten vorhanden sind
|
||||
|
||||
public double SchaueNachAllenMessageCounts()
|
||||
{
|
||||
TimeSpan lastTs = DateTime.UtcNow.TimeOfDay;
|
||||
{
|
||||
TimeSpan span = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
long unixTime = System.Convert.ToInt64(span.TotalSeconds);
|
||||
|
||||
double timespan = lastTs.TotalSeconds;
|
||||
|
||||
var x = SendeTimestampForEach(0, timespan);
|
||||
|
||||
|
||||
var x = SendeTimestampForEach(0, unixTime);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
private double SendeTimestampForEach(long groupId, double lastStamp)
|
||||
private double SendeTimestampForEach(long groupId, long lastStamp)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = ChatDaten.ServerUrl + "/api/ownchat/news/" + groupId + "/" + lastStamp;
|
||||
var endurl = ChatDaten.ServerUrl + "/api/ownchat/news/" + groupId + "/" + lastTimeStamp; //lastStamp
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
|
||||
@@ -652,6 +659,7 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
string message = "";
|
||||
DateTime timestamp = new DateTime();
|
||||
DateTime timeformated = new DateTime();
|
||||
|
||||
var lastMS = value.LastMessage;
|
||||
|
||||
@@ -661,6 +669,9 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
message = lastMS.Text;
|
||||
timestamp = DateTime.Parse(lastMS.Timestamp.Date);
|
||||
|
||||
var clientZone = TimeZoneInfo.Local;
|
||||
timeformated = TimeZoneInfo.ConvertTimeFromUtc(timestamp, clientZone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,7 +682,18 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
//null steht für employee
|
||||
Kontakt.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar),
|
||||
message, timestamp, value.Oid, null));
|
||||
message, timeformated, value.Oid, null));
|
||||
|
||||
if (lastMS != null && lastMS.Timestamp != null && lastMS.Timestamp.Date != null) {
|
||||
TimeSpan span = (DateTime.Parse(lastMS.Timestamp.Date) - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
long unixTime = System.Convert.ToInt64(span.TotalSeconds);
|
||||
|
||||
if (lastTimeStamp < unixTime)
|
||||
{
|
||||
lastTimeStamp = unixTime;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,6 +753,29 @@ namespace ChatController.HauptKlassen
|
||||
#endregion
|
||||
|
||||
#region Sende Normale Message an Kontakt
|
||||
|
||||
public void AddeNachrichtDerView(string nachricht)
|
||||
{
|
||||
try
|
||||
{
|
||||
string username = "";
|
||||
|
||||
foreach (var daten in ChatDaten.Userconect.Response)
|
||||
{
|
||||
username = daten.Value.Firstname + " " + daten.Value.Lastname;
|
||||
}
|
||||
|
||||
var time = DateTime.Now;
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(username, nachricht,
|
||||
time.ToString("dd MMMM yyyy HH:mm:ss"), true, time));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private HttpWebRequest requesten;
|
||||
|
||||
@@ -784,7 +829,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
#region Sende Media Nachricht an Kontakt
|
||||
|
||||
public void HoleUndSendeMediumAnKontakt(AktuellerKontakt kontakt)
|
||||
public string HoleMedium()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -796,11 +841,98 @@ namespace ChatController.HauptKlassen
|
||||
// openFileDialog1.Filter = "Office Dokumente |*.doc;*.xls;*.ppt;*.txt";
|
||||
|
||||
DialogResult result = openFileDialog1.ShowDialog();
|
||||
|
||||
|
||||
if (result == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
VerarbeiteMedia(openFileDialog1.FileName,kontakt);
|
||||
return openFileDialog1.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + e.Message, "Fehler", MessageBoxButton.OK);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddeMediumDerNachrichtView(string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ChatMessage = _userMessages.Response.Messages.Last();
|
||||
|
||||
var timeformated = DateTime.Now;
|
||||
|
||||
if (ImageExtensions.Contains(Path.GetExtension(file).ToUpperInvariant()))
|
||||
{
|
||||
BitmapImage logo = new BitmapImage();
|
||||
logo.BeginInit();
|
||||
logo.UriSource = new Uri(file);
|
||||
logo.EndInit();
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
timeformated.ToString("dd MMMM yyyy HH:mm:ss"), true, logo,
|
||||
timeformated, file));
|
||||
}
|
||||
else if (DokumentExtension.Contains(Path.GetExtension(file).ToUpperInvariant()))
|
||||
{
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
timeformated.ToString("dd MMMM yyyy HH:mm:ss"), true,file,
|
||||
timeformated));
|
||||
}
|
||||
else
|
||||
{
|
||||
//MP4 und gifs und so unbehandelten dreck
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
timeformated.ToString("dd MMMM yyyy HH:mm:ss"), true, file,
|
||||
timeformated));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddMediumContextDerNachrichtView(byte[] datei,string filename)
|
||||
{
|
||||
var ChatMessage = _userMessages.Response.Messages.Last();
|
||||
|
||||
var timeformated = DateTime.Now;
|
||||
|
||||
if (ImageExtensions.Contains(Path.GetExtension(filename).ToUpperInvariant()))
|
||||
{
|
||||
|
||||
BitmapImage biImg = new BitmapImage();
|
||||
MemoryStream ms = new MemoryStream(datei);
|
||||
biImg.BeginInit();
|
||||
biImg.StreamSource = ms;
|
||||
biImg.EndInit();
|
||||
|
||||
ImageSource logo = biImg;
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(filename),
|
||||
timeformated.ToString("dd MMMM yyyy HH:mm:ss"), true, logo,
|
||||
timeformated, filename));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(filename),
|
||||
timeformated.ToString("dd MMMM yyyy HH:mm:ss"), true, filename,
|
||||
timeformated));
|
||||
}
|
||||
}
|
||||
|
||||
public void SendeMediumAnKontakt(AktuellerKontakt kontakt,string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
VerarbeiteMedia(file,kontakt);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -818,9 +950,9 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
string filename = Path.GetFileName(file);
|
||||
|
||||
|
||||
SendMediaMessage(filename, kontakt.GroupId, mdatei);
|
||||
|
||||
//LoadKontakt();
|
||||
|
||||
}
|
||||
|
||||
private static byte[] ReadFully(Stream stream)
|
||||
@@ -996,7 +1128,7 @@ namespace ChatController.HauptKlassen
|
||||
#endregion
|
||||
|
||||
#region Fuege Daten Bilder usw via DragAndDrop in den Chat / muss noch bearbeitet werden
|
||||
public void Einfuegen(long groupOid)
|
||||
public void Einfuegen(long groupOid, ChatMainControl chatMainControl)
|
||||
{
|
||||
var d = System.Windows.Forms.Clipboard.GetDataObject();
|
||||
|
||||
@@ -1015,9 +1147,16 @@ namespace ChatController.HauptKlassen
|
||||
if (File.Exists(fileList[0]))
|
||||
{
|
||||
filename = Path.GetFileName(fileList[0]);
|
||||
|
||||
//file = File.OpenRead(fileList[0]);
|
||||
|
||||
byte[] myBinary = File.ReadAllBytes(fileList[0]);
|
||||
|
||||
AddMediumContextDerNachrichtView(myBinary,filename);
|
||||
|
||||
CollectionViewSource.GetDefaultView(chatMainControl.Chat.ItemsSource).Refresh();
|
||||
|
||||
chatMainControl.Chat.Items.MoveCurrentToLast();
|
||||
chatMainControl.Chat.ScrollIntoView(chatMainControl.Chat.Items.CurrentItem);
|
||||
|
||||
|
||||
SendMediaMessage(filename, groupOid, myBinary);
|
||||
}
|
||||
@@ -1032,7 +1171,14 @@ namespace ChatController.HauptKlassen
|
||||
if (d.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
string text = (string)d.GetData(DataFormats.StringFormat);
|
||||
|
||||
|
||||
AddeNachrichtDerView(text);
|
||||
|
||||
CollectionViewSource.GetDefaultView(chatMainControl.Chat.ItemsSource).Refresh();
|
||||
|
||||
chatMainControl.Chat.Items.MoveCurrentToLast();
|
||||
chatMainControl.Chat.ScrollIntoView(chatMainControl.Chat.Items.CurrentItem);
|
||||
|
||||
SendMessage(text, groupOid);
|
||||
}
|
||||
else
|
||||
@@ -1044,6 +1190,13 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
System.Drawing.Image img = pic;
|
||||
|
||||
AddMediumContextDerNachrichtView(ImageToByteArray(img),bildname);
|
||||
|
||||
CollectionViewSource.GetDefaultView(chatMainControl.Chat.ItemsSource).Refresh();
|
||||
|
||||
chatMainControl.Chat.Items.MoveCurrentToLast();
|
||||
chatMainControl.Chat.ScrollIntoView(chatMainControl.Chat.Items.CurrentItem);
|
||||
|
||||
SendMediaMessage(bildname,groupOid, ImageToByteArray(img));
|
||||
}
|
||||
else
|
||||
@@ -1105,7 +1258,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Zeige Kontakt Bild / hat noch probleme -> Show Kontakt
|
||||
@@ -1134,6 +1286,11 @@ namespace ChatController.HauptKlassen
|
||||
form.MaximumSize = new Size(500,500);
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
form.MaximizeBox = false;
|
||||
|
||||
form.Text = "ownChat Bild Voschau";
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
PictureBox pb = new PictureBox();
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = imgbit;
|
||||
@@ -1199,6 +1356,11 @@ namespace ChatController.HauptKlassen
|
||||
form.MaximumSize = new Size(500,500);
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
form.MaximizeBox = false;
|
||||
|
||||
form.Text = "ownChat Bild Voschau";
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
PictureBox pb = new PictureBox();
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = imgbit;
|
||||
@@ -1321,33 +1483,45 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
try
|
||||
{
|
||||
Kontaktliste.Clear();
|
||||
foreach (var kontakt in chatDaten.Response)
|
||||
{
|
||||
|
||||
foreach (var value in kontakt.Value)
|
||||
{
|
||||
string message = "";
|
||||
DateTime timestamp = new DateTime();
|
||||
//var val = Kontaktliste.Find(item => item.GroupId == value.Oid);
|
||||
|
||||
var lastMS = value.LastMessage;
|
||||
//if (val == null) //was tun wenn der nicht merh drinne ist ?? dann ist das ja auch null
|
||||
//{
|
||||
string message = "";
|
||||
DateTime timestamp = new DateTime();
|
||||
|
||||
var lastMS = value.LastMessage;
|
||||
|
||||
|
||||
if (lastMS != null)
|
||||
{
|
||||
if (lastMS.Text != null)
|
||||
if (lastMS != null)
|
||||
{
|
||||
message = lastMS.Text;
|
||||
timestamp = DateTime.Parse(lastMS.Timestamp.Date);
|
||||
if (lastMS.Text != null)
|
||||
{
|
||||
message = lastMS.Text;
|
||||
timestamp = DateTime.Parse(lastMS.Timestamp.Date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.Equals("") && value.LastMessage != null && !value.LastMessage.File.Equals(""))
|
||||
{
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
if (message.Equals("") && value.LastMessage != null && !value.LastMessage.File.Equals(""))
|
||||
{
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
|
||||
//null steht für employee
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar),
|
||||
message, timestamp, value.Oid, null));
|
||||
//null steht für employee
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name,
|
||||
AvatarToImageSourceConverter(value.Avatar),
|
||||
message, timestamp, value.Oid, null));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //Item Bereits vorhanden
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1371,7 +1545,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
#endregion
|
||||
|
||||
//unter konstruktion
|
||||
#region pruefe letzten Konversations timestamp für design element
|
||||
|
||||
public Dictionary<int, DateTime> PruefeTimeStampsBeiStart(List<KontaktlistBuilder> kontaktliste)
|
||||
@@ -1440,8 +1613,6 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
try
|
||||
{
|
||||
//Hole alle aktuellen, schreibe ihre oid und den Timestamp der Aktuellen nachricht in eine Datei
|
||||
|
||||
if (!File.Exists(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt")))
|
||||
{
|
||||
using (
|
||||
|
||||
@@ -64,9 +64,7 @@ namespace ChatController.HauptKlassen
|
||||
dic.Add("chatcode",_chatCode);
|
||||
|
||||
VerbindeMitChatServer(dic);
|
||||
|
||||
|
||||
// Gruppen abfragen
|
||||
|
||||
if (_ownchatVerbindungsaufbauOK)
|
||||
{
|
||||
GruppenHolen();
|
||||
@@ -74,8 +72,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
|
||||
if (_gruppeholenverbindungsaufbauOK)
|
||||
{
|
||||
|
||||
{
|
||||
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _userconect, _groupconect, _serverUrl, _authToken, _userid, _kundennummer,_apikey);
|
||||
|
||||
return ubergabe;
|
||||
@@ -102,7 +99,7 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Fehler: Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,12 +114,12 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
if (jsonDatentyp.Status == 1)
|
||||
{
|
||||
MessageBox.Show("Kundennummer unbekannt");
|
||||
MessageBox.Show("Fehler: Kundennummer unbekannt.\nBitte überprüfen Sie die Anmeldeinformationen.","Info",MessageBoxButton.OK,MessageBoxImage.Asterisk);
|
||||
return false;
|
||||
}
|
||||
else if (jsonDatentyp.Status == 2)
|
||||
{
|
||||
MessageBox.Show("Diensttyp ist für angegebene Kundennummer nicht definiert");
|
||||
MessageBox.Show("Der Diensttyp ist für die angegebene Kundennummer nicht definiert.","Info",MessageBoxButton.OK,MessageBoxImage.Asterisk);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -138,12 +135,12 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
if (jsonDatentyp.Status == 1)
|
||||
{
|
||||
MessageBox.Show("Kundennummer unbekannt");
|
||||
MessageBox.Show("Fehler: Kundennummer unbekannt.\nBitte überprüfen Sie die Anmeldeinformationen.","Info",MessageBoxButton.OK,MessageBoxImage.Asterisk);
|
||||
return false;
|
||||
}
|
||||
else if (jsonDatentyp.Status == 2)
|
||||
{
|
||||
MessageBox.Show("Diensttyp ist für angegebene Kundennummer nicht definiert");
|
||||
MessageBox.Show("Der Diensttyp ist für die angegebene Kundennummer nicht definiert.","Info",MessageBoxButton.OK,MessageBoxImage.Asterisk);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -153,8 +150,8 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Beim Parsen der Datei ist ein fehler aufgetreten.", "Fehler",
|
||||
MessageBoxButton.OK);
|
||||
MessageBox.Show("Fehler: "+e.Message,"Fehler",MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,16 +162,17 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Ein nicht weiter definierter fehler ist aufgetreten: "+ e.Message,"Fehler",MessageBoxButton.OK);
|
||||
MessageBox.Show("Fehler: "+ e.Message,"Fehler",MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void VerbindeMitChatServer(Dictionary<string, string> postparameter)
|
||||
{
|
||||
string fehlermeldung = "";
|
||||
try
|
||||
{
|
||||
var endurl = _url + "/api/user/login"; //loginwithchatcode
|
||||
var endurl = _url + "/api/user/loginwithchatcode";
|
||||
|
||||
string postdaten = "";
|
||||
|
||||
@@ -208,38 +206,36 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
string pageContent = myStreamReader.ReadToEnd();
|
||||
|
||||
|
||||
//UserDaten müssen mehrere wege der initialisierung bieten
|
||||
if (!pageContent.Equals(""))
|
||||
{
|
||||
//_serverCheckOK = true;
|
||||
|
||||
//string[] array = responseFromServer.Split(':');
|
||||
|
||||
//Json Verarbeitungsgedöns Dictionary < string, TestKlasse>
|
||||
var jsonDaten = JsonConvert.DeserializeObject<UserDaten>(pageContent);
|
||||
|
||||
//var serv = jsonDaten[_chatcode].ServerName;
|
||||
|
||||
foreach (var datev in jsonDaten.Response)
|
||||
if (jsonDaten.Success == true)
|
||||
{
|
||||
_authToken = datev.Value.Token;
|
||||
_userid = datev.Value.Oid;
|
||||
foreach (var datev in jsonDaten.Response)
|
||||
{
|
||||
_authToken = datev.Value.Token;
|
||||
_userid = datev.Value.Oid;
|
||||
}
|
||||
|
||||
_userconect = jsonDaten;
|
||||
|
||||
_ownchatVerbindungsaufbauOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonDaten.Errors.chatcode_failed != null)
|
||||
{
|
||||
MessageBox.Show("Fehler: "+ jsonDaten.Errors.chatcode_failed[0] + "\nBitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
}else if (jsonDaten.Errors.login_failed != null)
|
||||
{
|
||||
MessageBox.Show("Fehler: "+ jsonDaten.Errors.login_failed[0] + "\nBitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
}
|
||||
|
||||
_ownchatVerbindungsaufbauOK = false;
|
||||
}
|
||||
|
||||
_userconect = jsonDaten;
|
||||
|
||||
_ownchatVerbindungsaufbauOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//throw fehler
|
||||
// MessageBox.Show("Keine Daten Vorhanden.");
|
||||
}
|
||||
|
||||
|
||||
// MessageBox.Show(pageContent);
|
||||
|
||||
|
||||
myStreamReader.Close();
|
||||
responseStream.Close();
|
||||
|
||||
@@ -247,7 +243,7 @@ namespace ChatController.HauptKlassen
|
||||
catch (Exception e)
|
||||
{
|
||||
//throw fehler
|
||||
MessageBox.Show(e.Message, "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show(e.Message, "Fehler", MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,38 +258,28 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = _authToken;
|
||||
request.Headers["CustomerID"] = _kundennummer;
|
||||
|
||||
// Get the response.
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
//verarbeite hier zu json
|
||||
|
||||
if (!responseFromServer.Equals(""))
|
||||
{
|
||||
//################# Deserialisierung mit Json ###############################
|
||||
var jsonDaten = JsonConvert.DeserializeObject<ChatGruppenDaten>(responseFromServer);
|
||||
|
||||
_groupconect = jsonDaten;
|
||||
// var serv = jsonDaten[_chatcode].ServerName;
|
||||
|
||||
//MessageBox.Show(responseFromServer);
|
||||
|
||||
_gruppeholenverbindungsaufbauOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// MessageBox.Show("Keine Daten Vorhanden.");
|
||||
}
|
||||
|
||||
|
||||
response.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// MessageBox.Show(e.Message, "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Fehler: "+e.Message, "Fehler", MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<TextBox x:Name="TextBoxBenutzerName" Grid.Column="1" Grid.Row="2" Margin="3" VerticalContentAlignment="Center" />
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="3" Margin="3" Foreground="White">Passwort:</Label>
|
||||
<PasswordBox x:Name="TextBoxPasswort" Grid.Column="1" Grid.Row="3" Margin="3" VerticalContentAlignment="Center"/>
|
||||
<PasswordBox x:Name="TextBoxPasswort" Grid.Column="1" Grid.Row="3" Margin="3" VerticalContentAlignment="Center" KeyUp="TextBoxPasswort_OnKeyUp"/>
|
||||
|
||||
<!--
|
||||
<CheckBox x:Name="Merken" Margin="3" Content="Passwort Speichern" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4"/>-->
|
||||
|
||||
@@ -11,9 +11,9 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
@@ -22,7 +22,11 @@ using System.Windows.Shapes;
|
||||
using ChatController.HauptKlassen;
|
||||
using ChatController.Klassen;
|
||||
using Newtonsoft.Json;
|
||||
using Cursors = System.Windows.Input.Cursors;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Path = System.IO.Path;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
namespace ChatController
|
||||
{
|
||||
@@ -35,10 +39,6 @@ namespace ChatController
|
||||
|
||||
public event LoginDelegate OnLogin;
|
||||
|
||||
//private readonly string _dateiPfad = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "ownChatX1253781.txt"; //OwnChatX1253781
|
||||
|
||||
//private readonly string _merkeDaten = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "ownChatX1253782.txt"; //OwnChatX1253782
|
||||
|
||||
private string _newUrl = "https://dict.ownchat.de/api/server/resolve/1/";
|
||||
private string _benutzername = "";
|
||||
private string _passwort = "";
|
||||
@@ -59,13 +59,26 @@ namespace ChatController
|
||||
}
|
||||
|
||||
private void AnmeldenButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Anmelden();
|
||||
}
|
||||
|
||||
private void TextBoxPasswort_OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Return)
|
||||
{
|
||||
Anmelden();
|
||||
}
|
||||
}
|
||||
|
||||
private void Anmelden()
|
||||
{
|
||||
try
|
||||
{
|
||||
//TODO Abfrage einführen die prüft ob eine verbindung ueberhaupt hergestellt werde kann | FehlerMeldungen Genauer Definieren
|
||||
if (!TextBoxKundennummer.Text.Equals("") && !TextBoxChatCode.Text.Equals("") &&
|
||||
!TextBoxBenutzerName.Text.Equals("") && !TextBoxPasswort.Password.Equals(""))
|
||||
{
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
Login _login = new Login(TextBoxKundennummer.Text, TextBoxChatCode.Text, TextBoxBenutzerName.Text, TextBoxPasswort.Password);
|
||||
@@ -86,10 +99,11 @@ namespace ChatController
|
||||
|
||||
OnLogin(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Fehler bei der Anmeldung. Bitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// Auskommentiert weil bereits abgefangen
|
||||
// MessageBox.Show("Fehler bei der Anmeldung. Bitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
//}
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
@@ -100,13 +114,10 @@ namespace ChatController
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//MessageBox.Show("Fehler bei der Anmeldung!\n\n" + exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
MessageBox.Show("Fehler bei der Anmeldung. Bitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
//throw;
|
||||
MessageBox.Show("Fehler: " + exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Speichern / Laden / Löschen der Datei
|
||||
|
||||
@@ -284,7 +295,7 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetAndCreateUserAppDataPath()
|
||||
private static string GetAndCreateUserAppDataPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -314,8 +325,7 @@ namespace ChatController
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
//Neue Region zum VErschlüsseln und entschlüsseln der Daten
|
||||
#region Verschlüsseln/Entschlüsseln via Link // wird ersmal nicht mehr gebraucht
|
||||
|
||||
@@ -460,6 +470,7 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ChatController.Klassen
|
||||
{
|
||||
public Dictionary<string, TestInput> Response { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string Errors { get; set; }
|
||||
public Tetserror Errors { get; set; }
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
|
||||
@@ -31,4 +31,10 @@ namespace ChatController.Klassen
|
||||
public string Token { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Tetserror
|
||||
{
|
||||
public string[] chatcode_failed{ get; set; }
|
||||
public string[] login_failed { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ChatController.Klassen
|
||||
public string Original_Filename { get; set; }
|
||||
public string Smaller_Image { get; set; }
|
||||
public LastMessageTimeStamp Timestamp { get; set; }
|
||||
public long CreatetdAt { get; set; }
|
||||
public long Created_At { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public string User_Name { get; set; }
|
||||
public string UserPicture { get; set; }
|
||||
|
||||
@@ -112,16 +112,18 @@ namespace ownChat
|
||||
|
||||
private void MainWindow_OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
_emojiView = null;
|
||||
ChatMainControl.SpeichereMessageInfoInDatei();
|
||||
// Environment.Exit(0);
|
||||
LoginMaske newLogin = new LoginMaske();
|
||||
newLogin.Show();
|
||||
//_emojiView = null;
|
||||
//ChatMainControl.SpeichereMessageInfoInDatei();
|
||||
//// Environment.Exit(0);
|
||||
//LoginMaske newLogin = new LoginMaske();
|
||||
//newLogin.Show();
|
||||
}
|
||||
|
||||
private void ChatMainControl_OnOnClose()
|
||||
{
|
||||
this.Close();
|
||||
{
|
||||
//this.Close();
|
||||
ChatMainControl.SpeichereMessageInfoInDatei();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user