commitaf28476b76Merge:b76e16946c3b6a1e9cAuthor: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:53:31 2024 +0200 Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo # Conflicts: # ReportImp/VkmHamm/CustomerMitarbeiterstundenkontoBerechnung.cs commitb76e169462Author: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:40:08 2024 +0200 MH: vkm hamm stundenkonto commitc3b6a1e9c0Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:58:05 2024 +0200 Mergemarker entfernt commit5ff8fe343bMerge:c1aa61f05fc57725f4Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:52:16 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo commitc1aa61f058Merge:12faccb711c0a94c60Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:51:59 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo # Conflicts: # BeWo/ServiceProxy/Generated.cs # Data/Security/UserRightHelper.cs # Shared/BeWoEntityEnums.cs # Shared/Core/EnumTranslations.cs commit12faccb71bAuthor: Christian <christian.baeurle@beyondsoft.de> Date: Wed Jun 19 16:13:56 2024 +0200 Perseh Hilfeplan Import + KI Prototyp,
269 lines
8.1 KiB
C#
269 lines
8.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
|
|
using BeWo.Annotations;
|
|
using BeWo.Core;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.Validation;
|
|
using BeWo.View.Controls;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Utils;
|
|
using DevExpress.Xpf.Editors;
|
|
using DevExpress.Xpf.Grid;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
public partial class HilfeplanImportView : INotifyPropertyChanged
|
|
{
|
|
private HilfeplanImportDC _ViewModel;
|
|
private String _UploadFileName;
|
|
private long? _SupportConceptOid;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public event Action CloseButtonClicked;
|
|
|
|
private HilfeplanImportDC ViewModel
|
|
{
|
|
get { return _ViewModel; }
|
|
set
|
|
{
|
|
DataContext = value;
|
|
_ViewModel = value;
|
|
}
|
|
}
|
|
|
|
|
|
public HilfeplanImportView(long? supportConceptOid)
|
|
{
|
|
InitializeComponent();
|
|
_SupportConceptOid = supportConceptOid;
|
|
ClearControls();
|
|
}
|
|
|
|
|
|
|
|
private void ReloadViewModel(HilfeplanImportDC dc)
|
|
{
|
|
this.ViewModel = dc;
|
|
|
|
ClearControls();
|
|
UpdateControls(dc);
|
|
}
|
|
|
|
private void ClearControls()
|
|
{
|
|
PanelGruppen.Children.Clear();
|
|
treeview_Goals.ItemsSource = null;
|
|
|
|
}
|
|
|
|
private void UpdateControls(HilfeplanImportDC dc)
|
|
{
|
|
if (dc.Gruppen != null)
|
|
{
|
|
foreach (var gruppe in dc.Gruppen)
|
|
{
|
|
ErstelleGruppe(gruppe);
|
|
}
|
|
}
|
|
|
|
if (dc.Ziele != null)
|
|
{
|
|
ErstelleTreeView(dc.Ziele);
|
|
}
|
|
GroupBoxMain.Visibility = Visibility.Visible;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ErstelleGruppe(HilfeplanImportItemDC gruppe)
|
|
{
|
|
var expander = new Expander();
|
|
expander.Margin = new Thickness(5);
|
|
expander.FontSize = 14;
|
|
expander.Header = gruppe.Label;
|
|
expander.IsExpanded = true;
|
|
|
|
|
|
var itemGrid = new Grid();
|
|
|
|
//itemGrid.FontWeight = FontWeights.Normal;
|
|
itemGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
itemGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
|
|
expander.Content = itemGrid;
|
|
|
|
if (gruppe.Items != null)
|
|
{
|
|
foreach (var item in gruppe.Items)
|
|
{
|
|
itemGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
|
|
var label = new System.Windows.Controls.Label();
|
|
label.FontSize = 12;
|
|
label.Margin = new Thickness(3);
|
|
label.Content = item.Label;
|
|
label.SetValue(Grid.ColumnProperty, 0);
|
|
label.SetValue(Grid.RowProperty, itemGrid.RowDefinitions.Count - 1);
|
|
|
|
var txt = new System.Windows.Controls.TextBox();
|
|
txt.FontSize = 12;
|
|
txt.Margin = new Thickness(3);
|
|
txt.Text = item.Content;
|
|
txt.MinWidth = 300;
|
|
txt.SetValue(Grid.ColumnProperty, 1);
|
|
txt.SetValue(Grid.RowProperty, itemGrid.RowDefinitions.Count - 1);
|
|
txt.Tag = item;
|
|
|
|
itemGrid.Children.Add(label);
|
|
itemGrid.Children.Add(txt);
|
|
}
|
|
}
|
|
PanelGruppen.Children.Add(expander);
|
|
}
|
|
|
|
private void ErstelleTreeView(IList<HilfeplanImportZielDC> ziele)
|
|
{
|
|
var treeItems = new BindingList<GoalTreeItem>();
|
|
|
|
foreach (var item in ziele)
|
|
{
|
|
GoalTreeItem ziel = new GoalTreeItem { Name = item.ZielName, Notice = item.ZielBeschreibung };
|
|
|
|
GoalTreeItem parent = treeItems.Where(i => i.Name == item.Bereich).FirstOrDefault();
|
|
if (parent == null)
|
|
{
|
|
parent = new GoalTreeItem();
|
|
parent.Name = item.Bereich;
|
|
treeItems.Add(parent);
|
|
}
|
|
parent.Children.Add(ziel);
|
|
}
|
|
treeview_Goals.ItemsSource = treeItems;
|
|
}
|
|
|
|
private void popupedit_file_PopUpClick(object sender, RoutedEventArgs ev)
|
|
{
|
|
var dlg = new OpenFileDialog();
|
|
|
|
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
|
|
_UploadFileName = dlg.FileName;
|
|
|
|
popupedit_file.Text = dlg.SafeFileName;
|
|
ButtonImport.IsEnabled = true;
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
}
|
|
}
|
|
private void ButtonImport_Click(object sender, RoutedEventArgs pe)
|
|
{
|
|
if (!String.IsNullOrEmpty(popupedit_file.Text))
|
|
{
|
|
|
|
try
|
|
{
|
|
var upload = new ProgressStream(File.OpenRead(_UploadFileName));
|
|
//upload.ProgressChanged += (s, e) => Dispatcher.BeginInvoke(
|
|
// DispatcherPriority.Normal,
|
|
// (Action)(() =>
|
|
// {
|
|
// progressbar_upload.Value = e.Data;
|
|
// text_progress.Content = string.Format("Bitte warten... {0:00}%", e.Data * 100);
|
|
// }));
|
|
long oid = 0;
|
|
|
|
var lUlPackage = new UploadPackage(null, 0, _UploadFileName, null, 0, 0, upload);
|
|
|
|
ServiceFacade.DoStreamingServiceAsync(
|
|
s => s.UploadPersehFile(lUlPackage),
|
|
r => this.Dispatch(
|
|
delegate
|
|
{
|
|
upload.Dispose();
|
|
if (r.HilfeplanImportData != null)
|
|
{
|
|
ReloadViewModel(r.HilfeplanImportData);
|
|
}
|
|
|
|
}),
|
|
() => this.Dispatch(
|
|
delegate
|
|
{
|
|
|
|
upload.Dispose();
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void btnSave_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.SupportConceptOid = _SupportConceptOid;
|
|
|
|
var result = ServiceFacade.DoCustomerServiceSync(s => s.ImportSupportConcept(ViewModel));
|
|
if (!String.IsNullOrEmpty(result))
|
|
{
|
|
MessageBox.Show(result, "Import", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
CloseButtonClicked?.Invoke();
|
|
}
|
|
|
|
private void btnClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
CloseButtonClicked?.Invoke();
|
|
}
|
|
}
|
|
|
|
public class GoalTreeItem
|
|
{
|
|
private BindingList<GoalTreeItem> _Children;
|
|
|
|
public GoalTreeItem() { }
|
|
|
|
public bool IsHidden { get; set; }
|
|
|
|
public String Name { get; set; }
|
|
|
|
public String Notice { get; set; }
|
|
|
|
public BindingList<GoalTreeItem> Children
|
|
{
|
|
get => _Children ?? (_Children = new BindingList<GoalTreeItem>());
|
|
set => _Children = value;
|
|
}
|
|
|
|
}
|
|
}
|