diff --git a/BeWo/BeWo.csproj.user b/BeWo/BeWo.csproj.user index 0c15cac27..5c3337d7a 100644 --- a/BeWo/BeWo.csproj.user +++ b/BeWo/BeWo.csproj.user @@ -2,7 +2,7 @@ D:\Projects\beyondsoft\BeWoPlaner\Publish\|C:\Projects\beyondsoft\BeWoPlaner\Publish\|D:\Projects\BEYONDSOFT\BeWoPlaner\Publish\|C:\Projects\BEYONDSOFT\BeWoPlaner\Publish\|C:\Projects\BEYONDSOFT\BeWoPlaner\Publish4\ - http://app.beyondsoft.de/intern/|http://app.beyondsoft.de/deploy/|http://FOBP01.fortis-ev.org.local/|http://10.0.116.4/|http://app.beyondsoft.de/ + http://app.beyondsoft.de/intern/|http://app.beyondsoft.de/|http://app.beyondsoft.de/deploy/|http://FOBP01.fortis-ev.org.local/|http://10.0.116.4/ diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 1d64c33a6..b18888020 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -39,7 +39,7 @@ namespace BeWo //public static string Version = "Version 2.0"; - public static string Version = "Version 2.3"; + public static string Version = "Version 2.3.3"; public static int RenderTier = 0; @@ -426,11 +426,12 @@ namespace BeWo String url = ServerAddress.ToLower(); #if DEBUG - url = String.Format("http://localhost/Host"); - //url = String.Format("app1.bewoplaner.de/service"); + //url = String.Format("http://localhost/Host"); + url = String.Format("http://localhost:3777/Host"); + //url = String.Format("app1.bewoplaner.de/service"); #endif - if (url.IndexOf("localhost") < 0) + if (url.IndexOf("localhost") < 0) { int i; diff --git a/BeWo/Core/BeWoUtils.cs b/BeWo/Core/BeWoUtils.cs index 11744a8ad..d9ebf273c 100644 --- a/BeWo/Core/BeWoUtils.cs +++ b/BeWo/Core/BeWoUtils.cs @@ -5,6 +5,7 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Net; +using System.Text; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; @@ -1424,46 +1425,58 @@ namespace BeWo.Core System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(path)); } - //public static void Richloaded(object sender, RoutedEventArgs e) - //{ - // var richEditControl1 = (RichEditControl) sender; - // richEditControl1.ActiveViewType = RichEditViewType.Simple; - // richEditControl1.ShowBorder = false; - // richEditControl1.ShowHoverMenu = false; - // richEditControl1.CornerBoxVisibility = Visibility.Visible; - // richEditControl1.VerticalRulerVisibility = Visibility.Collapsed; - // richEditControl1.HorizontalRulerVisibility = Visibility.Collapsed; - // richEditControl1.Language = System.Windows.Markup.XmlLanguage.GetLanguage("de-DE"); - //} + public static void WriteFile(string content, string path) + { + using (var uFileStream = File.Create(path)) + using (var uSw = new StreamWriter(uFileStream, Encoding.GetEncoding(1252))) + uSw.Write(content); - //public static void Popupmenu(object sender, PopupMenuShowingEventArgs e) - //{ - // foreach (var item in e.Menu.ItemLinks.Where(x => x.ActualIsVisible).Where(item => !(item is BarItemLinkSeparator))) - // { - // var btn = (BarButtonItemLink)item; + if (MessageBox.Show("Möchten Sie die Datei öffnen?", "Datei öffnen", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) + { + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(path)); + } + } - // if (btn.ActualContent.Equals("Lösche Zeile") || - // btn.ActualContent.Equals("Lösche Spalte") || - // btn.ActualContent.Equals("Lösche Zelle...") || - // btn.ActualContent.Equals("Zellen verbinden") || - // btn.ActualContent.Equals("Teile Zellen...") || - // btn.ActualContent.Equals("Zellausrichtung") || - // btn.ActualContent.Equals("AutoAnpassen") || - // btn.ActualContent.Equals("Tabelleneigenschaften...") || - // btn.ActualContent.Equals("Einzug erhöhen") || - // btn.ActualContent.Equals("Einzug verringern") || - // btn.ActualContent.Equals("Schriftart") || - // btn.ActualContent.Equals("Absatz") || - // btn.ActualContent.Equals("Nummerierun") || - // btn.ActualContent.Equals("Lesezeichen...") || - // btn.ActualContent.Equals("Hyperlink...") || - // btn.ActualContent.Equals("Zeilenumbruch") || - // btn.ActualContent.Equals("Eine Ebene nach vorne") || - // btn.ActualContent.Equals("Eine Ebene nach hinten") || - // btn.ActualContent.Equals("Layout")) - // item.IsVisible = false; - // } - //} + //public static void Richloaded(object sender, RoutedEventArgs e) + //{ + // var richEditControl1 = (RichEditControl) sender; + // richEditControl1.ActiveViewType = RichEditViewType.Simple; + // richEditControl1.ShowBorder = false; + // richEditControl1.ShowHoverMenu = false; + // richEditControl1.CornerBoxVisibility = Visibility.Visible; + // richEditControl1.VerticalRulerVisibility = Visibility.Collapsed; + // richEditControl1.HorizontalRulerVisibility = Visibility.Collapsed; + // richEditControl1.Language = System.Windows.Markup.XmlLanguage.GetLanguage("de-DE"); + //} + + //public static void Popupmenu(object sender, PopupMenuShowingEventArgs e) + //{ + // foreach (var item in e.Menu.ItemLinks.Where(x => x.ActualIsVisible).Where(item => !(item is BarItemLinkSeparator))) + // { + // var btn = (BarButtonItemLink)item; + + // if (btn.ActualContent.Equals("Lösche Zeile") || + // btn.ActualContent.Equals("Lösche Spalte") || + // btn.ActualContent.Equals("Lösche Zelle...") || + // btn.ActualContent.Equals("Zellen verbinden") || + // btn.ActualContent.Equals("Teile Zellen...") || + // btn.ActualContent.Equals("Zellausrichtung") || + // btn.ActualContent.Equals("AutoAnpassen") || + // btn.ActualContent.Equals("Tabelleneigenschaften...") || + // btn.ActualContent.Equals("Einzug erhöhen") || + // btn.ActualContent.Equals("Einzug verringern") || + // btn.ActualContent.Equals("Schriftart") || + // btn.ActualContent.Equals("Absatz") || + // btn.ActualContent.Equals("Nummerierun") || + // btn.ActualContent.Equals("Lesezeichen...") || + // btn.ActualContent.Equals("Hyperlink...") || + // btn.ActualContent.Equals("Zeilenumbruch") || + // btn.ActualContent.Equals("Eine Ebene nach vorne") || + // btn.ActualContent.Equals("Eine Ebene nach hinten") || + // btn.ActualContent.Equals("Layout")) + // item.IsVisible = false; + // } + //} public static void OpenMailClient(string mailAddress, string subject = "") { @@ -1768,7 +1781,7 @@ namespace BeWo.Core } - public static PasswortSecurityStrength CheckPasswotrSecurity(string paswd) + public static PasswortSecurityStrength CheckPasswordSecurity(string paswd) { string zahlen = "0123456789"; string grossBuchstaben = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ"; diff --git a/BeWo/LoginControl.xaml.cs b/BeWo/LoginControl.xaml.cs index c065069d0..aefdf8307 100644 --- a/BeWo/LoginControl.xaml.cs +++ b/BeWo/LoginControl.xaml.cs @@ -183,8 +183,8 @@ namespace BeWo } else if (uri.Host.IndexOf("fortis") >= 0) { - BeWoProfile bp = new BeWoProfile("Fortis", "FOBP01.fortis-ev.org.local", "4526293996"); - ProfileList.Add(bp); + BeWoProfile bp = new BeWoProfile("Fortis", "fortis-bewoplaner.fortis-ev.org.local", "4526293996"); + ProfileList.Add(bp); SaveProfileListToFile(); } } @@ -758,7 +758,7 @@ namespace BeWo BeWoApp.UserName = lUserName; BeWoApp.UserPassword = lPassword; - BeWoApp.PasswortStrength = BeWoUtils.CheckPasswotrSecurity(lPassword); + BeWoApp.PasswortStrength = BeWoUtils.CheckPasswordSecurity(lPassword); ServiceFacade.DoUserServiceAsync(s2 => s2.LoadUserByLoginName(lUserName), r2 => diff --git a/BeWo/MainControl.xaml b/BeWo/MainControl.xaml index 9825c0d75..e62535f59 100644 --- a/BeWo/MainControl.xaml +++ b/BeWo/MainControl.xaml @@ -66,6 +66,18 @@ + + + + + + + + + + + diff --git a/BeWo/Scheduler/ISchedulerViewModel.cs b/BeWo/Scheduler/ISchedulerViewModel.cs index 161a2a6ba..e10bc2194 100644 --- a/BeWo/Scheduler/ISchedulerViewModel.cs +++ b/BeWo/Scheduler/ISchedulerViewModel.cs @@ -37,7 +37,7 @@ namespace BeWo.Scheduler void InitNewAppointment(Appointment appointment); - bool FilterAppointment(string filterCategory, object selectedObject, Appointment appointment, bool showPrivateAppointments); + bool HideAppointment(string filterCategory, object selectedObject, Appointment appointment, bool showPrivateAppointments); void InitChangedOccurrencyCustomFields(IEnumerable appList); } diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index 757e76a72..3c3d8af2b 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -375,7 +375,7 @@ namespace BeWo.Scheduler.View IsEmployeeBrushVisible = true; - if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) { Cache.GetInstance().GetAllActiveEmployeesCompact(liste => this.Dispatch(() => { @@ -526,15 +526,19 @@ namespace BeWo.Scheduler.View private void UpdateDataSource(ISchedulerViewModel vm) { - UpdateCustomFieldMappings(vm); + Scheduler.Storage.BeginUpdate(); + UpdateCustomFieldMappings(vm); + Scheduler.Storage.EndUpdate(); + IgnoreChangeEvents = true; - IgnoreChangeEvents = true; - Scheduler.Storage.AppointmentStorage.DataSource = vm.Appointments; - UpdateSchedulerSettings(); + Scheduler.Storage.BeginUpdate(); - foreach (var item in Scheduler.Storage.AppointmentStorage.Items) + UpdateSchedulerSettings(); + int idx = 1; + + foreach (var item in Scheduler.Storage.AppointmentStorage.Items) { var bapp = item.GetSourceObject(Scheduler.GetCoreStorage()) as IBeWoAppointment; @@ -563,7 +567,8 @@ namespace BeWo.Scheduler.View } } - IgnoreChangeEvents = false; + Scheduler.Storage.EndUpdate(); + IgnoreChangeEvents = false; } private void UpdateSchedulerSettings() @@ -838,8 +843,8 @@ namespace BeWo.Scheduler.View } var appList = e.Objects.Cast().ToList(); - - if (appList.Any(f => f.CustomFields["IsPrivate"] != null && (bool)f.CustomFields["IsPrivate"])) + + if (appList.Any(f => f.CustomFields["IsPrivate"] != null && (bool)f.CustomFields["IsPrivate"])) { ShowPrivateAppointmentsCheckBox.IsChecked = true; } @@ -857,10 +862,10 @@ namespace BeWo.Scheduler.View } var showOnlyPrivateApps = ShowPrivateAppointmentsCheckBox.IsChecked.HasValue && ShowPrivateAppointmentsCheckBox.IsChecked.Value; - - if (showOnlyPrivateApps) + + if (showOnlyPrivateApps) { - e.Cancel = ViewModel.ActiveAppointmentViewModel.FilterAppointment("NurPrivate", null, ((Appointment) e.Object), true); + e.Cancel = ViewModel.ActiveAppointmentViewModel.HideAppointment("NurPrivate", null, ((Appointment) e.Object), true); } var me = MitarbeiterEbenenCheckBox.IsChecked.HasValue && MitarbeiterEbenenCheckBox.IsChecked.Value; @@ -869,7 +874,7 @@ namespace BeWo.Scheduler.View if ((me || ke || re) && !SelectedItems.Any()) { - e.Cancel = ViewModel.ActiveAppointmentViewModel.FilterAppointment("Ebenen", new List { me, re, ke }, ((Appointment)e.Object), showOnlyPrivateApps); + e.Cancel = ViewModel.ActiveAppointmentViewModel.HideAppointment("Ebenen", new List { me, re, ke }, ((Appointment)e.Object), showOnlyPrivateApps); return; } @@ -879,18 +884,11 @@ namespace BeWo.Scheduler.View ; if ((m.Any() || r.Any() || k.Any()) && ZeigeNurMeineTermineCheckBox.IsChecked == false) { - e.Cancel = ViewModel.ActiveAppointmentViewModel.FilterAppointment("NachAuswahl", new Dictionary { { "Mitarbeiter", m }, { "Ressourcen", r }, { "Klienten", k } }, ((Appointment)e.Object), showOnlyPrivateApps); + e.Cancel = ViewModel.ActiveAppointmentViewModel.HideAppointment("NachAuswahl", new Dictionary { { "Mitarbeiter", m }, { "Ressourcen", r }, { "Klienten", k } }, ((Appointment)e.Object), showOnlyPrivateApps); return; } - - var abc = ((Appointment) e.Object).Subject; - if (abc.Equals("Ohne Chandler")) - { - - } - - - e.Cancel = ViewModel.ActiveAppointmentViewModel.FilterAppointment("NurEigene", new Dictionary { { "Mitarbeiter", m }, { "Ressourcen", r }, { "Klienten", k }, {"Teams", EmployeesTeams} }, ((Appointment)e.Object), showOnlyPrivateApps); + + e.Cancel = ViewModel.ActiveAppointmentViewModel.HideAppointment("NurEigene", new Dictionary { { "Mitarbeiter", m }, { "Ressourcen", r }, { "Klienten", k }, {"Teams", EmployeesTeams} }, ((Appointment)e.Object), showOnlyPrivateApps); } private void NewSchedulerStorage_AppointmentDeleting(object sender, PersistentObjectCancelEventArgs e) @@ -995,43 +993,35 @@ namespace BeWo.Scheduler.View { var darfTerminDetailsSehen = true; var appointment = e.Appointment; - var originator = (CompactEmployeeDC) appointment.CustomFields["Originator"]; + var ersteller = (CompactEmployeeDC) appointment.CustomFields["Originator"]; var mitarbeiterliste = (List)appointment.CustomFields["EmployeeList"]; - var hatMitarbeiter = mitarbeiterliste.Count > 0 && !(mitarbeiterliste.Count == 1 && mitarbeiterliste.ElementAt(0).Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)); + var hatNurAndereMitarbeiter = mitarbeiterliste.Count > 0 && !(mitarbeiterliste.Count == 1 && mitarbeiterliste.ElementAt(0).Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)); var hatKlienten = ((List) appointment.CustomFields["CustomerList"]).Count > 0; - //var hatRessourcen = ((List) apt.CustomFields["ResourceList"]).Count > 0; + bool istErsteller = ersteller.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid); - if (hatMitarbeiter) + //var hatRessourcen = ((List) apt.CustomFields["ResourceList"]).Count > 0; + + if (hatNurAndereMitarbeiter || !istErsteller) { - darfTerminDetailsSehen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAendern); - } + darfTerminDetailsSehen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAendern); + } if (hatKlienten) { darfTerminDetailsSehen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderKliententermineAendern); - } + } - //if (hatRessourcen) - //{ - // darfTerminDetailsSehen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAendern); - //} + if (hatNurAndereMitarbeiter && !darfTerminDetailsSehen) + { + darfTerminDetailsSehen = mitarbeiterliste.Select(ml => ml.Employee).Any(a => a.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) || istErsteller; + } - //if (hatRessourcen && !o.Equals(BeWoApp.LoggedOnEmployeeCompact)) - //{ - // darfTerminDetailsSehen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAndererAendern); - //} - - if (darfTerminDetailsSehen == false) - { - darfTerminDetailsSehen = mitarbeiterliste.Select(ml => ml.Employee).Any(a => a.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) || originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid); - } - - if (!originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && (bool)appointment.CustomFields["IsPrivate"] && !mitarbeiterliste.Any(em => em.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) + if (!istErsteller && ((bool)appointment.CustomFields["IsPrivate"]) && !mitarbeiterliste.Any(em => em.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) { darfTerminDetailsSehen = false; } - + e.Allow = darfTerminDetailsSehen; } diff --git a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs index 4951149e0..262767f7d 100644 --- a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs +++ b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs @@ -1,10 +1,16 @@ using System; - +using System.Collections.Generic; +using System.Linq; +using BeWo.Core.Service; using BS.Shared.Core; using BeWo.Scheduler.View; +using BeWo.ServiceProxy; using BeWo.ViewModel; - +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraPrinting.Native; using DevExpress.XtraScheduler; namespace BeWo.Scheduler.ViewModel @@ -14,8 +20,8 @@ namespace BeWo.Scheduler.ViewModel public event EventHandler> ViewModelChanged; private ISchedulerViewModel mActiveAppointmentViewModel; - - public ISchedulerViewModel ActiveAppointmentViewModel + private Dictionary> mAllCats2ResInDic; + public ISchedulerViewModel ActiveAppointmentViewModel { get { @@ -38,16 +44,58 @@ namespace BeWo.Scheduler.ViewModel public void UpdateAppointmentViewModel(DateTime intervalStart, DateTime intervalEnd) { - VMFactory.CreateNewSchedulerAppointmentListVM(cb => - { - ActiveAppointmentViewModel = cb; - SchedulerSettings = GetActiveSettings(); - SchedulerSettings.StartDate = intervalStart; - BeWoApp.MainControl.AufOffeneTerminePruefen(); - }, intervalStart - NewSchedulerView.FetchPadding, intervalEnd + NewSchedulerView.FetchPadding); - } + BeWoApp.MainControl.StartWaiting(); - public AbstractAppointmentEditForm GetEditAppointmentForm(DevExpress.Xpf.Scheduler.SchedulerControl control, Appointment appointment) + if (!BeWoApp.LoggedOnEmployee.EmployeeOid.HasValue) + { + return; + } + + + var allEmps = new List(); + + var appointments = new List(); + var allCust = new List(); + + allEmps = Cache.GetInstance().GetAllActiveEmployeesCompactSync(); + + if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) + { + ServiceFacade.DoEmployeeServiceSync(es => allEmps = new List { es.LoadCompactEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value) }); + } + + if (mAllCats2ResInDic == null) + { + ServiceFacade.DoResourceServiceSync(s => mAllCats2ResInDic = s.GetAllCategories2ResourcesInDictionary()); + } + + var start = intervalStart - NewSchedulerView.FetchPadding; + var end = intervalEnd + NewSchedulerView.FetchPadding; + + ServiceFacade.DoResourceServiceSync(rs => appointments = rs.GetAllActiveAppointmentsForEmployeeInInterval2(start, end, BeWoApp.LoggedOnEmployee.EmployeeOid.Value, BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen))); + + allCust = Cache.GetInstance().GetAllActiveCustomersCompactSync(); + + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyCustomers) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View)) + { + allCust = allCust.Where(c => BeWoApp.LoggedOnEmployee.RelatedCustomers.Any(a => a.Customer.Equals(c))).ToList(); + } + + var prefilteredAppointments = appointments.Where(w => ((w.EmployeeList.Count == 0 && w.Originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) || + w.EmployeeList.Count > 0 && w.EmployeeList.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) || + BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) && (!w.EmployeeList.TrueForAll(e2a => e2a.ParticipationAnswer == ParticipationAnswer.Absage) || w.EmployeeList.IsEmpty())); + + var vm = new SchedulerAppointmentListVM(prefilteredAppointments.ToList(), allCust, allEmps, mAllCats2ResInDic); + + ActiveAppointmentViewModel = vm; + SchedulerSettings = GetActiveSettings(); + SchedulerSettings.StartDate = intervalStart; + + BeWoApp.MainControl.EndWaiting(); + //BeWoApp.MainControl.AufOffeneTerminePruefen(); + } + + public AbstractAppointmentEditForm GetEditAppointmentForm(DevExpress.Xpf.Scheduler.SchedulerControl control, Appointment appointment) { return ActiveAppointmentViewModel != null ? ActiveAppointmentViewModel.GetEditAppointmentForm(control, appointment) : null; } diff --git a/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs b/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs index 5deb13f1a..37475a56f 100644 --- a/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs +++ b/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs @@ -432,119 +432,101 @@ namespace BeWo.Scheduler.ViewModel appointment.StatusId = 0; } - public bool FilterAppointment(string filterCategory, object selectedObject, Appointment appointment, bool showPrivateAppointments) - { - var wirdAngezeigt = true; // -> wird standardmäßig angezeigt + public bool HideAppointment(string filterCategory, object selectedObject, Appointment appointment, bool showPrivateAppointments) + { + var wirdAngezeigt = true; // -> wird standardmäßig angezeigt - if(showPrivateAppointments) - if (appointment.CustomFields["IsPrivate"] != null) - { - var isPrivate = Convert.ToBoolean(appointment.CustomFields["IsPrivate"]); - if(!isPrivate) - return true; - } + bool isPrivate = false; + if (appointment.CustomFields["IsPrivate"] != null) + { + isPrivate = Convert.ToBoolean(appointment.CustomFields["IsPrivate"]); + } - switch (filterCategory) - { - case "NurEigene": - var resourceList = (List) appointment.CustomFields["ResourceList"]; - if (resourceList != null && resourceList.Any()) - { - break; - } + if (showPrivateAppointments && !isPrivate) + { + return true; + } - var emps = (List)appointment.CustomFields["EmployeeList"]; - var orig = (CompactEmployeeDC) appointment.CustomFields["Originator"]; - var cus = (List) appointment.CustomFields["CustomerList"]; - var hatEigeneKlienten = false; - var teams = (List)((Dictionary)selectedObject)["Teams"]; + var ersteller = (CompactEmployeeDC)appointment.CustomFields["Originator"]; + var employeeList = (List)appointment.CustomFields["EmployeeList"]; + var customerList = (List)appointment.CustomFields["CustomerList"]; + var resourceList = (List)appointment.CustomFields["ResourceList"]; - if (cus != null) - { - hatEigeneKlienten = cus.Select(sel => sel.CustomerOid).Intersect(BeWoApp.LoggedOnEmployee.RelatedCustomers.Select(se => se.Customer.CustomerOid)).Any() || - cus.Any(c => c.RelatedTeamOids != null && c.RelatedTeamOids.Intersect(teams.Select(t => t.TeamOid)).Any()); - } + if (isPrivate) + { + if (ersteller == null || !ersteller.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) + { + return true; + } + } + + switch (filterCategory) + { + + case "NurEigene": + var istEigenerTermin = (ersteller != null && ersteller.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && employeeList != null && employeeList.Count == 0) || + (employeeList != null && employeeList.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))); - // Ursprünglich: var isOriginatorWithoutParticipants = (orig != null && orig.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && (emps != null && (emps.Count == 0 || emps.Count == 1 && emps.Any(a => a.Employee.Equals(orig))))); + wirdAngezeigt = istEigenerTermin; - var isOriginatorWithoutParticipants = (orig != null && orig.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && ((emps != null && emps.Count == 1 && emps.Any(a => a.Employee.Equals(orig)))) || emps != null && emps.Count == 0); + break; + case "NachAuswahl": + var dictionary = (Dictionary)selectedObject; + var ressourcen = (List)dictionary["Ressourcen"]; + var mitarbeiter = (List)dictionary["Mitarbeiter"]; + var klienten = (List)dictionary["Klienten"]; - var istEigenerTermin = (orig != null && orig.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && emps != null && emps.Count == 0) || - (emps != null && emps.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))); - var empsContainsEmployeesExceptOriginator = emps != null && emps.Count > 0 && orig != null && (orig.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && false == emps.Any(a => a.Employee.Equals(orig))); - // Eingeloggter muss Originator oder in der Liste sein oder er darf Termine anderer ansehen - wirdAngezeigt = istEigenerTermin;//isOriginatorWithoutParticipants || false == empsContainsEmployeesExceptOriginator;// orig != null && (orig.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) && (emps != null && emps.Count == 0)) - //|| emps != null && emps.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) && emps.Count == 1 - //|| hatEigeneKlienten; - //|| BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen); - // false -> wird ignoriert (herausgefiltert) - //wirdAngezeigt = isOriginatorWithoutParticipants || empsContainsEmployeesExceptOriginator == false || BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen); + var cfe = (employeeList == null ? new List() : employeeList.Select(s => s.Employee).ToList()); + var cfr = resourceList ?? new List(); + var cfc = customerList ?? new List(); - break; - case "NachAuswahl": - var dictionary = (Dictionary) selectedObject; - var ressourcen = (List) dictionary["Ressourcen"]; - var mitarbeiter = (List) dictionary["Mitarbeiter"]; - var klienten = (List) dictionary["Klienten"]; + var hasOnlyOriginatorInCommon = employeeList != null && ersteller != null && employeeList.Any() == false && mitarbeiter.Contains(ersteller); - var originator = appointment.CustomFields["Originator"] as CompactEmployeeDC; - var appEL = (List) appointment.CustomFields["EmployeeList"]; - var appRL = (List) appointment.CustomFields["ResourceList"]; - var appCL = (List) appointment.CustomFields["CustomerList"]; + var m = cfe.Intersect(mitarbeiter).ToList(); + var r = cfr.Intersect(ressourcen).ToList(); + var k = cfc.Intersect(klienten).ToList(); - var cfe = (appEL == null ? new List() : appEL.Select(s=>s.Employee).ToList()); - var cfr = appRL ?? new List(); - var cfc = appCL ?? new List(); + wirdAngezeigt = (m.Any() || k.Any() || r.Any()) || hasOnlyOriginatorInCommon; + break; + case "Ebenen": + var liste = (List)selectedObject; // mkr + var appEList = employeeList.Where(w => !w.Employee.Equals(appointment.CustomFields["Originator"])).ToList(); - var hasOnlyOriginatorInCommon = appEL!=null && originator != null && appEL.Any() == false && mitarbeiter.Contains(originator); + // Ersteller und Rechte beachten - var m = cfe.Intersect(mitarbeiter).ToList(); - var r = cfr.Intersect(ressourcen).ToList(); - var k = cfc.Intersect(klienten).ToList(); + var istEigen = ersteller.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid); - wirdAngezeigt = (m.Any() || k.Any() || r.Any()) || hasOnlyOriginatorInCommon; - break; - case "Ebenen": - var liste = (List) selectedObject; // mkr - var appEList = ((List) appointment.CustomFields["EmployeeList"]).Where(w => !w.Employee.Equals(appointment.CustomFields["Originator"])).ToList(); - var appRList = (List) appointment.CustomFields["ResourceList"]; - var appCList = (List) appointment.CustomFields["CustomerList"]; + var mVorhanden = appEList.Any(a2app => mAllEmployees.Contains(a2app.Employee)); + var kVorhanden = customerList.Any(mAllCustomers.Contains); - // Ersteller und Rechte beachten - var o = (CompactEmployeeDC) appointment.CustomFields["Originator"]; - var istEigen = o.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid); + wirdAngezeigt = liste[0] && mVorhanden || liste[1] && resourceList.Any() || liste[2] && kVorhanden; - var mVorhanden = appEList.Any(a2app => mAllEmployees.Contains(a2app.Employee)); - var kVorhanden = appCList.Any(mAllCustomers.Contains); - - wirdAngezeigt = liste[0] && mVorhanden || liste[1] && appRList.Any() || liste[2] && kVorhanden; - - // Nur Ansehen + // Nur Ansehen if (!istEigen && !BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen) && liste[0] && mVorhanden && !appEList.Select(e2sa => e2sa.Employee).Any(a => a.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) { wirdAngezeigt = false; } - if (!istEigen && !BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderKliententermineAlleAnsehen) && liste[2] && kVorhanden) - { - wirdAngezeigt = false; - } - - if (!istEigen && !BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnsehen) && liste[1] && appRList.Any()) - { - wirdAngezeigt = false; - } + if (!istEigen && !BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderKliententermineAlleAnsehen) && liste[2] && kVorhanden) + { + wirdAngezeigt = false; + } - break; - } + if (!istEigen && !BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnsehen) && liste[1] && resourceList.Any()) + { + wirdAngezeigt = false; + } - return !wirdAngezeigt; - } + break; + } - public void InitChangedOccurrencyCustomFields(IEnumerable appList) + return !wirdAngezeigt; + } + + public void InitChangedOccurrencyCustomFields(IEnumerable appList) { changedOccurencyCustomFields = new Dictionary>>(); foreach (var termin in appList) diff --git a/BeWo/ServiceProxy/ServiceFacade.cs b/BeWo/ServiceProxy/ServiceFacade.cs index a4311d502..56a1b4e21 100644 --- a/BeWo/ServiceProxy/ServiceFacade.cs +++ b/BeWo/ServiceProxy/ServiceFacade.cs @@ -161,7 +161,21 @@ namespace BeWo.ServiceProxy } } - public static void DoEmployeeServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) + public static T DoDownloadServiceSync(Func pFunc) + { + try + { + return pFunc.Invoke(GetInstance()); + } + catch (Exception e) + { + ShowErrorMessage(e); + } + + return default(T); + } + + public static void DoEmployeeServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) { DoAsync(pFunc, pCallBack, showWaitDialog); } diff --git a/BeWo/View/ChatView.xaml.cs b/BeWo/View/ChatView.xaml.cs index 6b73327b8..61e2f0209 100644 --- a/BeWo/View/ChatView.xaml.cs +++ b/BeWo/View/ChatView.xaml.cs @@ -319,7 +319,7 @@ namespace BeWo.View { var mitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeWithPersonOid(personoid)); - KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname,StatusType.Online, BuildImg(mitarbeiter.EmployeeImage,ChatType.Mitarbeiter), personoid, ChatType.Mitarbeiter);//"Online" + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname,StatusType.Online, BuildImgList(mitarbeiter.Images,ChatType.Mitarbeiter), personoid, ChatType.Mitarbeiter);//"Online" var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(personoid)); @@ -354,7 +354,7 @@ namespace BeWo.View customerCompact.LastName = klienten.LastName; customerCompact.DateOfBirth = klienten.DateOfBirth; - KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(klienten.CustomerImage,ChatType.Klienten), personoid, ChatType.Klienten, customerCompact);//"Online" + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImgList(klienten.Images,ChatType.Klienten), personoid, ChatType.Klienten, customerCompact);//"Online" foreach (var variable in ita) { @@ -600,7 +600,7 @@ namespace BeWo.View foreach (var team in employeeteamoids) { - Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null,ChatType.Team), team.TeamOid, ChatType.Team)); + Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null, ChatType.Team), team.TeamOid, ChatType.Team)); } foreach (var list in offmitarbeiter) @@ -1299,19 +1299,25 @@ namespace BeWo.View MessageBox.Show("Beim Auswählen eines Users ist ein Fehler aufgetreten. " + s.Message + "\n" + s.StackTrace, "Fehler: 2280 ", MessageBoxButton.OK); } } - - - - - public ImageSource BuildImg(Byte[] c ,ChatType x) + + public ImageSource BuildImgList(List images, ChatType x) + { + if (images != null && images.Count > 0) + { + return BuildImg(images[0], x); + } + return null; + } + + public ImageSource BuildImg(Byte[] image, ChatType x) { try { - if (c != null) + if (image != null) { var biImg = new BitmapImage(); - using (var ms = new MemoryStream(c)) + using (var ms = new MemoryStream(image)) { biImg.BeginInit(); biImg.StreamSource = ms; diff --git a/BeWo/View/ChatWindow.xaml b/BeWo/View/ChatWindow.xaml new file mode 100644 index 000000000..a88063605 --- /dev/null +++ b/BeWo/View/ChatWindow.xaml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/View/ChatWindow.xaml.cs b/BeWo/View/ChatWindow.xaml.cs new file mode 100644 index 000000000..2fddfb828 --- /dev/null +++ b/BeWo/View/ChatWindow.xaml.cs @@ -0,0 +1,1514 @@ +using System; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; + +using BeWo.ServiceProxy; +using BeWo.ViewModel; + +using BS.Shared.Extensions; +using System.Windows.Controls; +using System.Net.Sockets; +using System.Threading; +using System.Windows.Threading; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Media.Imaging; +using BeWo.View.Detail; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.Xpf.Core; +using DevExpress.Xpf.Docking; +using DevExpress.XtraPrinting.Native; +using DevExpress.XtraPrinting.XamlExport; +using Microsoft.Office.Interop.Word; +using Brush = System.Windows.Media.Brush; +using Color = System.Drawing.Color; +using ContextMenu = System.Windows.Controls.ContextMenu; +using Image = System.Windows.Controls.Image; +using KeyEventArgs = System.Windows.Input.KeyEventArgs; +using MenuItem = System.Windows.Controls.MenuItem; +using MessageBox = System.Windows.MessageBox; +using Point = System.Windows.Point; +using SelectionMode = System.Windows.Controls.SelectionMode; +using Size = System.Windows.Size; + +namespace BeWo.View +{ + public partial class ChatWindow + { + public int abr = 0; + + protected TcpClient tcpClient; + + protected CollectionView view; + + protected ChatEmojisView emojiView = null; + + protected List ita = new List(); + protected List oidspeicher = new List(); + protected List teamdc = new List(); + protected PropertyGroupDescription groupDescription; + protected bool isOnFocus = false; + + protected ContextMenu context; + + public ChatWindow(String nameinf, String Chatinf, TcpClient tcpClient) + { + InitializeComponent(); + + rootGroupBox.Header = nameinf; + + this.tcpClient = tcpClient; + + CloseWindow(); + LoadallChatKontakts(); + ErstelleContextMenue(); + SetChatSetting(); + + } + + private void SetChatSetting() + { + try + { + List data = new List(); + data.Add("Online"); + data.Add("Offline"); + data.Add("Beschäftigt"); + + StatusSetting.ItemsSource = data; + // StatusSetting.SelectedIndex = 0; + } + catch (Exception edf) + { + MessageBox.Show("Das Aufbauen der Chat-Settings ist fehlgeschlagen. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2200 ", MessageBoxButton.OK); + } + } + + public void UpdateTcp(TcpClient tcpClient) + { + this.tcpClient = tcpClient; + } + + + private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + DragMove(); + } + catch (Exception) { } + } + + public void CloseWindow() + { + CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => + { + abr = 1; + + //Close(); + + if (emojiView != null && emojiView.Visibility == Visibility.Visible) + { + emojiView.Visibility = Visibility.Collapsed; + } + + Visibility = Visibility.Collapsed; + })); + } + + public void SetText(String text, String nameclient, long personoid) + { + try + { + if (AktChatUser.Items.Count != 0) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + if (curItem.EmpfaengerOid == personoid) + { + foreach (var collection in ita) + { + if (collection.EmpfaengerOid == personoid) + collection.Receivems = ""; + + view.Refresh(); + } + + curItem.Receivems = ""; + + Chat.Items.Add(new KontakMessageBuilder(nameclient, text, DateTime.Now.ToString(), personoid, false)); + + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); + } + } + else + { + foreach (var abc in ita) + { + if (abc.EmpfaengerOid == personoid) + { + int x; + bool wasdrin = int.TryParse(abc.Receivems, out x); + + if (wasdrin) + abc.Receivems = x++.ToString(); + else + abc.Receivems = 1.ToString(); + } + } + + view.Refresh(); + } + } + catch (Exception edf) + { + MessageBox.Show("Beim verarbeiten der Nachricht ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2220 ", MessageBoxButton.OK); + } + } + + public void SetTeamAnzahlErhalteneNachricht(long personoid, ChatType type) + { + try + { + foreach (var abc in ita) + { + + if (abc.EmpfaengerOid == personoid && abc.TypeChat == type) + { + int x; + bool wasdrin = int.TryParse(abc.Receivems, out x); + + if (wasdrin) + { + x++; + abc.Receivems = x.ToString(); + + } + else + abc.Receivems = 1.ToString(); + } + } + view.Refresh(); + } + catch (Exception edf) + { + MessageBox.Show("Beim Setzen der Anzahl angekommender Nachrichten ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler 2391", MessageBoxButton.OK); + } + } + + public void RefreshViewModel() + { + view.Refresh(); + } + + + public void SetList(String clientname, long personoid) + { + try + { + List x = new List(); + x.Add(personoid); + + var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x)); + + var a = person[0].Type; + + if (a == PersonType.Employee) + { + var mitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeWithPersonOid(personoid)); + + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(mitarbeiter.EmployeeImage), personoid, ChatType.Mitarbeiter);//"Online" + + var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(personoid)); + + foreach (var variable in ita) + { + if (konbuild.Name.Equals(variable.Name)) + variable.StatusTyp = StatusType.Online; + + if (variable.TypeChat == ChatType.Team) + { + foreach (var zug in zugehorigkeit) + { + if (zug.SimpleDescription.Equals(variable.Name)) + { + variable.StatusTyp = StatusType.Online; + } + } + } + } + view.Refresh(); + } + else if (a == PersonType.Customer) + { + + var klienten = ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerWithPersonOid(personoid)); + + CompactCustomerDC customerCompact = new CompactCustomerDC(); + customerCompact = new CompactCustomerDC(); + customerCompact.CustomerOid = klienten.CustomerOid.Value; + customerCompact.PersonOid = klienten.PersonOid.Value; + customerCompact.FirstName = klienten.FirstName; + customerCompact.LastName = klienten.LastName; + customerCompact.DateOfBirth = klienten.DateOfBirth; + + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(klienten.CustomerImage), personoid, ChatType.Klienten, customerCompact);//"Online" + + foreach (var variable in ita) + { + if (konbuild.Name.Equals(variable.Name)) + variable.StatusTyp = StatusType.Online; + } + + view.Refresh(); + } + + if (AktChatUser.Items.Count != 0) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + if (curItem.EmpfaengerOid == personoid) + { + curItem.StatusTyp = StatusType.Online; + view.Refresh(); + } + } + } + catch (Exception edf) + { + MessageBox.Show("Beim Erweitern der 'Gerade Online' liste ist ein fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2230 ", MessageBoxButton.OK); + } + } + + + public void RemoveListItem(long clientid) + { + try + { + foreach (var abc in ita) + { + if (abc.EmpfaengerOid == clientid) + { + abc.StatusTyp = StatusType.Offline; + } + } + + PruefeTeamsObOnline(); + + teamdc.Clear(); + oidspeicher.Clear(); + + if (AktChatUser.Items.Count > 0) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + if (curItem.EmpfaengerOid.Equals(clientid)) + { + curItem.StatusTyp = StatusType.Offline; + } + } + + view.Refresh(); + } + catch (Exception e) + { + MessageBox.Show("Beim Entfernen eines Users von der 'Gerade Online' liste ist ein Fehler aufgetreten. " + e.Message + "\n" + e.StackTrace, "Fehler: 2240 ", MessageBoxButton.OK); + } + } + + + + public void PruefeTeamsObOnline() + { + try + { + foreach (var teamprof in ita) + { + if (teamprof.TypeChat == ChatType.Mitarbeiter) + { + if (teamprof.StatusTyp == StatusType.Online) + { + oidspeicher.Add(teamprof.EmpfaengerOid); + } + } + } + + if (oidspeicher.Count == 0) + { + foreach (var tt in ita) + { + if (tt.TypeChat == ChatType.Team) + { + tt.StatusTyp = StatusType.Offline; + } + } + } + else + { + foreach (var oid in oidspeicher) + { + var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(oid)); + + foreach (var dc in zugehorigkeit) + { + if (!teamdc.Contains(dc.SimpleDescription)) + teamdc.Add(dc.SimpleDescription); + } + } + + foreach (var tt in ita) + { + if (tt.TypeChat == ChatType.Team && !teamdc.Contains(tt.Name)) + { + tt.StatusTyp = StatusType.Offline; + } + } + } + } + catch (Exception edf) + { + MessageBox.Show("Es ist ein Fehler Aufgetreten. Bitte Ruhe Bewahren. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2390 ", MessageBoxButton.OK); + } + } + + + + public Boolean CompareWithListItem(long personid) + { + try + { + foreach (var abc in ita) + { + if (abc.EmpfaengerOid == personid) + { + if (abc.StatusTyp == StatusType.Online) + return true; + } + } + return false; + } + catch (Exception edf) + { + MessageBox.Show("Das Vergleichen mit der User-Liste ist nicht möglich. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2350 ", + MessageBoxButton.OK); + return false; + } + } + + public void SetServerStats(String servstats) + { + ServerStats.Text = servstats; + } + + private void SendButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals("") && isOnFocus) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + SendMessage(curItem.EmpfaengerOid, curItem.TypeChat); + + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); + + Chatbox.Text = ""; + + if (Chatbox.Text.Equals("")) + { + Chatbox.Text = "Nachricht schreiben"; + Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray); + isOnFocus = false; + } + } + else + { + if (AktChatUser.Items.IsEmpty) + { + MessageBox.Show("Bitte wählen Sie einen Chatpartner aus.", "Fehler", MessageBoxButton.OK); + if (Chatbox.Text.Equals("")) + { + Chatbox.Text = "Nachricht schreiben"; + Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray); + isOnFocus = false; + } + } + else if (Chatbox.Text.Equals("")) + { + MessageBox.Show("Sie können keine lehre Nachricht verschicken.", "Fehler", MessageBoxButton.OK); + if (Chatbox.Text.Equals("")) + { + Chatbox.Text = "Nachricht schreiben"; + Chatbox.Foreground = new SolidColorBrush(Colors.DarkGray); + isOnFocus = false; + } + } + } + } + catch (Exception sf) + { + MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + sf.Message + "\n" + sf.StackTrace, "Fehler: 2250 ", MessageBoxButton.OK); + } + } + + private void OnKeyDownHandler(object sender, KeyEventArgs e) + { + try + { + if (e.Key == Key.Return) + { + if (!AktChatUser.Items.IsEmpty && !Chatbox.Text.Equals("")) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + SendMessage(curItem.EmpfaengerOid, curItem.TypeChat); + + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); + + Chatbox.Text = ""; + } + else + { + if (AktChatUser.Items.IsEmpty) + { + MessageBox.Show("Bitte wählen Sie einen Chatpartner aus.", "Fehler", MessageBoxButton.OK); + } + else if (Chatbox.Text.Equals("")) + { + MessageBox.Show("Sie können keine lehre Nachricht verschicken.", "Fehler", MessageBoxButton.OK); + } + } + } + } + catch (Exception ed) + { + MessageBox.Show("Beim Senden einer Nachricht ist ein Fehler aufgetreten. " + ed.Message + "\n" + ed.StackTrace, "Fehler: 2260 ", MessageBoxButton.OK); + } + } + + + public void LoadallChatKontakts() + { + try + { + var employeeteamoids = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + var offmitarbeiter = + ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact()); + var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); // dieser code muss erweitert werden + + /* var employee = ServiceFacade.DoEmployeeServiceSync( + s => s.GetEmployeeWithPersonOid(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + + employee.Employee2CustomerList.Select(s => s.CustomerOid.Value);*/ + + foreach (var team in employeeteamoids) + { + Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null), team.TeamOid, ChatType.Team)); + } + + foreach (var list in offmitarbeiter) + { + if (list.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid) + { + Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, StatusType.Offline, + BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(list.EmployeeOid))), + list.PersonOid, ChatType.Mitarbeiter)); + } + } + foreach (var list in offklienten) + { + + Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, StatusType.Offline, + BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(list.CustomerOid))), + list.PersonOid, ChatType.Klienten, list)); + } + + + foreach (var a in Clientlist.Items) + { + KontaktlistBuilder cl = (KontaktlistBuilder)a; + + ita.Add(cl); + } + + Clientlist.Items.Clear(); + Clientlist.ItemsSource = ita; + + view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource); + groupDescription = new PropertyGroupDescription("TypeChat"); + view.GroupDescriptions.Add(groupDescription); + } + catch (Exception edf) + { + MessageBox.Show("Beim Setzen einer Neuen Chat Einstellung ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2270 ", MessageBoxButton.OK); + } + } + + public void AktualisiereChatKontakt() + { + try + { + var employeeteamoids = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + var offmitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact()); + var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + + List idMitarbeitspeicher = new List(); + List idteamspeicher = new List(); + List idKlientspeicher = new List(); + + foreach (var teamprof in ita) + { + if (teamprof.TypeChat == ChatType.Klienten) + { + idKlientspeicher.Add(teamprof.EmpfaengerOid); + } + if (teamprof.TypeChat == ChatType.Team) + { + idteamspeicher.Add(teamprof.EmpfaengerOid); + } + if (teamprof.TypeChat == ChatType.Mitarbeiter) + { + idMitarbeitspeicher.Add(teamprof.EmpfaengerOid); + } + } + + foreach (var var in employeeteamoids) + { + if (!idteamspeicher.Contains(var.TeamOid) && idteamspeicher.Count <= employeeteamoids.Count) + { + ita.Add(new KontaktlistBuilder(var.Name, StatusType.Offline, BuildImg(null), var.TeamOid, ChatType.Team)); + view.Refresh(); + } + + if (idteamspeicher.Contains(var.TeamOid)) + idteamspeicher.Remove(var.TeamOid); + } + + foreach (var var in offmitarbeiter) + { + if (!idMitarbeitspeicher.Contains(var.PersonOid) && idMitarbeitspeicher.Count <= offmitarbeiter.Count && var.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid) + { + ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName, StatusType.Offline, + BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(var.EmployeeOid))), + var.PersonOid, ChatType.Mitarbeiter)); + view.Refresh(); + } + + if (idMitarbeitspeicher.Contains(var.PersonOid)) + idMitarbeitspeicher.Remove(var.PersonOid); + } + + foreach (var var in offklienten) + { + if (!idKlientspeicher.Contains(var.PersonOid) && idKlientspeicher.Count <= offklienten.Count) + { + ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName, StatusType.Offline, + BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(var.CustomerOid))), + var.PersonOid, ChatType.Klienten, var)); + view.Refresh(); + } + + if (idKlientspeicher.Contains(var.PersonOid)) + idKlientspeicher.Remove(var.PersonOid); + } + + if (idKlientspeicher.Count != 0) + { + var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idKlientspeicher[0] && r.TypeChat == ChatType.Klienten); + + if (itemToRemove != null) + ita.Remove(itemToRemove); + + view.Refresh(); + } + + if (idMitarbeitspeicher.Count != 0) + { + var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idMitarbeitspeicher[0] && r.TypeChat == ChatType.Mitarbeiter); + + if (itemToRemove != null) + ita.Remove(itemToRemove); + + view.Refresh(); + } + + if (idteamspeicher.Count != 0) + { + var itemToRemove = ita.SingleOrDefault(r => r.EmpfaengerOid == idteamspeicher[0] && r.TypeChat == ChatType.Team); + + if (itemToRemove != null) + ita.Remove(itemToRemove); + + view.Refresh(); + } + } + catch (Exception edf) + { + MessageBox.Show("Beim Aktualisieren der Kontakt Liste ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2210 ", MessageBoxButton.OK); + } + } + + public void SetAllUserOfflineIfNoInet() + { + foreach (var list in ita) + { + list.StatusTyp = StatusType.Offline; + } + + view.Refresh(); + } + + public void SetUserBeschäftigt(long oid, DataIdentifier type) + { + foreach (var list in ita) + { + if (oid == list.EmpfaengerOid) + { + if (type == DataIdentifier.StatusNotificationBeschäftigt) + list.StatusTyp = StatusType.Beschäftigt;// "Beschäftigt"; + else if (type == DataIdentifier.StatusNotificationOnline) + list.StatusTyp = StatusType.Online;// "Online"; + else if (type == DataIdentifier.StatusNotificationOffline) + list.StatusTyp = StatusType.Offline; //"Offline"; //<--- testen + } + + } + + view.Refresh(); + } + + + private void ErstelleContextMenue() + { + try + { + context = new ContextMenu(); + + MenuItem item1 = new MenuItem(); + + context.Items.Add(item1); + + item1.Header = "Dokumentieren"; + item1.Visibility = Visibility.Visible; + item1.Click += new RoutedEventHandler(OnChatRightClickMenue); + + Image icon = new Image(); + //icon.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png"); + icon.Source = new BitmapImage(new Uri(@"..\..\Ressources\Icons\ClipboardDisabled.png", UriKind.Relative)); + icon.SetSize(new Size(16, 16)); + item1.Icon = icon; + + + Chat.ContextMenu = context; + } + catch (Exception edf) + { + MessageBox.Show("Beim Setzen einer Neuen Chat Einstellung ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2380 ", MessageBoxButton.OK); + } + + } + + private void OnChatRightClickMenue(object sender, RoutedEventArgs e) + { + List itemListe = new List(); + + + KontakMessageBuilder Item; + foreach (Object selecteditem in Chat.SelectedItems) + { + Item = selecteditem as KontakMessageBuilder; + + if (Item.MessagePersonOid != 0) + { + itemListe.Add(Item); + } + + } + + if (itemListe.Count != 0) + { + KontaktlistBuilder curItem = (KontaktlistBuilder)AktChatUser.Items[0]; + + if (curItem.TypeChat != ChatType.Team && curItem.TypeChat != ChatType.Mitarbeiter) + { + ChatDokumentationsView newView = new ChatDokumentationsView(itemListe, BeWoApp.LoggedOnUser.Employee.PersonOid, curItem.EmpfaengerOid, curItem.Customer); + + + //newView.Activate(); + newView.ShowDialog(); + + Chat.SelectedIndex = -1; + } + else + { + MessageBox.Show("Sie können nur Klienten Nachrichten Dokumentieren.", "Info", MessageBoxButton.OK, MessageBoxImage.Exclamation); + } + } + else + { + MessageBox.Show("Sie müssen für diese art von Dokumentation Chat-Nachrichten auswählen.", "Info", MessageBoxButton.OK, MessageBoxImage.Exclamation); + } + itemListe.Clear(); + } + + + private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + try + { + switch (StatusSetting.SelectedIndex) + { + case 0: + if (tcpClient == null) + { + StatusSetting.SelectedIndex = 1; + } + else if (!tcpClient.Connected) + { + StatusSetting.SelectedIndex = 1; + } + else + { + SendUserStatus(DataIdentifier.StatusNotificationOnline); + } + + break; + + case 1: + if (tcpClient == null) + { + StatusSetting.SelectedIndex = 1; + } + else if (!tcpClient.Connected) + { + StatusSetting.SelectedIndex = 1; + } + else + { + SendUserStatus(DataIdentifier.StatusNotificationOffline); + } + + break; + + case 2: + if (tcpClient == null) + { + StatusSetting.SelectedIndex = 1; + } + else if (!tcpClient.Connected) + { + StatusSetting.SelectedIndex = 1; + } + else + { + SendUserStatus(DataIdentifier.StatusNotificationBeschäftigt); + } + + break; + } + } + catch (Exception edf) + { + MessageBox.Show("Beim Setzen eines neuen Statuses ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2270 ", MessageBoxButton.OK); + } + } + + public void SendUserStatus(DataIdentifier identi) + { + try + { + NetworkStream serverStream = tcpClient.GetStream(); + + String abc = ""; + + Packet a = new Packet(); + + byte[] outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, 0, + BeWoApp.LoggedOnUser.LoginName, abc, identi, BeWoApp.Tenant, false); + + serverStream.Write(outStream, 0, outStream.Length); + serverStream.Flush(); + } + catch (Exception edf) + { + Console.WriteLine(edf.StackTrace); + } + } + + public void SetListBoxSelection(long personoid, ChatType type) + { + try + { + context.IsOpen = false; + + foreach (var blub in ita) + { + if (blub.EmpfaengerOid == personoid && blub.TypeChat == type) + { + AktChatUser.Items.Clear(); + Chat.Items.Clear(); + blub.Receivems = ""; + + if (blub.TypeChat == ChatType.Klienten) + { + AktChatUser.Items.Add(new KontaktlistBuilder(blub.Name, blub.StatusTyp, blub.Image, blub.EmpfaengerOid, blub.TypeChat, blub.Customer)); + } + else + { + AktChatUser.Items.Add(new KontaktlistBuilder(blub.Name, blub.StatusTyp, blub.Image, blub.EmpfaengerOid, blub.TypeChat)); + } + + LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, blub.EmpfaengerOid, blub); + + + if (blub.TypeChat == ChatType.Klienten) + { + context.Visibility = Visibility.Visible; + Chat.SelectionMode = SelectionMode.Extended; + Chat.Focusable = true; + } + else + { + context.Visibility = Visibility.Collapsed; + Chat.SelectionMode = SelectionMode.Single; + Chat.Focusable = false; + } + } + } + + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); + + } + catch (Exception edf) + { + MessageBox.Show("Fehler siehe Fehlercode. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2370", MessageBoxButton.OK); + } + } + + + private void ListBoxSelectedIndexChanged(object sender, System.EventArgs e) + { + KontaktlistBuilder curItem; + try + { + context.IsOpen = false; + + if (!Clientlist.Items.IsEmpty) + { + curItem = (KontaktlistBuilder)Clientlist.SelectedItem; + + Chat.Items.Clear(); + + AktChatUser.Items.Clear(); + + if (!curItem.Receivems.Equals("")) + { + curItem.Receivems = ""; + } + + if (curItem.TypeChat == ChatType.Klienten) + { + AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat, curItem.Customer)); + } + else + { + AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat)); + } + + + LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, curItem.EmpfaengerOid, curItem); + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); + view.Refresh(); + + + if (curItem.TypeChat == ChatType.Klienten) + { + context.Visibility = Visibility.Visible; + Chat.SelectionMode = SelectionMode.Extended; + Chat.Focusable = true; + } + else + { + context.Visibility = Visibility.Collapsed; + Chat.SelectionMode = SelectionMode.Single; + Chat.Focusable = false; + } + + } + } + catch (Exception s) + { + curItem = null; + MessageBox.Show("Beim Auswählen eines Users ist ein Fehler aufgetreten. " + s.Message + "\n" + s.StackTrace, "Fehler: 2280 ", MessageBoxButton.OK); + } + } + + public ImageSource BuildImg(Byte[] c) + { + try + { + if (c != null) + { + var biImg = new BitmapImage(); + + using (var ms = new MemoryStream(c)) + { + biImg.BeginInit(); + biImg.StreamSource = ms; + biImg.CacheOption = BitmapCacheOption.OnLoad; + biImg.EndInit(); + + } + return biImg; + } + else + { + //return null; + //return new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative)); + BitmapImage bi = new BitmapImage(); + bi.BeginInit(); + bi.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png"); + bi.EndInit(); + return bi; + + //return new ImageSource new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative)); + + //(ImageSource) + // new ImageSourceConverter().ConvertFromString( + // "../../Ressources/Icons/UserHomeBoyDisabled.png"); + } + } + catch (Exception edf) + { + MessageBox.Show("Beim Aufbauen der Profilbilder ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2290 ", MessageBoxButton.OK); + return null; + } + } + + public void setConnectionLostIcon() + { + System.Drawing.Icon icon = System.Drawing.SystemIcons.Warning; + BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + AlarmLabel.Source = bs; + + ButtonAlarmLabel.Visibility = Visibility.Visible; + } + + public void SendMessage(long empfängeroid, ChatType type) + { + try + { + string msg = Chatbox.Text; + + Chat.Items.Add(new KontakMessageBuilder(BeWoApp.LoggedOnUser.Employee.FirstName, msg, DateTime.Now.ToString(), BeWoApp.LoggedOnUser.Employee.PersonOid, true)); + + + if (tcpClient.Connected) + { + NetworkStream serverStream = tcpClient.GetStream(); + + Packet a = new Packet(); + + byte[] outStream; + + if (type == ChatType.Team) + { + outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.LoginName, msg, DataIdentifier.Team, BeWoApp.Tenant, false); + } + else + { + outStream = a.GetDataStream(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, BeWoApp.LoggedOnUser.LoginName, msg, 0, BeWoApp.Tenant, false); + } + + + serverStream.Write(outStream, 0, outStream.Length); + serverStream.Flush(); + + ServerStats.Text = "Nachricht erfolgreich gesendet"; + } + else + { + SaveChatMessageinDB(BeWoApp.LoggedOnUser.Employee.PersonOid, empfängeroid, msg, false, type); + } + } + catch (Exception xe) + { + if (tcpClient.Connected) + { + MessageBox.Show("Beim Senden einer Nachricht zum Server ist ein Fehler aufgetreten. " + xe.Message + "\n" + xe.StackTrace, + "Fehler: 2300 ", MessageBoxButton.OK); + + ServerStats.Text = "Fehler: Die Nachricht konnte nicht gesendet werden."; + } + } + } + + public void SaveChatMessageinDB(long senderoid, long empfangid, string message, bool istZugestellt, ChatType type) + { + try + { + if (type == ChatType.Team) + { + ServiceFacade.DoOperationsServiceSync(s => s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, empfangid)); + } + else + { + ServiceFacade.DoOperationsServiceSync(s => s.CreateNewChatMessagesDC(senderoid, empfangid, message, istZugestellt, 0)); + } + } + catch (InvalidOperationException e) + { + MessageBox.Show("Beim Speichern einer Nachricht in die Datenbank ist ein Fehler aufgetreten." + e.Message + "\n" + e.StackTrace, "Fehler: 2310 ", MessageBoxButton.OK); + } + } + + + + public void LoadChatMessagefromDB(long senderoid, long empfaengerOid, KontaktlistBuilder Curitem) + { + try + { + if (Curitem.TypeChat == ChatType.Team) + { + int sx = 0; + + var allTeamItems = + ServiceFacade.DoCustomerServiceSync( + s => s.FindAllChatMessagesFromTeam(senderoid, empfaengerOid)); + + List x = new List(); + + foreach (var team in allTeamItems) + { + if (!x.Contains(team.SenderPersonOid.Value)) + x.Add(team.SenderPersonOid.Value); + } + + x.Sort(); + + + var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x)); + + foreach (var anzeige in allTeamItems) + { + + if (x.Contains(anzeige.SenderPersonOid.Value)) + { + if (anzeige.SenderPersonOid.Value == BeWoApp.LoggedOnUser.Employee.PersonOid) + { + int zahl = (int)x.IndexOf(anzeige.SenderPersonOid.Value); + Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText, + anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, true)); + + } + else + { + if (sx == 0 && anzeige.IstGelesen != 1) + { + Chat.Items.Add(new KontakMessageBuilder("", "------------------------ Ungelesene Nachrichten -----------------------", "", 0, false)); + sx++; + } + + int zahl = (int)x.IndexOf(anzeige.SenderPersonOid.Value); + Chat.Items.Add(new KontakMessageBuilder(person[zahl].FirstName, anzeige.ChatText, + anzeige.Uhrzeit.ToString(), anzeige.SenderPersonOid.Value, false)); + } + + if (anzeige.IstGelesen != 1) + { + ServiceFacade.DoCustomerServiceAsync(s => s.UpdateIstGelesen(anzeige.EmpfängerPersonOid.Value, anzeige.SenderPersonOid.Value, true)); + } + + } + } + + } + else + { + var allitems = + ServiceFacade.DoCustomerServiceSync( + s => s.FindAllChatMessages(senderoid, empfaengerOid)); + + List x = new List(); + x.Add(senderoid); + x.Add(empfaengerOid); + + var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x)); + + int i = 0; + + foreach (var list in allitems) + { + if (list.IstGelesen == 1 && (list.TeamOid == null || list.TeamOid == 0)) + { + if (list.SenderPersonOid == senderoid) + { + Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText, + list.Uhrzeit.ToString(), senderoid, true)); + } + else + { + Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText, + list.Uhrzeit.ToString(), empfaengerOid, false)); + } + } + else + { + if (list.TeamOid == null || list.TeamOid == 0) + { + if (list.SenderPersonOid == senderoid) + { + Chat.Items.Add(new KontakMessageBuilder(person[0].FirstName, list.ChatText, + list.Uhrzeit.ToString(), senderoid, true)); + } + else + { + if (i == 0) + { + Chat.Items.Add(new KontakMessageBuilder("", "------------------------ Ungelesene Nachrichten -----------------------", "", 0, false)); + i++; + } + + Chat.Items.Add(new KontakMessageBuilder(person[1].FirstName, list.ChatText, + list.Uhrzeit.ToString(), empfaengerOid, false)); + } + } + } + } + ServiceFacade.DoCustomerServiceAsync(s => s.UpdateIstGelesen(empfaengerOid, senderoid, true)); + } + } + catch (Exception edf) + { + MessageBox.Show("Beim Laden einer Nachricht aus der Datenbank ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2320 ", MessageBoxButton.OK); + } + } + + //placeholder + private void OnFocus(object sender, EventArgs e) + { + try + { + + if (Chatbox.Text.Equals("Nachricht schreiben")) + { + Chatbox.Text = ""; + Chatbox.Foreground = new SolidColorBrush(Colors.Black); + isOnFocus = true; + } + + + if (emojiView != null) + { + if (emojiView.Visibility == Visibility.Visible) + { + emojiView.Visibility = Visibility.Collapsed; + } + } + } + catch (Exception edf) + { + MessageBox.Show("Fehler beim Fokusieren der Nachrichten Leiste. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2330 ", MessageBoxButton.OK); + } + } + + + //Rechte Maus Taste an dem Chat + public void OnRightClickEvent(object sender, RoutedEventArgs e) + { + e.Handled = true; + } + + + public void SmileyButton_OnClick(object sender, RoutedEventArgs e) + { + if (emojiView == null) + { + emojiView = new ChatEmojisView(); + + var x = EmojiButton.PointToScreen(new Point(0, 0)); + PresentationSource source = PresentationSource.FromVisual(EmojiButton); + + emojiView.Top = (x.Y / source.CompositionTarget.TransformToDevice.M22) - emojiView.Height - 5; + emojiView.Left = x.X / source.CompositionTarget.TransformToDevice.M11; + + + emojiView.Show(); + } + else + { + if (emojiView.Visibility == Visibility.Visible) + { + emojiView.Visibility = Visibility.Collapsed; + } + else + { + emojiView.Visibility = Visibility.Visible; + + var x = EmojiButton.PointToScreen(new Point(0, 0)); + PresentationSource source = PresentationSource.FromVisual(EmojiButton); + + emojiView.Top = (x.Y / source.CompositionTarget.TransformToDevice.M22) - emojiView.Height - 5; + emojiView.Left = x.X / source.CompositionTarget.TransformToDevice.M11; + } + } + } + + private void Chatbox_OnTextChanged(object sender, TextChangedEventArgs e) + { + if (this.Height < 850 && Chatbox.LineCount >= 3) + { + this.Height = this.Height + 50; + + } + else + if (Chatbox.LineCount <= 2) + { + this.Height = 800; + } + } + + + public void PruefeInDbObNeueNachrichtenVerfügbar() + { + try + { + + ServiceFacade.DoOperationsServiceAsync( + s => s.FindUnreadChatMessagesForRecipient(BeWoApp.LoggedOnEmployee.PersonOid.Value), + m => + { + Dispatcher.Invoke( + DispatcherPriority.Normal, + (ThreadStart)delegate + { + foreach (var ChatMessage in m) + { + foreach (var aktChatPersons in ita) + { + if (aktChatPersons.EmpfaengerOid == ChatMessage.SenderPersonOid && + aktChatPersons.TypeChat != ChatType.Team) + { + int aktc; + bool wasdrin = int.TryParse(aktChatPersons.Receivems, out aktc); + + if (wasdrin) + { + aktc++; + aktChatPersons.Receivems = aktc.ToString(); + + } + else + aktChatPersons.Receivems = 1.ToString(); + + } + else if (aktChatPersons.EmpfaengerOid == ChatMessage.TeamOid) + { + int aktt; + bool wasdrin = int.TryParse(aktChatPersons.Receivems, out aktt); + + if (wasdrin) + { + aktt++; + aktChatPersons.Receivems = aktt.ToString(); + + } + else + aktChatPersons.Receivems = 1.ToString(); + + } + } + } + }); + }); + + } + catch (Exception e) + { + MessageBox.Show("Fehler :" + e.Message + "\n" + e.StackTrace, "Info", MessageBoxButton.OK); + } + } + } + + public class KontaktlistBuilder : INotifyPropertyChanged + { + public KontaktlistBuilder(string name, StatusType statustyp, ImageSource image, long empfaengerid, ChatType typeChat) + { + this.Name = name; + this.StatusTyp = statustyp; + this.Image = image; + this.EmpfaengerOid = empfaengerid; + + Receivems = ""; + TypeChat = typeChat; + + if (statustyp == StatusType.Online) + { + this.Color = new SolidColorBrush(Colors.Green); + //Color.Opacity = 0.5; + } + else if (statustyp == StatusType.Offline) + { + this.Color = new SolidColorBrush(Colors.Red); + } + else + { + this.Color = new SolidColorBrush(Colors.Orange); + } + } + + public KontaktlistBuilder(string name, StatusType statustyp, ImageSource image, long empfaengerid, ChatType typeChat, CompactCustomerDC customer) + { + this.Customer = customer; + this.Name = name; + this.StatusTyp = statustyp; + this.Image = image; + this.EmpfaengerOid = empfaengerid; + + Receivems = ""; + TypeChat = typeChat; + + if (statustyp == StatusType.Online) + { + this.Color = new SolidColorBrush(Colors.Green); + } + else if (statustyp == StatusType.Offline) + { + this.Color = new SolidColorBrush(Colors.Red); + } + else + { + this.Color = new SolidColorBrush(Colors.Orange); + } + } + + public string Name { get; private set; } + + private StatusType _statustyp; + public StatusType StatusTyp + { + get { return _statustyp; } + set + { + _statustyp = value; + + if (_statustyp == StatusType.Online) + { + _color = new SolidColorBrush(Colors.Green); + } + else if (_statustyp == StatusType.Offline) + { + _color = new SolidColorBrush(Colors.Red); + } + else + { + _color = new SolidColorBrush(Colors.Orange); //Orange + } + + OnPropertyChanged("Lastms"); + } + } + + public ImageSource Image { get; private set; } + + public long EmpfaengerOid { get; private set; } + + private string _receivems; + public string Receivems { get { return _receivems; } set { _receivems = value; OnPropertyChanged("Receivems"); } } + + public ChatType TypeChat { get; set; } + + private Brush _color; + public Brush Color + { + get + { + return _color; + } + set + { + if (StatusTyp == StatusType.Online) + { + _color = new SolidColorBrush(Colors.Green); + } + else if (StatusTyp == StatusType.Offline) + { + _color = new SolidColorBrush(Colors.Red); + } + else + { + _color = new SolidColorBrush(Colors.Orange); + } + + //_color = value; + OnPropertyChanged("Color"); + } + } + + public CompactCustomerDC Customer { get; set; } + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string propertyName) + { + var handler = PropertyChanged; + if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public class KontakMessageBuilder + { + public KontakMessageBuilder(string username, string message, string sendtime, long messagePersonOid, bool isme) + { + Username = username; + UserMessage = message; + SendTime = sendtime; + MessagePersonOid = messagePersonOid; + + if (isme && messagePersonOid == 0) + { + ChatColor = new SolidColorBrush(Colors.DeepSkyBlue); + Posi = "Center"; + } + else + if (isme) + { + ChatColor = new SolidColorBrush(Colors.DarkOrange); + Posi = "Right"; + } + else + { + ChatColor = new SolidColorBrush(Colors.LightGray); + Posi = "Left"; + } + + } + + public string Username { get; private set; } + public string UserMessage { get; private set; } + public string SendTime { get; private set; } + public long MessagePersonOid { get; private set; } + public Brush ChatColor { get; private set; } + public int ChatPosition { get; private set; } + public string Posi { get; private set; } + } +} \ No newline at end of file diff --git a/BeWo/View/Detail/CustomerView.xaml.cs b/BeWo/View/Detail/CustomerView.xaml.cs index b1d016f3c..78c643d10 100644 --- a/BeWo/View/Detail/CustomerView.xaml.cs +++ b/BeWo/View/Detail/CustomerView.xaml.cs @@ -234,16 +234,15 @@ namespace BeWo.View.Detail if (_ViewModel.CustomerImage != null) { - var biImg = new BitmapImage(); - var ms = new MemoryStream(_ViewModel.CustomerImage); - - biImg.BeginInit(); - biImg.StreamSource = ms; - biImg.EndInit(); - - var imgSrc = biImg as ImageSource; - - Img.Source = biImg; + using (var ms = new System.IO.MemoryStream(_ViewModel.CustomerImage)) + { + var image = new BitmapImage(); + image.BeginInit(); + image.CacheOption = BitmapCacheOption.OnLoad; // here + image.StreamSource = ms; + image.EndInit(); + Img.Source = image; + } } Img.EditValueChanged += Image_EditValueChanged; diff --git a/BeWo/View/Detail/EmployeeView.xaml b/BeWo/View/Detail/EmployeeView.xaml index 9f50092ea..928396466 100644 --- a/BeWo/View/Detail/EmployeeView.xaml +++ b/BeWo/View/Detail/EmployeeView.xaml @@ -110,7 +110,8 @@ - + + @@ -169,8 +170,7 @@ - - diff --git a/BeWo/View/Detail/Report/QueryView.xaml.cs b/BeWo/View/Detail/Report/QueryView.xaml.cs index 8fa4a414c..7158d757e 100644 --- a/BeWo/View/Detail/Report/QueryView.xaml.cs +++ b/BeWo/View/Detail/Report/QueryView.xaml.cs @@ -42,6 +42,8 @@ namespace BeWo.View.Detail.Report private CompactEmployeeDC lastSelectedEmployee; private CompactCustomerDC lastSelectedCustomer; + private CompactSupportConceptDC lastSelectedSupportConcept; + private CompactTeamDC lastSelectedTeam; public QueryView(IEnumerable pQueries) { @@ -155,6 +157,45 @@ namespace BeWo.View.Detail.Report switch (item.ParamType) { case QueryParameterType.SupportConcept: + var peSc = new PopUpEdit + { + IsReadOnly = true, + MinWidth = 250, + Margin = new Thickness(3), + DeleteButtonVisibility = Visibility.Collapsed + }; + + if (lastSelectedSupportConcept != null) + { + peSc.Text = lastSelectedSupportConcept.ToString(); + } + + var popupSc = new Popup(); + popupSc.StaysOpen = false; + popupSc.Placement = PlacementMode.MousePoint; + popupSc.Width = 370; + popupSc.Height = 250; + + var scsv = new SupportConceptSearchView(); + scsv.SearchMode = SearchMode.ActiveCostbearer2SupportConcepts; + scsv.ItemSelected += (s, e) => + { + popupSc.IsOpen = false; + peSc.Focus(); + + var newSc = e.Data; + + peSc.Text = String.Format("{0}, {1}", newSc.Customer.LastNameFirstName, newSc.CostBearer); + + lastSelectedSupportConcept = newSc; + }; + popupSc.Child = scsv; + + parameterUIElements.Add(item.Name + "_" + item.ParamType + "_1", scsv); + + peSc.PopUpClick += (s, e) => { popupSc.IsOpen = true; }; + sp.Children.Add(peSc); + sp.Children.Add(popupSc); break; case QueryParameterType.Employee: var peEmp = new PopUpEdit @@ -234,6 +275,45 @@ namespace BeWo.View.Detail.Report sp.Children.Add(pe); sp.Children.Add(popup); + break; + case QueryParameterType.Team: + var peTeam = new PopUpEdit + { + IsReadOnly = true, + Width = 250, + Margin = new Thickness(3), + DeleteButtonVisibility = Visibility.Collapsed + }; + + if (lastSelectedTeam != null) + { + peTeam.Text = lastSelectedTeam.ToString(); + } + + var popupTeam = new Popup(); + popupTeam.StaysOpen = false; + popupTeam.Width = 370; + popupTeam.Height = 250; + popupTeam.Placement = PlacementMode.MousePoint; + var tsv = new TeamSearchView(); + tsv.ItemSelected += (s, e) => + { + popupTeam.IsOpen = false; + peTeam.Focus(); + + CompactTeamDC newTeam = e.Data; + + peTeam.Text = newTeam.ToString(); + + lastSelectedTeam = newTeam; + }; + popupTeam.Child = tsv; + + parameterUIElements.Add(item.Name + "_" + item.ParamType + "_1", tsv); + + peTeam.PopUpClick += (s, e) => { popupTeam.IsOpen = true; }; + sp.Children.Add(peTeam); + sp.Children.Add(popupTeam); break; case QueryParameterType.Month: ComboBox monthCombo = CreateMonthCombo(); @@ -257,6 +337,10 @@ namespace BeWo.View.Detail.Report break; case QueryParameterType.Date: + DateEdit dtpStart2 = CreateDateEdit(); + sp.Children.Add(dtpStart2); + + parameterUIElements.Add(item.Name + "_" + item.ParamType + "_1", dtpStart2); break; case QueryParameterType.DateRange: DateEdit dtpStart = CreateDateEdit(); @@ -317,6 +401,18 @@ namespace BeWo.View.Detail.Report switch (item.ParamType) { case QueryParameterType.SupportConcept: + if (lastSelectedSupportConcept != null) + { + if (lastSelectedSupportConcept.CostBearerRelOids != null && + lastSelectedSupportConcept.CostBearerRelOids.Count == 1) + { + param.Value = lastSelectedSupportConcept.CostBearerRelOids[0]; + } + else + { + param.Value = lastSelectedSupportConcept.SupportConceptOid; + } + } break; case QueryParameterType.Employee: if (lastSelectedEmployee != null) @@ -330,6 +426,13 @@ namespace BeWo.View.Detail.Report param.Value = lastSelectedCustomer.CustomerOid; } + break; + case QueryParameterType.Team: + if (lastSelectedTeam != null) + { + param.Value = lastSelectedTeam.TeamOid; + } + break; case QueryParameterType.Month: if (parameterUIElements.ContainsKey(item.Name + "_" + item.ParamType + "_1") && @@ -358,6 +461,17 @@ namespace BeWo.View.Detail.Report break; case QueryParameterType.Date: + if (parameterUIElements.ContainsKey(item.Name + "_" + item.ParamType + "_1")) + { + var dtp = parameterUIElements[item.Name + "_" + item.ParamType + "_1"] as DateEdit; + + if (dtp.EditValue != null) + { + var dt = dtp.DateTime; + + param.Value = dt; + } + } break; case QueryParameterType.DateRange: if (parameterUIElements.ContainsKey(item.Name + "_" + item.ParamType + "_1") && @@ -576,8 +690,13 @@ namespace BeWo.View.Detail.Report ResetQueryFields(); + String exportTitle = "Bericht öffnen"; if (lQuery != null) { + if (!String.IsNullOrWhiteSpace(lQuery.ExportTitle)) + { + exportTitle = lQuery.ExportTitle; + } if (lQuery.Parameter == null || lQuery.Parameter.Count == 0) { if (lQuery.IsDirect) @@ -617,7 +736,7 @@ namespace BeWo.View.Detail.Report } } } - + TxtLinkExport.Text = exportTitle; UpdatePDFExportUri(lQuery); } } @@ -650,10 +769,20 @@ namespace BeWo.View.Detail.Report var path = BeWoApp.GetAndCreateUserAppDataPath() + "\\BeWoDokument.xls"; var lQuery = combo_query.SelectedItem as QueryDC; - if (lQuery != null) + + bool isExcel = true; + if (lQuery != null) { - path = String.Format("{0}\\{1}.xls", BeWoApp.GetAndCreateUserAppDataPath(), lQuery.Title); - } + if (!String.IsNullOrWhiteSpace(lQuery.FileName)) + { + path = String.Format("{0}\\{1}", BeWoApp.GetAndCreateUserAppDataPath(), lQuery.FileName); + isExcel = false; + } + else + { + path = String.Format("{0}\\{1}.xls", BeWoApp.GetAndCreateUserAppDataPath(), lQuery.Title); + } + } var sf = new SaveFileDialog { FileName = Path.GetFileName(path), @@ -661,10 +790,23 @@ namespace BeWo.View.Detail.Report }; if (sf.ShowDialog() != true) return; - ServiceFacade.DoDownloadServiceSync( - s => - BeWoUtils.WriteExcelFile(s.PrepareExcelFile(DownloadLinkEngine.ExcelFileId, lHeaderCaptions, lContent), - sf.FileName)); + + if (isExcel) + { + ServiceFacade.DoDownloadServiceSync( + s => + BeWoUtils.WriteExcelFile( + s.PrepareExcelFile(DownloadLinkEngine.ExcelFileId, lHeaderCaptions, lContent), + sf.FileName)); + } + else + { + ServiceFacade.DoDownloadServiceSync( + s => + BeWoUtils.WriteFile( + s.PrepareExcelFile(DownloadLinkEngine.ExcelFileId, lHeaderCaptions, lContent), + sf.FileName)); + } //string navitageUri = ((Hyperlink)sender).NavigateUri.ToString(); //BeWoUtils.NavigateToReportUri(navitageUri); @@ -699,20 +841,43 @@ namespace BeWo.View.Detail.Report private void linkPdfExport_direct_RequestNavigate(object sender, RequestNavigateEventArgs e) { - var lQuery = combo_query.SelectedItem as QueryDC; - if (lQuery != null) - { - List parameterList = CreateQueryParamValues(lQuery); + //###EINKOMMENTIEREN + // var lQuery = combo_query.SelectedItem as QueryDC; + // if (lQuery != null) + // { + // List parameterList = CreateQueryParamValues(lQuery); - DataTable dt = ServiceFacade.DoQueryServiceSync(s => s.ExecuteQuery(lQuery.Oid, parameterList)); - ServiceFacade.DoQueryServiceSync( - q => - q.PrepareQueryReport(dt, BeWoApp.Tenant + "queryeoid" + BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + // if (!String.IsNullOrWhiteSpace(lQuery.ExportTitle)) + // { + // lQuery.Parameter = parameterList; - string navigateUri = linkPdfExport.NavigateUri.ToString(); - navigateUri = BeWoUtils.RemoveAuthenticationInfoFromUri(navigateUri); - BeWoUtils.NavigateToReportUri(navigateUri, lQuery.Title); - } + // var result = ServiceFacade.DoDownloadServiceSync(s => s.CreateQuery(lQuery)); + + // var path = String.Format("{0}\\{1}", BeWoApp.GetAndCreateUserAppDataPath(), result.FileName); + + // var sf = new SaveFileDialog + // { + // FileName = Path.GetFileName(path), + // Filter = "Alle Dateien|*.*" + // }; + // if (sf.ShowDialog() != true) + // return; + + // BeWoUtils.WriteFile(result.QueryResult, sf.FileName); + // } + // else + // { + // DataTable dt = ServiceFacade.DoQueryServiceSync(s => s.ExecuteQuery(lQuery.Oid, parameterList)); + // ServiceFacade.DoQueryServiceSync( + // q => + // q.PrepareQueryReport(dt, BeWoApp.Tenant + "queryeoid" + BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + + // string navigateUri = linkPdfExport.NavigateUri.ToString(); + // navigateUri = BeWoUtils.RemoveAuthenticationInfoFromUri(navigateUri); + // BeWoUtils.NavigateToReportUri(navigateUri, lQuery.Title); + // } + + // } } } } \ No newline at end of file diff --git a/BeWo/View/Detail/Report/ServicesReportView.xaml b/BeWo/View/Detail/Report/ServicesReportView.xaml index afb9cdc48..502737e7b 100644 --- a/BeWo/View/Detail/Report/ServicesReportView.xaml +++ b/BeWo/View/Detail/Report/ServicesReportView.xaml @@ -7,7 +7,7 @@ xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Focusable="True"> - + diff --git a/BeWo/View/Detail/Report/ServicesReportView.xaml.cs b/BeWo/View/Detail/Report/ServicesReportView.xaml.cs index f43c4dc15..44e7a0f66 100644 --- a/BeWo/View/Detail/Report/ServicesReportView.xaml.cs +++ b/BeWo/View/Detail/Report/ServicesReportView.xaml.cs @@ -53,8 +53,9 @@ namespace BeWo.View.Detail.Report //} combobox_month.SelectionChanged += combobox_month_SelectionChanged; + combobox_year.SelectionChanged += combobox_year_SelectionChanged; - ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, Theme.Office2010Black); + ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, Theme.Office2010Black); //ThemeManager.SetTheme(docPrevControl, Theme.Office2010Black); Unloaded += delegate { ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, null); docPrevControl.Visibility = Visibility.Collapsed; }; @@ -65,6 +66,11 @@ namespace BeWo.View.Detail.Report InitDayCombos(); } + void combobox_year_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + InitDayCombos(); + } + private void CheckBox_Checked(object sender, RoutedEventArgs e) { if (popupedit_customer == null) diff --git a/BeWo/View/Detail/SupportConceptView.xaml b/BeWo/View/Detail/SupportConceptView.xaml index 9bff93c28..22bea5983 100644 --- a/BeWo/View/Detail/SupportConceptView.xaml +++ b/BeWo/View/Detail/SupportConceptView.xaml @@ -803,10 +803,10 @@ --> - -