public SendFeedbackInteractor( IFeedbackApi feedbackApi, ISingletonDataSource <IThreadSafeUser> userDataSource, IDataSource <IThreadSafeWorkspace, IDatabaseWorkspace> workspacesDataSource, IDataSource <IThreadSafeTimeEntry, IDatabaseTimeEntry> timeEntriesDataSource, IPlatformInfo platformInfo, IUserPreferences userPreferences, ILastTimeUsageStorage lastTimeUsageStorage, ITimeService timeService, string message) { Ensure.Argument.IsNotNull(message, nameof(message)); Ensure.Argument.IsNotNull(feedbackApi, nameof(feedbackApi)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo)); Ensure.Argument.IsNotNull(userDataSource, nameof(userDataSource)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage)); Ensure.Argument.IsNotNull(workspacesDataSource, nameof(workspacesDataSource)); Ensure.Argument.IsNotNull(timeEntriesDataSource, nameof(timeEntriesDataSource)); this.message = message; this.feedbackApi = feedbackApi; this.timeService = timeService; this.platformInfo = platformInfo; this.userDataSource = userDataSource; this.userPreferences = userPreferences; this.workspacesDataSource = workspacesDataSource; this.timeEntriesDataSource = timeEntriesDataSource; this.lastTimeUsageStorage = lastTimeUsageStorage; }
public ReportsBarChartViewModel( ISchedulerProvider schedulerProvider, ISingletonDataSource <IThreadSafePreferences> preferencesDataSource, IObservable <ITimeEntriesTotals> reports, INavigationService navigationService) : base(navigationService) { Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(preferencesDataSource, nameof(preferencesDataSource)); Ensure.Argument.IsNotNull(reports, nameof(reports)); DateFormat = preferencesDataSource.Current .Select(preferences => preferences.DateFormat) .AsDriver(onErrorJustReturn: defaultDateFormat, schedulerProvider: schedulerProvider); var finalReports = reports.Replay(1); reportsDisposable = finalReports.Connect(); Bars = finalReports.Select(bars) .AsDriver(onErrorJustReturn: Array.Empty <BarViewModel>(), schedulerProvider: schedulerProvider); MaximumHoursPerBar = finalReports.Select(upperHoursLimit) .AsDriver(onErrorJustReturn: 0, schedulerProvider: schedulerProvider); HorizontalLegend = finalReports.Select(weeklyLegend) .AsDriver(onErrorJustReturn: null, schedulerProvider: schedulerProvider); }
public UpdateWorkspaceInteractor(ISingletonDataSource <IThreadSafeUser> dataSource, long selectedWorkspaceId) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(selectedWorkspaceId, nameof(selectedWorkspaceId)); this.dataSource = dataSource; this.selectedWorkspaceId = selectedWorkspaceId; }
public UpdatePreferencesInteractor(ISingletonDataSource <IThreadSafePreferences> dataSource, EditPreferencesDTO dto) { Ensure.Argument.IsNotNull(dto, nameof(dto)); Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dto = dto; this.dataSource = dataSource; }
public PersistSingletonState( ISingletonDataSource <TThreadsafeInterface> dataSource, Func <TInterface, TThreadsafeInterface> convertToThreadsafeEntity) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(convertToThreadsafeEntity, nameof(convertToThreadsafeEntity)); this.dataSource = dataSource; this.convertToThreadsafeEntity = convertToThreadsafeEntity; }
public UpdateUserInteractor(ITimeService timeService, ISingletonDataSource <IThreadSafeUser> dataSource, EditUserDTO dto) { Ensure.Argument.IsNotNull(dto, nameof(dto)); Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); this.dto = dto; this.dataSource = dataSource; this.timeService = timeService; }
public SetDefaultWorkspaceInteractor( ITimeService timeService, ISingletonDataSource <IThreadSafeUser> userDataSource, long workspaceId) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(userDataSource, nameof(userDataSource)); this.timeService = timeService; this.userDataSource = userDataSource; this.workspaceId = workspaceId; }
private static IStateResult configurePushSingleton <TModel, TThreadsafe>( ITransitionConfigurator transitions, IStateResult entryPoint, ISingletonDataSource <TThreadsafe> dataSource, IAnalyticsService analyticsService, IUpdatingApiClient <TModel> updatingApi, Func <TModel, TThreadsafe> toClean, Func <TThreadsafe, string, TThreadsafe> toUnsyncable, ITogglApi api, IScheduler scheduler, IObservable <Unit> delayCancellation) where TModel : class where TThreadsafe : class, TModel, IThreadSafeModel, IDatabaseSyncable { var rnd = new Random(); var apiDelay = new RetryDelayService(rnd); var statusDelay = new RetryDelayService(rnd); var push = new PushSingleState <TThreadsafe>(dataSource); var pushOne = new PushOneEntityState <TThreadsafe>(); var update = new UpdateEntityState <TModel, TThreadsafe>(updatingApi, dataSource, analyticsService, toClean); var tryResolveClientError = new TryResolveClientErrorState <TThreadsafe>(); var unsyncable = new UnsyncableEntityState <TThreadsafe>(dataSource, toUnsyncable); var checkServerStatus = new CheckServerStatusState(api, scheduler, apiDelay, statusDelay, delayCancellation); var finished = new ResetAPIDelayState(apiDelay); transitions.ConfigureTransition(entryPoint, push); transitions.ConfigureTransition(push.PushEntity, pushOne); transitions.ConfigureTransition(pushOne.UpdateEntity, update); transitions.ConfigureTransition(pushOne.CreateEntity, new InvalidTransitionState($"Creating is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(pushOne.DeleteEntity, new InvalidTransitionState($"Deleting is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(pushOne.DeleteEntityLocally, new InvalidTransitionState($"Deleting locally is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(update.ClientError, tryResolveClientError); transitions.ConfigureTransition(update.ServerError, checkServerStatus); transitions.ConfigureTransition(update.UnknownError, checkServerStatus); transitions.ConfigureTransition(tryResolveClientError.UnresolvedTooManyRequests, checkServerStatus); transitions.ConfigureTransition(tryResolveClientError.Unresolved, unsyncable); transitions.ConfigureTransition(checkServerStatus.Retry, checkServerStatus); transitions.ConfigureTransition(checkServerStatus.ServerIsAvailable, push); transitions.ConfigureTransition(update.UpdatingSucceeded, finished); transitions.ConfigureTransition(finished.Continue, push); return(push.NothingToPush); }
public CreateDefaultWorkspaceInteractor( IIdProvider idProvider, ITimeService timeService, ISingletonDataSource <IThreadSafeUser> userDataSource, IDataSource <IThreadSafeWorkspace, IDatabaseWorkspace> workspaceDataSource) { Ensure.Argument.IsNotNull(idProvider, nameof(idProvider)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(userDataSource, nameof(userDataSource)); Ensure.Argument.IsNotNull(workspaceDataSource, nameof(workspaceDataSource)); this.idProvider = idProvider; this.timeService = timeService; this.userDataSource = userDataSource; this.workspaceDataSource = workspaceDataSource; }
private static LookForSingletonChangeToPushState <TThreadsafe> configurePushSingleton <TModel, TThreadsafe>( ITransitionConfigurator transitions, IStateResult entryPoint, ISingletonDataSource <TThreadsafe> dataSource, IAnalyticsService analyticsService, IUpdatingApiClient <TModel> updatingApi, ILeakyBucket minutesLeakyBucket, IRateLimiter rateLimiter, WaitForAWhileState waitForAWhileState, Func <TModel, TThreadsafe> toClean, Func <TThreadsafe, string, TThreadsafe> toUnsyncable) where TModel : class where TThreadsafe : class, TModel, IThreadSafeModel, IDatabaseSyncable, IIdentifiable { var lookForChange = new LookForSingletonChangeToPushState <TThreadsafe>(dataSource); var chooseOperation = new ChooseSyncOperationState <TThreadsafe>(); var update = new UpdateEntityState <TModel, TThreadsafe>(updatingApi, dataSource, analyticsService, minutesLeakyBucket, rateLimiter, toClean); var processClientError = new ProcessClientErrorState <TThreadsafe>(); var unsyncable = new MarkEntityAsUnsyncableState <TThreadsafe>(dataSource, toUnsyncable); transitions.ConfigureTransition(entryPoint, lookForChange); transitions.ConfigureTransition(lookForChange.ChangeFound, chooseOperation); transitions.ConfigureTransition(chooseOperation.UpdateEntity, update); transitions.ConfigureTransition(chooseOperation.CreateEntity, new InvalidTransitionState($"Creating is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(chooseOperation.DeleteEntity, new InvalidTransitionState($"Deleting is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(chooseOperation.DeleteEntityLocally, new InvalidTransitionState($"Deleting locally is not supported for {typeof(TModel).Name} during Push sync.")); transitions.ConfigureTransition(update.ClientError, processClientError); transitions.ConfigureTransition(update.ServerError, new FailureState()); transitions.ConfigureTransition(update.UnknownError, new FailureState()); transitions.ConfigureTransition(update.PreventOverloadingServer, waitForAWhileState); transitions.ConfigureTransition(processClientError.UnresolvedTooManyRequests, new FailureState()); transitions.ConfigureTransition(processClientError.Unresolved, unsyncable); transitions.ConfigureTransition(update.Done, lookForChange); transitions.ConfigureTransition(unsyncable.Done, lookForChange); transitions.ConfigureTransition(update.EntityChanged, lookForChange); return(lookForChange); }
public GetCurrentUserInteractor(ISingletonDataSource <IThreadSafeUser> dataSource) { this.dataSource = dataSource; }
public PushSingleState(ISingletonDataSource <T> dataSource) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dataSource = dataSource; }
public LookForSingletonChangeToPushState(ISingletonDataSource <T> dataSource) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dataSource = dataSource; }