Skip to content

Commit 27df762

Browse files
committed
Merge branch 'stable'
2 parents 1459c19 + 6d55cff commit 27df762

File tree

48 files changed

+410
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+410
-175
lines changed

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/EformBackendConfigurationPlugin.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,24 @@ private static async void SeedEForms(IServiceCollection services)
603603
Console.WriteLine(ex.Message);
604604
SentrySdk.CaptureException(ex);
605605
}
606+
607+
var compliancesForProperty = await backendConfigurationPnDbContext.Compliances
608+
.Where(x => x.PropertyId == property.Id)
609+
.Where(x => x.PlanningCaseSiteId == 0)
610+
.Where(x => x.WorkflowState != Microting.eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed)
611+
.ToListAsync();
612+
613+
foreach (var complianceForProperty in compliancesForProperty)
614+
{
615+
var planningCaseSite =
616+
await itemsPlanningContext.PlanningCaseSites.FirstOrDefaultAsync(x =>
617+
x.MicrotingSdkCaseId == complianceForProperty.MicrotingSdkCaseId);
618+
if (planningCaseSite != null)
619+
{
620+
complianceForProperty.PlanningCaseSiteId = planningCaseSite.PlanningCaseId;
621+
await complianceForProperty.Update(backendConfigurationPnDbContext).ConfigureAwait(false);
622+
}
623+
}
606624
}
607625

608626
var parentFolderTranslations =

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationAssignmentWorkerServiceHelper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,24 @@ public static async Task<OperationResult> UpdateDeviceUser(DeviceUserModel devic
287287
return new OperationDataResult<int>(false, "EmailIsAlreadyInUse");
288288
}
289289
var fullName = deviceUserModel.UserFirstName + " " + deviceUserModel.UserLastName;
290+
291+
if (string.IsNullOrEmpty(deviceUserModel.WorkerEmail) || !deviceUserModel.WorkerEmail.Contains("@") && deviceUserModel.TimeRegistrationEnabled == false)
292+
{
293+
// generate a fake email
294+
deviceUserModel.WorkerEmail = $"user_{worker.Id}_{siteDto.SiteId}@microting.invalid".ToLower();
295+
// return new OperationResult(false, "EmailIsNotValid");
296+
}
290297
var isUpdated = await core.SiteUpdate(deviceUserModel.SiteMicrotingUid, fullName, deviceUserModel.UserFirstName,
291-
deviceUserModel.UserLastName, worker.Email, deviceUserModel.LanguageCode).ConfigureAwait(false);
298+
deviceUserModel.UserLastName, deviceUserModel.WorkerEmail, deviceUserModel.LanguageCode).ConfigureAwait(false);
292299

293300
if (deviceUserModel.PinCode != "****") {
294301
worker.PinCode = deviceUserModel.PinCode;
295302
}
296303
worker.EmployeeNo = deviceUserModel.EmployeeNo;
297304
worker.Email = deviceUserModel.WorkerEmail;
298305
worker.PhoneNumber = deviceUserModel.PhoneNumber;
306+
worker.Resigned = deviceUserModel.Resigned;
307+
worker.ResignedAtDate = deviceUserModel.ResignedAtDate;
299308
await worker.Update(sdkDbContext).ConfigureAwait(false);
300309

301310
var user = await userService.GetByUsernameAsync(oldEmail).ConfigureAwait(false);

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Models/AssignmentWorker/PropertyWorkersFiltrationModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ namespace BackendConfiguration.Pn.Infrastructure.Models.AssignmentWorker;
66
public class PropertyWorkersFiltrationModel : FilterAndSortModel
77
{
88
public List<int> PropertyIds { get; set; }
9+
public bool ShowResigned { get; set; }
910
}

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Models/Compliances/CompliancesStatsModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace BackendConfiguration.Pn.Controllers;
24

35
public class CompliancesStatsModel
@@ -13,4 +15,10 @@ public class CompliancesStatsModel
1315
public int ThreeMonthsCount { get; set; }
1416
public int SixMonthsCount { get; set; }
1517
public int MoreThanSixMonthsCount { get; set; }
18+
public int NumberOfPlannedTasks { get; set; }
19+
public DateTime? DateOfOldestPlannedTask { get; set; }
20+
public int NumberOfPlannedEnvironmentInspectionTagTasks { get; set; }
21+
public DateTime? DateOfOldestEnvironmentInspectionTagPlannedTask { get; set; }
22+
public int NumberOfAdHocTasks { get; set; }
23+
public DateTime? DateOfOldestAdHocTask { get; set; }
1624
}

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Models/DeviceUserModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public class DeviceUserModel
108108
public string? PhoneNumber { get; set; }
109109
public DateTime? CreatedAt { get; set; }
110110
public DateTime? UpdatedAt { get; set; }
111+
public bool Resigned { get; set; }
112+
public DateTime ResignedAtDate { get; set; }
111113

112114
public static implicit operator DeviceUserModel(Microting.EformAngularFrontendBase.Infrastructure.Data.Models.DeviceUserModel model)
113115
{

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationAssignmentWorkerService/BackendConfigurationAssignmentWorkerService.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,14 @@ join worker in sdkDbContext.Workers on siteWorker.WorkerId equals worker.Id
368368
WorkerEmail = worker.Email,
369369
worker.PhoneNumber,
370370
site.CreatedAt,
371-
site.UpdatedAt
371+
site.UpdatedAt,
372+
worker.Resigned,
373+
worker.ResignedAtDate
372374

373375
};
374-
sitesQuery = sitesQuery.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed);
376+
sitesQuery = sitesQuery
377+
.Where(x => x.Resigned == requestModel.ShowResigned)
378+
.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed);
375379

376380
var deviceUsers = await sitesQuery
377381
.Select(x => new DeviceUserModel
@@ -390,7 +394,9 @@ join worker in sdkDbContext.Workers on siteWorker.WorkerId equals worker.Id
390394
PhoneNumber = x.PhoneNumber,
391395
Language = sdkDbContext.Languages.Where(y => y.Id == x.LanguageId).Select(y => y.Name).SingleOrDefault() ?? "Danish",
392396
LanguageCode = sdkDbContext.Languages.Where(y => y.Id == x.LanguageId).Select(y => y.LanguageCode).SingleOrDefault() ?? "da",
393-
IsLocked = x.IsLocked
397+
IsLocked = x.IsLocked,
398+
Resigned = x.Resigned,
399+
ResignedAtDate = x.ResignedAtDate
394400
})
395401
.ToListAsync().ConfigureAwait(false);
396402

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationCompliancesService/BackendConfigurationCompliancesService.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424

2525

2626
using BackendConfiguration.Pn.Controllers;
27+
using Microting.EformBackendConfigurationBase.Infrastructure.Enum;
2728

2829
namespace BackendConfiguration.Pn.Services.BackendConfigurationCompliancesService;
2930

@@ -393,6 +394,13 @@ public async Task<OperationDataResult<CompliancesStatsModel>> Stats()
393394
var complianceList = _backendConfigurationPnDbContext.Compliances;
394395
var oneWeekInTheFutureCount = await complianceList.CountAsync(x => x.Deadline >= DateTime.UtcNow && x.Deadline <= DateTime.UtcNow.AddDays(7));
395396
var todayCount = await complianceList.CountAsync(x => x.Deadline.Date <= DateTime.UtcNow.Date && x.WorkflowState != Constants.WorkflowStates.Removed);
397+
var NumberOfPlannedEnvironmentInspectionTagTasks = complianceList.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed).ToList().Where(x =>
398+
{
399+
var planningTags = _itemsPlanningPnDbContext.PlanningsTags
400+
.Where(y => y.PlanningId == x.PlanningId && y.PlanningTagId == envTag.Id)
401+
.ToList();
402+
return planningTags.Any();
403+
}).Count();
396404
var todayComplianceCountEnvironmentInspectionTag = await complianceList.Where(x => x.Deadline.Date <= DateTime.UtcNow.Date && x.WorkflowState != Constants.WorkflowStates.Removed).ToListAsync();
397405
var todayCountEnvironmentInspectionTag = todayComplianceCountEnvironmentInspectionTag.Where(x =>
398406
{
@@ -401,6 +409,16 @@ public async Task<OperationDataResult<CompliancesStatsModel>> Stats()
401409
.ToList();
402410
return planningTags.Any();
403411
}).Count();
412+
var oldestEnvironmentInspectionTagPlannedTask = todayComplianceCountEnvironmentInspectionTag
413+
.Where(x =>
414+
{
415+
var planningTags = _itemsPlanningPnDbContext.PlanningsTags
416+
.Where(y => y.PlanningId == x.PlanningId && y.PlanningTagId == envTag.Id)
417+
.ToList();
418+
return planningTags.Any();
419+
})
420+
.OrderBy(x => x.Deadline)
421+
.FirstOrDefault()?.Deadline;
404422
var oneWeekCount = await complianceList.CountAsync(x => x.Deadline <= DateTime.UtcNow && x.Deadline >= DateTime.UtcNow.AddDays(-7));
405423
var twoWeeksCount = await complianceList.CountAsync(x => x.Deadline <= DateTime.UtcNow.AddDays(-7) && x.Deadline >= DateTime.UtcNow.AddDays(-14));
406424
var oneMonthCount = await complianceList.CountAsync(x => x.Deadline <= DateTime.UtcNow.AddDays(-14) && x.Deadline >= DateTime.UtcNow.AddDays(-30));
@@ -409,6 +427,19 @@ public async Task<OperationDataResult<CompliancesStatsModel>> Stats()
409427
var sixMonthsCount = await complianceList.CountAsync(x => x.Deadline <= DateTime.UtcNow.AddDays(-90) && x.Deadline >= DateTime.UtcNow.AddDays(-180));
410428
var moreThanSixMonthsCount = await complianceList.CountAsync(x => x.Deadline < DateTime.UtcNow.AddDays(-180));
411429

430+
var numberOfWorkorderTasks = await _backendConfigurationPnDbContext.WorkorderCases
431+
.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed)
432+
.Where(x => x.CaseStatusesEnum != CaseStatusesEnum.NewTask)
433+
.Where(x => x.LeadingCase == true)
434+
.CountAsync();
435+
436+
var oldestWorkorderTask = await _backendConfigurationPnDbContext.WorkorderCases
437+
.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed)
438+
.Where(x => x.CaseStatusesEnum != CaseStatusesEnum.Completed && x.CaseStatusesEnum != CaseStatusesEnum.NewTask)
439+
.Where(x => x.LeadingCase == true)
440+
.OrderBy(x => x.CreatedAt)
441+
.FirstOrDefaultAsync();
442+
412443
var totalCount = complianceList.Count();
413444

414445
var statsModel = new CompliancesStatsModel
@@ -423,7 +454,11 @@ public async Task<OperationDataResult<CompliancesStatsModel>> Stats()
423454
ThreeMonthsCount = threeMonthsCount,
424455
SixMonthsCount = sixMonthsCount,
425456
MoreThanSixMonthsCount = moreThanSixMonthsCount,
426-
TodayCountEnvironmentInspectionTag = todayCountEnvironmentInspectionTag
457+
TodayCountEnvironmentInspectionTag = todayCountEnvironmentInspectionTag,
458+
DateOfOldestEnvironmentInspectionTagPlannedTask = oldestEnvironmentInspectionTagPlannedTask,
459+
NumberOfAdHocTasks = numberOfWorkorderTasks,
460+
DateOfOldestAdHocTask = oldestWorkorderTask.CreatedAt,
461+
NumberOfPlannedEnvironmentInspectionTagTasks = NumberOfPlannedEnvironmentInspectionTagTasks
427462
};
428463

429464
return new OperationDataResult<CompliancesStatsModel>(true, statsModel);

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationTaskWizardService/BackendConfigurationTaskWizardService.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public async Task<OperationResult> CreateTask(TaskWizardCreateModel createModel)
535535
AreaId = areaId,
536536
FolderId = (int)createModel.FolderId,
537537
ItemPlanningId = planning.Id,
538-
ComplianceEnabled = true,
538+
ComplianceEnabled = createModel.ComplianceEnabled,
539539
PlanningSites = createModel.Sites
540540
.Select(x =>
541541
new Microting.EformBackendConfigurationBase.Infrastructure.Data.Entities.PlanningSite
@@ -1126,42 +1126,6 @@ await PairItemWithSiteHelper.Pair(
11261126
}
11271127

11281128
await planning.Update(_itemsPlanningPnDbContext);
1129-
1130-
if (!_itemsPlanningPnDbContext.PlanningSites.Any(x =>
1131-
x.PlanningId == planning.Id &&
1132-
x.WorkflowState != Constants.WorkflowStates.Removed) ||
1133-
!areaRulePlanning.ComplianceEnabled)
1134-
{
1135-
var complianceList = await _backendConfigurationPnDbContext.Compliances
1136-
.Where(x => x.PlanningId == planning.Id)
1137-
.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed)
1138-
.ToListAsync().ConfigureAwait(false);
1139-
foreach (var compliance in complianceList)
1140-
{
1141-
await compliance.Delete(_backendConfigurationPnDbContext)
1142-
.ConfigureAwait(false);
1143-
if (_backendConfigurationPnDbContext.Compliances.Any(x =>
1144-
x.PropertyId == areaRulePlanning.PropertyId &&
1145-
x.Deadline < DateTime.UtcNow &&
1146-
x.WorkflowState != Constants.WorkflowStates.Removed))
1147-
{
1148-
areaRulePlanning.AreaRule.Property.ComplianceStatusThirty = 2;
1149-
areaRulePlanning.AreaRule.Property.ComplianceStatus = 2;
1150-
}
1151-
else
1152-
{
1153-
if (!_backendConfigurationPnDbContext.Compliances.Any(x =>
1154-
x.PropertyId == areaRulePlanning.AreaRule.Property.Id && x.WorkflowState !=
1155-
Constants.WorkflowStates.Removed))
1156-
{
1157-
areaRulePlanning.AreaRule.Property.ComplianceStatusThirty = 0;
1158-
areaRulePlanning.AreaRule.Property.ComplianceStatus = 0;
1159-
}
1160-
}
1161-
1162-
await areaRulePlanning.AreaRule.Property.Update(_backendConfigurationPnDbContext);
1163-
}
1164-
}
11651129
}
11661130

11671131
break;

eform-client/src/app/plugins/modules/backend-configuration-pn/i18n/bgBG.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,5 @@ export const bgBG = {
292292
'Employee no': 'Служител №',
293293
'Deactivate task': 'Деактивирайте задачата',
294294
Areas: 'Области',
295+
Pictures: 'Снимки',
295296
};

eform-client/src/app/plugins/modules/backend-configuration-pn/i18n/csCZ.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,5 @@ export const csCZ = {
292292
'Employee no': 'Zaměstnanec č',
293293
'Deactivate task': 'Deaktivovat úkol',
294294
Areas: 'Oblasti',
295+
Pictures: 'Obrázky',
295296
};

0 commit comments

Comments
 (0)