public async Task ReportLastSessionCrash() { if (await Crashes.HasCrashedInLastSessionAsync()) { //Functions.CreateZipFile(); var report = await Crashes.GetLastSessionCrashReportAsync(); if (report != null) { string macAddress = await DependencyService.Get <IWifiHandler>().GetWifiMacAddress(); UserLog u = new UserLog() { HasTheAppCrashed = true, OnRequest = false, LogName = report.AppErrorTime.ToString("yyyy-MM-dd HH:mm:ss"), Platform = $"{DeviceInfo.Platform.ToString()} {DeviceInfo.VersionString}", Device = $"{DeviceInfo.Manufacturer} {DeviceInfo.Model} {macAddress}", Comment = null, ErrorTime = report.AppErrorTime.DateTime, Message = MessageFromStackTrace(report.StackTrace), StackTrace = report.StackTrace, CreatedOn = DateTime.Now, CreatedBy = RuntimeSettings.CurrentUser.UserId, TenantId = RuntimeSettings.CurrentUser.TenantId }; UserLogKeeper.Items.Add(u); await UserLogKeeper.AddToSyncQueue(); try { File f = new File() { Name = report.AppErrorTime.ToString("yyyy-MM-dd HH:mm:ss"), Link = CreateSnapshotOfCurrentLog(), UserLogId = u.SqliteId }; FileKeeper fileKeeper = new FileKeeper(userLogId: u.SqliteId); fileKeeper.IsOfflineKeeper = true; fileKeeper.Items.Add(f); //await fileKeeper.DeleteTable(); await fileKeeper.AddToSyncQueue(); } catch (Exception ex) { throw; } } } }
public async Task OpenFile(File f) { Uri uri = null; if (f.IsUploaded == true) { if (!string.IsNullOrEmpty(f.Token) && !string.IsNullOrEmpty(f.Type)) { uri = new Uri(Secrets.ApiAddress + RuntimeSettings.FilesPath + $"{f.Token}.{f.Type.Trim()}"); } } else { if (System.IO.File.Exists(f.Link)) { uri = new Uri(f.Link); } } if (uri != null) { if (f.IsUploaded == true) { await Browser.OpenAsync(uri); } else { await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(f.Link) }); } } else { await App.Current.MainPage.DisplayAlert("Plik niedostępny", $"Plik nie jest jeszcze dostępny na serwerze({ f.Token}.{f.Type.Trim()}) ponieważ {f.CreatedByName} nie zsynchronizował jeszcze plików..", "OK"); } }