Jonathan Jenne 45f8dd2aad 16-12-2022
2022-12-16 15:59:26 +01:00

214 lines
15 KiB
Plaintext

@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject ImportProfileService Import;
@inject HelperService Jobs;
@inject WcfService Service;
@if (profile == null)
{
<p>Form loading..</p>
}
else
{
<EditForm Model="profile" OnValidSubmit="OnValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="row row-cols-1 row-cols-lg-2">
<div class="col">
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="enabled" @bind="profile.Active">
<label class="form-check-label" for="enabled">Aktiv</label>
</div>
</div>
<div class="col">
<div class="mb-3 form-check">
<input class="form-check-input" type="checkbox" id="flexCheckDefault" @bind="profile.DeleteFiles">
<label class="form-check-label" for="flexCheckDefault">
Originaldateien nach Verarbeitung löschen
</label>
</div>
<div class="mb-3 form-check">
<input class="form-check-input" type="checkbox" id="flexCheckChecked" @bind="profile.IncludeSubfolders">
<label class="form-check-label" for="flexCheckChecked">
Unterstruktur des Quellverzeichnisses im Zielverzeichnis abbilden
</label>
</div>
</div>
</div>
<div class="row row-cols-1 row-cols-lg-2">
<div class="col">
<div class="mb-3">
<label for="name" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-card-text" viewBox="0 0 16 16">
<path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h13zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z" />
<path d="M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8zm0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5z" />
</svg> Name
</label>
<input type="text" class="form-control" id="name" aria-describedby="nameHelp" @bind="profile.Job.Name">
<div id="nameHelp" class="form-text">Der Name des Jobs. Wird in der Übersicht angezeigt.</div>
</div>
<div class="mb-3">
<label for="jobType" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-seam" viewBox="0 0 16 16">
<path d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2l-2.218-.887zm3.564 1.426L5.596 5 8 5.961 14.154 3.5l-2.404-.961zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z" />
</svg> Objekttyp
</label>
<select class="form-select" aria-label="Job type selection" id="jobType" @bind="profile.ObjectTypeName">
<option selected>Auswählen..</option>
@if (objectTypes != null)
{
@foreach (ObjectType type in objectTypes)
{
<option value="@type.Name">@type.Name</option>
}
}
</select>
<div id="cronHelp" class="form-text">Der Windream Objekttyp, dem das Profil zugeordnet wird. Bestimmt u.a., welche Indexe zur Verfügung stehen.</div>
</div>
@*<div class="mb-3">
<label for="jobType" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-robot" viewBox="0 0 16 16">
<path d="M6 12.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5ZM3 8.062C3 6.76 4.235 5.765 5.53 5.886a26.58 26.58 0 0 0 4.94 0C11.765 5.765 13 6.76 13 8.062v1.157a.933.933 0 0 1-.765.935c-.845.147-2.34.346-4.235.346-1.895 0-3.39-.2-4.235-.346A.933.933 0 0 1 3 9.219V8.062Zm4.542-.827a.25.25 0 0 0-.217.068l-.92.9a24.767 24.767 0 0 1-1.871-.183.25.25 0 0 0-.068.495c.55.076 1.232.149 2.02.193a.25.25 0 0 0 .189-.071l.754-.736.847 1.71a.25.25 0 0 0 .404.062l.932-.97a25.286 25.286 0 0 0 1.922-.188.25.25 0 0 0-.068-.495c-.538.074-1.207.145-1.98.189a.25.25 0 0 0-.166.076l-.754.785-.842-1.7a.25.25 0 0 0-.182-.135Z" />
<path d="M8.5 1.866a1 1 0 1 0-1 0V3h-2A4.5 4.5 0 0 0 1 7.5V8a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1v1a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1v-.5A4.5 4.5 0 0 0 10.5 3h-2V1.866ZM14 7.5V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.5A3.5 3.5 0 0 1 5.5 4h5A3.5 3.5 0 0 1 14 7.5Z" />
</svg> Job Typ
</label>
<select class="form-select" aria-label="Job type selection" id="jobType" @bind="profile.Job.TypeId">
<option selected>Auswählen..</option>
@if (jobTypes != null)
{
@foreach (JobType type in jobTypes)
{
<option value="@type.Id">@type.Name</option>
}
}
</select>
<div id="cronHelp" class="form-text">Der Typ des Jobs.</div>
</div>*@
<div class="mb-3">
<label for="sourceFolder" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg> Quellverzeichnis
</label>
<input type="text" class="form-control" id="sourceFolder" aria-describedby="sourceFolderHelp" @bind="profile.SourceFolder" />
<div id="sourceFolderHelp" class="form-text">Lokales Verzeichnis, aus dem Dateien zur Verarbeitung gelesen werden.</div>
</div>
<div class="mb-3">
<label for="targetFolder" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-in-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 3.5a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-2a.5.5 0 0 0-1 0v2A1.5 1.5 0 0 0 6.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-8A1.5 1.5 0 0 0 5 3.5v2a.5.5 0 0 0 1 0v-2z" />
<path fill-rule="evenodd" d="M11.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H1.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg> Zielverzeichnis
</label>
<input type="text" class="form-control" id="targetFolder" aria-describedby="targetFolderHelp" @bind="profile.TargetFolder" />
<div id="targetFolderHelp" class="form-text">Windream Verzeichnis, in das die verarbeiteten Dateien geschrieben werden.</div>
</div>
</div>
<div class="col">
<div class="mb-3">
<label for="cronExpression" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-alarm" viewBox="0 0 16 16">
<path d="M8.5 5.5a.5.5 0 0 0-1 0v3.362l-1.429 2.38a.5.5 0 1 0 .858.515l1.5-2.5A.5.5 0 0 0 8.5 9V5.5z" />
<path d="M6.5 0a.5.5 0 0 0 0 1H7v1.07a7.001 7.001 0 0 0-3.273 12.474l-.602.602a.5.5 0 0 0 .707.708l.746-.746A6.97 6.97 0 0 0 8 16a6.97 6.97 0 0 0 3.422-.892l.746.746a.5.5 0 0 0 .707-.708l-.601-.602A7.001 7.001 0 0 0 9 2.07V1h.5a.5.5 0 0 0 0-1h-3zm1.038 3.018a6.093 6.093 0 0 1 .924 0 6 6 0 1 1-.924 0zM0 3.5c0 .753.333 1.429.86 1.887A8.035 8.035 0 0 1 4.387 1.86 2.5 2.5 0 0 0 0 3.5zM13.5 1c-.753 0-1.429.333-1.887.86a8.035 8.035 0 0 1 3.527 3.527A2.5 2.5 0 0 0 13.5 1z" />
</svg> Cron Expression
</label>
<input type="text" class="form-control" id="cronExpression" @bind="profile.Job.CronSchedule" aria-describedby="cronHelp">
<div id="cronHelp" class="form-text">Die Zeitplan des Jobs. Erwartet eine <a href="https://www.quartz-scheduler.net/documentation/quartz-3.x/how-tos/crontrigger.html#examples" target="_blank">Quartz.NET Cron Expression.</a></div>
</div>
<div class="mb-3">
<label for="backupFolder" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-life-preserver" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm6.43-5.228a7.025 7.025 0 0 1-3.658 3.658l-1.115-2.788a4.015 4.015 0 0 0 1.985-1.985l2.788 1.115zM5.228 14.43a7.025 7.025 0 0 1-3.658-3.658l2.788-1.115a4.015 4.015 0 0 0 1.985 1.985L5.228 14.43zm9.202-9.202-2.788 1.115a4.015 4.015 0 0 0-1.985-1.985l1.115-2.788a7.025 7.025 0 0 1 3.658 3.658zm-8.087-.87a4.015 4.015 0 0 0-1.985 1.985L1.57 5.228A7.025 7.025 0 0 1 5.228 1.57l1.115 2.788zM8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6z" />
</svg> Sicherungsverzeichnis
</label>
<input type="text" class="form-control" id="backupFolder" aria-describedby="backupFolderHelp" @bind="profile.BackupFolder" />
<div id="backupFolderHelp" class="form-text">Lokales Verzeichnis, in das die zu verarbeiteten Dateien als Sicherheitskopie geschrieben werden.</div>
</div>
<div class="mb-3">
<label for="jobType" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-folder" viewBox="0 0 16 16">
<path d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31zM2.19 4a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91h10.348a1 1 0 0 0 .995-.91l.637-7A1 1 0 0 0 13.81 4H2.19zm4.69-1.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707z" />
</svg> Unterordner nach Datum
</label>
<select class="form-select" aria-label="Job type selection" id="jobType" @bind="profile.SubfolderDateFormat">
<option selected value="">Keine Unterordner</option>
<option value="YYYY">YYYY (@DateTime.Now.ToString("yyyy"))</option>
<option value="YYYY-MM">YYYY-MM (@DateTime.Now.ToString("yyyy-MM"))</option>
<option value="YYYY-MM-DD">YYYY-MM-DD (@DateTime.Now.ToString("yyyy-MM-dd"))</option>
</select>
<div id="cronHelp" class="form-text">Der Windream Objekttyp, dem das Profil zugeordnet wird. Bestimmt u.a., welche Indexe zur Verfügung stehen.</div>
</div>
<div class="mb-3">
<label for="exclusionRegex" class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-regex" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 1 1 .707.707Zm9.9-.707a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.314.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707ZM6 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm5-6.5a.5.5 0 0 0-1 0v2.117L8.257 5.57a.5.5 0 0 0-.514.858L9.528 7.5 7.743 8.571a.5.5 0 1 0 .514.858L10 8.383V10.5a.5.5 0 1 0 1 0V8.383l1.743 1.046a.5.5 0 0 0 .514-.858L11.472 7.5l1.785-1.071a.5.5 0 1 0-.514-.858L11 6.617V4.5Z" />
</svg> Ausschlussregex
</label>
<textarea type="text" class="form-control" id="exclusionRegex" aria-describedby="exclusionRegexHelp" rows="3" @bind="profile.FileExcludeRegex" />
<div id="exclusionRegexHelp" class="form-text">Liste von Regular Expressions. Wird ein Match im Dateinamen gefunden, wird die Datei <strong>nicht</strong> verarbeitet. <a href="https://regexr.com/" target="_blank">Regular Expression Editor</a></div>
</div>
</div>
</div>
<div class="btn-group mt-3" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="@GetBackUrl()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z" />
</svg> Back
</a>
<button type="submit" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-save" viewBox="0 0 16 16">
<path d="M2 1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H9.5a1 1 0 0 0-1 1v7.293l2.646-2.647a.5.5 0 0 1 .708.708l-3.5 3.5a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L7.5 9.293V2a2 2 0 0 1 2-2H14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h2.5a.5.5 0 0 1 0 1H2z" />
</svg> Save
</button>
</div>
</EditForm>
}
@code {
[Parameter]
public int ProfileId { get; set; }
[Parameter]
public EventCallback<EditContext> OnValidSubmit { get; set; }
private ImportProfile? profile;
private List<JobType>? jobTypes;
private List<ObjectType>? objectTypes;
protected string GetBackUrl()
{
return ProfileId == Constants.ENTITY_ID_NEW ? "profiles/import" : $"profiles/import/{ProfileId}";
}
protected override async Task OnInitializedAsync()
{
jobTypes = await Service.GetJobTypes();
objectTypes = await Service.GetObjectTypes();
if (ProfileId == Constants.ENTITY_ID_NEW)
{
profile = new ImportProfile() { Id = Constants.ENTITY_ID_NEW, Job = new() };
}
else
{
profile = await Import.GetProfile(ProfileId);
}
}
}