private async Task SyncBackups(JobParameters args) { if (!Mvx.IoCProvider.CanResolve <IMvxFileStore>()) { return; } var settingsManager = new SettingsManager(new SettingsAdapter()); try { DataAccess.ApplicationContext.DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), DatabaseConstants.DB_NAME); await new BackupManager(new OneDriveService(new OneDriveAuthenticator()), Mvx.IoCProvider.Resolve <IMvxFileStore>(), settingsManager, new ConnectivityImplementation()) .DownloadBackup(); JobFinished(args, false); } catch (Exception ex) { Debug.Write(ex); } finally { settingsManager.LastExecutionTimeStampSyncBackup = DateTime.Now; } }
private async Task CheckRecurringPayments(JobParameters args) { try { Debug.WriteLine("RecurringPayment Job started."); DataAccess.ApplicationContext.DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), DatabaseConstants.DB_NAME); var ambientDbContextLocator = new AmbientDbContextLocator(); var dbContextScopeFactory = new DbContextScopeFactory(); await new RecurringPaymentManager( new RecurringPaymentService(ambientDbContextLocator, dbContextScopeFactory), new PaymentService(ambientDbContextLocator, dbContextScopeFactory)) .CreatePaymentsUpToRecur(); Debug.WriteLine("RecurringPayment Job finished."); JobFinished(args, false); } catch (Exception ex) { Crashes.TrackError(ex); Debug.Write(ex); } }
private async Task ClearPayments(JobParameters args) { try { Debug.WriteLine("ClearPayments Job started"); DataAccess.ApplicationContext.DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), DatabaseConstants.DB_NAME); var paymentService = new PaymentService(new AmbientDbContextLocator(), new DbContextScopeFactory()); var payments = await paymentService.GetUnclearedPayments(DateTime.Now); var unclearedPayments = payments.ToList(); if (unclearedPayments.Any()) { Debug.WriteLine("Payments for clearing found."); await paymentService.SavePayments(unclearedPayments.ToArray()); } Debug.WriteLine("ClearPayments Job finished."); JobFinished(args, false); } catch (Exception ex) { Debug.Write(ex); } }
public void PrintMatrix(double[,] matrix) { Debug.Write("["); for (int i = 0; i < matrix.GetLength(0); i++) { Debug.WriteLine(""); for (int j = 0; j < matrix.GetLength(1); j++) { Debug.Write($"{matrix[i, j]} |"); } } Debug.WriteLine("]"); }
private async Task SyncBackups(JobParameters args) { if (!Mvx.IoCProvider.CanResolve <IMvxFileStore>()) { return; } var settingsFacade = new SettingsFacade(new SettingsAdapter()); if (!settingsFacade.IsBackupAutouploadEnabled || !settingsFacade.IsLoggedInToBackupService) { return; } try { EfCoreContext.DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), DatabaseConstants.DB_NAME); var pca = PublicClientApplicationBuilder .Create(ServiceConstants.MSAL_APPLICATION_ID) .WithRedirectUri($"msal{ServiceConstants.MSAL_APPLICATION_ID}://auth") .Build(); var backupManager = new BackupManager( new OneDriveService(pca), Mvx.IoCProvider.Resolve <IMvxFileStore>(), new ConnectivityAdapter()); var backupService = new BackupService(backupManager, settingsFacade); var backupDate = await backupService.GetBackupDate(); if (settingsFacade.LastDatabaseUpdate > backupDate) { return; } await backupService.RestoreBackup(); JobFinished(args, false); } catch (Exception ex) { Debug.Write(ex); } finally { settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now; } }
private async Task SyncBackups(JobParameters args) { var settingsFacade = new SettingsFacade(new SettingsAdapter()); if (!settingsFacade.IsBackupAutouploadEnabled || !settingsFacade.IsLoggedInToBackupService) { return; } try { ExecutingPlatform.Current = AppPlatform.Android; var pca = PublicClientApplicationBuilder .Create(ServiceConstants.MSAL_APPLICATION_ID) .WithRedirectUri($"msal{ServiceConstants.MSAL_APPLICATION_ID}://auth") .Build(); var backupManager = new BackupManager( new OneDriveService(pca), ServiceLocator.Current.GetInstance <IFileStore>(), new ConnectivityAdapter()); var backupService = new BackupService(backupManager, settingsFacade); var backupDate = await backupService.GetBackupDate(); if (settingsFacade.LastDatabaseUpdate > backupDate) { return; } await backupService.RestoreBackup(); JobFinished(args, false); } catch (Exception ex) { Debug.Write(ex); } finally { settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now; } }
private async Task SyncBackups(JobParameters args) { try { DataAccess.ApplicationContext.DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), DatabaseConstants.DB_NAME); await new BackupManager(new OneDriveService(new OneDriveAuthenticator()), Mvx.Resolve <IMvxFileStore>(), new SettingsManager(new Settings()), new ConnectivityImplementation()) .DownloadBackup(); JobFinished(args, false); } catch (Exception ex) { Debug.Write(ex); } }
private double[,] ArrayPayloadToDiagonalArray(double[] payload, int width, int height) { var result2DArray = new double[width, height]; for (int j = 0; j < result2DArray.GetLength(1); j++) { for (int i = 0; i < result2DArray.GetLength(0); i++) { result2DArray[i, j] = 0; } } int payloadLength = payload.Length; var squareLength = (width <= height) ? width : height; if (payloadLength > squareLength) { throw new ArithmeticException("Message is too long"); } else { Debug.WriteLine("2D Payload array: "); for (int k = 0; k < squareLength; k++) { Debug.WriteLine(""); Debug.Write("["); if (k < payload.Length) { result2DArray[k, k] = payload[k]; } Debug.Write($"{result2DArray[k, k]}, "); Debug.Write("]"); } } return(result2DArray); }
public void ProcessPendingMessages() { if (messageQueue.Count > 0) { while (messageQueue.TryDequeue(out string message)) { #if DEBUG Debug.Write(message); #endif // DEBUG SystemOut?.Write(message); var fileMessage = $"[{DateTime.Now.ToLongTimeString()}] {message}"; if (LogFilePath != null) { file.Write(fileMessage); } else { logBeforeProjectOpened.Append(fileMessage); } textView.Append(message); } Application.InvokeOnNextUpdate(textView.ScrollToEnd); } }
/// <summary> /// File saving implementation /// </summary> /// <param name="allowedTypes">list of allowed types; may be null</param> /// <param name="action">Android intent action to use; unused</param> /// <returns>picked file data, or null when picking was cancelled</returns> private Task <FilePlaceholder> CreatOrOverwriteFileAsync(string[] allowedTypes) { var id = this.GetRequestId(); var ntcs = new TaskCompletionSource <FilePlaceholder>(id); var previousTcs = Interlocked.Exchange(ref this.completionCreationSource, ntcs); if (previousTcs != null) { previousTcs.TrySetResult(null); } try { var pickerIntent = new Intent(this.context, typeof(FileSaverActivity)); pickerIntent.SetFlags(ActivityFlags.NewTask); pickerIntent.PutExtra(FileSaverActivity.ExtraAllowedTypes, allowedTypes); this.context.StartActivity(pickerIntent); EventHandler <FilePickerEventArgs> handler = null; EventHandler <FilePickerCancelledEventArgs> cancelledHandler = null; handler = (s, e) => { var tcs = Interlocked.Exchange(ref this.completionCreationSource, null); FileSaverActivity.FilePickCancelled -= cancelledHandler; FileSaverActivity.FilePicked -= handler; tcs?.SetResult(new FilePlaceholder( e.FilePath, e.FileName, StreamSetter)); }; cancelledHandler = (s, e) => { var tcs = Interlocked.Exchange(ref this.completionCreationSource, null); FileSaverActivity.FilePickCancelled -= cancelledHandler; FileSaverActivity.FilePicked -= handler; if (e?.Exception != null) { tcs?.SetException(e.Exception); } else { tcs?.SetResult(null); } }; FileSaverActivity.FilePickCancelled += cancelledHandler; FileSaverActivity.FilePicked += handler; } catch (Exception ex) { Debug.Write(ex); this.completionPickerSource.SetException(ex); } return(this.completionCreationSource.Task); }
/// <summary> /// File picking implementation /// </summary> /// <param name="allowedTypes">list of allowed types; may be null</param> /// <param name="action">Android intent action to use; unused</param> /// <returns>picked file data, or null when picking was cancelled</returns> private Task <FileData> PickFileAsync(string[] allowedTypes) { var id = this.GetRequestId(); var ntcs = new TaskCompletionSource <FileData>(id); var previousTcs = Interlocked.Exchange(ref this.completionPickerSource, ntcs); if (previousTcs != null) { previousTcs.TrySetResult(null); } try { var pickerIntent = new Intent(this.context, typeof(FilePickerActivity)); pickerIntent.SetFlags(ActivityFlags.NewTask); pickerIntent.PutExtra(FilePickerActivity.ExtraAllowedTypes, allowedTypes); this.context.StartActivity(pickerIntent); EventHandler <FilePickerEventArgs> handler = null; EventHandler <FilePickerCancelledEventArgs> cancelledHandler = null; handler = (s, e) => { var tcs = Interlocked.Exchange(ref this.completionPickerSource, null); FilePickerActivity.FilePickCancelled -= cancelledHandler; FilePickerActivity.FilePicked -= handler; tcs?.SetResult(new FileData( e.FilePath, e.FileName, () => { if (IOUtil.IsMediaStore(e.FilePath)) { var contentUri = Android.Net.Uri.Parse(e.FilePath); return(Application.Context.ContentResolver.OpenInputStream(contentUri)); } else { return(System.IO.File.OpenRead(e.FilePath)); } })); }; cancelledHandler = (s, e) => { var tcs = Interlocked.Exchange(ref this.completionPickerSource, null); FilePickerActivity.FilePickCancelled -= cancelledHandler; FilePickerActivity.FilePicked -= handler; if (e?.Exception != null) { tcs?.SetException(e.Exception); } else { tcs?.SetResult(null); } }; FilePickerActivity.FilePickCancelled += cancelledHandler; FilePickerActivity.FilePicked += handler; } catch (Exception ex) { Debug.Write(ex); this.completionPickerSource.SetException(ex); } return(this.completionPickerSource.Task); }
public override bool OnStopJob(JobParameters @params) { Debug.Write("Fetch shut down by Android. Trying to reschedule."); return(true); }
public void Write(object item) { SysDebug.Write(item); }
public ArticleMappingContext() : base(ConnectionString) { Debug.Write(Database.Connection.ConnectionString); }