1943 lines
76 KiB
C#
1943 lines
76 KiB
C#
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;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using BS.Shared.Core;
|
|
using Newtonsoft.Json;
|
|
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;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for HomeView.xaml
|
|
/// </summary>
|
|
public partial class HomeDragPanelView : BeWoView
|
|
{
|
|
private List<TaskDC> _AllTasks;
|
|
|
|
|
|
//################# Variablen der Serveranwendung #################
|
|
protected ListBox Clientlist = new ListBox();
|
|
protected TextBox ServerStats = new TextBox();
|
|
protected TextBox chat = new TextBox();
|
|
|
|
protected MiniChatView miniChatView = null;
|
|
protected ChatView chatView = null;
|
|
|
|
Dictionary<long, MiniChatView> miniChatViewList = new Dictionary<long, MiniChatView>();
|
|
|
|
//---- änderungen ----
|
|
Dictionary<long, Packet> SaveAnkommendeServerMeldungen = new Dictionary<long, Packet>();
|
|
protected long zaehler = 1;
|
|
//--------------------
|
|
|
|
|
|
//Neue Version : Version 0.80
|
|
public TcpClient clientSocket = new TcpClient();
|
|
NetworkStream serverStream;
|
|
protected Thread asx;
|
|
protected bool isReconnect = false;
|
|
Packet messagePaket;
|
|
|
|
protected bool threadstop = false;
|
|
|
|
protected bool berechtigt = false;
|
|
|
|
//################################################################
|
|
|
|
public HomeDragPanelView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
txtHeader.Text = String.Format("{0} {1}", BeWoApp.LoggedOnUser.Employee.FirstName,
|
|
BeWoApp.LoggedOnUser.Employee.LastName);
|
|
txtVersion.Text = BeWoApp.Version;
|
|
|
|
txtLoginTime.Text = string.Empty;
|
|
txtLastLoginTime.Text = string.Empty;
|
|
|
|
//PreparePanels();
|
|
InitPanels(null);
|
|
|
|
#if DEBUG
|
|
txtChangePassword.Visibility = Visibility.Visible;
|
|
#else
|
|
if (BeWoApp.Tenant == "demo" || !BeWoApp.LoggedOnUser.HasRight(UserRightType.AllowChangeOwnPassword))
|
|
{
|
|
txtChangePassword.Visibility = Visibility.Collapsed;
|
|
}
|
|
#endif
|
|
// FillInbox();
|
|
// FillOutbox();
|
|
Loaded += HomeDragPanelViewLoaded;
|
|
|
|
/*this.Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Normal,
|
|
(Action)delegate
|
|
{
|
|
ConnectWithServer();
|
|
if(clientSocket.Connected)
|
|
MessageBox.Show("Verbindung geglückt.", "Info", MessageBoxButton.OK,MessageBoxImage.Information);
|
|
});*/
|
|
|
|
|
|
var berechtigung = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact());
|
|
foreach (var list in berechtigung)
|
|
{
|
|
if (list.PersonOid == BeWoApp.LoggedOnUser.Employee.PersonOid)
|
|
{
|
|
berechtigt = true;
|
|
}
|
|
}
|
|
|
|
|
|
if (berechtigt)
|
|
{
|
|
asx = new Thread(ConnectWithServer);
|
|
asx.Start();
|
|
}
|
|
else
|
|
{
|
|
BewoChat.Visibility = Visibility.Hidden;
|
|
}
|
|
}
|
|
|
|
private void PreparePanels()
|
|
{
|
|
ServiceFacade.DoOperationsServiceAsyncNoWait(
|
|
s => s.GetUiElements(UiElementType.StartPanel, BeWoApp.LoggedOnUser.Employee.EmployeeOid, null, null),
|
|
InitPanelsCallback, null);
|
|
}
|
|
|
|
private void InitPanelsCallback(IList<UiElementDC> elements, object state)
|
|
{
|
|
this.Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Normal,
|
|
(Action) delegate
|
|
{
|
|
InitPanels(elements);
|
|
});
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
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;
|
|
|
|
var fenster = new PasswortAenderungsView {AbbrechenButton = {IsEnabled = false}};
|
|
fenster.CommandBindings.Clear();
|
|
|
|
fenster.ShowDialog();
|
|
}
|
|
|
|
public void SaveState()
|
|
{
|
|
var order = new List<DragDockPanel>();
|
|
DragDockPanel panelWithMaxHeight = null;
|
|
double maxHeight = 0;
|
|
double normalHeight = 0;
|
|
|
|
var result = new List<DependencyObject>();
|
|
|
|
foreach (object item in panelHost.Children)
|
|
{
|
|
var p = item as DragDockPanel;
|
|
|
|
if (order.Count == 0)
|
|
{
|
|
order.Add(p);
|
|
}
|
|
else
|
|
{
|
|
int newIndex = -1;
|
|
int index = 0;
|
|
|
|
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;
|
|
}
|
|
|
|
if (Equals(rect.Y, rect2.Y) && rect.X < rect2.X)
|
|
{
|
|
newIndex = index;
|
|
continue;
|
|
}
|
|
|
|
index++;
|
|
}
|
|
|
|
if (newIndex < 0)
|
|
{
|
|
order.Add(p);
|
|
}
|
|
else
|
|
{
|
|
order.Insert(newIndex, p);
|
|
}
|
|
}
|
|
|
|
if (p.Height > maxHeight)
|
|
{
|
|
maxHeight = p.ActualHeight;
|
|
panelWithMaxHeight = p;
|
|
}
|
|
else
|
|
{
|
|
normalHeight = p.ActualHeight;
|
|
}
|
|
}
|
|
|
|
if ((maxHeight - normalHeight) > 1 && panelWithMaxHeight != null)
|
|
{
|
|
BeWoApp.AppSettings.StartupPanelMaximized = panelWithMaxHeight.Name;
|
|
}
|
|
else
|
|
{
|
|
BeWoApp.AppSettings.StartupPanelMaximized = null;
|
|
}
|
|
|
|
List<string> panelOrder = order.Select(item => item.Name).ToList();
|
|
|
|
BeWoApp.AppSettings.StartupPanelOrder = panelOrder;
|
|
}
|
|
|
|
private void ButtonOpenServiceRecordView_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var btn = sender as Button;
|
|
if (btn != null)
|
|
{
|
|
var dc = btn.Tag as CompactSupportConceptDC;
|
|
|
|
if (dc != null)
|
|
BeWoApp.MainControl.NavigateToServiceRecordView(dc.SupportConceptOid);
|
|
}
|
|
}
|
|
|
|
private void InitBewoNews()
|
|
{
|
|
try
|
|
{
|
|
if (BeWoApp.Tenant != "demo")
|
|
{
|
|
LoadFeed();
|
|
|
|
//LoadFeed("http://www.heise.de/foto/rss/news-atom.xml");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
private void ChatLinkOnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
|
{
|
|
if (chatView == null) //#################### neu ########## <--
|
|
{
|
|
chatView = new ChatView("BeWo Chat", chat.Text, clientSocket);
|
|
|
|
if (clientSocket.Connected)
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
chatView.SetServerStats("Verbunden");
|
|
|
|
chatView.RadioButtonOnline.IsChecked = true;
|
|
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.RadioButtonOffline.IsChecked = true;
|
|
});
|
|
}
|
|
|
|
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart)delegate
|
|
{
|
|
//Lade alle Ungelesenen Nachrichten
|
|
chatView.PruefeInDbObNeueNachrichtenVerfügbar();
|
|
});
|
|
|
|
chatView.Visibility = Visibility.Visible;
|
|
} //#################### neu ########## <--
|
|
else
|
|
{
|
|
if(chatView.Visibility == Visibility.Collapsed){
|
|
chatView.Visibility = Visibility.Visible;
|
|
chatView.AktualisiereChatKontakt();
|
|
chatView.Activate();
|
|
}
|
|
else
|
|
{
|
|
chatView.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
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 += () =>
|
|
{
|
|
SaveNewsItem(vm);
|
|
window.Close();
|
|
};
|
|
|
|
|
|
window.rootGroupBox.Header = "Neuer Eintrag";
|
|
window.Title = "Neuer Eintrag";
|
|
window.Show();
|
|
|
|
}
|
|
}
|
|
|
|
private void SaveNewsItem(NewsItemVM vm)
|
|
{
|
|
ServiceFacade.DoEmployeeServiceSync(s => s.InsertNewNewsItem(vm.CommitToDataContract()));
|
|
UpdateInternalNews();
|
|
}
|
|
|
|
|
|
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();
|
|
};
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
//####### Connection with Server ###########
|
|
private void ConnectWithServer()
|
|
{
|
|
try
|
|
{
|
|
var ipAdresse = "192.168.1.103"; //3 |9 || 192.168.1.103"app4.bewoplaner.de"
|
|
var port = 5000;
|
|
var uri = BeWoApp.SiteOfOrigin;
|
|
|
|
clientSocket.Connect(uri.Host, port);
|
|
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
if (chatView != null)
|
|
{
|
|
chatView.SetServerStats("Verbunden");
|
|
|
|
chatView.ButtonAlarmLabel.Visibility = Visibility.Collapsed;
|
|
|
|
if (isReconnect)
|
|
{
|
|
// MessageBox.Show("Die Verbindung konnte wieder Hergestellt werden. ", "", MessageBoxButton.OK);
|
|
}
|
|
|
|
isReconnect = false;
|
|
}
|
|
});
|
|
|
|
Thread prf = new Thread(PruefeServerDisconection);
|
|
prf.Start();
|
|
|
|
SendAnmeldungsMessagetoServer(clientSocket);
|
|
|
|
Thread getMs = new Thread(WaitForMsFromServer);
|
|
getMs.Start();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (!isReconnect)
|
|
MessageBox.Show("Verbindung zum Chat-Server konnte nicht aufgebaut werden.", "Fehler: 2010 ",
|
|
MessageBoxButton.OK);
|
|
|
|
if(!threadstop){
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
if (chatView != null)
|
|
{
|
|
chatView.RadioButtonOffline.IsChecked = true;
|
|
chatView.setConnectionLostIcon();
|
|
}
|
|
|
|
});
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
ReConnectAfterLoseConnection();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void SendAnmeldungsMessagetoServer(TcpClient s)
|
|
{
|
|
try
|
|
{
|
|
NetworkStream serverStream = s.GetStream();
|
|
|
|
String abc = NetworkInterface.GetAllNetworkInterfaces().Where(inc => inc.OperationalStatus == OperationalStatus.Up).Select(inc => inc.GetPhysicalAddress().ToString()).FirstOrDefault();
|
|
|
|
Packet a = new Packet();
|
|
|
|
byte[] outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, 0,
|
|
BeWoApp.LoggedOnUser.LoginName, abc, DataIdentifier.Login, BeWoApp.Tenant, false);
|
|
|
|
serverStream.Write(outStream, 0, outStream.Length);
|
|
serverStream.Flush();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Anmeldung am Server zurzeit nicht möglich.", "Fehler: 2020 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
public void WaitForMsFromServer()
|
|
{
|
|
try
|
|
{
|
|
if (clientSocket != null)
|
|
{
|
|
serverStream = clientSocket.GetStream();
|
|
|
|
byte[] inStream = new byte[1024];
|
|
|
|
Int32 bits = serverStream.Read(inStream, 0, inStream.Length);
|
|
|
|
string data = Encoding.UTF8.GetString(inStream, 0, bits);
|
|
|
|
ErhalteDatenFromString(data);
|
|
|
|
if (chatView == null)
|
|
{
|
|
SaveAnkommendeServerMeldungen.Add(zaehler, messagePaket);
|
|
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();
|
|
}
|
|
|
|
}
|
|
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;
|
|
|
|
if (persoid != 0)
|
|
{
|
|
|
|
List<long> x = new List<long>();
|
|
x.Add(paket.SenderPersonOid);
|
|
|
|
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
|
|
|
switch (paket.DataIdentifier)
|
|
{
|
|
case DataIdentifier.StatusNotificationLoginBroadcast:
|
|
|
|
String[] oids = paket.ChatMessage.Split(',');
|
|
|
|
foreach (var oid in oids)
|
|
{
|
|
int result = Convert.ToInt32(oid);
|
|
if (!chatView.CompareWithListItem(result))
|
|
{
|
|
ErstelleChatViews(result);
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case DataIdentifier.StatusNotificationLogin:
|
|
|
|
if (!chatView.CompareWithListItem(persoid))
|
|
{
|
|
ErstelleChatViews(persoid);
|
|
}
|
|
|
|
break;
|
|
|
|
case DataIdentifier.StatusNotificationBeschäftigt:
|
|
|
|
if (chatView.CompareWithListItem(persoid))
|
|
{
|
|
AktualisiereStatus(persoid, paket.DataIdentifier);
|
|
}
|
|
|
|
break;
|
|
|
|
case DataIdentifier.StatusNotificationOnline:
|
|
|
|
if (chatView.CompareWithListItem(persoid))
|
|
{
|
|
AktualisiereStatus(persoid, paket.DataIdentifier);
|
|
}
|
|
|
|
break;
|
|
|
|
case DataIdentifier.StatusNotificationOffline:
|
|
|
|
if (chatView.CompareWithListItem(persoid))
|
|
{
|
|
AktualisiereStatus(persoid, paket.DataIdentifier);
|
|
}
|
|
|
|
break;
|
|
|
|
case DataIdentifier.StatusNotificationLogout:
|
|
|
|
DeleteLoggedOffUsers(person[0].FirstName + " " + person[0].LastName, persoid);
|
|
|
|
break;
|
|
|
|
case DataIdentifier.Message:
|
|
|
|
UebergebeNachricht(paket.ChatMessage, person[0].FirstName,
|
|
persoid, paket.DataIdentifier, paket.RecipientPersonOid);
|
|
|
|
break;
|
|
|
|
case DataIdentifier.Team:
|
|
|
|
UebergebeNachricht(paket.ChatMessage, person[0].FirstName + " " + person[0].LastName,
|
|
persoid, paket.DataIdentifier, paket.RecipientPersonOid);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Sortieren von Nachrichten ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace , "Fehler",
|
|
MessageBoxButton.OK);
|
|
|
|
}
|
|
}
|
|
|
|
public void ErhalteDatenFromString(String message)
|
|
{
|
|
try
|
|
{
|
|
messagePaket = new Packet();
|
|
|
|
messagePaket.GetData(message);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Beim Sortieren von Nachrichten ist ein Fehler aufgetreten.", "Fehler: 2040 ",
|
|
MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void AktualisiereStatus(long oid, DataIdentifier type)
|
|
{
|
|
try
|
|
{
|
|
chatView.SetUserBeschäftigt(oid, type);
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Setzen des Statuses auf Beschäftigt ist ein Fehler aufgetreten.", "Fehler: 2130 ",
|
|
MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void AktualisiereOnlineList(string name,long oid)
|
|
{
|
|
try
|
|
{
|
|
if (chatView.CompareWithListItem(oid))
|
|
{
|
|
DeleteLoggedOffUsers(name,oid);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Beim Aktualisieren der Online-Liste ist ein Fehler aufgetreten ", "Fehler: 2050 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
public void UebergebeNachricht(String text,String name, long personoid ,DataIdentifier team, long empfaenger)
|
|
{
|
|
try
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
if (miniChatViewList.ContainsKey(personoid) && team != DataIdentifier.Team)
|
|
{
|
|
if (chatView.AktChatUser.Items.Count > 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)chatView.AktChatUser.Items[0];
|
|
|
|
if (chatView.Visibility == Visibility.Collapsed &&
|
|
miniChatViewList[personoid].Visibility == Visibility.Collapsed)
|
|
{
|
|
// miniChatViewList[personoid].Visibility = Visibility.Visible;
|
|
// miniChatViewList[personoid].SetText(text, 1);
|
|
}
|
|
else if (miniChatViewList[personoid].Visibility == Visibility.Collapsed && chatView.Visibility == Visibility.Visible && curItem.EmpfaengerOid.Equals(personoid))
|
|
{
|
|
chatView.SetText(text, name, personoid);
|
|
}
|
|
else if (miniChatViewList[personoid].Visibility == Visibility.Collapsed && !curItem.EmpfaengerOid.Equals(personoid))
|
|
{
|
|
// miniChatViewList[personoid].Visibility = Visibility.Visible;
|
|
// miniChatViewList[personoid].SetText(text, 1);
|
|
|
|
chatView.SetAnzahlErhalteneNachricht(personoid);
|
|
}
|
|
else if (chatView.Visibility == Visibility.Collapsed && !curItem.EmpfaengerOid.Equals(personoid))
|
|
{
|
|
//miniChatViewList[personoid].AppendTextwhileViewOpen(text, 1);
|
|
chatView.SetAnzahlErhalteneNachricht(personoid);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (chatView.Visibility == Visibility.Collapsed &&
|
|
miniChatViewList[personoid].Visibility == Visibility.Collapsed)
|
|
{
|
|
//miniChatViewList[personoid].Visibility = Visibility.Visible;
|
|
//miniChatViewList[personoid].SetText(text, 1);
|
|
chatView.SetAnzahlErhalteneNachricht(personoid);
|
|
}
|
|
else if (miniChatViewList[personoid].Visibility == Visibility.Collapsed && chatView.Visibility == Visibility.Visible)
|
|
{
|
|
//miniChatViewList[personoid].Visibility = Visibility.Visible;
|
|
//miniChatViewList[personoid].SetText(text, 1);
|
|
|
|
chatView.SetAnzahlErhalteneNachricht(personoid);
|
|
}
|
|
else
|
|
{
|
|
// miniChatViewList[personoid].AppendTextwhileViewOpen(text, 1);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (chatView.AktChatUser.Items.Count > 0)
|
|
{
|
|
KontaktlistBuilder curItem = (KontaktlistBuilder)chatView.AktChatUser.Items[0];
|
|
|
|
if (team == DataIdentifier.Team && curItem.TypeChat == ChatType.Team && curItem.EmpfaengerOid.Equals(empfaenger))
|
|
{
|
|
var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.PersonOid));
|
|
|
|
foreach (var dc in zugehorigkeit)
|
|
{
|
|
if (dc.TeamOid == curItem.EmpfaengerOid)
|
|
{
|
|
chatView.SetText(text, name, dc.TeamOid);
|
|
}
|
|
}
|
|
}
|
|
else if(team == DataIdentifier.Team && (!curItem.EmpfaengerOid.Equals(empfaenger)))
|
|
{
|
|
var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.PersonOid));
|
|
|
|
foreach (var dc in zugehorigkeit)
|
|
{
|
|
if (dc.TeamOid == empfaenger)
|
|
{
|
|
chatView.SetTeamAnzahlErhalteneNachricht(dc.TeamOid, ChatType.Team);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Nachrichtenübermittlung fehlgeschlagen ", "Fehler: 2060 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
public void DeleteLoggedOffUsers(String personname,long personoid)
|
|
{
|
|
try
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart)delegate
|
|
{
|
|
chatView.RemoveListItem(personoid);
|
|
chatView.SetServerStats(personname + " Disconnected ! ");
|
|
|
|
miniChatViewList.Remove(personoid);
|
|
|
|
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Es ist ein Fehler aufgetreten, bei dem versucht wurde User aus der Onlineanzeige zu entfernen", "Fehler: 2070 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void ÜbergebeEmojiAnChatView(String Emojicode, String EmojiPfad)
|
|
{
|
|
try
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart)delegate
|
|
{
|
|
chatView.Chatbox.Focus();
|
|
chatView.Chatbox.Text += " " + Emojicode;
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void PruefeServerDisconection()
|
|
{
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
if (clientSocket.Connected == false)
|
|
{
|
|
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();
|
|
|
|
|
|
this.Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Normal,
|
|
(Action) delegate
|
|
{
|
|
if(chatView != null){
|
|
chatView.UpdateTcp(clientSocket);
|
|
chatView.ButtonAlarmLabel.Visibility = Visibility.Visible;
|
|
chatView.SetAllUserOfflineIfNoInet();
|
|
|
|
chatView.RadioButtonOffline.IsChecked = true;
|
|
chatView.SetServerStats("Verbindung zum Server Unterbrochen");
|
|
}
|
|
});
|
|
|
|
ReConnectAfterLoseConnection();
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Es ist ein Fehler mit der Verbindung aufgetreten", "Fehler: 2080 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
private void ReConnectAfterLoseConnection()
|
|
{
|
|
try
|
|
{
|
|
if (clientSocket.Client != null)
|
|
{
|
|
if (clientSocket.Client.Connected)
|
|
{
|
|
isReconnect = false;
|
|
}
|
|
else
|
|
{
|
|
asx = new Thread(ConnectWithServer);
|
|
asx.Start();
|
|
isReconnect = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Fehler, Siehe fehlercode."+ e.Message + "\n" + e.StackTrace , "Fehler: 2120 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
private void ErstelleChatViews(long personOid)
|
|
{
|
|
try
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart)delegate
|
|
{
|
|
List<long> x = new List<long>();
|
|
x.Add(personOid);
|
|
|
|
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
|
|
|
chatView.SetList(person[0].FirstName + " " + person[0].LastName, personOid);
|
|
chatView.SetServerStats(person[0].FirstName + " " + person[0].LastName + " Connected");
|
|
|
|
if(person[0].Type == PersonType.Customer)
|
|
miniChatView = new MiniChatView(person[0].FirstName, person[0].LastName, "", chatView, personOid, ChatType.Klienten);
|
|
else if (person[0].Type == PersonType.Employee)
|
|
miniChatView = new MiniChatView(person[0].FirstName, person[0].LastName, "", chatView, personOid, ChatType.Mitarbeiter);
|
|
else if(person[0].Type == PersonType.Others)
|
|
miniChatView = new MiniChatView(person[0].FirstName, person[0].LastName, "", chatView, personOid, ChatType.Team);
|
|
|
|
miniChatView.Visibility = Visibility.Collapsed;
|
|
|
|
if(!miniChatViewList.ContainsKey(personOid))
|
|
miniChatViewList.Add(personOid, miniChatView);
|
|
});
|
|
}
|
|
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)
|
|
{
|
|
threadstop = true;
|
|
clientSocket.Close();
|
|
}
|
|
|
|
if (serverStream != null)
|
|
{
|
|
serverStream.Close();
|
|
}
|
|
|
|
if (asx != null)
|
|
{
|
|
if (asx.IsAlive)
|
|
{
|
|
asx.Join();
|
|
// asx.Abort();
|
|
asx = null;
|
|
|
|
threadstop = true;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Beim Versuch ,die verbindung mit dem Server zu trennen, ist ein Fehler unterlaufen. " + edf.Message +"\n"+edf.StackTrace, "Fehler: 2100 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
} |