public AddSubTaskDialogViewModelValidator(ITextProvider textProvider) { RuleFor(vm => vm.SubTaskTitle) .NotEmpty() .WithMessage(textProvider.Get("TitleCannotBeEmpty")) .MaximumLength(MaxChars) .WithMessage(textProvider.Get("TitleMaxLength", $"{MaxChars}")); }
public AddEditTaskListDialogViewModelValidator(ITextProvider textProvider) { RuleFor(vm => vm.TaskListTitle) .MaximumLength(50) .WithMessage(textProvider.Get("TitleMaxLength", "50")) .NotEmpty() .WithMessage(textProvider.Get("TitleCannotBeEmpty")); }
public PasswordDialogViewModelValidator(ITextProvider textProvider) { When(vm => vm.PromptForPassword, () => { RuleFor(vm => vm.Password) .NotEmpty() .WithMessage(textProvider.Get("PasswordCantBeEmpty")) .Equal(vm => vm.CurrentPassword) .WithMessage(textProvider.Get("PasswordCantBeEmpty")); }).Otherwise(() => { RuleFor(vm => vm.Password) .NotEmpty() .WithMessage(textProvider.Get("PasswordCantBeEmpty")) .MaximumLength(10) .WithMessage(textProvider.Get("PasswordMaxLength", "10")) .Equal(vm => vm.ConfirmPassword) .WithMessage(textProvider.Get("PasswordDoesntMatch")); RuleFor(vm => vm.ConfirmPassword) .NotEmpty() .WithMessage(textProvider.Get("ConfirmPasswordCantBeEmpty")) .MaximumLength(10) .WithMessage(textProvider.Get("ConfirmPasswordMaxLength", "10")) .Equal(vm => vm.Password) .WithMessage(textProvider.Get("ConfirmPasswordDoesntMatch")); }); }
public void ShowTaskReminderNotification(TaskReminderNotification notification) { //we create the pending intent when the user clicks the notification... var action = new NotificationAction { Action = NotificationActionType.OPEN_TASK, TaskId = notification.TaskId, TaskListId = notification.TaskListId }; var clickIntent = MainActivity.CreateIntent( notification.Id, MainActivity.InitParamsKey, JsonConvert.SerializeObject(action)); var pendingIntent = TaskStackBuilder.Create(Application.Context) .AddNextIntent(clickIntent) .GetPendingIntent(1, (int)PendingIntentFlags.UpdateCurrent); var localNotification = new TaskNotification { LargeContent = $"{notification.TaskTitle}{System.Environment.NewLine}" + $"{notification.TaskBody}", Title = notification.TaskListTitle, Id = notification.Id }; var builder = BuildSimpleNotification(localNotification); builder.SetContentIntent(pendingIntent); //we create the pending intent when the user clicks the mark as completed button... var mcIntent = MarkTaskAsCompletedReceiver.CreateIntent( notification.Id, MarkTaskAsCompletedReceiver.MarkTaskAsCompletedKey, JsonConvert.SerializeObject(notification)); var mcPendingIntent = PendingIntent.GetBroadcast( Application.Context, 0, mcIntent, 0); string title = _textProvider.Get("MarkTaskAs", _textProvider.Get("Completed")); builder.AddAction(Resource.Drawable.ic_check_white_48dp, title, mcPendingIntent); var notif = builder.Build(); NotifManager.Notify(notification.Id, notif); }
public TaskItemViewModelValidator(ITextProvider textProvider) { RuleFor(vm => vm.Title) .NotEmpty() .WithMessage(textProvider.Get("TitleCannotBeEmpty")) .MaximumLength(TitleMaxLength) .WithMessage(textProvider.Get("TitleMaxLength", $"{TitleMaxLength}")); RuleFor(vm => vm.Notes) .NotEmpty() .WithMessage(textProvider.Get("NotesCannotBeEmpty")) .MaximumLength(NotesMaxLength) .WithMessage(textProvider.Get("NotesMaxLength", $"{NotesMaxLength}")); }
public ActionResult Index() { var text = _textProvider.Get(); var model = new TextViewModel(text); return(View(model)); }
private void RegisterTask(int id, long runEach) { var constraints = new Constraints.Builder() .SetRequiredNetworkType(NetworkType.Connected) .Build(); var workRequest = PeriodicWorkRequest.Builder .From <SyncBackgroundTask>(TimeSpan.FromMinutes(runEach)) .SetConstraints(constraints) .AddTag($"{id}") .Build(); WorkManager.Instance.EnqueueUniquePeriodicWork($"{id}", ExistingPeriodicWorkPolicy.Replace, workRequest); _dialogService.ShowSucceedToast(_textProvider.Get("JobWasScheduled")); }
public TaskDateDialogViewModelValidator(ITextProvider textProvider) { RuleFor(dto => dto.DateText) .NotEmpty() .WithMessage(textProvider.Get("ReminderDateCannotBeEmpty")); When(dto => dto.Parameter.DateType == TaskNotificationDateType.REMINDER_DATE, () => { RuleFor(dto => dto.HourText) .NotEmpty() .WithMessage(textProvider.Get("ReminderHourCannotBeEmpty")) .Must((dto, hourText) => { var currentTime = DateTime.Now; var selectedDate = DateTime.Parse(dto.FullText, textProvider.CurrentCulture); return(selectedDate > currentTime); }) .WithMessage(textProvider.Get("InvalidReminderHour")); RuleFor(dto => dto.FullText) .Must(text => DateTime.TryParse(text, out _)) .WithMessage(textProvider.Get("InvalidReminderDate")); }); }
public async Task Sync() { try { _logger.Information( $"{nameof(Sync)}: Started {(_startedManually ? "manually" : "automatically")}"); bool isSyncServiceRunning = (_appSettings as IAndroidAppSettings) .GetBoolean(SyncBackgroundService.IsServiceRunningKey); if (!_startedManually && isSyncServiceRunning) { _logger.Warning($"{nameof(Sync)}: The sync bg service is already running..."); return; } string msg = $"{_textProvider.Get("Syncing")}..."; await _dispatcher.ExecuteOnMainThreadAsync(() => _messenger.Publish(new ShowProgressOverlayMsg(this, msg: msg))); if (!_networkService.IsInternetAvailable()) { _logger.Warning($"{nameof(Sync)}: Network is not available..."); msg = _textProvider.Get("NetworkNotAvailable"); await _dispatcher.ExecuteOnMainThreadAsync(() => _messenger.Publish(new ShowProgressOverlayMsg(this, false, msg))); return; } bool syncOnlyOneTaskList = _taskListId.HasValue; if (syncOnlyOneTaskList) { _logger.Information($"{nameof(Sync)}: We will perform a partial sync for the " + $"tasklistId = {_taskListId.Value} and its associated tasks"); } else { _logger.Information($"{nameof(Sync)}: We will perform a full sync"); } var syncResults = !syncOnlyOneTaskList ? await _syncService.PerformFullSync(true) : await _syncService.PerformSyncOnlyOn(_taskListId.Value); if (syncResults.Any(r => !r.Succeed)) { var errors = string.Join( $".{Environment.NewLine}", syncResults .Where(r => !r.Succeed) .Select(r => r.Message) .Distinct()); _logger.Error($"{nameof(Sync)}: Sync completed with errors = {errors}"); } string message = syncResults.Any(r => !r.Succeed) ? _textProvider.Get("SyncUnknownError") : !_startedManually ? _textProvider.Get("SyncAutoCompleted") : _textProvider.Get("SyncManualCompleted"); if (string.IsNullOrEmpty(message)) { message = "An unknown error occurred while trying to perform the sync operation."; } _logger.Information($"{nameof(Sync)}: results = {message}"); await _dispatcher.ExecuteOnMainThreadAsync(() => _messenger.Publish(new ShowProgressOverlayMsg(this, false))); bool isInForeground = AndroidUtils.IsAppInForeground(); if (!isInForeground && _appSettings.ShowToastNotificationAfterFullSync) { _logger.Information($"{nameof(Sync)}: App is not in foreground, showing a notification..."); var notif = new TaskNotification { Content = message, Title = _textProvider.Get("SyncResults") }; _notificationService.ShowNotification(notif); } else if (isInForeground) { _logger.Information($"{nameof(Sync)}: App is in foreground, showing the snackbar msg..."); await _dispatcher.ExecuteOnMainThreadAsync(() => { _dialogService.ShowSnackBar(message); _messenger.Publish(new OnFullSyncMsg(this)); }); } _logger.Information($"{nameof(Sync)}: completed successfully"); } catch (Exception e) { _logger?.Error(e, $"{nameof(Sync)}: An unknown error occurred while trying to sync task / tasklists"); _telemetryService?.TrackError(e); } }
public async Task MarkAsCompleted() { try { bool isAppInForeground = AndroidUtils.IsAppInForeground(); if (!isAppInForeground) { _telemetryService.Init(); } _logger.Information($"Marking taskId = {_notification.TaskId} as completed..."); //if i pass the notifaction in the lambda, the task crashes.. int taskId = _notification.TaskId; var taskResponse = await _dataService.TaskService .FirstOrDefaultAsNoTrackingAsync(t => t.ID == taskId); if (!taskResponse.Succeed) { _logger.Error( $"Couldnt retrieve taskId = {_notification.Id}. " + $"Error = {taskResponse.Message}"); return; } var googleTaskId = taskResponse.Result.GoogleTaskID; var response = await _dataService.TaskService .ChangeTaskStatusAsync(googleTaskId, GoogleTaskStatus.COMPLETED); if (response.Succeed) { _logger.Information( $"TaskId = {_notification.TaskId} " + $"was successfully marked as completed"); if (isAppInForeground) { var task = response.Result; var msg = new TaskStatusChangedMsg( this, task.GoogleTaskID, task.ParentTask, task.CompletedOn, task.UpdatedAt, task.Status); _messenger.Publish(msg); } } else { _logger.Error( $"TaskId = {_notification.TaskId} couldnt be marked as completed. " + $"Error = {response.Message}"); _notificationService.ShowNotification(new TaskNotification { Content = _textProvider.Get("TaskCouldntBeMarkedAsCompleted", _notification.TaskTitle), Title = _textProvider.Get("Error") }); } _logger.Information("Process completed..."); } catch (Exception e) { _logger?.Error(e, $"An unknown error occurred while trying " + $"to mark taskId = {_notification.Id} as completed"); _telemetryService?.TrackError(e); } }