Generelle Ausnahmenanzeige
This commit is contained in:
@@ -78,6 +78,9 @@
|
||||
<Compile Include="Core\OwnChatCache.cs" />
|
||||
<Compile Include="Core\OwnChatRichTextBox.cs" />
|
||||
<Compile Include="Data\LookupResult.cs" />
|
||||
<Compile Include="ExceptionViewControl.xaml.cs">
|
||||
<DependentUpon>ExceptionViewControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Extensions\IDictionaryTExtensions.cs" />
|
||||
<Compile Include="Extensions\IListTExtensions.cs" />
|
||||
<Compile Include="HauptKlassen\Chat.cs" />
|
||||
@@ -126,6 +129,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ExceptionViewControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="LoginControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -80,8 +79,6 @@ namespace ChatController
|
||||
}
|
||||
|
||||
public void PassEmojiToChatMainControl(string emojiCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.Invoke(
|
||||
DispatcherPriority.Normal,
|
||||
@@ -94,10 +91,5 @@ namespace ChatController
|
||||
_ChatMainControl.Chatbox.SelectionStart = selectionStart + emojiCode.Length;
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,15 @@ namespace ChatController.ChatKlassen
|
||||
get => _Image;
|
||||
set
|
||||
{
|
||||
if(!Equals(_Image, value))
|
||||
if(Equals(_Image, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Image = value;
|
||||
OnPropertyChanged(nameof(Image));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime TimeStamp { get; set; }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="600"
|
||||
Loaded="ChatMainControl_OnLoaded"
|
||||
SnapsToDevicePixels="True" d:DataContext="{d:DesignData Type=ChatMainControl}">
|
||||
SnapsToDevicePixels="True" d:DataContext="{d:DesignData Type=chatController:ChatMainControl}">
|
||||
<UserControl.Resources>
|
||||
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
<converter:StringEmptyToVisibilityConverter x:Key="StringEmptyToVisibilityConverter" />
|
||||
|
||||
@@ -40,7 +40,6 @@ using Timer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace ChatController
|
||||
{
|
||||
// Test
|
||||
public partial class ChatMainControl : INotifyPropertyChanged
|
||||
{
|
||||
private readonly Dictionary<long, List<NotifyIcon>> _Group2NotifyIcons = new Dictionary<long, List<NotifyIcon>>();
|
||||
@@ -55,8 +54,11 @@ namespace ChatController
|
||||
|
||||
set
|
||||
{
|
||||
if(!Equals(_ThreadExceptionMessage, value))
|
||||
if(Equals(_ThreadExceptionMessage, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ThreadExceptionMessage = value;
|
||||
OnPropertyChanged(nameof(ThreadExceptionMessage));
|
||||
OnPropertyChanged(nameof(CurrentContactInformationString));
|
||||
@@ -64,7 +66,6 @@ namespace ChatController
|
||||
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ImageSource _ThreadExceptionImageSource;
|
||||
|
||||
@@ -84,13 +85,15 @@ namespace ChatController
|
||||
{
|
||||
_ContainingWindow = value;
|
||||
|
||||
if(!(value is null))
|
||||
if(value is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ContainingWindow.Deactivated += ContainingWindowOnDeactivated;
|
||||
_ContainingWindow.Activated += ContainingWindowOnActivated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Chat _Chat;
|
||||
public Chat Chat
|
||||
@@ -115,8 +118,11 @@ namespace ChatController
|
||||
|
||||
set
|
||||
{
|
||||
if(!Equals(_CurrentContact, value))
|
||||
if(Equals(_CurrentContact, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_CurrentContact = value;
|
||||
|
||||
OnPropertyChanged(nameof(CurrentContact));
|
||||
@@ -127,7 +133,6 @@ namespace ChatController
|
||||
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableSortCollection<ContactDependencyObject> ContactList
|
||||
{
|
||||
@@ -199,25 +204,17 @@ namespace ChatController
|
||||
|
||||
foreach(var file in files)
|
||||
{
|
||||
if(File.Exists(file))
|
||||
if(!File.Exists(file))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
continue;
|
||||
}
|
||||
catch(IOException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
EndWaiting();
|
||||
});
|
||||
this.Dispatch(EndWaiting);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -263,7 +260,6 @@ namespace ChatController
|
||||
|
||||
_ContactList = new ObservableSortCollection<ContactDependencyObject>();
|
||||
|
||||
// ToDo: Hier tritt eine NullPointer-Exception auf!
|
||||
foreach(var contact in Chat.AddContacts())
|
||||
{
|
||||
ContactList.Add(new ContactDependencyObject(contact));
|
||||
@@ -331,7 +327,7 @@ namespace ChatController
|
||||
|
||||
notifyIcon.BalloonTipClosed += (sender, args) =>
|
||||
{
|
||||
// TODO: wird beim ausblenden bzw. automatischem Schließen des "Balloons" ausgelöst
|
||||
// Wird beim ausblenden bzw. automatischem Schließen des "Balloons" ausgelöst
|
||||
DisposeAndRemoveNotification((NotifyIcon)sender, pGroupId);
|
||||
};
|
||||
|
||||
@@ -385,8 +381,6 @@ namespace ChatController
|
||||
}
|
||||
|
||||
private void SelectContact(Contact contact)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(contact is null)
|
||||
{
|
||||
@@ -458,23 +452,6 @@ namespace ChatController
|
||||
});
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
#if DEBUG
|
||||
var desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
||||
|
||||
using(var fileStream = new FileStream(Path.Combine(desktop, "ownchat_log.txt"), FileMode.OpenOrCreate))
|
||||
{
|
||||
using(var streamWriter = new StreamWriter(fileStream))
|
||||
{
|
||||
streamWriter.WriteLine(exception.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MessageBox.Show(exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetContextHandler()
|
||||
{
|
||||
@@ -514,12 +491,14 @@ namespace ChatController
|
||||
}
|
||||
|
||||
// neu und vor Einfügen setzen und anpassen
|
||||
if(contextItems.Count > 2)
|
||||
if(contextItems.Count <= 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var copyMenuItem = (MenuItem) contextItems[2];
|
||||
copyMenuItem.Click += CopyOnClick;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveAsOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
@@ -658,8 +637,11 @@ namespace ChatController
|
||||
{
|
||||
var pathToOriginalImage = Chat.OpenFile();
|
||||
|
||||
if(File.Exists(pathToOriginalImage))
|
||||
if(!File.Exists(pathToOriginalImage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartWaitingImmediately("Skaliere Bild ...");
|
||||
|
||||
var scalingTask = new Task(() =>
|
||||
@@ -694,7 +676,6 @@ namespace ChatController
|
||||
|
||||
scalingTask.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Bitte wählen Sie einen Kontakt aus.","ownChat",MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
@@ -772,16 +753,16 @@ namespace ChatController
|
||||
|
||||
private void Chatbox_OnGotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Chatbox.Text.Equals("Nachricht schreiben"))
|
||||
if(!Chatbox.Text.Equals("Nachricht schreiben"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Chatbox.Text = string.Empty;
|
||||
Chatbox.Foreground = new SolidColorBrush(Colors.Black);
|
||||
}
|
||||
}
|
||||
|
||||
private void Chatbox_OnKeyDownHandler(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (e.Key == Key.Return)
|
||||
//{
|
||||
@@ -803,11 +784,6 @@ namespace ChatController
|
||||
OnPropertyChanged(nameof(IsBroadcastButtonEnabled));
|
||||
OnPropertyChanged(nameof(IsSendButtonEnabled));
|
||||
}
|
||||
catch (Exception ed)
|
||||
{
|
||||
MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + ed.Message + "\n" + ed.StackTrace, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private void Chatbox_OnKeyUpHandler(object sender, KeyEventArgs e)
|
||||
{
|
||||
@@ -842,12 +818,18 @@ namespace ChatController
|
||||
|
||||
private void VerticalScrollbarChanged(object sender, RoutedPropertyChangedEventArgs<double> routedPropertyChangedEventArgs)
|
||||
{
|
||||
if (_ScrollPrueferAktivieren)
|
||||
if(!_ScrollPrueferAktivieren)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var scrollBar = (ScrollBar) sender;
|
||||
|
||||
if(!(scrollBar.Value > 0))
|
||||
if(scrollBar.Value > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartWaitingImmediately();
|
||||
|
||||
_ScrollPrueferAktivieren = false;
|
||||
@@ -856,8 +838,11 @@ namespace ChatController
|
||||
|
||||
var currentChatMessage = ChatMessages.CurrentItem;
|
||||
|
||||
if(!(Clientlist.SelectedItem is null))
|
||||
if(Clientlist.SelectedItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedContact = ((ContactDependencyObject) Clientlist.SelectedItem).Contact;
|
||||
|
||||
Chat.LoadMoreMessagesAsync(selectedContact, GetFirstMessage(), chatMessages =>
|
||||
@@ -872,9 +857,6 @@ namespace ChatController
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ListenForMessages()
|
||||
{
|
||||
@@ -905,18 +887,22 @@ namespace ChatController
|
||||
var updatedContacts = updatedContactList.ToList();
|
||||
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var contactDependencyObject in _ContactList)
|
||||
{
|
||||
foreach (var newContact in updatedContacts)
|
||||
{
|
||||
if (contactDependencyObject.Contact.GroupId == newContact.GroupId)
|
||||
if(contactDependencyObject.Contact.GroupId != newContact.GroupId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// ReceivedMessage kann null sein!
|
||||
if (!(contactDependencyObject.Contact.ReceivedMessage is null) && !contactDependencyObject.Contact.ReceivedMessage.Id.Equals(newContact.ReceivedMessage?.Id))
|
||||
if(contactDependencyObject.Contact.ReceivedMessage is null || contactDependencyObject.Contact.ReceivedMessage.Id.Equals(newContact.ReceivedMessage?.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
contactDependencyObject.Contact.ReceivedMessage = newContact.ReceivedMessage;
|
||||
contactDependencyObject.Contact.TimeStamp = newContact.TimeStamp;
|
||||
|
||||
@@ -956,8 +942,6 @@ namespace ChatController
|
||||
contactDependencyObject.Contact.IsNewMessage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!updatedContacts.Contains(contactDependencyObject.Contact))
|
||||
{
|
||||
@@ -968,12 +952,6 @@ namespace ChatController
|
||||
ContactList.Sort((x, y) => DateTime.Compare(y.Contact.TimeStamp, x.Contact.TimeStamp));
|
||||
OnPropertyChanged(nameof(ChatMessages));
|
||||
OnPropertyChanged(nameof(ContactList));
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
throw;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1040,12 +1018,18 @@ namespace ChatController
|
||||
|
||||
private void Chat_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if(ChatListBox.SelectedItems.Count > 0)
|
||||
if(ChatListBox.SelectedItems.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedItem = ChatListBox.SelectedItems[0];
|
||||
|
||||
if(selectedItem is ChatMessage selectedMessage)
|
||||
if(!(selectedItem is ChatMessage selectedMessage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(selectedMessage.OriginalImage))
|
||||
{
|
||||
var uri = new Uri(selectedMessage.OriginalImage);
|
||||
@@ -1078,8 +1062,6 @@ namespace ChatController
|
||||
LoadDocumentAsync(selectedMessage.FilePath, Path.GetFileName(selectedMessage.FilePath), EndWaiting);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDocumentAsync(string uri, string fileName, Action callback)
|
||||
{
|
||||
@@ -1111,11 +1093,10 @@ namespace ChatController
|
||||
callback?.Invoke();
|
||||
}
|
||||
}
|
||||
catch(Exception exception)
|
||||
finally
|
||||
{
|
||||
EndWaiting();
|
||||
|
||||
MessageBox.Show(exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,15 +1109,17 @@ namespace ChatController
|
||||
|
||||
public void StartWaitingImmediately(string dialogText = null)
|
||||
{
|
||||
if (_WaitLayer is null)
|
||||
if(!(_WaitLayer is null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_WaitLayer = new ChatControlWaitLayer(dialogText);
|
||||
Grid.SetRowSpan(_WaitLayer, 3);
|
||||
RootGrid.Children.Add(_WaitLayer);
|
||||
Panel.SetZIndex(_WaitLayer, int.MaxValue);
|
||||
_WaitLayer.RefreshChatUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void EndWaiting()
|
||||
{
|
||||
@@ -1144,11 +1127,13 @@ namespace ChatController
|
||||
DispatcherPriority.Background,
|
||||
(Action) delegate
|
||||
{
|
||||
if(!(_WaitLayer is null))
|
||||
if(_WaitLayer is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RootGrid.Children.Remove(_WaitLayer);
|
||||
_WaitLayer = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1197,10 +1182,9 @@ namespace ChatController
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
finally
|
||||
{
|
||||
EndWaiting();
|
||||
MessageBox.Show("Ein Fehler bei der Synchronisation ist aufgetreten.\nFehler:\n" + e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1305,8 +1289,11 @@ namespace ChatController
|
||||
// Wird im BeWoPlaner benutzt
|
||||
public void ResetNumberOfUnreadMessages(Dictionary<long, DateTime> pGroupId2DateTime)
|
||||
{
|
||||
if(!(pGroupId2DateTime is null))
|
||||
if(pGroupId2DateTime is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var contactDependencyObject in _ContactList)
|
||||
{
|
||||
foreach(var groupId2DateTime in pGroupId2DateTime)
|
||||
@@ -1318,7 +1305,6 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wird im BeWoPlaner benutzt
|
||||
public List<ChatMessage> GetSelectedMessages()
|
||||
@@ -1449,15 +1435,15 @@ namespace ChatController
|
||||
|
||||
private CancellationTokenSource _CancellationTokenSource;
|
||||
|
||||
private string _DefaultBroadcastInfoText = "Sie befinden Sich im Stapel-Modus. In diesem Modus können Sie eine Nachricht in einem Schritt an mehrere Empfänger & Gruppen senden. Bitte setzen Sie dazu in der Kontaktliste bei den gewünschten Empfängern & Gruppen ein Häkchen und schreiben Sie Ihre Nachricht wie gewohnt. Wenn Sie auf senden klicken, wird die Nachricht an alle ausgewählten Empfänger & Gruppen gesendet.";
|
||||
private const string DefaultBroadcastInfoText = "Sie befinden Sich im Stapel-Modus. In diesem Modus können Sie eine Nachricht in einem Schritt an mehrere Empfänger & Gruppen senden. Bitte setzen Sie dazu in der Kontaktliste bei den gewünschten Empfängern & Gruppen ein Häkchen und schreiben Sie Ihre Nachricht wie gewohnt. Wenn Sie auf senden klicken, wird die Nachricht an alle ausgewählten Empfänger & Gruppen gesendet.";
|
||||
|
||||
private string _BroadcastInfoText;
|
||||
public string BroadcastInfoText
|
||||
{
|
||||
get => _BroadcastInfoText ?? (_BroadcastInfoText = _DefaultBroadcastInfoText);
|
||||
get => _BroadcastInfoText ?? (_BroadcastInfoText = DefaultBroadcastInfoText);
|
||||
set
|
||||
{
|
||||
_BroadcastInfoText = $"{_DefaultBroadcastInfoText}{Environment.NewLine}{value}";
|
||||
_BroadcastInfoText = $"{DefaultBroadcastInfoText}{Environment.NewLine}{value}";
|
||||
OnPropertyChanged(BroadcastInfoText);
|
||||
}
|
||||
}
|
||||
@@ -1598,8 +1584,11 @@ namespace ChatController
|
||||
|
||||
private void SelectAllContacts_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(sender is CheckBox checkBox)
|
||||
if(!(sender is CheckBox checkBox))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var isChecked = checkBox.IsChecked ?? false;
|
||||
|
||||
foreach(var contactDependencyObject in ContactList)
|
||||
@@ -1610,7 +1599,6 @@ namespace ChatController
|
||||
OnPropertyChanged(nameof(ContactList));
|
||||
OnPropertyChanged(nameof(IsBroadcastButtonEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
private void SendBroatcastButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -1626,12 +1614,18 @@ namespace ChatController
|
||||
|
||||
private void AddMediaFileToBroadcastMessage_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(Chat.IsInBroadcastMode)
|
||||
if(!Chat.IsInBroadcastMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var originalFilePath = Chat.OpenFile();
|
||||
|
||||
if(File.Exists(originalFilePath))
|
||||
if(!File.Exists(originalFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartWaitingImmediately("Skaliere Bild ...");
|
||||
|
||||
var scalingTask = new Task(() =>
|
||||
@@ -1661,8 +1655,6 @@ namespace ChatController
|
||||
|
||||
scalingTask.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseBroadcastMode()
|
||||
{
|
||||
|
||||
57
ChatController/ExceptionViewControl.xaml
Normal file
57
ChatController/ExceptionViewControl.xaml
Normal file
@@ -0,0 +1,57 @@
|
||||
<UserControl x:Class="ChatController.ExceptionViewControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="OrangeButtonStyle" TargetType="{x:Type Button}">
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="MinWidth" Value="100"></Setter>
|
||||
<Setter Property="BorderBrush" Value="#FF5A00" />
|
||||
<Setter Property="Background" Value="#FF5A00" />
|
||||
<Setter Property="Foreground" Value="White"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border x:Name="Border" Background="#FF5A00" CornerRadius="5" Padding="5,2">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FF988F" TargetName="Border" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#FF7654" TargetName="Border" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="LightGray" TargetName="Border" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" TextWrapping="Wrap" FontWeight="Bold" Text="Es ist leider ein unbekannter Fehler aufgetreten. Prüfen Sie Ihre Internetverbindung oder versuchen Sie es später erneut. Wir sind stets bemüht, das Programm zu verbessern, daher freuen wir uns auch, wenn Sie die Fehlerdetails unten in einer Mail an support@bewoplaner.de senden." Margin="5, 5, 5, 10" FontSize="14" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="5" FontSize="12" TextDecorations="Underline">Fehlerdetails:</TextBlock>
|
||||
<TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="5" IsReadOnly="True" Text="{Binding Path=Exception.StackTrace, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" />
|
||||
<Button Grid.Column="0" Grid.Row="3" Style="{StaticResource OrangeButtonStyle}" HorizontalAlignment="Left" Click="CopyToClipboardButton_OnClick">In die Zwischenablage kopieren</Button>
|
||||
<Button Grid.Column="2" Grid.Row="3" Style="{StaticResource OrangeButtonStyle}" HorizontalAlignment="Right" Click="OkButton_OnClick">OK</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
46
ChatController/ExceptionViewControl.xaml.cs
Normal file
46
ChatController/ExceptionViewControl.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
namespace ChatController
|
||||
{
|
||||
public partial class ExceptionViewControl : INotifyPropertyChanged
|
||||
{
|
||||
public event EventHandler OkButtonClicked;
|
||||
|
||||
private Exception _Exception;
|
||||
public Exception Exception
|
||||
{
|
||||
get => _Exception;
|
||||
set
|
||||
{
|
||||
_Exception = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ExceptionViewControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void OkButton_OnClick(object sender, RoutedEventArgs args)
|
||||
{
|
||||
OkButtonClicked?.Invoke(this, args);
|
||||
}
|
||||
|
||||
private void CopyToClipboardButton_OnClick(object sender, RoutedEventArgs args)
|
||||
{
|
||||
Clipboard.SetText(Exception.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
private static bool PinPublicKey(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(certificate is null || chain is null)
|
||||
{
|
||||
@@ -95,11 +93,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
return chainContainsPk && subjectAccepted;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private const string PubKeyX3 = "3082010A02820101009CD30CF05AE52E47B7725D3783B3686330EAD735261925E1BDBE35F170922FB7B84B4105ABA99E350858ECB12AC468870BA3E375E4E6F3A76271BA7981601FD7919A9FF3D0786771C8690E9591CFFEE699E9603C48CC7ECA4D7712249D471B5AEBB9EC1E37001C9CAC7BA705EACE4AEBBD41E53698B9CBFD6D3C9668DF232A42900C867467C87FA59AB8526114133F65E98287CBDBFA0E56F68689F3853F9786AFB0DC1AEF6B0D95167DC42BA065B299043675806BAC4AF31B9049782FA2964F2A20252904C674C0D031CD8F31389516BAA833B843F1B11FC3307FA27931133D2D36F8E3FCF2336AB93931C5AFC48D0D1D641633AAFA8429B6D40BC0D87DC3930203010001";
|
||||
|
||||
@@ -133,8 +126,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
private void LoadMessagesFromServerAsync(long groupId, Action callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = $"{ChatDaten.ServerUrl}{Constants.LoadMessagesForGroupUrl}{groupId}";
|
||||
|
||||
@@ -161,11 +152,6 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke();
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ThreadExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadMoreMessagesAsync(Contact contact, ChatMessage previousMessage, Action<List<ChatMessage>> callback)
|
||||
{
|
||||
@@ -176,8 +162,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
private void LoadMoreMessagesFromServerAsync(long groupId, string page, Action callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(page is null || !page.Contains("="))
|
||||
{
|
||||
@@ -210,11 +194,6 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke();
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private double _FormerMessagesCount;
|
||||
|
||||
@@ -259,8 +238,8 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
callback?.Invoke(0d);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +257,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
private void LoadNumberOfNewMessagesFromServerAsync(long groupId, Action<double> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = $"{ChatDaten.ServerUrl}{Constants.LoadOwnChatNewsUrl}{groupId}/{LastTimeStamp}";
|
||||
|
||||
@@ -296,15 +273,8 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke(messageCounter?.MessageCount ?? 0);
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ThreadExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadGroupsAsync(Action<ChatGruppenDaten> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = $"{ChatDaten.ServerUrl}{Constants.GetChatGroupsUrl}";
|
||||
|
||||
@@ -321,15 +291,8 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke(contacts);
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateContactList(Action<IOrderedEnumerable<Contact>> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadGroupsAsync(rawData =>
|
||||
{
|
||||
@@ -338,39 +301,21 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke(contacts.OrderByDescending(c => c.TimeStamp));
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChatMessage> AddNewMessage(string pMessage, long pGroupId, ChatMessage previousMessage)
|
||||
{
|
||||
var result = new List<ChatMessage>();
|
||||
|
||||
try
|
||||
{
|
||||
var time = DateTime.Now;
|
||||
|
||||
var chatMessage = new ChatMessage(pGroupId, 0, ChatDaten.LoggedInUser.Response.User.UserName, pMessage, time, true, 0, null, null, null, null, null, ChatMessageType.Message, ChatDaten.LoggedInUser.Response.User.Oid);
|
||||
|
||||
result = AddSeparators(new List<ChatMessage> {previousMessage, chatMessage});
|
||||
var result = AddSeparators(new List<ChatMessage> {previousMessage, chatMessage});
|
||||
|
||||
result.Remove(previousMessage);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task SendMessage(string message, long groupId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = ChatDaten.ServerUrl + Constants.SendMessageUrl;
|
||||
|
||||
@@ -390,15 +335,8 @@ namespace ChatController.HauptKlassen
|
||||
await httpClient.SendAsync(httpRequest, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public string OpenFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
@@ -409,19 +347,11 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
return result == DialogResult.OK ? openFileDialog.FileName : null;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChatMessage> AddNewFile(string pathToScaledFile, string originalFilePath, long groupId, ChatMessage previousMessage, string chatBoxText)
|
||||
{
|
||||
var result = new List<ChatMessage>();
|
||||
|
||||
try
|
||||
{
|
||||
if(string.IsNullOrEmpty(pathToScaledFile) || string.IsNullOrEmpty(originalFilePath))
|
||||
{
|
||||
return result;
|
||||
@@ -450,16 +380,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
return result;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
if(!(exception is IOException))
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static BitmapImage GetImageFile(string pathToScaledFile, out long fileSize)
|
||||
{
|
||||
@@ -562,16 +482,9 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
public async Task SendFileToContact(Contact currentContact, string scaledImagePath, string originalFilePath, string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
await SendFile(scaledImagePath, currentContact, originalFilePath, message);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendFile(string pFile, Contact currentContact, string pOriginalFilePath, string message)
|
||||
{
|
||||
@@ -669,8 +582,6 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
byte[] mediaFile = null;
|
||||
|
||||
try
|
||||
{
|
||||
using(var webClient = new WebClient())
|
||||
{
|
||||
webClient.Credentials = CredentialCache.DefaultCredentials;
|
||||
@@ -681,17 +592,8 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
return mediaFile;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
|
||||
return mediaFile;
|
||||
}
|
||||
|
||||
private void SaveAs(int pFilterType, string pFileName, byte[] pMediaFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFileDialog = new SaveFileDialog {FileName = Path.GetFileName(pFileName)};
|
||||
|
||||
@@ -723,11 +625,6 @@ namespace ChatController.HauptKlassen
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Paste(long pGroupOid, ChatMainControl pChatMainControl)
|
||||
{
|
||||
@@ -739,8 +636,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
if(dataObject.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
try
|
||||
{
|
||||
if(dataObject.GetData(DataFormats.FileDrop) is string[] fileList)
|
||||
{
|
||||
@@ -763,11 +658,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dataObject.GetDataPresent(DataFormats.Text))
|
||||
@@ -824,20 +714,11 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
public void ShowProfilePicture(Contact currentContact)
|
||||
{
|
||||
try
|
||||
{
|
||||
ShowPictureWindow(currentContact.Image, currentContact.Name);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPictureWindow(ImageSource imageSource, string title)
|
||||
{
|
||||
try
|
||||
{
|
||||
var imageWidth = Convert.ToInt32(imageSource.Width);
|
||||
var imageHeight = Convert.ToInt32(imageSource.Height);
|
||||
@@ -900,11 +781,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
window.ShowDialog();
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPicture(string originalImage, long groupId, Action<ImageSource, string> downloadCompletedCallback)
|
||||
{
|
||||
@@ -913,8 +789,6 @@ namespace ChatController.HauptKlassen
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Utils.DownloadImageAsync(originalImage, $"group-{groupId}", CacheCategory.MessageAttachment, imageSource =>
|
||||
{
|
||||
var splitName = originalImage.Split('/');
|
||||
@@ -923,11 +797,6 @@ namespace ChatController.HauptKlassen
|
||||
downloadCompletedCallback?.Invoke(imageSource, last ?? "Bild");
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadGroupsAsync(Action<ChatGruppenDaten> callback)
|
||||
{
|
||||
@@ -950,8 +819,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
public List<Contact> UpdateContacts(ChatGruppenDaten chatDaten)
|
||||
{
|
||||
try
|
||||
{
|
||||
_Contacts.Clear();
|
||||
|
||||
@@ -962,12 +829,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
return _Contacts;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Contact> GenerateContactsFromServerResponse(GroupInput[] pGroupInputs, bool pShouldUpdateLastTimeStamp = false)
|
||||
{
|
||||
@@ -1015,10 +876,11 @@ namespace ChatController.HauptKlassen
|
||||
groupInput.Avatar,
|
||||
key, groupInput.Users.ToDictionary(user => user.Oid, user => user.Picture)));
|
||||
|
||||
if(pShouldUpdateLastTimeStamp)
|
||||
{
|
||||
if(!(latestMessage?.Timestamp?.Date is null))
|
||||
if(!pShouldUpdateLastTimeStamp || latestMessage?.Timestamp?.Date is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var unixTimeStamp = DateTime.Parse(latestMessage.Timestamp.Date).GetUnixTimeStamp();
|
||||
|
||||
if(LastTimeStamp < unixTimeStamp)
|
||||
@@ -1026,8 +888,6 @@ namespace ChatController.HauptKlassen
|
||||
LastTimeStamp = unixTimeStamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return contacts;
|
||||
}
|
||||
@@ -1091,8 +951,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
public void DownloadFileAsync(string uri, string path, Action callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient(uri);
|
||||
var request = new RestRequest();
|
||||
@@ -1114,11 +972,6 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke();
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsInBroadcastMode;
|
||||
|
||||
|
||||
@@ -83,8 +83,11 @@ namespace ChatController.HauptKlassen
|
||||
// Wird im BeWoPlaner benutzt
|
||||
public ChatDatenUebergabe AnmeldevorgangDurchFuehren()
|
||||
{
|
||||
if(ServerErmittlung())
|
||||
if(!ServerErmittlung())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var dic = new Dictionary<string, string>
|
||||
{
|
||||
{ "username", _UserName},
|
||||
@@ -99,20 +102,18 @@ namespace ChatController.HauptKlassen
|
||||
GetGroups();
|
||||
}
|
||||
|
||||
if(_GruppeholenverbindungsaufbauOk)
|
||||
if(!_GruppeholenverbindungsaufbauOk)
|
||||
{
|
||||
var maxUploadSize = GetMaiximumAllowedFileUploadSize(_AuthToken, _Tenant);
|
||||
|
||||
return new ChatDatenUebergabe(_LoggedInUser, _AllGroups, ServerUrl, _AuthToken, _UserId, _Tenant, _ApiKey, maxUploadSize);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var maxUploadSize = GetMaiximumAllowedFileUploadSize(_AuthToken, _Tenant);
|
||||
|
||||
return new ChatDatenUebergabe(_LoggedInUser, _AllGroups, ServerUrl, _AuthToken, _UserId, _Tenant, _ApiKey, maxUploadSize);
|
||||
|
||||
}
|
||||
|
||||
public void DoLoginAsync(Action<ChatDatenUebergabe> callback, Action<string> exceptionCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
LookupServerUrlAsync(isConnectedWithServer =>
|
||||
{
|
||||
@@ -140,15 +141,8 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}, errorMessage => { exceptionCallback?.Invoke(errorMessage); });
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
callback?.Invoke(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void LookupServerUrlAsync(Action<bool> callback, Action<string> exceptionCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(ServerUrl))
|
||||
{
|
||||
@@ -187,17 +181,10 @@ namespace ChatController.HauptKlassen
|
||||
callback?.Invoke(result);
|
||||
});
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
exceptionCallback?.Invoke("Fehler: Es konnte keine Verbindung aufgebaut werden.");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ServerErmittlung()
|
||||
{
|
||||
if(string.IsNullOrEmpty(ServerUrl))
|
||||
{
|
||||
try
|
||||
{
|
||||
var serverURl = DictionaryServerUrl + _Tenant;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
@@ -205,22 +192,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
|
||||
WebResponse response;
|
||||
|
||||
try
|
||||
{
|
||||
response = request.GetResponse();
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
if (_ShouldShowMessageBox)
|
||||
{
|
||||
MessageBox.Show("Fehler: Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var response = request.GetResponse();
|
||||
var responseFromServer = Utils.ReadStream(response);
|
||||
|
||||
try
|
||||
@@ -248,8 +220,6 @@ namespace ChatController.HauptKlassen
|
||||
_BaseUrl = jsonDatentyp.Url;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonDatentyp = JsonConvert.DeserializeObject<AuthenticationDataType2>(responseFromServer);
|
||||
|
||||
@@ -273,37 +243,17 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
_BaseUrl = jsonDatentyp.Url;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
if(_ShouldShowMessageBox)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + e.Message, "ownChat Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response.Close();
|
||||
|
||||
ServerUrl = _BaseUrl;
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
if(_ShouldShowMessageBox)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + e.Message, "ownChat Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void VerbindeMitChatServer(Dictionary<string, string> postparameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = _BaseUrl + Constants.LoginWithChatCodeUrl;
|
||||
|
||||
@@ -360,18 +310,8 @@ namespace ChatController.HauptKlassen
|
||||
MessageBox.Show(response.Content, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
if(_ShouldShowMessageBox)
|
||||
{
|
||||
MessageBox.Show("Fehler:" + e.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GetGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = _BaseUrl + Constants.GetChatGroupsUrl;
|
||||
|
||||
@@ -385,8 +325,11 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
var serverResponse = Utils.ReadStream(response);
|
||||
|
||||
if (!string.IsNullOrEmpty(serverResponse))
|
||||
if(string.IsNullOrEmpty(serverResponse))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var jsonDaten = JsonConvert.DeserializeObject<ChatGruppenDaten>(serverResponse);
|
||||
|
||||
_AllGroups = jsonDaten;
|
||||
@@ -394,15 +337,6 @@ namespace ChatController.HauptKlassen
|
||||
_GruppeholenverbindungsaufbauOk = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_ShouldShowMessageBox)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + e.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectWithChatServerAsync(Action<bool> callback, Action<string> exceptionCallback)
|
||||
{
|
||||
@@ -479,10 +413,8 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
public long GetMaiximumAllowedFileUploadSize(string pToken, string pCustomerId)
|
||||
{
|
||||
long maximumFileSize;
|
||||
long maximumFileSize = 0L;
|
||||
|
||||
try
|
||||
{
|
||||
var endurl = ServerUrl + Constants.MaxUploadFileSizeUrl;
|
||||
|
||||
var request = WebRequest.Create(endurl);
|
||||
@@ -501,11 +433,6 @@ namespace ChatController.HauptKlassen
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
maximumFileSize = Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return maximumFileSize;
|
||||
}
|
||||
@@ -522,7 +449,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
client.ExecuteAsync(request, response =>
|
||||
{
|
||||
Debug.WriteLine("+++>Maximale Dateigröße erhalten");
|
||||
var maxFileSizeAnonymous = JsonConvert.DeserializeAnonymousType(response.Content, new { file_upload_max_size = string.Empty });
|
||||
|
||||
var maxUploadFileSize = Convert.ToInt64(maxFileSizeAnonymous.file_upload_max_size);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@@ -29,13 +28,15 @@ namespace ChatController
|
||||
|
||||
set
|
||||
{
|
||||
if (!Equals(_Benutzername, value))
|
||||
if(Equals(_Benutzername, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Benutzername = value;
|
||||
OnPropertyChanged(nameof(UserName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
@@ -50,13 +51,15 @@ namespace ChatController
|
||||
|
||||
set
|
||||
{
|
||||
if(!Equals(_ChatCode, value))
|
||||
if(Equals(_ChatCode, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ChatCode = value;
|
||||
OnPropertyChanged(nameof(ChatCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Tenant
|
||||
{
|
||||
@@ -64,13 +67,15 @@ namespace ChatController
|
||||
|
||||
set
|
||||
{
|
||||
if(!Equals(_Kundennummer, value))
|
||||
if(Equals(_Kundennummer, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Kundennummer = value;
|
||||
OnPropertyChanged(nameof(Tenant));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void LoginDelegate(ChatDatenUebergabe cdu);
|
||||
|
||||
@@ -104,24 +109,28 @@ namespace ChatController
|
||||
|
||||
private void StartWaitingImmediately()
|
||||
{
|
||||
if (_WaitLayer is null)
|
||||
if(!(_WaitLayer is null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_WaitLayer = new ChatControlWaitLayer();
|
||||
Panel.SetZIndex(_WaitLayer, int.MaxValue);
|
||||
RootGrid.Children.Add(_WaitLayer);
|
||||
_WaitLayer.RefreshUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void EndWaiting()
|
||||
{
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate
|
||||
{
|
||||
if(!(_WaitLayer is null))
|
||||
if(_WaitLayer is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RootGrid.Children.Remove(_WaitLayer);
|
||||
_WaitLayer = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,12 +150,14 @@ namespace ChatController
|
||||
{
|
||||
EndWaiting();
|
||||
|
||||
if(chatDatenUebergabe != null)
|
||||
if(chatDatenUebergabe is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AutosetDaten();
|
||||
|
||||
OnLogin?.Invoke(chatDatenUebergabe);
|
||||
}
|
||||
});
|
||||
},
|
||||
errorMessage =>
|
||||
@@ -164,17 +175,14 @@ namespace ChatController
|
||||
MessageBox.Show("Bitte alle Felder ausfüllen!", "Info", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
finally
|
||||
{
|
||||
MessageBox.Show("Fehler: " + exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
EndWaiting();
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTenantAndChatCodeFromFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(File.Exists(Path.Combine(GetAndCreateUserAppDataPath(), Constants.TenantAndChatCodeFileName)))
|
||||
{
|
||||
@@ -213,8 +221,6 @@ namespace ChatController
|
||||
while(!((line = streamReader2.ReadLine()) is null))
|
||||
{
|
||||
if(counter == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var encodedTextBytes = Convert.FromBase64String(line);
|
||||
|
||||
@@ -222,15 +228,7 @@ namespace ChatController
|
||||
|
||||
UserName = plainText;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Der Zeile muss im Base64-Format kodiert sein.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
}
|
||||
else if(counter == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
var encodedTextBytes = Convert.FromBase64String(line);
|
||||
|
||||
@@ -238,11 +236,6 @@ namespace ChatController
|
||||
|
||||
Password = plainText;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Der Zeile muss im Base64-Format kodiert sein.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
@@ -250,11 +243,6 @@ namespace ChatController
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show("Fehler: \n" + e.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LeseDateiFallsVorhanden()
|
||||
{
|
||||
@@ -262,8 +250,6 @@ namespace ChatController
|
||||
}
|
||||
|
||||
private void AutosetDaten()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(File.Exists(Path.Combine(GetAndCreateUserAppDataPath(), Constants.TenantAndChatCodeFileName)))
|
||||
{
|
||||
@@ -286,15 +272,8 @@ namespace ChatController
|
||||
File.SetAttributes(Path.Combine(GetAndCreateUserAppDataPath(), Constants.TenantAndChatCodeFileName), FileAttributes.ReadOnly);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Fehler: \n" + e.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAndCreateUserAppDataPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var companyFilePath = Path.Combine(localAppData, "ownSoft");
|
||||
@@ -313,14 +292,6 @@ namespace ChatController
|
||||
|
||||
return bewoFilePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Fehler beim Anlegen des Anwendungsordners. Sie besitzen nicht die erforderlichen Rechte, bitte wenden Sie sich an Ihren Systemadministrator.\n" +
|
||||
ex.Message, "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
|
||||
public void Login()
|
||||
{
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace ChatController.Utilities
|
||||
public class FileUtils
|
||||
{
|
||||
public static string ScaleImage(string pFile, string pFormat, long maxUploadSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
var isImageFile = Constants.ImageFileExtensions.Contains(Path.GetExtension(pFile).ToUpperInvariant());
|
||||
|
||||
@@ -124,11 +122,6 @@ namespace ChatController.Utilities
|
||||
|
||||
return filePath;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
return pFile;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckFileSize(string pathToFile, long maxFileSize)
|
||||
{
|
||||
|
||||
@@ -212,8 +212,6 @@ namespace ChatController.Utilities
|
||||
}
|
||||
|
||||
public static string GetAndCreateUserAppDataPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var companyFilePath = Path.Combine(localAppData, Resource.CompanyName);
|
||||
@@ -232,13 +230,6 @@ namespace ChatController.Utilities
|
||||
|
||||
return bewoFilePath;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Anlegen des Anwendungsordners. Sie besitzen nicht die erforderlichen Rechte, bitte wenden Sie sich an Ihren Systemadministrator.\n" + exception.Message, "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
|
||||
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
|
||||
public static string GenerateTempName()
|
||||
{
|
||||
@@ -252,8 +243,6 @@ namespace ChatController.Utilities
|
||||
}
|
||||
|
||||
public static byte[] ImageToByteArray(Image pImage)
|
||||
{
|
||||
try
|
||||
{
|
||||
using(var memoryStream = new MemoryStream())
|
||||
{
|
||||
@@ -261,12 +250,6 @@ namespace ChatController.Utilities
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + exception.Message, "Fehler", MessageBoxButton.OK);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageSource ConvertIconToImageSource(Icon pIcon)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:ownChat"
|
||||
DispatcherUnhandledException="App_DispatcherUnhandledException"
|
||||
StartupUri="LoginMaske.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
namespace ownChat
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ownChat
|
||||
{
|
||||
public partial class App
|
||||
{
|
||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs args)
|
||||
{
|
||||
new ExceptionWindow(args.Exception) { Owner = MainWindow }.Show();
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
PrototypChat/ExceptionWindow.xaml
Normal file
12
PrototypChat/ExceptionWindow.xaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="ownChat.ExceptionWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:chatController="clr-namespace:ChatController;assembly=ChatController"
|
||||
mc:Ignorable="d" WindowStartupLocation="CenterOwner"
|
||||
Title="Es ist ein Fehler aufgetreten" Height="450" Width="800">
|
||||
<Grid>
|
||||
<chatController:ExceptionViewControl x:Name="ExceptionViewControl" OkButtonClicked="ExceptionViewControl_OnOkButtonClicked" />
|
||||
</Grid>
|
||||
</Window>
|
||||
18
PrototypChat/ExceptionWindow.xaml.cs
Normal file
18
PrototypChat/ExceptionWindow.xaml.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace ownChat
|
||||
{
|
||||
public partial class ExceptionWindow
|
||||
{
|
||||
public ExceptionWindow(Exception exception)
|
||||
{
|
||||
InitializeComponent();
|
||||
ExceptionViewControl.Exception = exception;
|
||||
}
|
||||
|
||||
private void ExceptionViewControl_OnOkButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ namespace ownChat
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.UnhandledException += ExceptionHandler;
|
||||
|
||||
ChatMainControl.ContainingWindow = this;
|
||||
|
||||
ChatMainControl.InitMitChatdaten(x);
|
||||
@@ -24,6 +27,13 @@ namespace ownChat
|
||||
_EmojiView = new ChatEmojisView(ChatMainControl);
|
||||
}
|
||||
|
||||
private void ExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
var exception = (Exception)args.ExceptionObject;
|
||||
|
||||
new ExceptionWindow(exception) { Owner = this }.Show();
|
||||
}
|
||||
|
||||
private void ChatMainControl_OnOnEmojii(System.Windows.Controls.Button emojiButton)
|
||||
{
|
||||
_EmojiView.Visibility = Visibility.Visible;
|
||||
@@ -31,12 +41,14 @@ namespace ownChat
|
||||
var pointToScreen = emojiButton.PointToScreen(new Point(0, 0));
|
||||
var presentationSource = PresentationSource.FromVisual(emojiButton);
|
||||
|
||||
if(presentationSource?.CompositionTarget != null)
|
||||
if(presentationSource?.CompositionTarget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_EmojiView.Top = pointToScreen.Y / presentationSource.CompositionTarget.TransformToDevice.M22 - _EmojiView.Height - 5;
|
||||
_EmojiView.Left = pointToScreen.X / presentationSource.CompositionTarget.TransformToDevice.M11 - 270;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ExceptionWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="LoginMaske.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -117,6 +121,9 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExceptionWindow.xaml.cs">
|
||||
<DependentUpon>ExceptionWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoginMaske.xaml.cs">
|
||||
<DependentUpon>LoginMaske.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user