Warnung bei 500er Fehlern anstatt von zig einzelnen Fehlermeldungen
This commit is contained in:
@@ -149,6 +149,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="ownchat_favicon.ico" />
|
<Content Include="ownchat_favicon.ico" />
|
||||||
|
<Resource Include="Ressourcen\warning-exclamation-mark.png" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Resources\oC-favico_NewMessage.ico" />
|
<None Include="Resources\oC-favico_NewMessage.ico" />
|
||||||
<Content Include="Resources\ownchat_favicon.ico" />
|
<Content Include="Resources\ownchat_favicon.ico" />
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
<Setter Property="Template" Value="{StaticResource ContactListBoxTemplate}" />
|
<Setter Property="Template" Value="{StaticResource ContactListBoxTemplate}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Kontaktliste -->
|
||||||
<Style x:Key="ContactListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
<Style x:Key="ContactListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||||
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
||||||
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
||||||
@@ -210,29 +211,20 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<ListBox x:Name="AktChatUserList" HorizontalAlignment="Left" Margin="0" Grid.Row="0" Background="Transparent" BorderBrush="Transparent" VerticalAlignment="Bottom" ItemTemplate="{DynamicResource DataTemplate2}" MouseDoubleClick="AktChatUser_OnMouseDoubleClick" >
|
<Grid Grid.Row="0" HorizontalAlignment="Left" Background="Transparent" VerticalAlignment="Center" Height="50" PreviewMouseDown="CurrentContactImage_OnMouseDoubleClick">
|
||||||
<ListBox.Resources>
|
<Grid.ColumnDefinitions>
|
||||||
<DataTemplate x:Key="DataTemplate2" DataType="chatKlassen:Contact">
|
<ColumnDefinition Width="50" />
|
||||||
<Grid>
|
<ColumnDefinition Width="*" />
|
||||||
<Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="50"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="10*" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
<Ellipse Width='40' Height='40' VerticalAlignment="Center" RenderOptions.BitmapScalingMode="HighQuality">
|
<Ellipse Width='40' Height='40' VerticalAlignment="Center" RenderOptions.BitmapScalingMode="HighQuality">
|
||||||
<Ellipse.Fill >
|
<Ellipse.Fill >
|
||||||
<ImageBrush ImageSource='{Binding Image}' Stretch="UniformToFill"/>
|
<ImageBrush ImageSource='{Binding Path=ThreadExceptionImageSource, UpdateSourceTrigger=PropertyChanged}' Stretch="UniformToFill"/>
|
||||||
</Ellipse.Fill>
|
</Ellipse.Fill>
|
||||||
</Ellipse>
|
</Ellipse>
|
||||||
|
|
||||||
<TextBlock Grid.Column="1" Margin="8" Text="{Binding Path=Name, FallbackValue=FirstName}" FontSize="16" Foreground="{Binding AccentColorBrush}" />
|
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="8" TextWrapping="Wrap" Text="{Binding CurrentContactInformationString}" FontSize="16" Foreground="{Binding CurrencContactInfoForeground}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.Resources>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
<ListBox x:Name="ChatListBox" ItemsSource="{Binding CurrentChatMessages, UpdateSourceTrigger=PropertyChanged}"
|
<ListBox x:Name="ChatListBox" ItemsSource="{Binding CurrentChatMessages, UpdateSourceTrigger=PropertyChanged}"
|
||||||
HorizontalAlignment="Stretch" ScrollViewer.CanContentScroll="False" VerticalAlignment="Stretch" Grid.Row="1"
|
HorizontalAlignment="Stretch" ScrollViewer.CanContentScroll="False" VerticalAlignment="Stretch" Grid.Row="1"
|
||||||
@@ -366,7 +358,8 @@
|
|||||||
Margin="2"
|
Margin="2"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
GotFocus="Chatbox_OnGotFocus"
|
GotFocus="Chatbox_OnGotFocus"
|
||||||
KeyDown="Chatbox_OnKeyDownHandler">
|
KeyDown="Chatbox_OnKeyDownHandler"
|
||||||
|
TextChanged="Chatbox_OnTextChanged">
|
||||||
<TextBox.Resources>
|
<TextBox.Resources>
|
||||||
<Style TargetType="{x:Type Border}">
|
<Style TargetType="{x:Type Border}">
|
||||||
<Setter Property="CornerRadius" Value="2"/>
|
<Setter Property="CornerRadius" Value="2"/>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using System.Windows.Data;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using ChatController.Annotations;
|
using ChatController.Annotations;
|
||||||
@@ -43,6 +44,33 @@ namespace ChatController
|
|||||||
|
|
||||||
private readonly Dictionary<int, SyncFileInfoStruct> _GroupId2DateTime = new Dictionary<int, SyncFileInfoStruct>();
|
private readonly Dictionary<int, SyncFileInfoStruct> _GroupId2DateTime = new Dictionary<int, SyncFileInfoStruct>();
|
||||||
|
|
||||||
|
private string _ThreadExceptionMessage;
|
||||||
|
|
||||||
|
public string ThreadExceptionMessage
|
||||||
|
{
|
||||||
|
get => _ThreadExceptionMessage;
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(!Equals(_ThreadExceptionMessage, value))
|
||||||
|
{
|
||||||
|
_ThreadExceptionMessage = value;
|
||||||
|
OnPropertyChanged(nameof(ThreadExceptionMessage));
|
||||||
|
OnPropertyChanged(nameof(CurrentContactInformationString));
|
||||||
|
OnPropertyChanged(nameof(CurrencContactInfoForeground));
|
||||||
|
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ImageSource _ThreadExceptionImageSource;
|
||||||
|
|
||||||
|
public ImageSource ThreadExceptionImageSource => ThreadExceptionMessage != null ? _ThreadExceptionImageSource : CurrentContact?.Image;
|
||||||
|
|
||||||
|
public SolidColorBrush CurrencContactInfoForeground => ThreadExceptionMessage != null ? new SolidColorBrush(Color.FromRgb(185, 65, 0)) : CurrentContact?.AccentColorBrush ?? new SolidColorBrush(Colors.Transparent);
|
||||||
|
|
||||||
|
public string CurrentContactInformationString => ThreadExceptionMessage ?? CurrentContact?.Name;
|
||||||
|
|
||||||
private Window _ContainingWindow;
|
private Window _ContainingWindow;
|
||||||
|
|
||||||
public Window ContainingWindow
|
public Window ContainingWindow
|
||||||
@@ -79,6 +107,9 @@ namespace ChatController
|
|||||||
OnPropertyChanged(nameof(CurrentContact));
|
OnPropertyChanged(nameof(CurrentContact));
|
||||||
OnPropertyChanged(nameof(ChatMessageInputGridVisibility));
|
OnPropertyChanged(nameof(ChatMessageInputGridVisibility));
|
||||||
OnPropertyChanged(nameof(CurrentChatMessages));
|
OnPropertyChanged(nameof(CurrentChatMessages));
|
||||||
|
OnPropertyChanged(nameof(CurrentContactInformationString));
|
||||||
|
OnPropertyChanged(nameof(CurrencContactInfoForeground));
|
||||||
|
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +153,8 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
_ThreadExceptionImageSource = new BitmapImage(new Uri("pack://application:,,,/ChatController;component/Ressourcen/warning-exclamation-mark.png", UriKind.Absolute));
|
||||||
|
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
|
||||||
ReloadGruppen.Visibility = Visibility.Collapsed;
|
ReloadGruppen.Visibility = Visibility.Collapsed;
|
||||||
@@ -140,11 +173,24 @@ namespace ChatController
|
|||||||
public void InitMitChatdaten(ChatDatenUebergabe cdu)
|
public void InitMitChatdaten(ChatDatenUebergabe cdu)
|
||||||
{
|
{
|
||||||
_Chat = new Chat(cdu, exception => {
|
_Chat = new Chat(cdu, exception => {
|
||||||
this.Dispatch(() => {
|
this.Dispatch(
|
||||||
EndWaiting();
|
() => {
|
||||||
MessageBox.Show($"Fehler: {exception.Message}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
EndWaiting();
|
||||||
|
|
||||||
|
MessageBox.Show($"Fehler: {exception.Message}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
exception => {
|
||||||
|
this.Dispatch(
|
||||||
|
() => {
|
||||||
|
if(exception == null)
|
||||||
|
{
|
||||||
|
ThreadExceptionMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadExceptionMessage = exception?.Message?.Contains("500") ?? false ? "ownChat ist vorrübergehend nicht verfügbar. Bitte versuchen Sie es später noch einmal." : null;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
_ContactList = _Chat.AddContacts();
|
_ContactList = _Chat.AddContacts();
|
||||||
OnPropertyChanged(nameof(ContactList));
|
OnPropertyChanged(nameof(ContactList));
|
||||||
@@ -236,9 +282,12 @@ namespace ChatController
|
|||||||
_IsDesktopVersion = false;
|
_IsDesktopVersion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AktChatUser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void CurrentContactImage_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
_Chat.ShowProfilePicture(_CurrentContact);
|
if(e.ClickCount == 2)
|
||||||
|
{
|
||||||
|
_Chat.ShowProfilePicture(_CurrentContact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Clientlist_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void Clientlist_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
@@ -262,8 +311,6 @@ namespace ChatController
|
|||||||
Cursor = Cursors.Wait;
|
Cursor = Cursors.Wait;
|
||||||
_ScrollPrueferAktivieren = false;
|
_ScrollPrueferAktivieren = false;
|
||||||
|
|
||||||
AktChatUserList.Items.Clear();
|
|
||||||
|
|
||||||
if (pContact.HasUnreadMessages)
|
if (pContact.HasUnreadMessages)
|
||||||
{
|
{
|
||||||
pContact.HasUnreadMessages = false;
|
pContact.HasUnreadMessages = false;
|
||||||
@@ -280,7 +327,6 @@ namespace ChatController
|
|||||||
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.ownchat_favicon);
|
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.ownchat_favicon);
|
||||||
}
|
}
|
||||||
|
|
||||||
AktChatUserList.Items.Add(currentContact);
|
|
||||||
CurrentContact = currentContact;
|
CurrentContact = currentContact;
|
||||||
|
|
||||||
if(Clientlist.Items.Contains(pContact))
|
if(Clientlist.Items.Contains(pContact))
|
||||||
@@ -368,8 +414,7 @@ namespace ChatController
|
|||||||
|
|
||||||
private void PasteOnClick(object sender, RoutedEventArgs routedEventArgs)
|
private void PasteOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||||
{
|
{
|
||||||
var kontakt = (Contact)AktChatUserList.Items[0];
|
_Chat.Paste(CurrentContact.GroupId,this);
|
||||||
_Chat.Paste(kontakt.GroupId,this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyOnClick(object sender, RoutedEventArgs routedEventArgs)
|
private void CopyOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||||
@@ -468,9 +513,8 @@ namespace ChatController
|
|||||||
ContextItemSpeichernUnter.Visibility = Visibility.Collapsed;
|
ContextItemSpeichernUnter.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//prüfe ob dokumentation erlaubt
|
// Prüfe, ob Dokumentation erlaubt
|
||||||
var kontakt = (Contact)AktChatUserList.Items[0];
|
if(CurrentContact.UserIdManage == null && ChatListBox.ContextMenu.Items.Count > 3)
|
||||||
if(kontakt.UserIdManage == null && ChatListBox.ContextMenu.Items.Count > 3)
|
|
||||||
{
|
{
|
||||||
var contextItems = ChatListBox.ContextMenu.Items;
|
var contextItems = ChatListBox.ContextMenu.Items;
|
||||||
var ContextItemSpeichernUnter = (MenuItem)contextItems[3];
|
var ContextItemSpeichernUnter = (MenuItem)contextItems[3];
|
||||||
@@ -492,7 +536,7 @@ namespace ChatController
|
|||||||
|
|
||||||
private void MediaButton_OnClick(object sender, RoutedEventArgs e)
|
private void MediaButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (AktChatUserList.Items.Count > 0)
|
if(CurrentContact != null)
|
||||||
{
|
{
|
||||||
var fileToOpen = _Chat.OpenFile();
|
var fileToOpen = _Chat.OpenFile();
|
||||||
|
|
||||||
@@ -510,7 +554,7 @@ namespace ChatController
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(filePath))
|
if (!string.IsNullOrWhiteSpace(filePath))
|
||||||
{
|
{
|
||||||
//_Chat.AddNewFile(filePath, fileToOpen, CurrentContact.GroupId);
|
_Chat.AddNewFile(filePath, fileToOpen, CurrentContact.GroupId);
|
||||||
|
|
||||||
OnPropertyChanged(nameof(CurrentChatMessages));
|
OnPropertyChanged(nameof(CurrentChatMessages));
|
||||||
|
|
||||||
@@ -534,7 +578,7 @@ namespace ChatController
|
|||||||
|
|
||||||
private void SendButton_OnClick(object sender, RoutedEventArgs e)
|
private void SendButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!AktChatUserList.Items.IsEmpty && !string.IsNullOrEmpty(Chatbox.Text))
|
if(CurrentContact != null && !string.IsNullOrEmpty(Chatbox.Text))
|
||||||
{
|
{
|
||||||
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
||||||
|
|
||||||
@@ -564,7 +608,7 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
if (e.Key == Key.Return)
|
if (e.Key == Key.Return)
|
||||||
{
|
{
|
||||||
if (!AktChatUserList.Items.IsEmpty && !string.IsNullOrEmpty(Chatbox.Text))
|
if(CurrentContact != null && !string.IsNullOrEmpty(Chatbox.Text))
|
||||||
{
|
{
|
||||||
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
||||||
|
|
||||||
@@ -646,7 +690,7 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
EmojisListeningThreadTimer?.Stop();
|
EmojisListeningThreadTimer?.Stop();
|
||||||
EmojisListeningThreadTimer = null;
|
EmojisListeningThreadTimer = null;
|
||||||
InitListeningThread((Contact)AktChatUserList.Items[0]);
|
InitListeningThread(CurrentContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer EmojisListeningThreadTimer;
|
public Timer EmojisListeningThreadTimer;
|
||||||
@@ -656,7 +700,7 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
GlobalListeningThreadtimer = new Timer();
|
GlobalListeningThreadtimer = new Timer();
|
||||||
GlobalListeningThreadtimer.Tick += GlobalListeningThreadTimerTickEvent;
|
GlobalListeningThreadtimer.Tick += GlobalListeningThreadTimerTickEvent;
|
||||||
GlobalListeningThreadtimer.Interval = 2000;
|
GlobalListeningThreadtimer.Interval = 10000;
|
||||||
GlobalListeningThreadtimer.Start();
|
GlobalListeningThreadtimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,13 +721,6 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
var contacts = _Chat.NeueGroupklassenKontakte().ToList();
|
var contacts = _Chat.NeueGroupklassenKontakte().ToList();
|
||||||
|
|
||||||
Contact currentContact = null;
|
|
||||||
|
|
||||||
if (AktChatUserList.HasItems)
|
|
||||||
{
|
|
||||||
currentContact = (Contact) AktChatUserList.Items[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var contact in _ContactList)
|
foreach (var contact in _ContactList)
|
||||||
{
|
{
|
||||||
foreach (var newContact in contacts)
|
foreach (var newContact in contacts)
|
||||||
@@ -696,15 +733,17 @@ namespace ChatController
|
|||||||
contact.ReceivedMessage = newContact.ReceivedMessage;
|
contact.ReceivedMessage = newContact.ReceivedMessage;
|
||||||
contact.TimeStamp = newContact.TimeStamp;
|
contact.TimeStamp = newContact.TimeStamp;
|
||||||
|
|
||||||
// TODO: Prüfen, ob die App im Hintergrund oder minimiert ist
|
var selectedContact = (Contact) Clientlist.SelectedItem;
|
||||||
if (Clientlist.SelectedItem != null && !((Contact)Clientlist.SelectedItem).GroupId.Equals(newContact.GroupId) || Clientlist.SelectedItem == null || _IsInBackground)
|
var userOid = _Chat.ChatDaten.LoggedInUser.Response.User.Oid;
|
||||||
|
|
||||||
|
if (selectedContact != null && !selectedContact.GroupId.Equals(newContact.GroupId) || selectedContact == null || _IsInBackground && userOid != contact?.ReceivedMessage?.UserId)
|
||||||
{
|
{
|
||||||
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.oC_favico_NewMessage);
|
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.oC_favico_NewMessage);
|
||||||
ShowNotification(newContact.Name, newContact.ReceivedMessage, newContact.GroupId);
|
ShowNotification(newContact.Name, newContact.ReceivedMessage, newContact.GroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wenn der momentan ausgewählte Kontakt der aktuelle Kontakt in der Schleife ist, werden die Nachrichten nicht als ungelesen angezeigt, sonst schon.
|
// Wenn der momentan ausgewählte Kontakt der aktuelle Kontakt in der Schleife ist, werden die Nachrichten nicht als ungelesen angezeigt, sonst schon.
|
||||||
if (currentContact != null && newContact.GroupId == currentContact.GroupId)
|
if (CurrentContact != null && newContact.GroupId == CurrentContact.GroupId)
|
||||||
{
|
{
|
||||||
contact.HasUnreadMessages = false;
|
contact.HasUnreadMessages = false;
|
||||||
}
|
}
|
||||||
@@ -737,7 +776,7 @@ namespace ChatController
|
|||||||
{
|
{
|
||||||
EmojisListeningThreadTimer = new Timer {Tag = currentContact};
|
EmojisListeningThreadTimer = new Timer {Tag = currentContact};
|
||||||
EmojisListeningThreadTimer.Tick += ListeningThreadTimerTickEvent;
|
EmojisListeningThreadTimer.Tick += ListeningThreadTimerTickEvent;
|
||||||
EmojisListeningThreadTimer.Interval = 2000;
|
EmojisListeningThreadTimer.Interval = 10000;
|
||||||
EmojisListeningThreadTimer.Start();
|
EmojisListeningThreadTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1052,14 +1091,7 @@ namespace ChatController
|
|||||||
// Wird im BeWoPlaner benutzt
|
// Wird im BeWoPlaner benutzt
|
||||||
public Contact GetCurrentContact()
|
public Contact GetCurrentContact()
|
||||||
{
|
{
|
||||||
if(AktChatUserList != null && AktChatUserList.Items.Count > 0)
|
return CurrentContact?.UserIdManage != null ? CurrentContact : null;
|
||||||
{
|
|
||||||
var contact = (Contact) AktChatUserList.Items[0];
|
|
||||||
|
|
||||||
return contact.UserIdManage == null ? null : contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wird im BeWoPlaner benutzt
|
// Wird im BeWoPlaner benutzt
|
||||||
@@ -1107,5 +1139,13 @@ namespace ChatController
|
|||||||
var view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
|
var view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
|
||||||
view.Filter = UserFilter;
|
view.Filter = UserFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Chatbox_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(Chatbox.Text))
|
||||||
|
{
|
||||||
|
Chatbox.Height = 25;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace ChatController.HauptKlassen
|
|||||||
public class Chat
|
public class Chat
|
||||||
{
|
{
|
||||||
public Action<Exception> ExceptionCallback { get; set; }
|
public Action<Exception> ExceptionCallback { get; set; }
|
||||||
|
public Action<Exception> ThreadExceptionCallback { get; set; }
|
||||||
|
|
||||||
private readonly List<Contact> _Contacts = new List<Contact>();
|
private readonly List<Contact> _Contacts = new List<Contact>();
|
||||||
|
|
||||||
@@ -49,10 +50,11 @@ namespace ChatController.HauptKlassen
|
|||||||
|
|
||||||
public long LastTimeStamp { get; set; }
|
public long LastTimeStamp { get; set; }
|
||||||
|
|
||||||
public Chat(ChatDatenUebergabe chatDaten, Action<Exception> exceptionCallback)
|
public Chat(ChatDatenUebergabe chatDaten, Action<Exception> exceptionCallback, Action<Exception> threadExceptionCallback)
|
||||||
{
|
{
|
||||||
ChatDaten = chatDaten;
|
ChatDaten = chatDaten;
|
||||||
ExceptionCallback = exceptionCallback;
|
ExceptionCallback = exceptionCallback;
|
||||||
|
ThreadExceptionCallback = threadExceptionCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebRequest
|
// WebRequest
|
||||||
@@ -82,14 +84,7 @@ namespace ChatController.HauptKlassen
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var bitmapImage = new BitmapImage();
|
return DownloadImageWithRestRequest(pUri);
|
||||||
|
|
||||||
bitmapImage.BeginInit();
|
|
||||||
bitmapImage.UriSource = new Uri(pUri);
|
|
||||||
bitmapImage.CacheOption = BitmapCacheOption.OnDemand;
|
|
||||||
bitmapImage.EndInit();
|
|
||||||
|
|
||||||
return bitmapImage;
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@@ -98,6 +93,38 @@ namespace ChatController.HauptKlassen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImageSource DownloadImageWithRestRequest(string uri)
|
||||||
|
{
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
|
||||||
|
if(!string.IsNullOrWhiteSpace(uri))
|
||||||
|
{
|
||||||
|
var client = new RestClient(uri);
|
||||||
|
|
||||||
|
var request = new RestRequest(Method.GET)
|
||||||
|
{
|
||||||
|
ResponseWriter = responseStream =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bitmap = new Bitmap(responseStream);
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
request.AddHeader(Constants.Token, ChatDaten.AuthToken);
|
||||||
|
request.AddHeader(Constants.CustomerId, ChatDaten.Kundennummer);
|
||||||
|
|
||||||
|
client.DownloadData(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap != null ? Utils.ImageSourceForBitmap(bitmap) : null;
|
||||||
|
}
|
||||||
|
|
||||||
// WebRequest
|
// WebRequest
|
||||||
private void LoadMessagesFromServer(long pGroupId)
|
private void LoadMessagesFromServer(long pGroupId)
|
||||||
{
|
{
|
||||||
@@ -131,10 +158,12 @@ namespace ChatController.HauptKlassen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThreadExceptionCallback?.Invoke(null);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
ExceptionCallback?.Invoke(exception);
|
ThreadExceptionCallback?.Invoke(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,11 +350,12 @@ namespace ChatController.HauptKlassen
|
|||||||
|
|
||||||
var messageCounter = JsonConvert.DeserializeObject<MessageCounter>(responseFromServer);
|
var messageCounter = JsonConvert.DeserializeObject<MessageCounter>(responseFromServer);
|
||||||
|
|
||||||
|
ThreadExceptionCallback?.Invoke(null);
|
||||||
return messageCounter.MessageCount;
|
return messageCounter.MessageCount;
|
||||||
}
|
}
|
||||||
catch(Exception exception)
|
catch(Exception exception)
|
||||||
{
|
{
|
||||||
ExceptionCallback?.Invoke(exception);
|
ThreadExceptionCallback?.Invoke(exception);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -521,7 +551,7 @@ namespace ChatController.HauptKlassen
|
|||||||
{
|
{
|
||||||
var openFileDialog = new OpenFileDialog
|
var openFileDialog = new OpenFileDialog
|
||||||
{
|
{
|
||||||
Filter = Resource.OpenFileDialogFilter_Test //Resource.OpenFileDialogFilter_DocumentsAndImages
|
Filter = Resource.OpenFileDialogFilter_Test
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = openFileDialog.ShowDialog();
|
var result = openFileDialog.ShowDialog();
|
||||||
|
|||||||
@@ -90,6 +90,13 @@ namespace ChatController
|
|||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
|
||||||
LeseDateiFallsVorhanden();
|
LeseDateiFallsVorhanden();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
_Kundennummer = "4368658436";
|
||||||
|
_ChatCode = "ZMCKb-BckTt";
|
||||||
|
_Benutzername = "muellerp";
|
||||||
|
Password = "F5aTk9Co47JFJCWB2Z7Y";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AnmeldenButton_OnClick(object sender, RoutedEventArgs e)
|
private void AnmeldenButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
BIN
ChatController/Ressourcen/warning-exclamation-mark.png
Normal file
BIN
ChatController/Ressourcen/warning-exclamation-mark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 677 B |
Reference in New Issue
Block a user