PWA Fundvelo der Caritas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CaritasServiceFundVeloFoundKeyDataPage.razor 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. @page "/fundvelo/keydata/Found"
  2. @inherits CaritasServiceFundVeloKeyDataPageBase
  3. @implements IDisposable;
  4. @using cwebplusApp.Shared.Models;
  5. @using cwebplusApp.Shared.Services;
  6. @using System.Globalization;
  7. @using Microsoft.AspNetCore.Components.Forms;
  8. @using System.IO;
  9. @inject NavigationManager NavigationManager
  10. @inject IStringLocalizer<Resources> I18n
  11. @inject PageHistoryManager PageHistoryManager
  12. @inject MasterDataService MasterDataService
  13. @inject Toaster Toaster
  14. @inject IJSRuntime JS
  15. @inject ReportDataProvider ReportDataProvider
  16. @inject OnlineStatusProvider OnlineStatusProvider
  17. @inject InputCursorHandler InputCursorHandler
  18. @inject PermissionsProvider PermissionsProvider
  19. <div class="row px-3 h-100">
  20. <div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em">
  21. <h2>@I18n["FoundBike"]</h2>
  22. </div>
  23. <div class="row no-gutters align-items-center justify-content-center w-100">
  24. <div class="mat-layout-grid w-100">
  25. <div class="mat-layout-grid-inner">
  26. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-1 justify-content-center" style="text-align: center">
  27. <div>
  28. <InputFile class="inputFile" id="camera" type="file" name="camera" accept="image/*" capture="environment" OnChange="@OnGatheringPicture" />
  29. <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
  30. <label for="camera">
  31. <svg xmlns="http://www.w3.org/2000/svg" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
  32. <path d="M0 0h21v21H0V0z" fill="none" />
  33. <path d="M20 6h-4.05l-1.83-2H9.88L8.05 6H4v12h16V6zm-8 11c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" opacity=".3" />
  34. <path d="M4 20h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2zM4 6h4.05l1.83-2h4.24l1.83 2H20v12H4V6zm8 1c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0 8c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z" />
  35. </svg>
  36. </label>
  37. </MatRipple>
  38. </div>
  39. <div style="margin-top:1rem">
  40. <InputFile class="inputFile" id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" OnChange="@OnGatheringPicture" />
  41. <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
  42. <label for="file">
  43. <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
  44. <g><rect fill="none" height="24" width="24" /></g>
  45. <g>
  46. <g>
  47. <path d="M13,4H6v16h12V9h-5V4z M16,15h-3v4h-2v-4H8l4.01-4L16,15z" opacity=".3" />
  48. <path d="M14,2H6C4.9,2,4.01,2.9,4.01,4L4,20c0,1.1,0.89,2,1.99,2H18c1.1,0,2-0.9,2-2V8L14,2z M18,20H6V4h7v5h5V20z" />
  49. <polygon points="8,15 11,15 11,19 13,19 13,15 16,15 12.01,11" />
  50. </g>
  51. </g>
  52. </svg>
  53. </label>
  54. </MatRipple>
  55. </div>
  56. </div>
  57. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-3">
  58. <div>
  59. <MatCard Id="bikePic" Class="fv-mat-card">
  60. <MatCardContent>
  61. <MatCardMedia Square="true" ImageUrl="@imgUrl">
  62. @if (loading) {
  63. <MatProgressCircle Indeterminate="true" Size="MatProgressCircleSize.Medium" />
  64. }
  65. </MatCardMedia>
  66. </MatCardContent>
  67. </MatCard>
  68. </div>
  69. </div>
  70. @if (OnlineStatusProvider.Online) {
  71. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-1 justify-content-center" style="text-align: center">
  72. @if (IsGeoLocationAllowed) {
  73. <div>
  74. <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default" @onclick="InitializeDeviceMapPosition">
  75. <label>
  76. <svg xmlns="http://www.w3.org/2000/svg" height="48px" width="48px" viewBox="0 0 24 24" fill="#000000">
  77. <path d="M0 0h24v24H0V0z" fill="none" />
  78. <path d="M13 3.06V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06c-.46-4.17-3.77-7.48-7.94-7.94zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z" />
  79. <circle cx="12" cy="12" opacity=".3" r="2" />
  80. <path d="M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z" />
  81. </svg>
  82. </label>
  83. </MatRipple>
  84. </div>
  85. }
  86. <div style="margin-top:1rem">
  87. <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default" @onclick="InitializeBicycleMapPosition">
  88. <label>
  89. <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 20 20" height="48px" viewBox="0 0 20 20" width="48px" fill="#000000">
  90. <g><rect fill="none" height="20" width="20" /></g>
  91. <g><g><path d="M15.5,9h-0.68l-1.58-4.34C13.1,4.26,12.72,4,12.3,4H10v1h2.3l1.46,4H8.75L8.38,8H10V7H6v1h1.32l1.46,4H7.95 C7.7,10.19,6.13,8.86,4.2,9.01c-1.64,0.13-3.01,1.46-3.18,3.1C0.8,14.25,2.41,16,4.5,16c1.79,0,3.21-1.29,3.45-3h4.1 c0.25,1.81,1.83,3.14,3.75,2.99c1.64-0.13,3.01-1.46,3.18-3.1C19.2,10.75,17.59,9,15.5,9z M6.95,13c-0.23,1.15-1.22,2-2.45,2 C3.1,15,2,13.9,2,12.5S3.1,10,4.5,10c1.23,0,2.23,0.85,2.45,2H4v1H6.95z M12.05,12H9.84l-0.73-2h3.92 C12.5,10.52,12.16,11.22,12.05,12z M15.5,15c-1.4,0-2.5-1.1-2.5-2.5c0-0.94,0.5-1.73,1.24-2.16l1.03,2.83l0.94-0.34l-1.02-2.8 C15.3,10.02,15.4,10,15.5,10c1.4,0,2.5,1.1,2.5,2.5S16.9,15,15.5,15z" /></g></g>
  92. </svg>
  93. </label>
  94. </MatRipple>
  95. </div>
  96. </div>
  97. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-3">
  98. <div class="w-100 fv-osm-tile map-wrapper">
  99. <Map @ref="mapRef" MapOptions="@mapOptions" AfterRender="AfterRenderMap"></Map>
  100. </div>
  101. </div>
  102. }
  103. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-4-desktop">
  104. <div class="mat-layout-grid-inner">
  105. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  106. <MatStringField Class="w-100 form-check-label" Label="@getAddressLbl()" Outlined="true" Required="true" Type="text" @bind-Value="@bicycleGeoPosition.Address"
  107. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="50"
  108. OnFocusOut="@TransformAdressToDeviceMapLocation"></MatStringField>
  109. </div>
  110. @if (OnlineStatusProvider.Online) {
  111. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  112. <MatStringField Class="w-100 form-check-label" Label="@getZipCityLbl()" Outlined="true" Required="true" type="text" @bind-Value="@bicycleGeoPosition.DisplayCity"
  113. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"
  114. OnFocusOut="@TransformAdressToDeviceMapLocation"></MatStringField>
  115. </div>
  116. } else {
  117. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
  118. <div class="outlined">
  119. <MatAutocompleteList TItem="ZipCity" FullWidth="true" Label="@getZipCityLbl()" Required="true" Items="@ZipCities" OnTextChanged="setZipCityValue" @bind-Value="SelectedZipCity" CustomStringSelector="@(i => i?.Zip_City)"
  120. ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  121. <ItemTemplate>
  122. <div>
  123. <span>@context?.Zip_City</span>
  124. </div>
  125. </ItemTemplate>
  126. </MatAutocompleteList>
  127. </div>
  128. </div>
  129. }
  130. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  131. <MatTextField Class="w-100 form-check-label italic" Label="@I18n["Latitude"]" Outlined="true" ReadOnly="true" @bind-Value="@bicycleGeoPosition.Latitude"
  132. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
  133. </div>
  134. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  135. <MatTextField Class="w-100 form-check-label italic" Label="@I18n["Longitude"]" Outlined="true" ReadOnly="true" @bind-Value="@bicycleGeoPosition.Longitude"
  136. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
  141. <div class="mat-layout-grid-inner">
  142. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-3-tablet mat-layout-grid-cell-span-3-desktop">
  143. <MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@I18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)"
  144. @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  145. <ItemTemplate>
  146. <div>
  147. <span class="btn-sm" style="background-color:@context.Code;
  148. display:initial;
  149. border:1px solid black;
  150. box-shadow:0.2em 0.2em 0.3em 0.025em #3f4244" />
  151. <span class="btn">@context?.Bezeichnung</span>
  152. </div>
  153. </ItemTemplate>
  154. </MatSelectValue>
  155. </div>
  156. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-3-tablet mat-layout-grid-cell-span-3-desktop">
  157. <div class="outlined">
  158. <MatAutocompleteList TItem="Brand" FullWidth="true" Label="@I18n["Brand"]" Required="true" Items="@Brands" OnTextChanged="setBrandValue" @bind-Value="SelectedBrand" CustomStringSelector="@(i => i?.Bezeichnung)"
  159. ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  160. <ItemTemplate>
  161. <div>
  162. <span>@context?.Bezeichnung</span>
  163. </div>
  164. </ItemTemplate>
  165. </MatAutocompleteList>
  166. </div>
  167. </div>
  168. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-3-tablet mat-layout-grid-cell-span-3-desktop">
  169. <div class="outlined">
  170. <MatAutocompleteList TItem="BicycleType" FullWidth="true" Label="@I18n["Type"]" Required="true" Items="@BicycleTypes" OnTextChanged="setBcTypeValue" @bind-Value="SelectedBcType" CustomStringSelector="@(i=>i?.Bezeichnung)"
  171. ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  172. <ItemTemplate>
  173. <div>
  174. <span>@context?.Bezeichnung</span>
  175. </div>
  176. </ItemTemplate>
  177. </MatAutocompleteList>
  178. </div>
  179. </div>
  180. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-3-tablet mat-layout-grid-cell-span-3-desktop">
  181. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  182. <MatStringField Class="w-100 form-check-label" Label="@I18n["FrameNumber"]" Outlined="true" type="text" @bind-Value="frameNumber"
  183. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="20"></MatStringField>
  184. </div>
  185. </div>
  186. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-12-phone mat-layout-grid-cell-span-12-tablet mat-layout-grid-cell-span-12-desktop">
  187. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
  188. <MatStringField Class="w-100 form-check-label" Label="@I18n["Remark"]" Outlined="true" type="text" @bind-Value="remark"
  189. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="1000" rows="1" TextArea="true"></MatStringField>
  190. </div>
  191. </div>
  192. <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
  193. <div>
  194. <MatCheckbox @bind-Value="@abholadresseIsNotContact" Label="@I18n["AlternatePickupContact"]"
  195. @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync"></MatCheckbox>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em;padding-top:2em">
  204. <div class="col" style="padding-right:0.5em">
  205. <MatButton Class="w-100" Outlined="true" @onclick="Cancel">@I18n["Cancel"]</MatButton>
  206. </div>
  207. <div class="col" style="padding-left:0.5em">
  208. <MatButton Class="w-100" Raised="true" @onclick="Next">@I18n["Continue"]</MatButton>
  209. </div>
  210. </div>
  211. </div>
  212. @code {
  213. private static long MAX_FILE_SIZE = 3145728; //3MB
  214. private string imgUrl = string.Empty;
  215. private Boolean loading = false;
  216. private ColorItem selectedColor;
  217. private bool IsGeoLocationAllowed = false;
  218. private string brandStringValue;
  219. private Brand selectedBrand;
  220. private Brand SelectedBrand {
  221. get { return selectedBrand; }
  222. set { selectedBrand = (value != null) ? value : new Brand(-999, brandStringValue); }
  223. }
  224. private void setBrandValue(string value) {
  225. brandStringValue = value;
  226. selectedBrand = null;
  227. }
  228. private string bcTypeStringValue;
  229. private BicycleType selectedBcType;
  230. private BicycleType SelectedBcType {
  231. get { return selectedBcType; }
  232. set { selectedBcType = (value != null) ? value : new BicycleType(-999, bcTypeStringValue); }
  233. }
  234. private void setBcTypeValue(string value) {
  235. bcTypeStringValue = value;
  236. }
  237. private string zipCityStringValue;
  238. private ZipCity selectedZipCity;
  239. private ZipCity SelectedZipCity {
  240. get { return selectedZipCity; }
  241. set { selectedZipCity = (value != null) ? value : new ZipCity(zipCityStringValue); }
  242. }
  243. private void setZipCityValue(string value) {
  244. zipCityStringValue = value;
  245. selectedZipCity = null;
  246. }
  247. private string frameNumber;
  248. private string remark;
  249. private bool abholadresseIsNotContact;
  250. public void Dispose() {
  251. OnlineStatusProvider.RemoveOnlineStatusChangeCallBack(OnOnlineStatusChanged);
  252. }
  253. protected async override void OnInitialized() {
  254. base.OnInitialized();
  255. await GetColors();
  256. await GetBicycleTypes();
  257. await GetBrands();
  258. await GetZipCities();
  259. RefreshGUIFromDto();
  260. OnlineStatusProvider.AddOnlineStatusChangeCallBack(OnOnlineStatusChanged);
  261. PermissionsProvider.SetGeoLocationPermissionChangeCallBack(OnGeoLocationPermissionChanged);
  262. StateHasChanged();
  263. }
  264. private void OnOnlineStatusChanged(bool isOnline) {
  265. StateHasChanged();
  266. }
  267. private async void OnGeoLocationPermissionChanged(bool allowed) {
  268. IsGeoLocationAllowed = allowed;
  269. MouseEvent mouseEvent = new MouseEvent();
  270. mouseEvent.LatLng = await InitializeDeviceMapPosition();
  271. await OnMouseMapClicked(mouseEvent);
  272. StateHasChanged();
  273. }
  274. private async void AfterRenderMap() {
  275. FoundReport report = ReportDataProvider.GetFoundReport();
  276. MouseEvent mouseEvent = new MouseEvent();
  277. LatLng coordinates;
  278. LatLng devicePosition = await InitializeDeviceMapPosition();
  279. if (report != null && ((report.GeographicInfo.Latitude != 0 && report.GeographicInfo.Longitude != 0) ||
  280. (ReportDataProvider.ReportRepositoryItem != null && ReportDataProvider.ReportRepositoryItem.ID != 0))) {
  281. bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
  282. coordinates = new LatLng(report.GeographicInfo.Latitude, report.GeographicInfo.Longitude);
  283. mouseEvent.LatLng = coordinates;
  284. await InitializeBicycleMapPosition();
  285. await AddBicycleMarkerOnClickPosition(mouseEvent);
  286. StateHasChanged();
  287. } else { // Set bicycle postion equal to device position
  288. coordinates = new LatLng(devicePosition.Lat, devicePosition.Lng);
  289. mouseEvent.LatLng = coordinates;
  290. await OnMouseMapClicked(mouseEvent);
  291. }
  292. StateHasChanged();
  293. }
  294. private Brand getBrand(Brand brand) {
  295. return brand != null ? brand : new Brand(-999, "Test");
  296. }
  297. private async Task GetColors() {
  298. await MasterDataService.GetColors();
  299. }
  300. private async Task GetBicycleTypes() {
  301. await MasterDataService.GetBicycleTypes();
  302. }
  303. private async Task GetBrands() {
  304. await MasterDataService.GetBrands();
  305. }
  306. private async Task GetZipCities() {
  307. await MasterDataService.GetZipCities();
  308. }
  309. private ColorItem[] Colors {
  310. get => MasterDataService.Colors;
  311. }
  312. private BicycleType[] BicycleTypes {
  313. get => MasterDataService.BicycleTypes;
  314. }
  315. private Brand[] Brands {
  316. get => MasterDataService.Brands;
  317. }
  318. private ZipCity[] ZipCities {
  319. get => MasterDataService.ZipCities;
  320. }
  321. private void Next() {
  322. UpdateDtoFromGUI();
  323. PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
  324. try {
  325. Validator.ValidateFoundReportKeyData(ReportDataProvider.GetFoundReport());
  326. if (abholadresseIsNotContact) {
  327. NavigationManager.NavigateTo("fundvelo/alternate_pickup");
  328. } else {
  329. NavigationManager.NavigateTo("fundvelo/account/Found");
  330. }
  331. } catch (ArgumentException) {
  332. Toaster.ShowWarning(I18n.GetString("Warning.MandatoryFields.Title"), I18n.GetString("Warning.MandatoryFields.Msg"));
  333. }
  334. }
  335. private void Cancel() {
  336. NavigationManager.NavigateTo("caritas_services");
  337. }
  338. private string getAddressLbl() {
  339. return I18n.GetString("Street");
  340. }
  341. private string getZipCityLbl() {
  342. return String.Format("{0} {1}", I18n.GetString("Zip"), I18n.GetString("City"));
  343. }
  344. private async Task OnGatheringPicture(InputFileChangeEventArgs e) {
  345. IBrowserFile imgFile = e.File;
  346. var buffer = new byte[imgFile.Size];
  347. imgUrl = string.Empty;
  348. loading = true;
  349. StateHasChanged();
  350. try {
  351. using (var stream = imgFile.OpenReadStream(MAX_FILE_SIZE)) {
  352. await stream.ReadAsync(buffer);
  353. imgUrl = $"data:{imgFile.ContentType};base64,{Convert.ToBase64String(buffer)}";
  354. await stream.DisposeAsync();
  355. }
  356. } catch (IOException ex) {
  357. Console.WriteLine("Ex.Message is: {0}.", ex.Message);
  358. if (ex.Message.Contains("exceeds the maximum of")) {
  359. Toaster.ShowError(I18n.GetString("Error.PhotoOrPictureToBig.Title"), I18n.GetString("Error.PhotoOrPictureToBig.Msg", MAX_FILE_SIZE / (1024 * 1024)));
  360. } else {
  361. Toaster.ShowError(I18n.GetString("Error.IOException.Title"), I18n.GetString("Error.IOException.Msg"));
  362. }
  363. } catch (JSException ex) {
  364. Console.WriteLine("Ex.Message is: {0}.", ex.Message);
  365. } finally {
  366. Array.Clear(buffer, 0, buffer.Length);
  367. buffer = null;
  368. loading = false;
  369. StateHasChanged();
  370. }
  371. }
  372. private async void RefreshGUIFromDto() {
  373. FoundReport report = ReportDataProvider.GetFoundReport();
  374. bicycleGeoPosition.Address = report.GeographicInfo.Address;
  375. bicycleGeoPosition.Zip = report.GeographicInfo.Postcode;
  376. bicycleGeoPosition.City = report.GeographicInfo.Town;
  377. bicycleGeoPosition.Latitude = report.GeographicInfo.Latitude;
  378. bicycleGeoPosition.Longitude = report.GeographicInfo.Longitude;
  379. if (OnlineStatusProvider.Online) {
  380. bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
  381. } else {
  382. setZipCityValue(report.GeographicInfo.Postcode + " " + report.GeographicInfo.Town);
  383. SelectedZipCity = new ZipCity(zipCityStringValue);
  384. }
  385. imgUrl = report.FotoString;
  386. selectedColor = Array.Find(Colors, color => color.Id == report.FarbeId);
  387. selectedBrand = String.IsNullOrEmpty(report.NeueMarke) ? Array.Find(Brands, brand => brand.Id == report.MarkeId) : new Brand(-999, report.NeueMarke);
  388. selectedBcType = Array.Find(BicycleTypes, bcType => bcType.Id == report.TypId);
  389. frameNumber = report.RahmenNummer;
  390. remark = report.Bemerkung;
  391. abholadresseIsNotContact = !report.AbholadresseIstKontakt;
  392. StateHasChanged();
  393. }
  394. private void UpdateDtoFromGUI() {
  395. FoundReport report = ReportDataProvider.GetFoundReport();
  396. report.GeographicInfo.Address = bicycleGeoPosition.Address;
  397. if (OnlineStatusProvider.Online) {
  398. report.GeographicInfo.Postcode = bicycleGeoPosition.Zip;
  399. report.GeographicInfo.Town = bicycleGeoPosition.City;
  400. } else {
  401. report.GeographicInfo.Postcode = SelectedZipCity.Zip;
  402. report.GeographicInfo.Town = SelectedZipCity.City;
  403. }
  404. report.GeographicInfo.Latitude = bicycleGeoPosition.Latitude;
  405. report.GeographicInfo.Longitude = bicycleGeoPosition.Longitude;
  406. report.FotoString = imgUrl;
  407. report.FarbeId = selectedColor != null ? selectedColor.Id : null;
  408. report.TypId = selectedBcType != null ? selectedBcType.Id : null;
  409. if (SelectedBrand != null) {
  410. if (SelectedBrand.Id == -999) {
  411. report.NeueMarke = SelectedBrand.Bezeichnung;
  412. report.MarkeId = null;
  413. } else {
  414. report.MarkeId = SelectedBrand.Id;
  415. }
  416. }
  417. report.RahmenNummer = frameNumber;
  418. report.Bemerkung = remark;
  419. report.AbholadresseIstKontakt = !abholadresseIsNotContact;
  420. }
  421. private async void TransformAdressToDeviceMapLocation() {
  422. bicycleGeoPosition.DisplayCity = bicycleGeoPosition.DisplayCity; // Hack, force a decode of zip and city
  423. await ShowBicycleGeoLocation(true);
  424. StateHasChanged();
  425. }
  426. }