public LogToFileTask(IAdapter adapter, IAppSettings settings, IUserDialogs dialogs, SampleDbConnection data) { this.adapter = adapter; this.settings = settings; this.data = data; }
public LogViewModel(IAdapter adapter, IAppSettings settings, IUserDialogs dialogs, SampleDbConnection data) { this.adapter = adapter; this.data = data; this.Clear = ReactiveCommand.CreateFromTask(async _ => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .SetMessage("Are you sure you wish to delete the log?") .UseYesNo() ); if (result) { this.data.DeleteAll <BleRecord>(); this.LoadData(); } }); this.Refresh = new Command(this.LoadData); this.Show = new Command <BleRecord>(rec => dialogs.Alert(rec.Description, "Info")); this.IsLoggingEnabled = settings.IsLoggingEnabled; this.WhenAnyValue(x => x.IsLoggingEnabled) .Skip(1) .Subscribe(enabled => { settings.IsLoggingEnabled = enabled; if (enabled) { this.logger = this.adapter .CreateLogger(BleLogFlags.All) .Buffer(TimeSpan.FromSeconds(5)) .Where(x => x.Count > 0) .Subscribe(x => this.LoadData()); } else { this.logger?.Dispose(); } }); }
public HistoryViewModel(SampleDbConnection conn, IGeofenceManager geofences, IUserDialogs dialogs, IMessaging messaging) { this.conn = conn; this.geofences = geofences; this.Reload = new Command(this.Load); this.Clear = ReactiveCommand.CreateAsyncTask(async x => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("Are you sure you want to delete all of your history?")); if (result) { this.conn.DeleteAll<GeofenceEvent>(); this.Load(); } }); this.SendDatabase = new Command(() => { var backupLocation = conn.CreateDatabaseBackup(conn.Platform); var mail = new EmailMessageBuilder() .Subject("Geofence Database") //.WithAttachment(conn.DatabasePath, "application/octet-stream") .WithAttachment(backupLocation, "application/octet-stream") .Body("--") .Build(); messaging.EmailMessenger.SendEmail(mail); }); }
public LogToFileTask(IAppSettings settings, SampleDbConnection data) { this.settings = settings; this.data = data; }