2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Diagnostics ;
using System.Globalization ;
using System.Linq ;
using System.Threading ;
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Controls.Primitives ;
using System.Windows.Data ;
using System.Windows.Documents ;
using System.Windows.Input ;
using System.Windows.Media ;
using System.Windows.Media.Imaging ;
using System.Windows.Navigation ;
using System.Windows.Threading ;
using BeWo.Core ;
using BeWo.ServiceProxy ;
using BeWo.View.Controls ;
using BeWo.View.Detail ;
using BeWo.ViewModel ;
using Blacklight.Wpf.Controls ;
using BS.Shared ;
using BS.Shared.DataContracts ;
using BS.Shared.DataContracts.Compact ;
using BS.Shared.Extensions ;
using BS.Shared.RSS ;
using DevExpress.Xpf.Core ;
using DevExpress.Xpf.Editors.Helpers ;
using System.Net.Sockets ;
using System.Collections ;
2016-09-13 11:19:36 +02:00
using System.Drawing ;
using System.IO ;
2016-06-27 01:45:38 +02:00
using System.Net ;
2016-09-16 15:27:23 +02:00
using System.Net.NetworkInformation ;
2016-06-27 01:45:38 +02:00
using System.Text ;
2016-09-13 11:19:36 +02:00
using System.Windows.Forms ;
2016-07-29 13:11:34 +02:00
using BS.Shared.Core ;
using Newtonsoft.Json ;
2016-09-13 11:19:36 +02:00
using Brushes = System . Windows . Media . Brushes ;
using Button = System . Windows . Controls . Button ;
using Color = System . Windows . Media . Color ;
using Control = System . Windows . Controls . Control ;
using Image = System . Windows . Controls . Image ;
using ListBox = System . Windows . Controls . ListBox ;
using MessageBox = System . Windows . MessageBox ;
using ScrollBar = System . Windows . Controls . Primitives . ScrollBar ;
using TextBox = System . Windows . Controls . TextBox ;
2016-06-27 01:45:38 +02:00
namespace BeWo.View
{
2016-08-15 13:37:19 +02:00
/// <summary>
/// Interaction logic for HomeView.xaml
/// </summary>
public partial class HomeDragPanelView : BeWoView
{
private List < TaskDC > _AllTasks ;
2016-06-27 01:45:38 +02:00
//################# Variablen der Serveranwendung #################
protected ListBox Clientlist = new ListBox ( ) ;
protected TextBox ServerStats = new TextBox ( ) ;
protected TextBox chat = new TextBox ( ) ;
2016-09-02 10:00:31 +02:00
protected MiniChatView miniChatView = null ;
protected ChatView chatView = null ;
2016-06-27 01:45:38 +02:00
2016-09-02 10:00:31 +02:00
Dictionary < long , MiniChatView > miniChatViewList = new Dictionary < long , MiniChatView > ( ) ;
2016-07-25 09:26:56 +02:00
2016-09-02 10:00:31 +02:00
//---- änderungen ----
Dictionary < long , Packet > SaveAnkommendeServerMeldungen = new Dictionary < long , Packet > ( ) ;
protected long zaehler = 1 ;
//--------------------
2016-07-25 09:26:56 +02:00
2016-09-02 10:00:31 +02:00
//Neue Version : Version 0.80
2016-07-25 09:26:56 +02:00
public TcpClient clientSocket = new TcpClient ( ) ;
2016-08-15 13:37:19 +02:00
NetworkStream serverStream ;
protected Thread asx ;
2016-08-05 12:48:13 +02:00
protected bool isReconnect = false ;
2016-08-15 13:37:19 +02:00
Packet messagePaket ;
2016-08-12 14:50:25 +02:00
protected bool threadstop = false ;
2016-07-25 09:26:56 +02:00
2016-08-26 13:01:24 +02:00
protected bool berechtigt = false ;
2016-06-27 01:45:38 +02:00
//################################################################
2016-08-15 13:37:19 +02:00
public HomeDragPanelView ( )
{
InitializeComponent ( ) ;
txtHeader . Text = String . Format ( "{0} {1}" , BeWoApp . LoggedOnUser . Employee . FirstName ,
BeWoApp . LoggedOnUser . Employee . LastName ) ;
txtVersion . Text = BeWoApp . Version ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
txtLoginTime . Text = string . Empty ;
txtLastLoginTime . Text = string . Empty ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
//PreparePanels();
InitPanels ( null ) ;
2016-06-27 01:45:38 +02:00
#if DEBUG
txtChangePassword . Visibility = Visibility . Visible ;
#else
if ( BeWoApp . Tenant = = "demo" | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . AllowChangeOwnPassword ) )
{
txtChangePassword . Visibility = Visibility . Collapsed ;
}
#endif
2016-08-15 13:37:19 +02:00
// FillInbox();
// FillOutbox();
Loaded + = HomeDragPanelViewLoaded ;
2016-08-01 10:15:24 +02:00
/ * this . Dispatcher . BeginInvoke (
2016-07-25 09:26:56 +02:00
DispatcherPriority . Normal ,
( Action ) delegate
{
ConnectWithServer ( ) ;
2016-07-25 14:45:38 +02:00
if ( clientSocket . Connected )
MessageBox . Show ( "Verbindung geglückt." , "Info" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-08-01 10:15:24 +02:00
} ) ; * /
2016-07-25 09:26:56 +02:00
2016-08-26 13:01:24 +02:00
var berechtigung = ServiceFacade . DoEmployeeServiceSync ( s = > s . GetAllChatActiveEmployeesCompact ( ) ) ;
foreach ( var list in berechtigung )
{
if ( list . PersonOid = = BeWoApp . LoggedOnUser . Employee . PersonOid )
{
berechtigt = true ;
}
}
if ( berechtigt )
{
2016-09-13 11:19:36 +02:00
asx = new Thread ( ConnectWithServer ) ;
2016-08-26 13:01:24 +02:00
asx . Start ( ) ;
}
else
{
BewoChat . Visibility = Visibility . Hidden ;
}
2016-08-15 13:37:19 +02:00
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void PreparePanels ( )
{
ServiceFacade . DoOperationsServiceAsyncNoWait (
s = > s . GetUiElements ( UiElementType . StartPanel , BeWoApp . LoggedOnUser . Employee . EmployeeOid , null , null ) ,
InitPanelsCallback , null ) ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void InitPanelsCallback ( IList < UiElementDC > elements , object state )
{
this . Dispatcher . BeginInvoke (
DispatcherPriority . Normal ,
( Action ) delegate
{
InitPanels ( elements ) ;
} ) ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void InitPanels ( IList < UiElementDC > elements )
{
listboxExpiringSupportConcepts . Items . Clear ( ) ;
listboxConferenceDates . Items . Clear ( ) ;
listboxBirthdays . Items . Clear ( ) ;
listboxNews . Items . Clear ( ) ;
listboxTasks . Items . Clear ( ) ;
//ListboxInternalNews.Items.Clear();
InternalNewsGrid . Children . Clear ( ) ;
//if (elements == null || elements.Count == 0)
//{
// //
//}
//else
//{
// foreach (var uiElementDc in elements)
// {
// var xamlElement = System.Windows.Markup.XamlReader.Parse(uiElementDc.Xaml);
// if (xamlElement is DragDockPanel)
// {
// panelHost.Children.Add(xamlElement as UIElement);
// }
// }
//}
ReorderPanels ( ) ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void HomeDragPanelViewLoaded ( object o , RoutedEventArgs e )
{
InitContent ( ) ;
//Warum klappt das bei Köln Ring nicht?=
if ( BeWoApp . LoggedOnUser = = null | | BeWoApp . LoggedOnUser . ResetPasswordInfos = = null )
return ;
if ( ! BeWoApp . LoggedOnUser . ResetPasswordInfos . Any ( a = > a . HasToChangePW ) ) return ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
var fenster = new PasswortAenderungsView { AbbrechenButton = { IsEnabled = false } } ;
fenster . CommandBindings . Clear ( ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
fenster . ShowDialog ( ) ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
public void SaveState ( )
{
var order = new List < DragDockPanel > ( ) ;
DragDockPanel panelWithMaxHeight = null ;
double maxHeight = 0 ;
double normalHeight = 0 ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
var result = new List < DependencyObject > ( ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
foreach ( object item in panelHost . Children )
{
var p = item as DragDockPanel ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( order . Count = = 0 )
{
order . Add ( p ) ;
}
else
{
int newIndex = - 1 ;
int index = 0 ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
Vector rect = VisualTreeHelper . GetOffset ( p ) ;
foreach ( DragDockPanel item2 in order )
{
string name1 = p . Name ;
string name2 = item2 . Name ;
Vector rect2 = VisualTreeHelper . GetOffset ( item2 ) ;
if ( rect . Y < rect2 . Y )
{
newIndex = index ;
continue ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( Equals ( rect . Y , rect2 . Y ) & & rect . X < rect2 . X )
{
newIndex = index ;
continue ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
index + + ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( newIndex < 0 )
{
order . Add ( p ) ;
}
else
{
order . Insert ( newIndex , p ) ;
}
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( p . Height > maxHeight )
{
maxHeight = p . ActualHeight ;
panelWithMaxHeight = p ;
}
else
{
normalHeight = p . ActualHeight ;
}
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( ( maxHeight - normalHeight ) > 1 & & panelWithMaxHeight ! = null )
{
BeWoApp . AppSettings . StartupPanelMaximized = panelWithMaxHeight . Name ;
}
else
{
BeWoApp . AppSettings . StartupPanelMaximized = null ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
List < string > panelOrder = order . Select ( item = > item . Name ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
BeWoApp . AppSettings . StartupPanelOrder = panelOrder ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void ButtonOpenServiceRecordView_Click ( object sender , RoutedEventArgs e )
{
var btn = sender as Button ;
if ( btn ! = null )
{
var dc = btn . Tag as CompactSupportConceptDC ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
if ( dc ! = null )
BeWoApp . MainControl . NavigateToServiceRecordView ( dc . SupportConceptOid ) ;
}
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void InitBewoNews ( )
{
try
{
if ( BeWoApp . Tenant ! = "demo" )
{
LoadFeed ( ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
//LoadFeed("http://www.heise.de/foto/rss/news-atom.xml");
}
}
catch ( Exception )
{
}
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void InitBirthdays ( )
{
DateTime endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
endOfWeek = endOfWeek . AddDays ( 1 ) . GetNext ( DayOfWeek . Sunday ) . Date ;
ServiceFacade . DoAnalysisServiceAsync ( s1 = > s1 . GetPersonsHavingBirthday ( endOfWeek ) , ReloadBirthdays ) ;
}
private void InitContent ( )
{
SetMaximizedPanel ( ) ;
InitLoginInfo ( ) ;
InitExpiredSupportConcepts ( ) ;
InitNextConferenceDates ( ) ;
InitBewoNews ( ) ;
InitBirthdays ( ) ;
InitTasks ( ) ;
rb_open . IsChecked = true ;
UpdateInternalNews ( ) ;
}
private void InitExpiredSupportConcepts ( )
{
// DateTime endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
// DateTime endOfWeek2 = endOfWeek.AddDays(8);
DateTime dt = DateTime . Now . AddMonths ( BeWoApp . AppSettings . HilfeplanAuslaufAuswahl ) ;
ServiceFacade . DoAnalysisServiceAsync (
s1 = > s1 . GetExpiringSupportConcepts ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , dt ) ,
ReloadExpiringSupportConcepts ) ;
}
private void UpdateInternalNews ( )
{
var showTeamNews = BeWoApp . AppSettings . ShowTeamNews ;
//ServiceFacade.DoEmployeeServiceAsync(s => s.GetPublishedNewsItems(), cb => this.Dispatch(delegate { listboxInternalNews.ItemsSource = cb.OrderByDescending(i => i.PublishDate).ToList(); }));
ServiceFacade . DoEmployeeServiceAsync (
s = > s . GetPublishedNewsItemsForEmployee ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , showTeamNews ) ,
RefreshInternalNews ) ;
}
private void RefreshInternalNews ( List < NewsItemDC > news )
{
this . Dispatch ( delegate
{
var team2News = new Dictionary < long , TeamNewsItemVM > ( ) ;
var allNews = new TeamNewsItemVM ( ) ;
allNews . Team = new CompactTeamDC ( ) ;
allNews . Team . Name = "Allgemein" ;
allNews . AllowEdit = false ;
allNews . IsTitleVisible = true ;
foreach ( var newsItemDc in news )
{
if ( newsItemDc . Team ! = null )
{
newsItemDc . AllowEdit = true ;
newsItemDc . TitleString = String . Format ( "{0:dd.MM.yyyy}: {1}" , newsItemDc . PublishDate ,
newsItemDc . Title ) ;
if ( ! team2News . ContainsKey ( newsItemDc . Team . TeamOid ) )
{
team2News [ newsItemDc . Team . TeamOid ] = new TeamNewsItemVM ( ) ;
team2News [ newsItemDc . Team . TeamOid ] . Team = newsItemDc . Team ;
team2News [ newsItemDc . Team . TeamOid ] . AllowEdit = true ;
team2News [ newsItemDc . Team . TeamOid ] . IsTitleVisible = true ;
}
if ( newsItemDc . NewsItemOid . HasValue )
{
team2News [ newsItemDc . Team . TeamOid ] . NewsItems . Add ( newsItemDc ) ;
}
}
else
{
newsItemDc . TitleString = newsItemDc . Title ;
allNews . NewsItems . Add ( newsItemDc ) ;
}
}
var list = team2News . Values . OrderBy ( i = > i . Team . Name ) . ToList ( ) ;
if ( list . Count = = 0 )
allNews . IsTitleVisible = false ;
list . Add ( allNews ) ;
InternalNewsGrid . Children . Clear ( ) ;
InternalNewsGrid . Children . Add ( CreateInternalNewsControlList ( list ) ) ;
//ListboxInternalNews.ItemsSource = list;
} ) ;
}
private UIElement CreateInternalNewsControlList ( List < TeamNewsItemVM > list )
{
StackPanel sp = new StackPanel ( ) ;
foreach ( var teamNewsItemVm in list )
{
sp . Children . Add ( CreateInternalNewsTeamControl ( teamNewsItemVm ) ) ;
}
return sp ;
}
private UIElement CreateInternalNewsTeamControl ( TeamNewsItemVM teamNewsItemVm )
{
var sp = new StackPanel ( ) ;
foreach ( var newsItem in teamNewsItemVm . NewsItems )
{
sp . Children . Add ( CreateInternalNewsControl ( newsItem ) ) ;
}
if ( teamNewsItemVm . IsTitleVisible )
{
Expander ex = new Expander ( ) ;
ex . Style = ( Style ) FindResource ( "FlatLineExpander" ) ;
ex . IsExpanded = true ;
ex . Margin = new Thickness ( 0 , 5 , 5 , 5 ) ;
Grid grid = new Grid ( ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
TextBlock tb = new TextBlock ( ) ;
tb . FontSize = 14 ;
tb . FontWeight = FontWeights . Bold ;
tb . Text = teamNewsItemVm . Team . Name ;
grid . Children . Add ( tb ) ;
if ( teamNewsItemVm . AllowEdit )
{
Button newBtn = new Button ( ) ;
newBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
newBtn . SetValue ( Grid . ColumnProperty , 1 ) ;
newBtn . HorizontalAlignment = System . Windows . HorizontalAlignment . Right ;
newBtn . Width = 16 ;
newBtn . Height = 16 ;
newBtn . Click + = BtnCreateNewsItem_OnClick ;
newBtn . Tag = teamNewsItemVm ;
newBtn . Margin = new Thickness ( 0 , 0 , - 10 , 0 ) ;
Image img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\new.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
newBtn . Content = img ;
grid . Children . Add ( newBtn ) ;
}
ex . Header = grid ;
ex . Content = sp ;
return ex ;
}
return sp ;
//<Expander HorizontalAlignment="Stretch" IsExpanded="True" Style="{DynamicResource FlatLineExpander}" >
// <Expander.Header>
// <Grid Background="Transparent" Visibility="{Binding Path=IsTitleVisible, Converter={StaticResource BoolVisibilityConverter}}">
// <Grid.ColumnDefinitions>
// <ColumnDefinition Width="Auto" />
// <ColumnDefinition Width="*" />
// </Grid.ColumnDefinitions>
// <TextBlock FontSize="14" Foreground="Black" Grid.Column="0" Grid.Row="0" FontWeight="Bold" Text="{Binding Path=Team.Name}"/>
// <Button Grid.Column="1" x:Name="btnCreateNewsItem" Style="{DynamicResource FlatButton}" Tag="{Binding}" Margin="0,0,-10,0"
// HorizontalAlignment="Right" Width="16" Height="16" Click="BtnCreateNewsItem_OnClick" Visibility="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}">
// <Image Source="..\..\Ressources\Icons\new.png" Stretch="Uniform" />
// </Button>
// </Grid>
// </Expander.Header>
// <ListBox ScrollViewer.CanContentScroll="True" IsSynchronizedWithCurrentItem="True" Margin="0,3,0,0"
// Padding="0,0,0,0" Width="Auto" HorizontalAlignment="Stretch" MinWidth="0" HorizontalContentAlignment="Stretch" Background="{x:Null}" Style="{DynamicResource HomeViewListStyle}" ItemContainerStyle="{DynamicResource HomeViewListBoxItemStyle}" ScrollViewer.IsDeferredScrollingEnabled="False"
// ItemsSource="{Binding Path=NewsItems}">
// <ListBox.ItemTemplate>
// <DataTemplate DataType="{x:Type shared:NewsItemDC}">
// <Grid Margin="0 3">
// <Grid.ColumnDefinitions>
// <ColumnDefinition Width="*" />
// <ColumnDefinition Width="Auto" />
// <ColumnDefinition Width="Auto" />
// </Grid.ColumnDefinitions>
// <Grid.RowDefinitions>
// <RowDefinition Height="25" />
// <RowDefinition Height="*" />
// <RowDefinition Height="Auto" />
// </Grid.RowDefinitions>
// <TextBlock FontSize="12" Foreground="{DynamicResource BigInfoTextBrush}" Grid.Column="0" Grid.Row="0" FontWeight="Bold" Text="{Binding Path=TitleString}" Margin="0,0,0,0"/>
// <TextBlock FontSize="10" Foreground="#FF000000" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding Path=Text}" TextWrapping="Wrap" Margin="0,0,0,0" />
// <Border Grid.Column="1" Background="Transparent">
// </Border>
// <Button Grid.Column="1" x:Name="btnEditNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnEditNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\edit.png" Stretch="Uniform" Margin="1,1,1,1" />
// </Button>
// <Border Grid.Column="2" Background="Transparent">
// </Border>
// <Button Grid.Column="2" x:Name="btnDeleteNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnDeleteNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\delete.png" Stretch="Uniform" Margin="1,1,1,1" />
// </Button>
// </Grid>
// <DataTemplate.Triggers>
// <Trigger Property="IsMouseOver" Value="True">
// <Setter Property="Visibility" TargetName="btnEditNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// <Setter Property="Visibility" TargetName="btnDeleteNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// </Trigger>
// </DataTemplate.Triggers>
// </DataTemplate>
// </ListBox.ItemTemplate>
// </ListBox>
// </Expander>
}
private UIElement CreateInternalNewsControl ( NewsItemDC newsItem )
{
Grid grid = new Grid ( ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
grid . RowDefinitions . Add ( new RowDefinition { Height = new GridLength ( 25 , GridUnitType . Pixel ) } ) ;
grid . RowDefinitions . Add ( new RowDefinition { Height = new GridLength ( 1 , GridUnitType . Star ) } ) ;
grid . Margin = new Thickness ( 0 , 5 , 0 , 0 ) ;
TextBlock tb = new TextBlock ( ) ;
tb . Margin = new Thickness ( 0 , 5 , 0 , 0 ) ;
tb . Foreground = new SolidColorBrush ( Color . FromRgb ( 43 , 80 , 139 ) ) ;
tb . Text = newsItem . TitleString ;
tb . FontSize = 12 ;
tb . FontWeight = FontWeights . Bold ;
grid . Children . Add ( tb ) ;
tb = new TextBlock ( ) ;
tb . Text = newsItem . Text ;
tb . FontSize = 10 ;
tb . TextWrapping = TextWrapping . Wrap ;
tb . SetValue ( Grid . RowProperty , 1 ) ;
tb . SetValue ( Grid . ColumnSpanProperty , 3 ) ;
grid . Children . Add ( tb ) ;
if ( newsItem . AllowEdit )
{
// <DataTemplate.Triggers>
// <Trigger Property="IsMouseOver" Value="True">
// <Setter Property="Visibility" TargetName="btnEditNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// <Setter Property="Visibility" TargetName="btnDeleteNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// </Trigger>
// </DataTemplate.Triggers>
Border b = new Border ( ) ;
b . Background = Brushes . Transparent ;
b . SetValue ( Grid . ColumnProperty , 1 ) ;
grid . Children . Add ( b ) ;
// <Border Grid.Column="1" Background="Transparent">
// </Border>
Button editBtn = new Button ( ) ;
editBtn . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
editBtn . Padding = new Thickness ( 1 , 1 , 1 , 1 ) ;
editBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
editBtn . SetValue ( Grid . ColumnProperty , 1 ) ;
editBtn . VerticalAlignment = VerticalAlignment . Top ;
editBtn . Width = 16 ;
editBtn . Height = 16 ;
editBtn . Click + = BtnEditNewsItem_OnClick ;
editBtn . Tag = newsItem ;
editBtn . Visibility = Visibility . Hidden ;
Image img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\edit.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
img . Margin = new Thickness ( 1 , 1 , 1 , 1 ) ;
editBtn . Content = img ;
grid . Children . Add ( editBtn ) ;
b = new Border ( ) ;
b . Background = Brushes . Transparent ;
b . SetValue ( Grid . ColumnProperty , 2 ) ;
grid . Children . Add ( b ) ;
Button deleteBtn = new Button ( ) ;
deleteBtn . Padding = new Thickness ( 1 , 1 , 1 , 1 ) ;
deleteBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
deleteBtn . SetValue ( Grid . ColumnProperty , 2 ) ;
deleteBtn . VerticalAlignment = VerticalAlignment . Top ;
deleteBtn . Width = 16 ;
deleteBtn . Height = 16 ;
deleteBtn . Click + = BtnDeleteNewsItem_OnClick ;
deleteBtn . Tag = newsItem ;
deleteBtn . Visibility = Visibility . Hidden ;
img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\delete.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
img . Margin = new Thickness ( 1 , 1 , 1 , 1 ) ;
deleteBtn . Content = img ;
grid . Children . Add ( deleteBtn ) ;
grid . MouseEnter + = ( s , e ) = >
{
editBtn . Visibility = Visibility . Visible ;
deleteBtn . Visibility = Visibility . Visible ;
} ;
grid . MouseLeave + = ( s , e ) = >
{
editBtn . Visibility = Visibility . Hidden ;
deleteBtn . Visibility = Visibility . Hidden ;
} ;
}
//<Border Grid.Column="1" Background="Transparent">
//</Border>
//<Button Grid.Column="1" x:Name="btnEditNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnEditNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\edit.png" Stretch="Uniform" Margin="1,1,1,1" />
//</Button>
//<Border Grid.Column="2" Background="Transparent">
//</Border>
//<Button Grid.Column="2" x:Name="btnDeleteNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnDeleteNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\delete.png" Stretch="Uniform" Margin="1,1,1,1" />
//</Button>
return grid ;
}
private void InitLoginInfo ( )
{
DateTime endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
ServiceFacade . DoAnalysisServiceAsync ( s1 = > s1 . GetLastLogins ( BeWoApp . LoggedOnUser . LoginName ) , ReloadLogins ) ;
}
private void InitNextConferenceDates ( )
{
DateTime endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
DateTime endOfWeek2 = endOfWeek . AddDays ( 8 ) ;
ServiceFacade . DoAnalysisServiceAsync (
s1 = > s1 . GetSupportConceptsWithConferenceDate ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , endOfWeek2 ) ,
ReloadConferenceDates ) ;
}
private void InitTasks ( )
{
int test = 0 ;
while ( BeWoApp . LoggedOnEmployee = = null & & test < 10 )
{
Thread . Sleep ( 100 ) ;
test + + ;
}
if ( BeWoApp . LoggedOnEmployee ! = null )
{
ServiceFacade . DoAnalysisServiceAsync ( s = >
s . GetTasksForEmployee ( BeWoApp . LoggedOnEmployee . EmployeeOid . Value ) ,
cb = >
{
this . Dispatch ( delegate
{
if ( BeWoApp . Tenant = = "3057313346" )
{
_AllTasks =
cb . Where (
i = >
i . DueDate . HasValue & & i . DueDate . Value . Date < = DateTime . Now . Date . AddMonths ( 1 ) )
.
ToList ( ) ;
}
else
{
_AllTasks = cb ;
}
listboxTasks . ItemsSource = _AllTasks . Where ( i = > ! i . CompletedDate . HasValue )
. OrderBy (
i = > { return i . DueDate ; } ) . ToList ( ) ;
} ) ;
} ) ;
}
}
private bool IsPartOf ( object p , Type type )
{
if ( p ! = null )
{
var fe = p as FrameworkElement ;
if ( fe ! = null )
{
if ( fe . GetType ( ) = = type )
return true ;
return IsPartOf ( fe . TemplatedParent , type ) ;
}
}
return false ;
}
private void LoadFeed ( )
{
String url = BeWoApp . Mandator . RssFeedUrl ;
if ( String . IsNullOrEmpty ( url ) )
{
ServiceFacade . DoDownloadServiceAsync (
dwn = >
{
try
{
return dwn . ReadRssFeed ( null ) ;
}
catch ( Exception )
{
}
return null ;
} ,
ReloadRssFeed ) ;
}
else
{
RssFeed feed = new RssFeed ( ) ;
RssManager mgr = new RssManager ( url ) ;
feed . Items = mgr . GetFeed ( ) ;
feed . Title = mgr . FeedTitle ;
feed . Description = mgr . FeedDescription ;
ReloadRssFeed ( feed , false ) ;
}
}
private void RadioButton_Checked ( object sender , RoutedEventArgs e )
{
if ( _AllTasks ! = null )
{
switch ( ( e . OriginalSource as Control ) . Name )
{
case "rb_all" :
listboxTasks . ItemsSource =
_AllTasks . OrderBy ( i = > i . CompletedDate . HasValue ? i . CompletedDate : i . DueDate ) . ToList ( ) ;
break ;
case "rb_open" :
listboxTasks . ItemsSource =
_AllTasks . Where ( i = > ! i . CompletedDate . HasValue ) . OrderBy ( i = > i . DueDate ) . ToList ( ) ;
break ;
case "rb_closed" :
listboxTasks . ItemsSource =
_AllTasks . Where ( i = > i . CompletedDate . HasValue )
. OrderByDescending ( i = > i . CompletedDate )
. ToList ( ) ;
break ;
}
}
}
private void ReloadRssFeed ( RssFeed feed )
{
ReloadRssFeed ( feed , true ) ;
}
private void ReloadRssFeed ( RssFeed feed , bool addBeWoParameter )
{
if ( feed ! = null )
{
if ( feed . Items ! = null & & addBeWoParameter )
{
foreach ( RssItem rssItem in feed . Items )
{
if ( ! String . IsNullOrEmpty ( rssItem . Link ) )
{
rssItem . Link + = String . Format ( "&k={0}&s={1}" , BeWoApp . Tenant , BeWoApp . ServerName ) ;
}
}
}
this . Dispatch ( delegate { listboxNews . ItemsSource = feed . Items ; } ) ;
}
}
private void ReloadBirthdays ( List < CompactPersonDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . DateOfBirth . Value . DayOfYear . CompareTo ( l2 . DateOfBirth . Value . DayOfYear ) ) ;
listboxBirthdays . ItemsSource = list ;
} ) ;
}
private void ReloadConferenceDates ( List < CompactSupportConceptDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . ConferenceDate . Value . CompareTo ( l2 . ConferenceDate . Value ) ) ;
listboxConferenceDates . ItemsSource = list ;
} ) ;
}
private void ReloadExpiringSupportConcepts ( List < CompactSupportConceptDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . EndDate . Value . CompareTo ( l2 . EndDate . Value ) ) ;
listboxExpiringSupportConcepts . ItemsSource = list ;
} ) ;
}
private void ReloadLogins ( List < LoginDC > list )
{
this . Dispatch (
delegate
{
// listboxNews.ItemsSource = list;
list . Sort ( ( l1 , l2 ) = > l1 . LoginDate . Value . CompareTo ( l2 . LoginDate . Value ) ) ;
if ( list . Count > 0 )
{
LoginDC last = list [ list . Count - 1 ] ;
txtLoginTime . Text = "Angemeldet seit " + last . LoginDate . Value . ToShortDateString ( ) + " " +
last . LoginDate . Value . ToShortTimeString ( ) ;
if ( list . Count > 1 )
{
LoginDC dc = list [ list . Count - 2 ] ;
txtLastLoginTime . Text = ", zuletzt angemeldet am " + dc . LoginDate . Value . ToShortDateString ( ) +
" " + dc . LoginDate . Value . ToShortTimeString ( ) ;
}
}
} ) ;
}
public void ReorderPanels ( )
{
List < string > order = BeWoApp . AppSettings . StartupPanelOrder ;
if ( order ! = null & & order . Count > 0 )
{
var panels = new Dictionary < string , DragDockPanel > ( ) ;
foreach ( object item in panelHost . Children )
{
var p = item as DragDockPanel ;
panels . Add ( p . Name , p ) ;
}
panelHost . Children . Clear ( ) ;
foreach ( string item in order )
{
if ( panels . ContainsKey ( item ) )
{
DragDockPanel p = panels [ item ] ;
panelHost . AddPanel ( p ) ; // Children.Add(p);
panels . Remove ( item ) ;
}
}
foreach ( DragDockPanel item in panels . Values )
{
panelHost . AddPanel ( item ) ;
}
}
}
private void SetMaximizedPanel ( )
{
if ( ! String . IsNullOrEmpty ( BeWoApp . AppSettings . StartupPanelMaximized ) )
{
foreach ( object item in panelHost . Children )
{
var p = item as DragDockPanel ;
if ( BeWoApp . AppSettings . StartupPanelMaximized . Equals ( p . Name ) )
{
IEnumerable < DependencyObject > objekts = p . GetAllChildren ( ) ;
foreach ( DependencyObject child in objekts )
{
if ( child is ToggleButton )
{
var btn = child as ToggleButton ;
btn . IsChecked = true ;
}
}
}
}
}
}
private void listboxBirthdays_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
if ( ! IsPartOf ( e . OriginalSource , typeof ( ScrollBar ) ) )
{
var dc = ( ( ListBox ) sender ) . SelectedItem as CompactPersonDC ;
if ( dc ! = null )
{
if ( dc . PersonType = = PersonType . Customer )
{
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . CustomerView_View ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) )
{
ServiceFacade . DoCustomerServiceAsync (
s = > s . GetCustomerWithPersonOid ( dc . PersonOid ) ,
cb = > VMFactory . CreateCustomerVMAsync (
cb ,
cb2 = > this . Dispatch (
delegate
{
MainControl . NavigateTo (
new CustomerView ( cb2 )
{
ParentView = this
} ) ;
} ) ) ) ;
}
}
else if ( dc . PersonType = = PersonType . Employee )
{
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . EmployeeView_View ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) )
{
ServiceFacade . DoEmployeeServiceAsync (
s = > s . GetEmployeeWithPersonOid ( dc . PersonOid ) ,
cb = > VMFactory . CreateEmployeeVMAsync (
cb ,
cb2 = > this . Dispatch (
delegate
{
MainControl . NavigateTo (
new EmployeeView ( cb2 )
{
ParentView = this
} ) ;
} ) ) ) ;
}
}
else if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . PersonView_View ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) )
{
VMFactory . CreatePersonVMAsync (
dc . PersonOid ,
cb = > this . Dispatch (
delegate
{
MainControl . NavigateTo (
new PersonView ( cb )
{
ParentView = this
} ) ;
} ) ) ;
}
}
}
}
private void listboxSupportConcepts_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
if ( ! IsPartOf ( e . OriginalSource , typeof ( ScrollBar ) ) )
{
var sc = ( ( ListBox ) sender ) . SelectedItem as CompactSupportConceptDC ;
if ( sc ! = null & &
( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ViewAllSupportConcepts ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_View ) ) )
{
VMFactory . CreateSupportConceptVMAsync (
sc . SupportConceptOid ,
cb = > this . Dispatch (
delegate
{
MainControl . NavigateTo ( new SupportConceptView ( cb ) { ParentView = this } ) ;
//new SupportConceptView2(cb)
// {
// ParentView = this
// });
} ) ) ;
}
}
}
private void listboxTasks_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
if ( ! IsPartOf ( e . OriginalSource , typeof ( ScrollBar ) ) )
{
var sc = ( ( ListBox ) sender ) . SelectedItem as TaskDC ;
if ( sc ! = null & &
( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ViewAllSupportConcepts ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_View ) ) )
{
VMFactory . CreateSupportConceptVMAsync (
sc . SupportConceptOid . Value ,
cb = > this . Dispatch (
delegate
{
MainControl . NavigateTo (
new SupportConceptView ( cb , sc )
{
ParentView = this
} ) ;
//new SupportConceptView2(cb)
//{
// ParentView = this
//});
} ) ) ;
}
}
}
// private void FillOutbox()
// {
// if (BeWoApp.LoggedOnUser.Employee != null)
// {
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(
// s => s.GetOutgoingMails(BeWoApp.LoggedOnUser.Employee.EmployeeOid),
// result => this.Dispatcher.BeginInvoke(new Call(delegate()
// {
// outboxList.ItemsSource = result;
// }))
// );
// }
// }
// private void FillInbox()
// {
// if (BeWoApp.LoggedOnUser.Employee != null)
// {
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(
// s => s.GetIncomingMails(BeWoApp.LoggedOnUser.Employee.EmployeeOid),
// result => this.Dispatcher.BeginInvoke(new Call(delegate()
// {
// text.Text = GenerateMailText(result);
// inboxList.ItemsSource = result;
// }))
// );
// }
// }
// delegate void Call();
// private static string GenerateMailText(List<MailDC> result)
// {
// //var builder = new StringBuilder();
// //var unreadMails = result.Where(r => r.Status == null || r.Status == Status.unread).Count();
// //builder.AppendLine("Sie haben " + unreadMails + "/" + result.Count + " Mails");
// //foreach (var item in result)
// //{
// // builder.AppendLine(item.Subject);
// //}
// //return builder.ToString();
// var unreadMails = result.Where(r => r.Status == null || r.Status == Status.unread).Count();
// return "Sie haben " + unreadMails + "/" + result.Count + " Mails";
// }
// private void ButtonNew_Click(object sender, RoutedEventArgs e)
// {
// OpenSendMailView();
// // throw new NotImplementedException();
// }
// private void OpenSendMailView()
// {
// BeWoApp.MainControl.NavigateTo(new SendMailView() { ParentView = this });
// //throw new NotImplementedException();
// }
// private void ButtonReplyNew_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWoApp.MainControl.NavigateTo(new SendMailView(SendMailView.Mode.Reply, mailDC));
// }
// else
// {
// MessageBox.Show("Sie können nicht auf Ihre eigene Mail antworten");
// }
// }
// private void ButtonForward_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWoApp.MainControl.NavigateTo(new SendMailView(SendMailView.Mode.Forward, mailDC));
// }
// else
// {
// MessageBox.Show("Sie können Ihre eigene Mail nicht wieterleiten");
// }
// }
// private void ButtonDelete_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(s => s.DeleteMail(BeWoApp.LoggedOnUser.Employee.EmployeeOid, mailDC));
// //inboxList.ItemsSource.RemoveAt(inboxList.SelectedIndex);
// FillInbox();
// }
// else
// {
// MessageBox.Show("Outbox funktioniert noch nicht");
// //BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(s => s.DeleteMail(BeWoApp.LoggedOnUser.Employee.EmployeeOid, outboxList.SelectedItem as MailDC);
// }
// //throw new NotImplementedException();
// }
// private void InboxItem_DoubleClick(object sender, RoutedEventArgs e)
// {
// var listboItem = sender as ListBoxItem;
// var content = listboItem.Content as MailDC;
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
// //throw new NotImplementedException();
// }
// private void OutboxItem_DoubleClick(object sender, RoutedEventArgs e)
// {
// var listboItem = sender as ListBoxItem;
// var content = listboItem.Content as MailDC;
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
// }
private void Hyperlink_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
Process . Start ( new ProcessStartInfo ( ( sender as Hyperlink ) . NavigateUri . ToString ( ) ) ) ;
}
private delegate void loadFeed ( string url ) ;
private void PasswortAendernLinkOnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
var pav = new PasswortAenderungsView ( ) ;
pav . ShowDialog ( ) ;
}
2016-06-27 01:45:38 +02:00
private void ChatLinkOnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
2016-09-02 10:00:31 +02:00
if ( chatView = = null ) //#################### neu ########## <--
{
chatView = new ChatView ( "BeWo Chat" , chat . Text , clientSocket ) ;
if ( clientSocket . Connected )
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
chatView . SetServerStats ( "Verbunden" ) ;
2016-09-22 10:57:02 +02:00
2016-09-02 10:00:31 +02:00
chatView . StatusSetting . SelectedIndex = 0 ;
chatView . ButtonAlarmLabel . Visibility = Visibility . Collapsed ;
} ) ;
if ( SaveAnkommendeServerMeldungen . Count > 0 )
{
foreach ( var dateiverarbeitung in SaveAnkommendeServerMeldungen )
{
ChatBuilder ( dateiverarbeitung . Value ) ;
}
SaveAnkommendeServerMeldungen . Clear ( ) ;
zaehler = 1 ;
}
}
else
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
chatView . SetServerStats ( "Zurzeit nicht Verbunden" ) ;
chatView . StatusSetting . SelectedIndex = 1 ;
} ) ;
}
2016-09-22 10:57:02 +02:00
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
//Lade alle Ungelesenen Nachrichten
chatView . PruefeInDbObNeueNachrichtenVerfügbar ( ) ;
} ) ;
2016-09-02 10:00:31 +02:00
chatView . Visibility = Visibility . Visible ;
} //#################### neu ########## <--
else
{
if ( chatView . Visibility = = Visibility . Collapsed ) {
chatView . Visibility = Visibility . Visible ;
chatView . AktualisiereChatKontakt ( ) ;
chatView . Activate ( ) ;
}
else
{
chatView . Visibility = Visibility . Collapsed ;
}
}
2016-06-27 01:45:38 +02:00
}
2016-08-15 13:37:19 +02:00
private void BtnCreateNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
TeamNewsItemVM teamVm = ( ( Button ) sender ) . Tag as TeamNewsItemVM ;
if ( teamVm ! = null )
{
NewsItemDC dc = new NewsItemDC ( ) ;
dc . PublishDate = DateTime . Now ;
dc . Team = teamVm . Team ;
NewsItemVM vm = new NewsItemVM ( dc ) ;
var ctrl = new NewsItemEditControl ( vm ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
BeWoWindow window = BeWoWpfUtils . CreateBeWoPopupWindow ( 400 , 500 ) ;
window . GroupBoxContent = ctrl ;
window . Height = 400 ;
window . Owner = BeWoApp . CurrentBeWo . MainWindow ;
//ThemeManager.SetTheme(window, Theme.Office2010Black);
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
ctrl . CancelButtonClicked + = window . Close ;
ctrl . OkButtonClicked + = ( ) = >
{
SaveNewsItem ( vm ) ;
window . Close ( ) ;
} ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
window . rootGroupBox . Header = "Neuer Eintrag" ;
window . Title = "Neuer Eintrag" ;
window . Show ( ) ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
}
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void SaveNewsItem ( NewsItemVM vm )
{
ServiceFacade . DoEmployeeServiceSync ( s = > s . InsertNewNewsItem ( vm . CommitToDataContract ( ) ) ) ;
UpdateInternalNews ( ) ;
}
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
private void BtnEditNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
NewsItemDC dc = ( ( Button ) sender ) . Tag as NewsItemDC ;
if ( dc ! = null )
{
NewsItemVM vm = new NewsItemVM ( dc ) ;
var ctrl = new NewsItemEditControl ( vm ) ;
BeWoWindow window = BeWoWpfUtils . CreateBeWoPopupWindow ( 400 , 500 ) ;
window . GroupBoxContent = ctrl ;
window . Height = 400 ;
window . Owner = BeWoApp . CurrentBeWo . MainWindow ;
//ThemeManager.SetTheme(window, Theme.Office2010Black);
ctrl . CancelButtonClicked + = window . Close ;
ctrl . OkButtonClicked + = ( ) = >
{
UpdateNewsItem ( vm ) ;
window . Close ( ) ;
} ;
2016-06-27 01:45:38 +02:00
2016-08-15 13:37:19 +02:00
window . rootGroupBox . Header = "Eintrag bearbeiten" ;
window . Title = "Eintrag bearbeiten" ;
window . Show ( ) ;
}
}
private void UpdateNewsItem ( NewsItemVM vm )
{
ServiceFacade . DoEmployeeServiceSync ( s = > s . UpdateNewsItem ( vm . CommitToDataContract ( ) ) ) ;
UpdateInternalNews ( ) ;
}
private void BtnDeleteNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
NewsItemDC dc = ( ( Button ) sender ) . Tag as NewsItemDC ;
if ( dc ! = null )
{
if ( MessageBox . Show ( "Wollen Sie den Eintrag '" + dc . Title + "' wirklich löschen?" , "Löschen bestätigen" ,
MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . Yes )
{
ServiceFacade . DoEmployeeServiceSync (
s = > s . DeleteNewsItem ( dc . NewsItemOid . Value , dc . NewsItemVersion . Value ) ) ;
UpdateInternalNews ( ) ;
}
}
}
2016-06-27 01:45:38 +02:00
2016-08-26 13:01:24 +02:00
//####### Connection with Server ###########
2016-08-15 13:37:19 +02:00
private void ConnectWithServer ( )
{
try
2016-08-26 13:01:24 +02:00
{
2016-09-14 13:53:58 +02:00
var ipAdresse = "192.168.1.103" ; //3 |9 || 192.168.1.103"app4.bewoplaner.de"
2016-08-26 13:01:24 +02:00
var port = 5000 ;
2016-08-31 10:55:59 +02:00
var uri = BeWoApp . SiteOfOrigin ;
2016-09-02 10:00:31 +02:00
2016-08-31 10:55:59 +02:00
clientSocket . Connect ( uri . Host , port ) ;
2016-07-25 09:26:56 +02:00
2016-08-01 10:15:24 +02:00
Dispatcher . Invoke (
2016-08-15 13:37:19 +02:00
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
2016-09-02 10:00:31 +02:00
if ( chatView ! = null )
2016-08-15 13:37:19 +02:00
{
2016-09-02 10:00:31 +02:00
chatView . SetServerStats ( "Verbunden" ) ;
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
chatView . ButtonAlarmLabel . Visibility = Visibility . Collapsed ;
if ( isReconnect )
{
// MessageBox.Show("Die Verbindung konnte wieder Hergestellt werden. ", "", MessageBoxButton.OK);
}
isReconnect = false ;
}
2016-08-15 13:37:19 +02:00
} ) ;
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
Thread prf = new Thread ( PruefeServerDisconection ) ;
2016-07-25 14:45:38 +02:00
prf . Start ( ) ;
2016-07-25 09:26:56 +02:00
SendAnmeldungsMessagetoServer ( clientSocket ) ;
2016-08-15 13:37:19 +02:00
Thread getMs = new Thread ( WaitForMsFromServer ) ;
getMs . Start ( ) ;
}
catch ( Exception e )
{
2016-08-05 12:48:13 +02:00
if ( ! isReconnect )
2016-08-15 13:37:19 +02:00
MessageBox . Show ( "Verbindung zum Chat-Server konnte nicht aufgebaut werden." , "Fehler: 2010 " ,
MessageBoxButton . OK ) ;
2016-09-01 14:37:20 +02:00
if ( ! threadstop ) {
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
2016-09-02 10:00:31 +02:00
if ( chatView ! = null )
{
chatView . StatusSetting . SelectedIndex = 1 ;
chatView . setConnectionLostIcon ( ) ;
}
2016-09-01 14:37:20 +02:00
} ) ;
2016-08-12 14:50:25 +02:00
2016-09-01 14:37:20 +02:00
Thread . Sleep ( 5000 ) ;
ReConnectAfterLoseConnection ( ) ;
}
2016-08-15 13:37:19 +02:00
}
}
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
public void SendAnmeldungsMessagetoServer ( TcpClient s )
{
try
{
2016-09-30 10:19:11 +02:00
var serverStream = s . GetStream ( ) ;
2016-07-25 09:26:56 +02:00
2016-09-30 10:19:11 +02:00
var macAddress = NetworkInterface . GetAllNetworkInterfaces ( ) . Where ( inc = > inc . OperationalStatus = = OperationalStatus . Up ) . Select ( inc = > inc . GetPhysicalAddress ( ) . ToString ( ) ) . FirstOrDefault ( ) ;
2016-07-25 09:26:56 +02:00
2016-09-30 10:19:11 +02:00
var formattedMacAddress = "" ;
if ( macAddress ! = null )
{
for ( var i = 0 ; i < macAddress . Length ; i + + )
{
formattedMacAddress + = macAddress [ i ] ;
if ( ( i + 1 ) % 2 = = 0 & & i < macAddress . Length - 1 )
{
formattedMacAddress + = ":" ;
}
}
}
var a = new Packet ( ) ;
2016-08-05 12:48:13 +02:00
2016-09-30 10:19:11 +02:00
var outStream = a . GetDataStream ( BeWoApp . LoggedOnUser . Employee . PersonOid , 0 , BeWoApp . LoggedOnUser . LoginName , formattedMacAddress , DataIdentifier . Login , BeWoApp . Tenant , false ) ;
2016-08-15 13:37:19 +02:00
2016-07-25 09:26:56 +02:00
serverStream . Write ( outStream , 0 , outStream . Length ) ;
serverStream . Flush ( ) ;
2016-08-15 13:37:19 +02:00
}
catch ( Exception e )
{
2016-07-25 09:26:56 +02:00
MessageBox . Show ( "Anmeldung am Server zurzeit nicht möglich." , "Fehler: 2020 " , MessageBoxButton . OK ) ;
2016-08-15 13:37:19 +02:00
}
}
2016-07-25 09:26:56 +02:00
public void WaitForMsFromServer ( )
2016-08-15 13:37:19 +02:00
{
2016-07-25 09:26:56 +02:00
try
2016-08-15 13:37:19 +02:00
{
if ( clientSocket ! = null )
{
serverStream = clientSocket . GetStream ( ) ;
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
byte [ ] inStream = new byte [ 1024 ] ;
2016-08-12 14:50:25 +02:00
2016-08-15 13:37:19 +02:00
Int32 bits = serverStream . Read ( inStream , 0 , inStream . Length ) ;
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
string data = Encoding . UTF8 . GetString ( inStream , 0 , bits ) ;
2016-07-29 13:11:34 +02:00
2016-08-15 13:37:19 +02:00
ErhalteDatenFromString ( data ) ;
2016-08-05 12:48:13 +02:00
2016-09-02 10:00:31 +02:00
if ( chatView = = null )
{
SaveAnkommendeServerMeldungen . Add ( zaehler , messagePaket ) ; // muss noch ordnungsgemäß gesetzt werden
zaehler + + ;
}
else
{
if ( SaveAnkommendeServerMeldungen . Count > 0 )
{
foreach ( var dateiverarbeitung in SaveAnkommendeServerMeldungen )
{
ChatBuilder ( dateiverarbeitung . Value ) ;
}
SaveAnkommendeServerMeldungen . Clear ( ) ;
zaehler = 1 ;
WaitForMsFromServer ( ) ;
}
else
{
ChatBuilder ( messagePaket ) ;
zaehler = 1 ;
WaitForMsFromServer ( ) ;
}
2016-09-13 11:19:36 +02:00
//original
2016-09-02 10:00:31 +02:00
}
WaitForMsFromServer ( ) ;
}
}
catch ( Exception e )
{
if ( clientSocket . Connected )
MessageBox . Show ( "Beim Erhalten von Nachrichten ist ein Fehler aufgetreten." , "Fehler: 2030 " ,
MessageBoxButton . OK ) ;
}
}
public void ChatBuilder ( Packet paket )
{
try
{
long persoid = paket . SenderPersonOid ;
2016-09-01 14:37:20 +02:00
2016-09-02 10:00:31 +02:00
if ( persoid ! = 0 )
{
2016-08-05 12:48:13 +02:00
2016-09-02 10:00:31 +02:00
List < long > x = new List < long > ( ) ;
x . Add ( paket . SenderPersonOid ) ;
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
var person = ServiceFacade . DoCustomerServiceSync ( s = > s . GetPersonsById ( x ) ) ;
2016-09-01 14:37:20 +02:00
2016-09-02 10:00:31 +02:00
switch ( paket . DataIdentifier )
2016-08-15 13:37:19 +02:00
{
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationLoginBroadcast :
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
String [ ] oids = paket . ChatMessage . Split ( ',' ) ;
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
foreach ( var oid in oids )
{
int result = Convert . ToInt32 ( oid ) ;
if ( ! chatView . CompareWithListItem ( result ) )
{
ErstelleChatViews ( result ) ;
}
}
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationLogin :
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
if ( ! chatView . CompareWithListItem ( persoid ) )
{
ErstelleChatViews ( persoid ) ;
}
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationBeschäftigt :
2016-08-05 12:48:13 +02:00
2016-09-02 10:00:31 +02:00
if ( chatView . CompareWithListItem ( persoid ) )
{
AktualisiereStatus ( persoid , paket . DataIdentifier ) ;
}
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationOnline :
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
if ( chatView . CompareWithListItem ( persoid ) )
{
AktualisiereStatus ( persoid , paket . DataIdentifier ) ;
}
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-05 12:48:13 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationOffline :
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
if ( chatView . CompareWithListItem ( persoid ) )
{
AktualisiereStatus ( persoid , paket . DataIdentifier ) ;
}
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . StatusNotificationLogout :
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
DeleteLoggedOffUsers ( person [ 0 ] . FirstName + " " + person [ 0 ] . LastName , persoid ) ;
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . Message :
2016-08-23 10:22:01 +02:00
2016-09-22 10:57:02 +02:00
UebergebeNachricht ( paket . ChatMessage , person [ 0 ] . FirstName ,
2016-09-02 10:00:31 +02:00
persoid , paket . DataIdentifier , paket . RecipientPersonOid ) ;
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
case DataIdentifier . Team :
2016-08-23 10:22:01 +02:00
2016-09-02 10:00:31 +02:00
UebergebeNachricht ( paket . ChatMessage , person [ 0 ] . FirstName + " " + person [ 0 ] . LastName ,
persoid , paket . DataIdentifier , paket . RecipientPersonOid ) ;
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
break ;
2016-08-15 13:37:19 +02:00
}
}
}
2016-09-02 10:00:31 +02:00
catch ( Exception edf )
2016-08-15 13:37:19 +02:00
{
2016-09-02 10:00:31 +02:00
MessageBox . Show ( "Beim Sortieren von Nachrichten ist ein Fehler aufgetreten. " + edf . Message + "\n" + edf . StackTrace , "Fehler" ,
MessageBoxButton . OK ) ;
2016-08-15 13:37:19 +02:00
}
2016-09-02 10:00:31 +02:00
}
2016-07-25 09:26:56 +02:00
2016-08-12 14:50:25 +02:00
public void ErhalteDatenFromString ( String message )
2016-08-15 13:37:19 +02:00
{
2016-07-25 09:26:56 +02:00
try
2016-07-29 13:11:34 +02:00
{
2016-08-12 14:50:25 +02:00
messagePaket = new Packet ( ) ;
2016-07-25 09:26:56 +02:00
2016-08-12 14:50:25 +02:00
messagePaket . GetData ( message ) ;
2016-07-25 09:26:56 +02:00
}
catch ( Exception e )
{
2016-08-15 13:37:19 +02:00
MessageBox . Show ( "Beim Sortieren von Nachrichten ist ein Fehler aufgetreten." , "Fehler: 2040 " ,
MessageBoxButton . OK ) ;
2016-07-25 09:26:56 +02:00
}
2016-08-15 13:37:19 +02:00
}
public void AktualisiereStatus ( long oid , DataIdentifier type )
{
try
{
2016-09-02 10:00:31 +02:00
chatView . SetUserBeschäftigt ( oid , type ) ;
2016-08-15 13:37:19 +02:00
}
catch ( Exception edf )
{
MessageBox . Show ( "Beim Setzen des Statuses auf Beschäftigt ist ein Fehler aufgetreten." , "Fehler: 2130 " ,
MessageBoxButton . OK ) ;
}
}
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
public void AktualisiereOnlineList ( string name , long oid )
2016-07-25 09:26:56 +02:00
{
try
{
2016-09-02 10:00:31 +02:00
if ( chatView . CompareWithListItem ( oid ) )
2016-07-25 09:26:56 +02:00
{
2016-08-01 10:15:24 +02:00
DeleteLoggedOffUsers ( name , oid ) ;
2016-07-25 09:26:56 +02:00
}
}
catch ( Exception e )
{
MessageBox . Show ( "Beim Aktualisieren der Online-Liste ist ein Fehler aufgetreten " , "Fehler: 2050 " , MessageBoxButton . OK ) ;
}
}
2016-08-23 10:22:01 +02:00
public void UebergebeNachricht ( String text , String name , long personoid , DataIdentifier team , long empfaenger )
2016-07-25 09:26:56 +02:00
{
try
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
if ( miniChatViewList . ContainsKey ( personoid ) & & team ! = DataIdentifier . Team )
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
if ( chatView . AktChatUser . Items . Count > 0 )
2016-08-05 12:48:13 +02:00
{
2016-09-02 10:00:31 +02:00
KontaktlistBuilder curItem = ( KontaktlistBuilder ) chatView . AktChatUser . Items [ 0 ] ;
2016-08-12 14:50:25 +02:00
2016-09-02 10:00:31 +02:00
if ( chatView . Visibility = = Visibility . Collapsed & &
miniChatViewList [ personoid ] . Visibility = = Visibility . Collapsed )
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . Visibility = Visibility . Visible ;
miniChatViewList [ personoid ] . SetText ( text , 1 ) ;
2016-08-12 14:50:25 +02:00
}
2016-09-02 10:00:31 +02:00
else if ( miniChatViewList [ personoid ] . Visibility = = Visibility . Collapsed & & chatView . Visibility = = Visibility . Visible & & curItem . EmpfaengerOid . Equals ( personoid ) )
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
chatView . SetText ( text , name , personoid ) ;
2016-08-12 14:50:25 +02:00
}
2016-09-02 10:00:31 +02:00
else if ( miniChatViewList [ personoid ] . Visibility = = Visibility . Collapsed & & ! curItem . EmpfaengerOid . Equals ( personoid ) )
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . Visibility = Visibility . Visible ;
miniChatViewList [ personoid ] . SetText ( text , 1 ) ;
2016-08-12 14:50:25 +02:00
}
else
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . AppendTextwhileViewOpen ( text , 1 ) ;
2016-08-12 14:50:25 +02:00
}
2016-08-05 12:48:13 +02:00
}
else
{
2016-09-02 10:00:31 +02:00
if ( chatView . Visibility = = Visibility . Collapsed & &
miniChatViewList [ personoid ] . Visibility = = Visibility . Collapsed )
2016-08-05 12:48:13 +02:00
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . Visibility = Visibility . Visible ;
miniChatViewList [ personoid ] . SetText ( text , 1 ) ;
2016-08-05 12:48:13 +02:00
}
2016-09-02 10:00:31 +02:00
else if ( miniChatViewList [ personoid ] . Visibility = = Visibility . Collapsed & & chatView . Visibility = = Visibility . Visible )
2016-08-05 12:48:13 +02:00
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . Visibility = Visibility . Visible ;
miniChatViewList [ personoid ] . SetText ( text , 1 ) ;
2016-08-05 12:48:13 +02:00
}
else
{
2016-09-02 10:00:31 +02:00
miniChatViewList [ personoid ] . AppendTextwhileViewOpen ( text , 1 ) ;
2016-08-05 12:48:13 +02:00
}
2016-08-12 14:50:25 +02:00
}
}
else
{
2016-09-02 10:00:31 +02:00
if ( chatView . AktChatUser . Items . Count > 0 )
2016-08-12 14:50:25 +02:00
{
2016-09-02 10:00:31 +02:00
KontaktlistBuilder curItem = ( KontaktlistBuilder ) chatView . AktChatUser . Items [ 0 ] ;
2016-08-12 14:50:25 +02:00
2016-08-23 10:22:01 +02:00
if ( team = = DataIdentifier . Team & & curItem . TypeChat = = ChatType . Team & & curItem . EmpfaengerOid . Equals ( empfaenger ) )
2016-08-12 14:50:25 +02:00
{
2016-08-26 13:01:24 +02:00
var zugehorigkeit = ServiceFacade . DoEmployeeServiceSync ( s = > s . GetTeamOidsByEmployee ( BeWoApp . LoggedOnUser . Employee . PersonOid ) ) ;
2016-08-23 10:22:01 +02:00
foreach ( var dc in zugehorigkeit )
{
if ( dc . TeamOid = = curItem . EmpfaengerOid )
{
2016-09-02 10:00:31 +02:00
chatView . SetText ( text , name , dc . TeamOid ) ;
2016-08-23 10:22:01 +02:00
}
}
2016-08-12 14:50:25 +02:00
}
2016-08-23 10:22:01 +02:00
else if ( team = = DataIdentifier . Team & & ( ! curItem . EmpfaengerOid . Equals ( empfaenger ) ) )
2016-08-12 14:50:25 +02:00
{
2016-08-26 13:01:24 +02:00
var zugehorigkeit = ServiceFacade . DoEmployeeServiceSync ( s = > s . GetTeamOidsByEmployee ( BeWoApp . LoggedOnUser . Employee . PersonOid ) ) ;
2016-08-23 10:22:01 +02:00
foreach ( var dc in zugehorigkeit )
{
if ( dc . TeamOid = = empfaenger )
{
2016-09-02 10:00:31 +02:00
chatView . SetTeamAnzahlErhalteneNachricht ( dc . TeamOid , ChatType . Team ) ;
2016-08-23 10:22:01 +02:00
}
}
2016-08-12 14:50:25 +02:00
}
}
}
2016-07-25 09:26:56 +02:00
} ) ;
2016-07-18 09:15:00 +02:00
}
catch ( Exception e )
{
2016-07-25 09:26:56 +02:00
MessageBox . Show ( "Nachrichtenübermittlung fehlgeschlagen " , "Fehler: 2060 " , MessageBoxButton . OK ) ;
}
}
2016-07-18 09:15:00 +02:00
2016-07-25 09:26:56 +02:00
2016-08-01 10:15:24 +02:00
public void DeleteLoggedOffUsers ( String personname , long personoid )
2016-07-25 09:26:56 +02:00
{
try
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
2016-08-23 10:22:01 +02:00
{
2016-09-02 10:00:31 +02:00
chatView . RemoveListItem ( personoid ) ;
chatView . SetServerStats ( personname + " Disconnected ! " ) ;
miniChatViewList . Remove ( personoid ) ;
2016-08-23 10:22:01 +02:00
2016-07-25 09:26:56 +02:00
} ) ;
}
catch ( Exception e )
{
MessageBox . Show ( "Es ist ein Fehler aufgetreten, bei dem versucht wurde User aus der Onlineanzeige zu entfernen" , "Fehler: 2070 " , MessageBoxButton . OK ) ;
2016-07-18 09:15:00 +02:00
}
}
2016-09-13 11:19:36 +02:00
public void Ü bergebeEmojiAnChatView ( String Emojicode , String EmojiPfad )
{
try
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
{
chatView . Chatbox . Focus ( ) ;
2016-09-16 15:27:23 +02:00
chatView . Chatbox . Text + = " " + Emojicode ;
2016-09-13 11:19:36 +02:00
chatView . Chatbox . SelectionStart = chatView . Chatbox . Text . Length ;
} ) ;
}
catch ( Exception edf )
{
MessageBox . Show ( "Es ist ein Fehler aufgetreten, bei dem versucht wurde User aus der Onlineanzeige zu entfernen" , "Fehler: " , MessageBoxButton . OK ) ;
}
}
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
public void PruefeServerDisconection ( )
{
try
{
while ( true )
{
2016-07-25 14:45:38 +02:00
if ( clientSocket . Connected = = false )
2016-07-25 09:26:56 +02:00
{
2016-08-26 13:01:24 +02:00
if ( ! threadstop )
{
MessageBox . Show ( "Die verbindung zum Server wurde seitens dem Server unterbrochen" , "Info" , MessageBoxButton . OK ) ;
clientSocket . Client . Disconnect ( true ) ;
clientSocket . Client . Close ( ) ;
clientSocket = null ;
clientSocket = new TcpClient ( ) ;
2016-07-29 13:11:34 +02:00
this . Dispatcher . BeginInvoke (
DispatcherPriority . Normal ,
( Action ) delegate
2016-09-01 14:37:20 +02:00
{
2016-09-02 10:45:47 +02:00
if ( chatView ! = null ) {
chatView . UpdateTcp ( clientSocket ) ;
chatView . ButtonAlarmLabel . Visibility = Visibility . Visible ;
chatView . SetAllUserOfflineIfNoInet ( ) ;
2016-08-05 12:48:13 +02:00
2016-09-02 10:45:47 +02:00
chatView . StatusSetting . SelectedIndex = 1 ;
chatView . SetServerStats ( "Verbindung zum Server Unterbrochen" ) ;
}
2016-08-26 13:01:24 +02:00
} ) ;
2016-08-12 14:50:25 +02:00
ReConnectAfterLoseConnection ( ) ;
2016-08-26 13:01:24 +02:00
}
2016-08-12 14:50:25 +02:00
break ;
2016-07-25 09:26:56 +02:00
}
}
}
catch ( Exception e )
{
2016-08-18 12:52:26 +02:00
MessageBox . Show ( "Es ist ein Fehler mit der Verbindung aufgetreten" , "Fehler: 2080 " , MessageBoxButton . OK ) ;
2016-07-25 09:26:56 +02:00
}
}
2016-09-13 11:19:36 +02:00
2016-07-25 09:26:56 +02:00
2016-08-01 10:15:24 +02:00
private void ReConnectAfterLoseConnection ( )
{
try
{
2016-09-01 14:37:20 +02:00
if ( clientSocket . Client ! = null )
{
if ( clientSocket . Client . Connected )
{
isReconnect = false ;
}
else
{
asx = new Thread ( ConnectWithServer ) ;
asx . Start ( ) ;
isReconnect = true ;
}
}
2016-08-01 10:15:24 +02:00
}
catch ( Exception e )
{
2016-09-01 14:37:20 +02:00
MessageBox . Show ( "Fehler, Siehe fehlercode." + e . Message + "\n" + e . StackTrace , "Fehler: 2120 " , MessageBoxButton . OK ) ;
2016-08-01 10:15:24 +02:00
}
}
2016-07-25 09:26:56 +02:00
2016-07-25 14:45:38 +02:00
private void ErstelleChatViews ( long personOid )
2016-07-25 09:26:56 +02:00
{
try
{
Dispatcher . Invoke (
DispatcherPriority . Normal ,
( ThreadStart ) delegate
2016-08-01 10:15:24 +02:00
{
2016-07-25 09:26:56 +02:00
List < long > x = new List < long > ( ) ;
x . Add ( personOid ) ;
var person = ServiceFacade . DoCustomerServiceSync ( s = > s . GetPersonsById ( x ) ) ;
2016-09-02 10:00:31 +02:00
chatView . SetList ( person [ 0 ] . FirstName + " " + person [ 0 ] . LastName , personOid ) ;
chatView . SetServerStats ( person [ 0 ] . FirstName + " " + person [ 0 ] . LastName + " Connected" ) ;
2016-07-25 09:26:56 +02:00
2016-08-15 13:37:19 +02:00
if ( person [ 0 ] . Type = = PersonType . Customer )
2016-09-22 10:57:02 +02:00
miniChatView = new MiniChatView ( person [ 0 ] . FirstName , person [ 0 ] . LastName , "" , chatView , personOid , ChatType . Klienten ) ;
2016-08-15 13:37:19 +02:00
else if ( person [ 0 ] . Type = = PersonType . Employee )
2016-09-22 10:57:02 +02:00
miniChatView = new MiniChatView ( person [ 0 ] . FirstName , person [ 0 ] . LastName , "" , chatView , personOid , ChatType . Mitarbeiter ) ;
2016-08-15 13:37:19 +02:00
else if ( person [ 0 ] . Type = = PersonType . Others )
2016-09-22 10:57:02 +02:00
miniChatView = new MiniChatView ( person [ 0 ] . FirstName , person [ 0 ] . LastName , "" , chatView , personOid , ChatType . Team ) ;
2016-08-15 13:37:19 +02:00
2016-09-02 10:00:31 +02:00
miniChatView . Visibility = Visibility . Collapsed ;
2016-07-25 09:26:56 +02:00
2016-09-13 11:19:36 +02:00
if ( ! miniChatViewList . ContainsKey ( personOid ) )
miniChatViewList . Add ( personOid , miniChatView ) ;
2016-07-25 09:26:56 +02:00
} ) ;
}
catch ( Exception e )
{
MessageBox . Show ( "Das Erstellen der Chat-Views konnt nicht ausgeführt werden" , "Fehler: 2090 " , MessageBoxButton . OK ) ;
}
}
public void CloseServerConnection ( )
{
try
{
if ( clientSocket ! = null )
{
2016-08-26 13:01:24 +02:00
threadstop = true ;
2016-08-12 14:50:25 +02:00
clientSocket . Close ( ) ;
2016-07-25 09:26:56 +02:00
}
if ( serverStream ! = null )
{
serverStream . Close ( ) ;
}
2016-08-05 12:48:13 +02:00
2016-08-26 13:01:24 +02:00
if ( asx ! = null )
2016-08-05 12:48:13 +02:00
{
2016-08-26 13:01:24 +02:00
if ( asx . IsAlive )
{
asx . Join ( ) ;
2016-09-01 14:37:20 +02:00
// asx.Abort();
2016-08-26 13:01:24 +02:00
asx = null ;
2016-08-12 14:50:25 +02:00
2016-08-26 13:01:24 +02:00
threadstop = true ;
}
}
2016-09-01 14:37:20 +02:00
2016-08-26 13:01:24 +02:00
2016-07-25 09:26:56 +02:00
}
catch ( Exception edf )
{
2016-08-26 13:01:24 +02:00
MessageBox . Show ( "Beim Versuch ,die verbindung mit dem Server zu trennen, ist ein Fehler unterlaufen. " + edf . Message + "\n" + edf . StackTrace , "Fehler: 2100 " , MessageBoxButton . OK ) ;
2016-07-25 09:26:56 +02:00
}
}
2016-09-13 11:19:36 +02:00
//---------------------------------------------------------------------------------------------------------------------------
2016-06-27 01:45:38 +02:00
}
public class TaskDateDescriptionConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
var task = value as TaskDC ;
if ( task ! = null )
{
if ( task . CompletedDate . HasValue )
return string . Format ( "erledigt am: {0:d}" , task . CompletedDate ) ;
if ( task . DueDate . HasValue )
return string . Format ( "bis {0:d} {0:t}" , task . DueDate , task . DueDate ) ;
}
return string . Empty ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture )
{
throw new NotImplementedException ( ) ;
}
}
}