From 51dfd9416c155c07d4e1b8a7b34841fbc1672d4e Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Tue, 12 May 2020 14:20:58 +0200 Subject: [PATCH] =?UTF-8?q?Verbesserungen=20in=20der=20Mobilversion:=20Ter?= =?UTF-8?q?mine=20werden=20beim=20Anlegen=20und=20Bearbeiten=20auf=20?= =?UTF-8?q?=C3=9Cberschneidungen=20gepr=C3=BCft=20und=20es=20wird=20gewarn?= =?UTF-8?q?t,=20wenn=20dem=20so=20ist.=20Das=20Unterschriftenfeld=20hat=20?= =?UTF-8?q?jetzt=20eine=20Breite=20von=2090%=20des=20Browsers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeWo/BeWo.csproj | 170 ++++++------- BeWo/BeWoApp.xaml.cs | 29 ++- BeWo/Core/BeWoUtils.cs | 43 ++-- BeWo/View/HomeView.xaml.cs | 27 ++- BeWoPlanerMobil/Controllers/MainController.cs | 11 +- .../Controllers/SchedulerController.cs | 89 ++++--- .../Scripts/view-scripts/scheduler.js | 77 +++++- BeWoPlanerMobil/Views/Main/Main.cshtml | 58 +++-- .../Views/Scheduler/Scheduler.cshtml | 229 ++++++++++-------- Service/Plugins/PluginLoader.cs | 4 +- 10 files changed, 437 insertions(+), 300 deletions(-) diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 388313a3c..a8e814f33 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -137,9 +137,8 @@ - - False - ..\packages\Newtonsoft.Json.6.0.5\lib\net40\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll 3.0 @@ -150,6 +149,9 @@ 3.0 + + ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll + 3.5 @@ -292,11 +294,11 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -638,7 +640,6 @@ - @@ -662,7 +663,7 @@ Component - + @@ -707,11 +708,11 @@ - + - + AbsenceTimeEditView.xaml @@ -890,7 +891,7 @@ BudgetView.xaml - + AbsenceTimesView.xaml @@ -2149,6 +2150,7 @@ Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -2292,372 +2294,372 @@ False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly False + Include + True - Include - True Assembly diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 15e0ede6a..e243629d1 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -984,19 +984,28 @@ namespace BeWo } } - public static string GetChatServerURL() + public static void GetChatServerUrlAsync(Action callback) { - if (chatServerURL.IsNullOrEmpty()) + if (string.IsNullOrWhiteSpace(chatServerURL)) { -#if DEBUG - Login login = new Login("5473568546"); -#else - Login login = new Login(BeWoApp.Tenant); -#endif - chatServerURL = login.ServerUrl; + var tenant = Tenant; + + #if DEBUG + tenant = "5473568546"; + #endif + + var login = new Login(tenant, serverUrl => + { + if (!string.IsNullOrWhiteSpace(serverUrl)) + { + callback(serverUrl); + } + }); + } + else + { + callback?.Invoke(chatServerURL); } - return chatServerURL; - } public static void Cleanup() diff --git a/BeWo/Core/BeWoUtils.cs b/BeWo/Core/BeWoUtils.cs index 9388ca180..ca937f5a7 100644 --- a/BeWo/Core/BeWoUtils.cs +++ b/BeWo/Core/BeWoUtils.cs @@ -52,6 +52,7 @@ using DevExpress.Xpf.Bars; using DevExpress.Xpf.DocumentViewer; using DevExpress.Xpf.Printing.PreviewControl.Bars; using DevExpress.XtraScheduler; +using RestSharp; using Control = System.Windows.Controls.Control; using Utils = BS.Shared.Core.Utils; @@ -2109,26 +2110,40 @@ namespace BeWo.Core { try { - var serverUrl = BeWoApp.GetChatServerURL(); + var tenant = BeWoApp.Tenant; - if (!String.IsNullOrEmpty(serverUrl)) + #if DEBUG + tenant = "5473568546"; + #endif + + BeWoApp.GetChatServerUrlAsync(serverUrl => { -#if DEBUG - var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/5473568546"; -#else - var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/" + BeWoApp.Tenant; -#endif - WebRequest request = WebRequest.Create(endurl); + var client = new RestClient($"{serverUrl}/api/ownchat/sync/schedule/{BeWoApp.Mandator.Apikey}/{tenant}"); + var request = new RestRequest(); - request.Credentials = CredentialCache.DefaultCredentials; + client.ExecuteAsync(request, null); + }); - var response = request.GetResponse(); +// var serverUrl = BeWoApp.GetChatServerURL(); + +// if (!string.IsNullOrEmpty(serverUrl)) +// { +//#if DEBUG +// var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/5473568546"; +//#else +// var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/" + BeWoApp.Tenant; +//#endif +// WebRequest request = WebRequest.Create(endurl); + +// request.Credentials = CredentialCache.DefaultCredentials; + +// var response = request.GetResponse(); - response.Close(); - response.Dispose(); - } +// response.Close(); +// response.Dispose(); + //} } - catch (Exception e) + catch (Exception exception) { // MessageBox.Show("Die Verbindung konnte nicht aufgebaut werden.", "ownChat Fehler ", MessageBoxButton.OK); diff --git a/BeWo/View/HomeView.xaml.cs b/BeWo/View/HomeView.xaml.cs index c06a35ec5..c36ee5302 100644 --- a/BeWo/View/HomeView.xaml.cs +++ b/BeWo/View/HomeView.xaml.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Security; using System.Text; using System.Threading; using System.Windows; @@ -415,24 +416,24 @@ namespace BeWo.View // ServiceChatView.Show(); //#else - if (ServiceChatView == null) + if(ServiceChatView == null) { #if DEBUG - if (true) + if(true) { - const string chatCode = "8ycX9-ZWbyJ"; - const string tenant = "5473568546"; - const string userName = "cb"; - const string password = "bewo"; - string apiKey; + string _Code = "8ycX9-ZWbyJ"; + string _kundennummer = "5473568546"; + string _benutzername = "cb"; + string _passwort = "bewo"; + string _apikey; #else - var empAppCodes = ServiceFacade.DoEmployeeServiceSync(r=>r.GetAllEmployeeAppCodes(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); + var empAppCodes = ServiceFacade.DoEmployeeServiceSync(r => r.GetAllEmployeeAppCodes(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); - if (empAppCodes != null && empAppCodes.Count > 0) + if(empAppCodes != null && empAppCodes.Count > 0) { string _Code = ""; - foreach (var item in empAppCodes) + foreach(var item in empAppCodes) { if(item.EmployeeCode != null && !item.EmployeeCode.Equals("")) _Code = item.EmployeeCode; @@ -452,11 +453,11 @@ namespace BeWo.View // _ChatCode = xxx.EmployeeCode; //} - apiKey = BeWoApp.Mandator.Apikey ?? "0000"; + _apikey = BeWoApp.Mandator.Apikey ?? "0000"; - if (!chatCode.Equals("")) + if(!_Code.Equals("")) { - var login = new Login(tenant, chatCode, userName, password, apiKey); + var login = new Login(_kundennummer, _Code, _benutzername, _passwort, _apikey); var x = login.AnmeldevorgangDurchFuehren(); diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 1dbb407a8..77f549f58 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -257,7 +257,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string LoadGoalTreeItems() { - if ((!Model.CostBearer2SupportConceptOid.HasValue || Model.CostBearer2SupportConceptOid.Value > 0) || Model.SelectedSupportConcept == null) + if (!Model.CostBearer2SupportConceptOid.HasValue || Model.CostBearer2SupportConceptOid.Value > 0 || Model.SelectedSupportConcept == null) { return null; } @@ -309,7 +309,7 @@ namespace BeWoPlanerMobil.Controllers goalTreeDic[ziel.ParentOid.Value].nodes.Add(node); } } - // TODO: SelectedGoals beachten -> Neue GoalState-Objekt im GoalDisplayItem hinzufügen mit dem Namen state { checked: true|false, disabled: false, expanded: false, selected: false } + return JsonConvert.SerializeObject(goalTree, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore @@ -455,9 +455,6 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string SaveUnterschrift(string blob, string timeStamp, long? serviceRecordOid) { - var watch = new Stopwatch(); - watch.Start(); - try { if (Model == null) @@ -492,10 +489,6 @@ namespace BeWoPlanerMobil.Controllers Log.Error(e.Message, e); return SerializeObject("Fehler 540"); } - finally - { - watch.Stop(); - } } private void ApplyWatermark() diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index 751fa568a..c5894c28d 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -12,7 +12,6 @@ using BS.Shared.Extensions; using DevExpress.XtraScheduler; using DevExpress.XtraScheduler.Compatibility; - using static BeWoPlanerMobil.Util.MobileUtils; namespace BeWoPlanerMobil.Controllers @@ -167,40 +166,6 @@ namespace BeWoPlanerMobil.Controllers Model.Appointments = holySweetFlyingFuck; } - [Authorize] - public string UpdateAppointment(long oid, string betreff, string notice, string startZeit, string endZeit, string day, string endDate, string pLocation) - { - try - { - if (Model == null) - { - RedirectToActionPermanent("Index", "Login"); - return _LeerzeichenFuerGetMethoden; - } - - var date = DateTime.Parse(day); - var end = DateTime.Parse(endDate); - var zeit = ConvertRecordTimesWithEndDate(startZeit, endZeit, date, end, 0); - - var b1 = KalenderService.GetSchedulerAppointmentByid(oid); - - b1.EndDate = zeit[1]; - b1.StartDate = zeit[0]; - b1.Subject = betreff; - b1.Description = notice; - b1.Location = pLocation; - - KalenderService.UpdateSchedulerAppointments(new List { b1 }); - - return _LeerzeichenFuerGetMethoden; - } - catch (Exception e) - { - Log.Error(e.Message, e); - return SerializeObject("Fehler 550: Internal Server Error"); - } - } - [Authorize] [HttpPost] public ActionResult InsertOrUpdateAppointment(FormCollection formCollection) @@ -279,6 +244,11 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedDate = Model.SelectedDate.AddDays(-1); + if(Model != null) + { + Model.SelectedAppointment = null; + } + return RedirectToActionPermanent("Scheduler"); } @@ -293,6 +263,11 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedDate = Model.SelectedDate.AddDays(1); + if(Model != null) + { + Model.SelectedAppointment = null; + } + return RedirectToActionPermanent("Scheduler"); } @@ -310,6 +285,11 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedDate = schedulerDate; + if(Model != null) + { + Model.SelectedAppointment = null; + } + return RedirectToActionPermanent("Scheduler"); } @@ -329,6 +309,7 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Scheduler"); } + [Authorize] public JsonResult ResetSelectedAppointment() { if (Model != null) @@ -336,7 +317,43 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedAppointment = null; } - return Json(null); + return Json(null, JsonRequestBehavior.AllowGet); + } + + [Authorize] + public JsonResult CheckForOverlappingAppointments(string startDateRaw, string endDateRaw, string startTimeRaw, string endTimeRaw) + { + if (Model == null) + { + return null; + } + + var isOverlapping = false; + var oid = Model.SelectedAppointment?.SchedulerAppointmentOid; + + var isSuccessfulStartDate = DateTime.TryParseExact(startDateRaw, "dd.MM.yyyy", null, DateTimeStyles.None, out var startDate); + var isSuccessfulStartTime = DateTime.TryParseExact(startTimeRaw, "HH:mm", null, DateTimeStyles.None, out var startTime); + var isSuccessfulEndDate = DateTime.TryParseExact(endDateRaw, "dd.MM.yyyy", null, DateTimeStyles.None, out var endDate); + var isSuccessfulEndTime = DateTime.TryParseExact(endTimeRaw, "HH:mm", null, DateTimeStyles.None, out var endTime); + + if (isSuccessfulStartDate && isSuccessfulStartTime && isSuccessfulEndDate && isSuccessfulEndTime) + { + startDate = startDate.MergeDatesByDate(startTime); + endDate = endDate.MergeDatesByDate(endTime); + + var customerList = Model.SelectedAppointment?.CustomerList?.Select(customer => customer.CustomerOid).ToList() ?? new List(); + var employeeList = Model.SelectedAppointment?.EmployeeList?.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid).ToList() ?? new List(); + var resourceList = Model.SelectedAppointment?.ResourceList?.Select(resource => resource.ResourceOid.Value).ToList() ?? new List(); + + var originator = Model.SelectedAppointment?.Originator ?? MobileSessionFacade.LoggedInCompactEmployee; + + var recurrenceId = Model.SelectedAppointment?.RecurrenceId ?? string.Empty; + var recurrenceIndex = Model.SelectedAppointment?.RecurrenceIndex ?? 0; + + isOverlapping = KalenderService.OverlappingAppointmentsExist(startDate, endDate, employeeList, customerList, resourceList, originator.EmployeeOid, oid, recurrenceId, recurrenceIndex); + } + + return Json(isOverlapping, JsonRequestBehavior.AllowGet); } } } diff --git a/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js b/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js index a3eaf9e78..b8a2b814c 100644 --- a/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js +++ b/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js @@ -1,7 +1,9 @@ function resetInsertAppointmentForm() { $.get(getResetSelectedAppointmentUrl()); - $("#insert-appointment-form").trigger("reset"); + $("#scheduler-start-time, #scheduler-end-time, #subject, #location, #notice").val(""); + + $("#scheduler-start-date, #scheduler-end-date").val(moment().format("DD.MM.YYYY")); } function submitInsertAppointmentForm() { @@ -20,6 +22,23 @@ function validateAppointmentForm() { var endTimePicker = $("#scheduler-end-time-picker"); var endDatePicker = $("#scheduler-end-date-picker"); + var isStartTimeInputEmpty = isEmptyOrSpaces($("#scheduler-start-time").val()); + var isEndTimeInputEmpty = isEmptyOrSpaces($("#scheduler-end-time").val()); + var isStartDateInputEmpty = isEmptyOrSpaces($("#scheduler-start-date").val()); + var isEndDateInputEmpty = isEmptyOrSpaces($("#scheduler-end-date").val()); + + startTimePicker.datetimepicker("show"); + startTimePicker.datetimepicker("hide"); + + startDatePicker.datetimepicker("show"); + startDatePicker.datetimepicker("hide"); + + endTimePicker.datetimepicker("show"); + endTimePicker.datetimepicker("hide"); + + endDatePicker.datetimepicker("show"); + endDatePicker.datetimepicker("hide"); + var startTime = startTimePicker.datetimepicker("date"); var endTime = endTimePicker.datetimepicker("date"); var startDate = startDatePicker.datetimepicker("date"); @@ -30,10 +49,12 @@ function validateAppointmentForm() { var c = startTime === undefined || startTime === null || !startTime.isValid(); var d = endTime === undefined || endTime === null || !endTime.isValid(); - if(a || b || c || d) { + if(a || b || c || d || isStartDateInputEmpty || isStartTimeInputEmpty || isEndTimeInputEmpty || isEndDateInputEmpty) { + hideSpinner(); $("#messagePopup .modal-body").html(''); showMessagePopup("Fehler"); + $("#scheduler-start-time, #scheduler-end-time").val(""); return; } @@ -54,5 +75,55 @@ function validateAppointmentForm() { return; } - $("#insert-appointment-form").submit(); + $.get( + getCheckForOverlappingAppointmentsUrl(), + { + startDateRaw: startDate.format("DD.MM.YYYY"), + endDateRaw: endDate.format("DD.MM.YYYY"), + startTimeRaw: startDate.format("HH:mm"), + endTimeRaw: endDate.format("HH:mm") + } + ).done(function(result) { + var isOverlapping = $.parseJSON(result); + + if(isOverlapping === true) { + hideSpinner(); + $("#messagePopup .modal-body").html(''); + showMessagePopupWithCallback("Überschneidung", + null, + function() { + $("#messagePopup .modal-body").html(); + showSpinner(); + $("#insert-appointment-form").submit(); + }); + } else { + $("#insert-appointment-form").submit(); + } + }); +} + +function toggleFormVisibility() { + if($("#form-toggle-button").css("display") === "none") { + showAppointmentForm(); + } else { + hideAppointmentForm(); + } +} + +function hideAppointmentForm() { + $("#form-container").collapse("hide"); +} + +function showAppointmentForm() { + $("#form-container").collapse("show"); +} + +function toggleAppointmentForm() { + var isVisible = $("#form-container").css("display") === "block"; + + if (isVisible) { + hideAppointmentForm(); + } else { + showAppointmentForm(); + } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index 22e76bd50..26c8b12c5 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -138,9 +138,11 @@ if($("#sketch-pad").length !== 0) { var rowWidth = $("#canvas-row").innerWidth(); var canvasWidth = $("#sketch-pad").innerWidth(); + + var newWidth = rowWidth; - if(rowWidth < canvasWidth) { - $("#sketch-pad").prop("width", rowWidth); + if (newWidth !== canvasWidth) { + $("#sketch-pad").prop("width", newWidth); new Signature(); } } @@ -576,30 +578,34 @@
@if(Model != null) { -
- @using(Html.BeginForm("LoadServiceRecords", "Main", FormMethod.Post, new { id = "selectServiceRecordForm" })) - { - - } -
+ if (Model.SelectedSupportConcept != null) + { +
+ @using(Html.BeginForm("LoadServiceRecords", "Main", FormMethod.Post, new { id = "selectServiceRecordForm" })) + { + + } +
+ } +
@{ diff --git a/BeWoPlanerMobil/Views/Scheduler/Scheduler.cshtml b/BeWoPlanerMobil/Views/Scheduler/Scheduler.cshtml index 418a7341a..27398dabd 100644 --- a/BeWoPlanerMobil/Views/Scheduler/Scheduler.cshtml +++ b/BeWoPlanerMobil/Views/Scheduler/Scheduler.cshtml @@ -5,42 +5,62 @@ ViewBag.Title = "BeWoPlaner Mobil"; } - +
@@ -78,100 +98,103 @@
- @using (Html.BeginForm("InsertOrUpdateAppointment", "Scheduler", FormMethod.Post, new {id = "insert-appointment-form"})) - { -
-
-
-
- -
- -
-
+ +
+ @using(Html.BeginForm("InsertOrUpdateAppointment", "Scheduler", FormMethod.Post, new { id = "insert-appointment-form" })) + { +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
-
-
- -
- -
-
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
-
-
-
-
- -
- -
-
-
+
+
+
+ +
-
-
- -
- -
-
-
+
+
+
+ + +
+
+
+
+
+
+ +
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
- } + } -
-
- -
-
- -
-
- +
+
+ +
+
+ +
+
+ +
-
-
+
+
@foreach (var appointment in Model.AppointmentListItems) {
diff --git a/Service/Plugins/PluginLoader.cs b/Service/Plugins/PluginLoader.cs index f72743998..6b0a4684e 100644 --- a/Service/Plugins/PluginLoader.cs +++ b/Service/Plugins/PluginLoader.cs @@ -17,10 +17,10 @@ namespace BeWo.Service.Plugins { #if DEBUG var t = "demo"; - t = "irgendwaswasesnichtgibt"; + //t = "irgendwaswasesnichtgibt"; //t = "2356097460"; // Lebenshilfe Würzburg //t = "1234567890"; // Präsentationsdatenbank - t = "5687373602"; // LH Duisburg + //t = "5687373602"; // LH Duisburg //t = "5509064354"; // LH Duisburg Service Plus //t = "5620636022"; // GPZ Biberach //t = "8562233401"; // Sozialwirkstatt Schmitz