Ziele und Maßnahmen und deren Bewertungen können wiederhergestellt werden.

This commit is contained in:
2025-10-27 10:23:46 +01:00
parent 38fbea21ac
commit 638634b114
7 changed files with 137 additions and 77 deletions

View File

@@ -5162,7 +5162,7 @@ namespace BeWoPlanerMobil.Controllers
var selectedMultiBookingCb2ScOidsInputValue = formCollection[FormCollectionConstants.MultiBookingSelectedCb2ScOidsKey];
var selectedSingleBookingEmployeeOidInputValue = formCollection[FormCollectionConstants.SingleBookingEmployeeOidKey];
if(false == long.TryParse(selectedSingleBookingEmployeeOidInputValue, out var sbEmployeeOid))
if(false == long.TryParse(selectedSingleBookingEmployeeOidInputValue, out var sbEmployeeOid) && Model.LoggedInEmployee?.EmployeeOid != null)
{
sbEmployeeOid = Model.LoggedInEmployee.EmployeeOid.Value;
}
@@ -5182,7 +5182,7 @@ namespace BeWoPlanerMobil.Controllers
}
var isStartDateValid = DateTime.TryParse(dateInputValue, out var startDate);
if(false == isStartDateValid)
if(isStartDateValid is false)
{
startDate = DateTime.Today;
}
@@ -5253,20 +5253,20 @@ namespace BeWoPlanerMobil.Controllers
}
}
if(isEndDateValid == false)
if(isEndDateValid is false)
{
endDate = startDate;
}
serviceRecord.ServiceRecordType = marker ? ServiceRecordTypeId.Content : ServiceRecordTypeId.DefaultActivity;
serviceRecord.Start = startDate.MergeDateAndTimeString(startTimeInputValue);
serviceRecord.End = endDate.MergeDateAndTimeString(endTimeInputValue);
serviceRecord.ServiceRecordType = marker ? ServiceRecordTypeId.Content : ServiceRecordTypeId.DefaultActivity;
serviceRecord.Start = startDate.MergeDateAndTimeString(startTimeInputValue);
serviceRecord.End = endDate.MergeDateAndTimeString(endTimeInputValue);
serviceRecord.ServiceDescription = Model.SelectedServiceDescription;
serviceRecord.Betrag = betrag;
serviceRecord.Betrag = betrag;
serviceRecord.RoundedDuration = duration;
if(bookingMode == BookingMode.SingleBookingMode)
if(bookingMode is BookingMode.SingleBookingMode)
{
serviceRecord.Employee = Model.AllEmployees.FirstOrDefault(f => f.EmployeeOid == sbEmployeeOid) ?? Model.LoggedInUser.Employee;
}
@@ -5277,7 +5277,7 @@ namespace BeWoPlanerMobil.Controllers
{
scOids = Model.GroupBookingSelectedCostBearerSupportConcepts.Select(sc2Cb => sc2Cb.SupportConcept.SupportConceptOid).ToList();
}
else
else if(Model.SelectedSupportConcept is object)
{
scOids.Add(Model.SelectedSupportConcept.SupportConceptOid);
}

View File

@@ -485,4 +485,18 @@ function map2String(map) {
});
return output;
}
function array2Csv(array) {
if(array.length === 1) {
return array[0].toString();
}
var result = "";
for(let i = 0; i < array.length; i++) {
result += array[i] + ",";
}
return result.replace(/,\s*$/, "");
}

View File

@@ -69,7 +69,7 @@ namespace BeWoPlanerMobil.Service
// public static List<SettingsDC> UserSettings => LoggedInUser.Settings;
public static string LocalStorageKey => LoggedInUserOid.HasValue ? $"bwp_{MobileSessionFacade.Tenant}_{LoggedInUserOid}" : null;
public static string LocalStorageKey => LoggedInUserOid.HasValue ? $"bwp_{Tenant}_{LoggedInUserOid}" : null;
public static string EmployeeFullname
{

View File

@@ -186,13 +186,6 @@
loadServiceRecords();
</text>
}
@if(TempData[TempDataConstants.AfterRestoreKey] is true)
{
<text>
clearLocalBeWoStorage();
</text>
}
} catch(error) {
window.showErrorPopup(error);
}

View File

@@ -1,6 +1,6 @@
@using BeWoPlanerMobil.Service
@using BeWoPlanerMobil.Service
@using BeWoPlanerMobil.Util
@using NHibernate.Criterion
@model BeWoPlanerMobil.Models.MainModel
<script type="text/javascript">
@@ -8,7 +8,24 @@
{
<text>
clearLocalBeWoStorage();
saveSingleBookingLocally();
</text>
}
function saveSingleBookingLocally() {
const bookingMode = @((int) Model.CurrentBookingMode);
if(bookingMode === 0) {
const cb2ScRelOid = $("#sb-cb2ScRelOid").val();
const eOid = $("#sb-employee-input").val();
const categoryOid = $("#sb-category-select option:selected").val();
const descriptionOid = $("#sb-leistung-select option:selected").val();
updateCbScRelOids("sb", cb2ScRelOid);
updateEmployeeOids("sb", eOid);
updateCategory("sb", categoryOid);
updateServiceDescription("sb", descriptionOid);
}
}
var keyMap = new Map(
@@ -123,23 +140,19 @@
const mergedMap = new Map();
newMap.forEach((value, key, map) => {
const possibleRating =
oldMap.has(key)
? oldMap.get(key)
: null;
const possibleRating = oldMap.has(key) ? oldMap.get(key) : null;
mergedMap.set(key, possibleRating);
});
const strigified = JSON.stringify([...mergedMap]);
logColorfulMessage(`updateGoals2Ratings(${prefix}, ${window.map2String(newMap)}): Ziele/Maßnahmen gespeichert:\r\n${window.map2String(mergedMap)}\r\nstringified: ${strigified}`, "#FF5A00");
saveLocally(`@MobileSessionFacade.LocalStorageKey-${firstCharToUpperCase(prefix)}Goals2Ratings`, strigified);
}
function updateCbScRelOids(prefix, csv) {
if(csv === null || csv === undefined || csv.toString().length === 0) {
if(csv === null || csv === undefined || csv.length === 0) {
logInfo2(`csv ist leer: ${csv}; Entferne @MobileSessionFacade.LocalStorageKey-${firstCharToUpperCase(prefix)}Cb2ScRelOid${(prefix === "sb" ? "" : "s")}`);
localStorage.removeItem(`@MobileSessionFacade.LocalStorageKey-${firstCharToUpperCase(prefix)}Cb2ScRelOid${(prefix === "sb" ? "" : "s")}`);
return;
}
@@ -148,7 +161,7 @@
}
function updateEmployeeOids(prefix, csv) {
if(csv === null || csv === undefined || csv.toString().length === 0) {
if(csv === null || csv === undefined || csv.length === 0) {
localStorage.removeItem(`@MobileSessionFacade.LocalStorageKey-${firstCharToUpperCase(prefix)}EmployeeOids`);
return;
}
@@ -222,31 +235,30 @@
function clearLocalBeWoStorage() {
const keyArray = [];
for(let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if(key.startsWith(`@MobileSessionFacade.LocalStorageKey`)) {
localStorage.removeItem(key);
keyArray.push(key);
}
}
for(let i = 0; i < keyArray.length; i++) {
localStorage.removeItem(keyArray[i]);
}
}
function updateGoal2Rating(prefix, goalOid, ratingTypeOid) {
logInfo(`(${prefix}) Bewerte das Ziel mit der Oid ${goalOid} mit der Bewertungsid ${ratingTypeOid}`);
const localStorageKey = `@MobileSessionFacade.LocalStorageKey-${firstCharToUpperCase(prefix)}Goals2Ratings`;
const stored = localStorage.getItem(localStorageKey);
logInfo2(stored);
const map = stored ? new Map(JSON.parse(stored)) : new Map();
map.set(goalOid, ratingTypeOid);
for(const key of map.keys()) {
const val = map.get(key);
logInfo3(`${key}: ${val}`);
}
saveLocally(localStorageKey, JSON.stringify([...map]));
}
@@ -258,51 +270,51 @@
let output = "";
let singleBookingOutput = "<h2>Einzelbuchung</h2><table class='table table-sm table-striped'>" +
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
let groupBookingOutput = "<h2 class='mt-3'>Gruppenbuchung</h2><table class='table table-sm table-striped'>" +
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
let multiBookingOutput = "<h2 class='mt-3'>Mehrfachbuchung</h2><table class='table table-sm table-striped'>" +
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
"<thead>" +
"<tr>" +
"<th scope='col'>Id</th>" +
"<th scope='col'>Wert</th>" +
"<th scope='col'>Feld</th>" +
"<th scope='col'></th>" +
"</tr>" +
"</thead>";
for(let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
const key = localStorage.key(i);
if(false === key.startsWith(`@MobileSessionFacade.LocalStorageKey-`)) {
continue;
}
if(false === key.startsWith(`@MobileSessionFacade.LocalStorageKey-`)) {
continue;
}
const value = localStorage.getItem(key);
const value = localStorage.getItem(key);
if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Sb`)) {
singleBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
} else if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Gb`)) {
groupBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
} else if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Mb`)) {
multiBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
}
if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Sb`)) {
singleBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
} else if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Gb`)) {
groupBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
} else if(key.startsWith(`@MobileSessionFacade.LocalStorageKey-Mb`)) {
multiBookingOutput += `<tr><td>${key}</td><td>${keyMap.get(key)}</td><td>${value}</td><td><button type="button" class="btn btn-sm btn-danger" onclick="localStorage.removeItem('${key}');printLocalStorage();"><i class="fas fa-trash"></i></button></td></tr>`;
}
}
singleBookingOutput += "</table>";
@@ -351,7 +363,7 @@
$("#srr-leistung-select").val(localStorage.getItem(`@MobileSessionFacade.LocalStorageKey-${prefix}ServiceDescription`));
$("#srr-goals-ratings").val(localStorage.getItem(`@MobileSessionFacade.LocalStorageKey-${prefix}Goals2Ratings`));
$("#srr-goals-ratings").val(localStorage.getItem(`@MobileSessionFacade.LocalStorageKey-${prefix}Goals2Ratings`));
$("#srr-booking-mode").val(bookingMode);
@@ -361,6 +373,32 @@
$("#restore-service-record-form").submit();
}
function deleteBwpLocalStorage() {
const keyArray = [];
for(let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if(key.startsWith("bwp_demo_")) {
keyArray.push(key);
}
}
for(let i = 0; i < keyArray.length; i++) {
localStorage.removeItem(keyArray[i]);
}
}
function readWholeLocalStorage() {
logInfo3(`Es wurden ${localStorage.length} lokale gespeicherte Werte gefunden:`);
for(let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
logInfo3(`${key}: ${localStorage.getItem(key)}`);
}
}
</script>
@using(Html.BeginForm("RestoreServiceRecordForm", "Main", FormMethod.Post, new { id = "restore-service-record-form" }))
@@ -404,8 +442,18 @@
<input type="hidden" id="srr-booking-mode" name="@FormCollectionConstants.BookingModeKey" />
<button type="button" class="btn btn-bewo-dev bewo-restore-btn" onclick="window.restoreAllFields()">
<i class="fas fa-recycle"></i>
<i class="fas fa-recycle"></i>
</button>
if(Html.IsInDebugMode())
{
<button type="button" class="btn btn-danger" onclick="deleteBwpLocalStorage()">
<i class="fas fa-trash"></i>
</button>
<button type="button" class="btn btn-info" onclick="readWholeLocalStorage()">
<i class="far fa-eye"></i>
</button>
}
}

View File

@@ -53,7 +53,7 @@
<script type="text/javascript" src="@Scripts.Url("~/Scripts/moment/moment.min.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/moment/locale/de.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/ownSoft-Scripts/mobileUtils.js?v=1.6")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/ownSoft-Scripts/mobileUtils.js?v=1.7")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/ownSoft-Scripts/view-scripts/main.js?v=2.0")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/ownSoft-Scripts/signature.js?v=1.5")"></script>

View File

@@ -395,10 +395,15 @@
<add key="StoredTenantFilesFolderPath" value="C:\BeWoPlaner\StoredTenantFiles"/>
<add key="HelloWorldPdfLocation" value="C:\BeWoPlaner\StoredFiles\HelloWorld.pdf"/>
<add key="ServiceLogFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\service.log.txt"/>
<!--<add key="ServiceLogFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\service.log.txt"/>
<add key="WCFErrorLogFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\wcferror.log.txt"/>
<add key="JsonErrorLogFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\jsonerror.log.txt"/>
<add key="ApiServiceTestFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\apiservice.test.txt"/>
<add key="ApiServiceTestFilePath" value="D:\Projects\beyondSoft\BeWoPlaner\BeWo\Host\logs\apiservice.test.txt"/>-->
<add key="ServiceLogFilePath" value="C:\Users\Lyndon\Documents\Entwicklung\BeWo\Host\logs\service.log.txt"/>
<add key="WCFErrorLogFilePath" value="C:\Users\Lyndon\Documents\Entwicklung\BeWo\Host\logs\wcferror.log.txt"/>
<add key="JsonErrorLogFilePath" value="C:\Users\Lyndon\Documents\Entwicklung\BeWo\Host\logs\jsonerror.log.txt"/>
<add key="ApiServiceTestFilePath" value="C:\Users\Lyndon\Documents\Entwicklung\BeWo\Host\logs\apiservice.test.txt"/>
</appSettings>
<!-- <> <> <> Appsettings <> <> <> -->
</configuration>