Files
BeWoPlaner/BeWo/View/Report/Rating/RatingReportView.xaml.cs
2020-11-10 02:25:15 +01:00

181 lines
6.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using BS.Shared.Core;
using System.Windows.Media;
using BS.Shared.Extensions;
using System.Collections;
using System.Text;
using BeWo.Controls;
using BeWo.Core;
using System.Windows.Documents;
using BeWo.Core.Service;
using System.Windows.Threading;
using BeWo.View.Detail;
using BeWo.View.Master;
using BeWo.View.Report.FLSReport;
using BS.Shared.DataContracts.Compact;
using BS.Shared.DataContracts.Reports;
using BS.Shared.DataContracts;
using BeWo.ServiceProxy;
using BS.Shared;
using BeWo.ViewModel;
using DevExpress.Xpf.Core;
using Microsoft.Win32;
using BS.Shared.Translation;
using System.Web.ModelBinding;
using System.ComponentModel;
using System.Windows.Navigation;
using DevExpress.XtraScheduler.Internal;
namespace BeWo.View.Report.Rating
{
public partial class RatingReportView : BeWoView
{
private CompactSupportConceptDC _SelectedSupportConcept;
public RatingReportView()
{
InitializeComponent();
ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, Theme.Office2010Black);
//ThemeManager.SetTheme(docPrevControl, Theme.Office2010Black);
dp_start.EditValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1);
dp_end.EditValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
Unloaded += delegate
{
ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, null);
//docPrevControl.Visibility = Visibility.Collapsed;
};
}
private void button_generate_Click(object sender, RoutedEventArgs e)
{
if (_SelectedSupportConcept != null)
{
BorderRatingView.Visibility = Visibility.Visible;
if (chkTotalTimeSpan.IsChecked.HasValue && !chkTotalTimeSpan.IsChecked.Value)
{
SupportConceptRatingView.StartDate = dp_start.DateTime;
SupportConceptRatingView.EndDate = dp_end.DateTime;
}
else
{
SupportConceptRatingView.StartDate = null;
SupportConceptRatingView.EndDate = null;
}
UpdateRatingView();
GenerateURL();
}
}
private void LinkPdfExport_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
string url = GenerateURL();
BeWoUtils.NavigateToReportUri(url, Translator.Translate("Bewertungsstatistik"));
//System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString()));
}
private string GenerateURL()
{
string url = "";
url += BeWoApp.SiteOfOrigin + "/ReportView.aspx?";
long supportconceptOid = _SelectedSupportConcept.SupportConceptOid;
url += "&scOid=" + supportconceptOid;
DateTime? start = SupportConceptRatingView.StartDate;
DateTime? end = SupportConceptRatingView.EndDate;
if(start == null && end == null)
{
var sc = _SelectedSupportConcept;
start = sc.StartDate;
end = sc.EndDate;
}
url += "&start=" + start + "&end=" + end;
int inclZeiterfassung = 0;
if (SupportConceptRatingView.chkShowServiceRecordRatings.IsChecked.HasValue)
{
inclZeiterfassung = ((bool)SupportConceptRatingView.chkShowServiceRecordRatings.IsChecked) ? 1 : 0;
}
url += "&ze=" + inclZeiterfassung;
SupportConceptGoalRatingView view = this.SupportConceptRatingView;
var selected = view.GetSelectedGoals();
//Liste Oids entnehmen und als String an URL ranhängen
url += "&goals=";
foreach (var item in selected)
{
url += item.GoalEntry.ValueListEntryOid;
if (selected[selected.Count - 1] != item)
url += ",";
}
if (SupportConceptRatingView.RatingList != null)
{
var scgoals = SupportConceptRatingView.RatingList.DCBackup;
url += "&scgoals=";
foreach (var goal in scgoals)
{
url += goal.RatingOid;
if (scgoals[scgoals.Count - 1] != goal)
url += ",";
}
}
url += "&type=" + Utils.EnumName(ReportTypes.BewertungsstatistikReport);
url = BeWoWpfUtils.GetHTMLEncodedURL(url);
this.linkPdfExport.NavigateUri = new Uri(url);
return url;
}
private void UpdateRatingView()
{
VMFactory.CreateSupportConceptVMAsync(_SelectedSupportConcept.SupportConceptOid,
sc => this.Dispatch(
() =>
{
SupportConceptRatingView.SupportConcept = sc;
SupportConceptRatingView.RatingList = sc.Ratings; //abc123 Initial- und Zwischenbewertung hier!
SupportConceptRatingView.UpdateControl();
}
));
}
private void popupedit_CostBeaerer_PopUpClick(object sender, RoutedEventArgs ev)
{
this.popup_costBearer.IsOpen = true;
}
private void Popupedit_CostBeaerer_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
//if (!BeWoUtils.CheckPopupEditClickableSpace((PopUpEdit)sender, e) || _SelectedSupportConcept == null || !BeWoApp.LoggedOnUser.HasRight(UserRightType.SupportConceptView_Edit))
// return;
}
private void SupportConceptSearchView_ItemSelected(object sender, EventArgs<CompactSupportConceptDC> e)
{
this.popup_costBearer.IsOpen = false;
this.popupedit_CostBeaerer.Text = e.Data.DetailDescription;
this._SelectedSupportConcept = e.Data;
}
}
}