ソースを参照

Offline mode

- Resend reports workflow
master
Flo Smilari 4年前
コミット
4f2bb83089

+ 2
- 1
Pages/CaritasServiceFundVeloFoundKeyDataPage.razor ファイルの表示

@@ -216,12 +216,13 @@
private async void AfterRenderMap() {
FoundReport report = ReportDataProvider.GetFoundReport();
if (report.GeographicInfo.Latitude != 0 && report.GeographicInfo.Longitude != 0) {
bicycleGeoPosition.DisplayCity = GetFormattedAddressZipAndTown();
bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
LatLng coordinates = new LatLng(report.GeographicInfo.Latitude, report.GeographicInfo.Longitude);
MouseEvent mouseEvent = new MouseEvent();
mouseEvent.LatLng = coordinates;
await InitializeMapPosition();
await AddBicycleMarkerOnClickPosition(mouseEvent);
StateHasChanged();
}
}

+ 25
- 2
Pages/CaritasServiceFundVeloFoundKeyDataPage.razor.cs ファイルの表示

@@ -69,10 +69,19 @@ namespace cwebplusApp.Pages {
protected async Task InitializeMapPosition() {
CreateBicycleMarkerOptions();
await AddEventsToMap();
await ShowDeviceGeoLocation();
if (this.bicycleGeoPosition.Latitude == 0 && this.bicycleGeoPosition.Longitude == 0) {
await ShowDeviceGeoLocation();
} else {
await ShowBicycleGeoLocation();
}
}
protected static string GetFormattedAddressZipAndTown() {
protected async Task<string> GetFormattedAddressZipAndTown(ReportDataProvider ReportDataProvider) {
if (addressDto == null) {
this.bicycleGeoPosition.Latitude = ReportDataProvider.GetFoundReport().GeographicInfo.Latitude;
this.bicycleGeoPosition.Longitude = ReportDataProvider.GetFoundReport().GeographicInfo.Longitude;
addressDto =await NominatimService.GetAddressForCoordinates(this.bicycleGeoPosition.Latitude, this.bicycleGeoPosition.Longitude);
}
return GetFormattedAddressZipAndTown(addressDto);
}
@@ -113,6 +122,20 @@ namespace cwebplusApp.Pages {
}
}
private async Task ShowBicycleGeoLocation() {
if (this.bicycleGeoPosition.Latitude != 0 && this.bicycleGeoPosition.Longitude != 0) {
LatLng geoPosition = new(this.bicycleGeoPosition.Latitude, this.bicycleGeoPosition.Longitude);
if (this.devicePositionMarker != null) {
await devicePositionMarker.Remove();
}
this.devicePositionMarker = await this.MarkerFactory.CreateAndAddToMap(geoPosition, this.mapRef);
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);
}
}
private static string GetFormattedAddressZipAndTown(NominatimReverseAddress addressDto) {
string country_code = addressDto.address.country_code;
string zip = SplitAndGetFirstPostcode(addressDto.address.postcode);

+ 78
- 45
Pages/CaritasServiceFundVeloLostFoundPage.razor ファイルの表示

@@ -7,59 +7,92 @@
@inject PageHistoryManager PageHistoryManager
@inject ReportDataProvider ReportDataProvider
@inject UserDataProvider UserDataProvider
@inject ReportRepositoryService ReportRepositoryService
<div class="row px-3 h-100">
<div class="row no-gutters align-items-center w-100">
<div class="mat-layout-grid w-100">
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2">
<MatCard Class="fv-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_found.png" @onclick="Found"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2">
<MatCard Class="fv-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_missing.png" @onclick="Missing"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
<div class="row px-3 h-100">
<div class="row no-gutters align-items-center w-100">
<div class="mat-layout-grid w-100">
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2">
<MatCard Class="fv-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_found.png" @onclick="Found"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2">
<MatCard Class="fv-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_missing.png" @onclick="Missing"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2" style="text-align:end">
@if (NbrPendingReports > 0) {
<div>
<MatChip Label="@NbrPendingReports.ToString()" Class="pending_batch"></MatChip>
</div>
}
<MatCard Class="fv-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_pending.png" @onclick="Pending" Style="@getOpacity()"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1">
</div>
</div>
</div>
</div>
</div>
</div>
@code {
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
ReportDataProvider.Report = null;
ReportDataProvider.ReportRepositoryItem = null;
base.OnInitialized();
}
private int NbrPendingReports;
private async void Found() {
Report report = new FoundReport();
UserDataProvider.mapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report;
NavigationManager.NavigateTo("fundvelo/keydata/Found");
}
protected async override void OnInitialized() {
base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
ReportDataProvider.Report = null;
ReportDataProvider.ReportRepositoryItem = null;
NbrPendingReports = await ReportRepositoryService.GetNbrOfPendingReports();
StateHasChanged();
}
private async void Found() {
Report report = new FoundReport();
UserDataProvider.mapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report;
NavigationManager.NavigateTo("fundvelo/keydata/Found");
}
private async void Missing() {
Report report = new MissingReport();
UserDataProvider.mapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report;
NavigationManager.NavigateTo("fundvelo/keydata/Missing");
}
private void Pending() {
if(NbrPendingReports > 0) {
NavigationManager.NavigateTo("fundvelo/pending_overview");
}
}
private async void Missing() {
Report report = new MissingReport();
UserDataProvider.mapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report;
NavigationManager.NavigateTo("fundvelo/keydata/Missing");
private string getOpacity() {
return NbrPendingReports > 0 ? "opacity:1.0" : "opacity:0.5";
}
}
}

+ 5
- 1
Pages/CaritasServiceFundVeloMissingConclusion.razor ファイルの表示

@@ -70,10 +70,14 @@
</MatIcon>
<MatSubtitle1 Class="w-100" Style="font-family:Ubuntu; text-align:left; font-weight:800; display:contents">@i18n["FinishedTextMissing_LostOffice_Address"]</MatSubtitle1>
</div>
} else {
} else if (ResposeStatus.Error == responseStatus) {
<Animate Animation="Animations.ZoomIn" Duration="TimeSpan.FromSeconds(2.5)">
<FailureImage></FailureImage>
</Animate>
} else {
<Animate Animation="Animations.ZoomIn" Duration="TimeSpan.FromSeconds(2.5)">
<WarningImage></WarningImage>
</Animate>
}
}
</div>

+ 100
- 0
Pages/CaritasServiceFundVeloPendingOverviewPage.razor ファイルの表示

@@ -0,0 +1,100 @@
@page "/fundvelo/pending_overview"
@using cwebplusApp.Shared.Services;
@using cwebplusApp.Shared.Models;
@inject NavigationManager NavigationManager
@inject PageHistoryManager PageHistoryManager
@inject ReportDataProvider ReportDataProvider
@inject ReportRepositoryService ReportRepositoryService
@inject IStringLocalizer<Resources> i18n;
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start w-100" style="padding-top: 1rem;">
<div class="mat-layout-grid w-100">
<div>
<MatTable RowClass="ReportRepositoryItem" Items="pendingReports" class="mat-elevation-z5" ShowPaging="false" UseSortHeaderRow="true"
OnRowDbClick="OnReportDblClicked" AllowSelection="true">
<MatTableHeader>
<th>Id</th>
<th>@i18n["Type"]</th>
<th>@i18n["Date"]</th>
<th>@i18n["Address"]</th>
<th>@i18n["Picture"]</th>
<th>@i18n["Action"]</th>
</MatTableHeader>
<MatTableRow>
<td style="display:inline-flex">
<div>
<MatIconButton Icon="play_circle_filled" OnClick="@(_ => SendReport(context))"></MatIconButton>
</div>
<div style="padding-top: 0.8rem">@context.ID</div>
</td>
<td>@translateType(context.ReportType)</td>
<td>@ReportRepositoryService.GetCurrentDateTimeFromMillis(context.ID)</td>
<td>@getAddress(context)</td>
<td>@getPicture(context)</td>
<td>
<MatIconButton Icon="delete_forever" OnClick="@(_ => DeleteReport(context))"></MatIconButton>
</td>
</MatTableRow>
</MatTable>
</div>
</div>
</div>
</div>
@code {
private List<ReportRepositoryItem> pendingReports = new();
private ReportRepositoryItem selectedReport;
protected async override void OnInitialized() {
base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
pendingReports.AddRange(await ReportRepositoryService.GetPendingFoundReports());
pendingReports.AddRange(await ReportRepositoryService.GetPendingMissingReports());
StateHasChanged();
}
private void OnReportDblClicked(object item) {
var report = item as ReportRepositoryItem;
if (report == null) {
selectedReport = null;
return;
}
selectedReport = report;
}
private string translateType(ReportRepositoryItem.Type type) {
return i18n.GetString("ReportType." + type);
}
private string getAddress(ReportRepositoryItem item) {
return ReportRepositoryItem.Type.FOUND.Equals(item.ReportType) ? ((FoundReportRepositoryItem)item).Report.GeographicInfo.Address : "";
}
private string getPicture(ReportRepositoryItem item) {
string picData = ReportRepositoryItem.Type.FOUND.Equals(item.ReportType) ? ((FoundReportRepositoryItem)item).Report.FotoString : ((MissingReportRepositoryItem)item).Report.FotoString;
return "";
}
private void DeleteReport(ReportRepositoryItem item) {
}
private void SendReport(ReportRepositoryItem item) {
ReportDataProvider.ReportRepositoryItem = item;
if (ReportRepositoryItem.Type.FOUND.Equals(item.ReportType)) {
ReportDataProvider.Report = ((FoundReportRepositoryItem)item).Report;
NavigationManager.NavigateTo("fundvelo/keydata/Found");
} else {
ReportDataProvider.Report = ((MissingReportRepositoryItem)item).Report;
NavigationManager.NavigateTo("fundvelo/keydata/Missing");
}
}
}

+ 10
- 5
Pages/IndexPage.razor ファイルの表示

@@ -48,11 +48,16 @@
showProgressCircle = true;
StateHasChanged();
try {
BicycleRestService.Initialize(Configuration);
await MasterDataService.SynchronizeMasterdata();
await BicycleRestService.TrySendPendingReports();
} catch (Exception) {
Toaster.ShowWarning(i18n.GetString("Warning.Masterdata.Title"), i18n.GetString("Warning.Masterdata.Msg"));
try {
BicycleRestService.Initialize(Configuration);
await MasterDataService.SynchronizeMasterdata();
} catch (Exception) {
Toaster.ShowWarning(i18n.GetString("Warning.Masterdata.Title"), i18n.GetString("Warning.Masterdata.Msg"));
}
int sent = await BicycleRestService.TrySendPendingReports();
if (sent > 0) {
Toaster.ShowSuccess(i18n.GetString("Info.SendPendigs.Title"), i18n.GetString("Info.SendPendigs.Msg", sent));
}
} finally {
showProgressCircle = false;
NavigateToNext();

+ 8
- 0
Shared/Models/ReportRepositoryItem.cs ファイルの表示

@@ -29,5 +29,13 @@ namespace cwebplusApp.Shared.Models {
return (ID == rri.ID);
}
}
public override int GetHashCode() {
return base.GetHashCode();
}
public override string ToString() {
return base.ToString();
}
}
}

+ 24
- 0
Shared/ResourceFiles/Resources.de.resx ファイルの表示

@@ -123,6 +123,9 @@
<data name="account" xml:space="preserve">
<value>Konto</value>
</data>
<data name="Action" xml:space="preserve">
<value>Aktion</value>
</data>
<data name="Address" xml:space="preserve">
<value>Adresse</value>
</data>
@@ -264,6 +267,9 @@
<data name="Continue" xml:space="preserve">
<value>Weiter</value>
</data>
<data name="Date" xml:space="preserve">
<value>Datum</value>
</data>
<data name="DevelopedBy" xml:space="preserve">
<value>Entwickelt durch</value>
</data>
@@ -366,6 +372,9 @@
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Fundvelo</value>
</data>
<data name="fundvelo/pending_overview" xml:space="preserve">
<value>Fundvelo &gt; Übersicht Pendente</value>
</data>
<data name="info" xml:space="preserve">
<value>Info</value>
</data>
@@ -375,6 +384,12 @@
<data name="Info.Report.Transmitting" xml:space="preserve">
<value>Am Übertragen der Meldung...</value>
</data>
<data name="Info.SendPendigs.Msg" xml:space="preserve">
<value>{0:d} ausstehende Berichte erfolgreich gesendet.</value>
</data>
<data name="Info.SendPendigs.Title" xml:space="preserve">
<value>Ausstehende Berichte erfolgreich gesendet!</value>
</data>
<data name="Lastname" xml:space="preserve">
<value>Nachname</value>
</data>
@@ -414,6 +429,9 @@
<data name="PickupContact" xml:space="preserve">
<value>Abholkontakt</value>
</data>
<data name="Picture" xml:space="preserve">
<value>Bild</value>
</data>
<data name="PlaceOfDiscovery" xml:space="preserve">
<value>Fundort</value>
</data>
@@ -426,6 +444,12 @@
<data name="Remark" xml:space="preserve">
<value>Bemerkung</value>
</data>
<data name="ReportType.FOUND" xml:space="preserve">
<value>Fundmeldung</value>
</data>
<data name="ReportType.MISSING" xml:space="preserve">
<value>Suchauftrag</value>
</data>
<data name="Salutation" xml:space="preserve">
<value>Anrede</value>
</data>

+ 26
- 2
Shared/ResourceFiles/Resources.fr.resx ファイルの表示

@@ -123,6 +123,9 @@
<data name="account" xml:space="preserve">
<value>Compte</value>
</data>
<data name="Action" xml:space="preserve">
<value>Action</value>
</data>
<data name="Address" xml:space="preserve">
<value>Adresse</value>
</data>
@@ -264,6 +267,9 @@
<data name="Continue" xml:space="preserve">
<value>Continue</value>
</data>
<data name="Date" xml:space="preserve">
<value>Date</value>
</data>
<data name="DevelopedBy" xml:space="preserve">
<value>Développé par</value>
</data>
@@ -274,10 +280,10 @@
<value>Erreur {0:d} lors de la détermination de la position géographique.</value>
</data>
<data name="Error.IOException.Msg" xml:space="preserve">
<value>The file could not be read.</value>
<value>Le fichier n'a pas pu être lu.</value>
</data>
<data name="Error.IOException.Title" xml:space="preserve">
<value>Error while reading file!</value>
<value>Erreur lors de la lecture du fichier !</value>
</data>
<data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve">
<value>La taille de l'image sélectionnée ou de la photo prise dépasse la taille maximale autorisée de {0:d} MB.</value>
@@ -366,6 +372,9 @@
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Velo</value>
</data>
<data name="fundvelo/pending_overview" xml:space="preserve">
<value>Velo &gt; Raportes en attente</value>
</data>
<data name="info" xml:space="preserve">
<value>Information</value>
</data>
@@ -375,6 +384,12 @@
<data name="Info.Report.Transmitting" xml:space="preserve">
<value>Transmettant le rapport...</value>
</data>
<data name="Info.SendPendigs.Msg" xml:space="preserve">
<value>{0:d} rapports en attente envoyés avec succès.</value>
</data>
<data name="Info.SendPendigs.Title" xml:space="preserve">
<value>Rapports en attente envoyés avec succès !</value>
</data>
<data name="Lastname" xml:space="preserve">
<value>Nom de famille</value>
</data>
@@ -414,6 +429,9 @@
<data name="PickupContact" xml:space="preserve">
<value>Contact de ramassage</value>
</data>
<data name="Picture" xml:space="preserve">
<value>Photo</value>
</data>
<data name="PlaceOfDiscovery" xml:space="preserve">
<value>Lieu de découverte</value>
</data>
@@ -426,6 +444,12 @@
<data name="Remark" xml:space="preserve">
<value>Comment</value>
</data>
<data name="ReportType.FOUND" xml:space="preserve">
<value>Rapport de découverte</value>
</data>
<data name="ReportType.MISSING" xml:space="preserve">
<value>Rapport de disparition</value>
</data>
<data name="Salutation" xml:space="preserve">
<value>Salutation</value>
</data>

+ 25
- 1
Shared/ResourceFiles/Resources.it.resx ファイルの表示

@@ -123,6 +123,9 @@
<data name="account" xml:space="preserve">
<value>Profilo</value>
</data>
<data name="Action" xml:space="preserve">
<value>Azione</value>
</data>
<data name="Address" xml:space="preserve">
<value>Indirizzo</value>
</data>
@@ -264,6 +267,9 @@
<data name="Continue" xml:space="preserve">
<value>Continua</value>
</data>
<data name="Date" xml:space="preserve">
<value>Data</value>
</data>
<data name="DevelopedBy" xml:space="preserve">
<value>Sviluppata da</value>
</data>
@@ -366,6 +372,9 @@
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Bicicletta</value>
</data>
<data name="fundvelo/pending_overview" xml:space="preserve">
<value>Bicicletta &gt; Raporti in attesa</value>
</data>
<data name="info" xml:space="preserve">
<value>Informazione</value>
</data>
@@ -375,6 +384,12 @@
<data name="Info.Report.Transmitting" xml:space="preserve">
<value>Trasmissione del rapporto...</value>
</data>
<data name="Info.SendPendigs.Msg" xml:space="preserve">
<value>{0:d} rapporti in sospeso inviati con successo.</value>
</data>
<data name="Info.SendPendigs.Title" xml:space="preserve">
<value>Rapporti in sospeso inviati con successo!</value>
</data>
<data name="Lastname" xml:space="preserve">
<value>Cognome</value>
</data>
@@ -414,6 +429,9 @@
<data name="PickupContact" xml:space="preserve">
<value>Contatto di prelievo</value>
</data>
<data name="Picture" xml:space="preserve">
<value>Immagine</value>
</data>
<data name="PlaceOfDiscovery" xml:space="preserve">
<value>Luogo del ritrovamento</value>
</data>
@@ -426,6 +444,12 @@
<data name="Remark" xml:space="preserve">
<value>Commento</value>
</data>
<data name="ReportType.FOUND" xml:space="preserve">
<value>Rapporto di ritrovamento</value>
</data>
<data name="ReportType.MISSING" xml:space="preserve">
<value>Rapporto di perdita</value>
</data>
<data name="Salutation" xml:space="preserve">
<value>Saluto</value>
</data>
@@ -451,7 +475,7 @@
<value>Dati anagrafici non disponibili!</value>
</data>
<data name="Warning.NoConnection.Msg" xml:space="preserve">
<value>Il messaggio non può essere trasmesso. È stato salvato e sarà trasmesso al più presto.</value>
<value>Il rapporto non può essere trasmesso. È stato salvato e sarà trasmesso al più presto.</value>
</data>
<data name="Warning.NoConnection.Title" xml:space="preserve">
<value>Nessuna connessione a Internet!</value>

+ 24
- 0
Shared/ResourceFiles/Resources.resx ファイルの表示

@@ -123,6 +123,9 @@
<data name="account" xml:space="preserve">
<value>Account</value>
</data>
<data name="Action" xml:space="preserve">
<value>Action</value>
</data>
<data name="Address" xml:space="preserve">
<value>Address</value>
</data>
@@ -264,6 +267,9 @@
<data name="Continue" xml:space="preserve">
<value>Continue</value>
</data>
<data name="Date" xml:space="preserve">
<value>Date</value>
</data>
<data name="DevelopedBy" xml:space="preserve">
<value>Developed by</value>
</data>
@@ -366,6 +372,9 @@
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Bicycle</value>
</data>
<data name="fundvelo/pending_overview" xml:space="preserve">
<value>Bicycle &gt; Overview Pendigs</value>
</data>
<data name="info" xml:space="preserve">
<value>Info</value>
</data>
@@ -375,6 +384,12 @@
<data name="Info.Report.Transmitting" xml:space="preserve">
<value>Transmitting report...</value>
</data>
<data name="Info.SendPendigs.Msg" xml:space="preserve">
<value>{0:d} pending reports successfully sent.</value>
</data>
<data name="Info.SendPendigs.Title" xml:space="preserve">
<value>Pending reports successfully sent!</value>
</data>
<data name="Lastname" xml:space="preserve">
<value>Last name</value>
</data>
@@ -414,6 +429,9 @@
<data name="PickupContact" xml:space="preserve">
<value>Pickup Contact</value>
</data>
<data name="Picture" xml:space="preserve">
<value>Picture</value>
</data>
<data name="PlaceOfDiscovery" xml:space="preserve">
<value>Place Of Discovery</value>
</data>
@@ -426,6 +444,12 @@
<data name="Remark" xml:space="preserve">
<value>Remark</value>
</data>
<data name="ReportType.FOUND" xml:space="preserve">
<value>Found report</value>
</data>
<data name="ReportType.MISSING" xml:space="preserve">
<value>Missing report</value>
</data>
<data name="Salutation" xml:space="preserve">
<value>Salutation</value>
</data>

+ 21
- 11
Shared/Services/BicycleRestService.cs ファイルの表示

@@ -88,7 +88,7 @@ namespace cwebplusApp.Shared.Services {
public async Task<ReportResponse> SendFoundReport(Report report) {
string subResourceUrl = configuration.GetValue<string>("subresource_url_foundreport");
return await SendReport(report, subResourceUrl, new FoundReportRepositoryItem((FoundReport)report, GetCurrentTimeInMillis()));
return await SendReport(report, subResourceUrl, new FoundReportRepositoryItem((FoundReport)report, ReportRepositoryService.GetCurrentTimeInMillis()));
}
private async Task<ReportResponse> SendFoundReport(FoundReportRepositoryItem reportRepositoryItem) {
@@ -98,7 +98,7 @@ namespace cwebplusApp.Shared.Services {
public async Task<ReportResponse> SendMissingReport(Report report) {
string subResourceUrl = configuration.GetValue<string>("subresource_url_missingreport");
return await SendReport(report, subResourceUrl, new MissingReportRepositoryItem((MissingReport)report, GetCurrentTimeInMillis()));
return await SendReport(report, subResourceUrl, new MissingReportRepositoryItem((MissingReport)report, ReportRepositoryService.GetCurrentTimeInMillis()));
}
public async Task<ReportResponse> SendMissingReport(MissingReportRepositoryItem reportRepositoryItem) {
@@ -106,31 +106,45 @@ namespace cwebplusApp.Shared.Services {
return await SendReport(reportRepositoryItem.Report, subResourceUrl, reportRepositoryItem);
}
public async Task TrySendPendingReports() {
await TrySendFoundPendingReports();
await TrySendMissingPendingReports();
public async Task<int> TrySendPendingReports() {
int sent = 0;
if (onlineStatusProvider.Online) {
sent = await TrySendFoundPendingReports();
sent += await TrySendMissingPendingReports();
}
return sent;
}
public async Task TrySendFoundPendingReports() {
public async Task<int> TrySendFoundPendingReports() {
int sent = 0;
List<FoundReportRepositoryItem> pendingFoundReports = await reportRepositoryService.GetPendingFoundReports();
foreach (FoundReportRepositoryItem item in pendingFoundReports) {
try {
ReportResponse response = await SendFoundReport(item);
if (HttpStatusCode.OK == response.StatusCode) {
sent++;
}
} catch (Exception) {
continue;
}
}
return sent;
}
public async Task TrySendMissingPendingReports() {
public async Task<int> TrySendMissingPendingReports() {
int sent = 0;
List<MissingReportRepositoryItem> pendingMissingReports = await reportRepositoryService.GetPendingMissingReports();
foreach (MissingReportRepositoryItem item in pendingMissingReports) {
try {
ReportResponse response = await SendMissingReport(item);
if (HttpStatusCode.OK == response.StatusCode) {
sent++;
}
} catch (Exception) {
continue;
}
}
return sent;
}
protected async Task<ReportResponse> SendReport(Report report, string subResourceUrl, ReportRepositoryItem reportRepositoryItem) {
@@ -157,9 +171,5 @@ namespace cwebplusApp.Shared.Services {
await reportRepositoryService.SaveReport(reportRepositoryItem);
return response;
}
private long GetCurrentTimeInMillis() {
return DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
}
}

+ 3
- 3
Shared/Services/IBicycleRestService.cs ファイルの表示

@@ -18,10 +18,10 @@ namespace cwebplusApp.Shared.Services {
Task<ReportResponse> SendMissingReport(Report report);
Task TrySendPendingReports();
Task<int> TrySendPendingReports();
Task TrySendFoundPendingReports();
Task<int> TrySendFoundPendingReports();
Task TrySendMissingPendingReports();
Task<int> TrySendMissingPendingReports();
}
}

+ 16
- 0
Shared/Services/ReportRepositoryService.cs ファイルの表示

@@ -107,6 +107,12 @@ namespace cwebplusApp.Shared.Services {
await jsRuntime.InvokeVoidAsync("BlazorSetLocalStorage", KeyNameMissingReports, json);
}
public async ValueTask<int> GetNbrOfPendingReports() {
List<FoundReportRepositoryItem> foundReportRepositoryItems = await GetPendingFoundReports();
List<MissingReportRepositoryItem> missingReportRepositoryItems = await GetPendingMissingReports();
return foundReportRepositoryItems.Count + missingReportRepositoryItems.Count;
}
// This method is called from BlazorRegisterStorageEvent when the storage changed
[JSInvokable]
public void OnStorageUpdated(string key) {
@@ -115,5 +121,15 @@ namespace cwebplusApp.Shared.Services {
Changed?.Invoke(this, EventArgs.Empty);
}
}
public static long GetCurrentTimeInMillis() {
return DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
public static string GetCurrentDateTimeFromMillis(long millis) {
TimeSpan time = TimeSpan.FromMilliseconds(millis);
DateTime date = new DateTime() + time;
return date.ToString("dd.MM.yyyy HH:mm:ss");
}
}
}

+ 1
- 0
cwebplusApp.csproj.user ファイルの表示

@@ -6,5 +6,6 @@
<PropertyGroup>
<ActiveDebugProfile>CaritasPWA</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\Work\Caritas\cwebplusApp\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

+ 1
- 0
wwwroot/appsettings.json ファイルの表示

@@ -1,5 +1,6 @@
{
"host_base_url": "https://integrate.dynalias.net:9443/Fundvelo/",
//"host_base_url": "https://vm-caritas/Fundvelo/",
"subresource_url_colors": "api/{0}/{1}/fundvelo/colors",
"subresource_url_brands": "api/{0}/{1}/fundvelo/brands",
"subresource_url_types": "api/{0}/{1}/fundvelo/types",

+ 8
- 0
wwwroot/css/app.css ファイルの表示

@@ -235,4 +235,12 @@ div.mat-select.required span#outlined-select-label.mdc-floating-label::after {
.mat-toast-container.mat-toast-bottom-center > div {
width: 95%;
}
.pending_batch {
background-color: royalblue;
color: white;
position: absolute;
z-index: 3;
transform: translate(-24px, -8px)
}

バイナリ
wwwroot/images/batch_pending.png ファイルの表示


+ 1
- 0
wwwroot/service-worker.js ファイルの表示

@@ -27,6 +27,7 @@ const assets = [
'images/batch_kulturlegi.png',
'images/batch_markt.png',
'images/batch_missing.png',
'images/batch_pending.png',
'images/caritas_logo.png',
'images/integrate_logo.png',
'images/done.png',

読み込み中…
キャンセル
保存