Example #1
0
        public DatabaseModel(string name, DocumentStore documentStore)
        {
            this.name          = name;
            this.documentStore = documentStore;

            Statistics = new Observable <DatabaseStatistics>();
            Status     = new Observable <string>
            {
                Value = "Offline"
            };
            OnPropertyChanged(() => StatusImage);

            asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
                                                                                        ? documentStore.AsyncDatabaseCommands.ForSystemDatabase()
                                                        : documentStore.AsyncDatabaseCommands.ForDatabase(name);

            DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
            .SampleResponsive(TimeSpan.FromSeconds(2))
            .Subscribe(_ => RefreshStatistics());

            databaseChanges.ConnectionStatusChanged += (sender, args) =>
            {
                ApplicationModel.Current.Server.Value.SetConnected(((IDatabaseChanges)sender).Connected);
                UpdateStatus();
            };

            RefreshStatistics();
        }
Example #2
0
        public DatabaseModel(string name, DocumentStore documentStore)
        {
            this.name          = name;
            this.documentStore = documentStore;

            Tasks = new BindableCollection <TaskModel>(x => x.Name)
            {
                new ImportTask(),
                new ExportTask(),
                new StartBackupTask(),
                new IndexingTask(),
                new SampleDataTask()
            };

            SelectedTask = new Observable <TaskModel> {
                Value = Tasks.FirstOrDefault()
            };
            Statistics = new Observable <DatabaseStatistics>();
            Status     = new Observable <string>
            {
                Value = "Offline"
            };

            asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
                                                                                        ? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
                                                                                        : documentStore.AsyncDatabaseCommands.ForDatabase(name);

            DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
            .SampleResponsive(TimeSpan.FromSeconds(2))
            .Subscribe(_ => RefreshStatistics(), exception => ApplicationModel.Current.Server.Value.IsConnected.Value = false);

            RefreshStatistics();
        }
Example #3
0
        public DatabaseModel(string name, DocumentStore documentStore)
        {
            this.name          = name;
            this.documentStore = documentStore;

            Tasks = new BindableCollection <TaskModel>(x => x.Name)
            {
                new ImportTask(),
                new ExportTask(),
                new StartBackupTask(),
                new IndexingTask(),
                new SampleDataTask(),
                new CsvImportTask()
            };

            if (name == null || name == Constants.SystemDatabase)
            {
                Tasks.Insert(3, new StartRestoreTask());
            }

            SelectedTask = new Observable <TaskModel> {
                Value = Tasks.FirstOrDefault()
            };
            Statistics = new Observable <DatabaseStatistics>();
            Status     = new Observable <string>
            {
                Value = "Offline"
            };
            OnPropertyChanged(() => StatusImage);

            asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
                                                        ? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
                                                        : documentStore.AsyncDatabaseCommands.ForDatabase(name);

            DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
            .SampleResponsive(TimeSpan.FromSeconds(2))
            .Subscribe(_ => RefreshStatistics());

            databaseChanges.ConnectionStatusCahnged += (sender, args) =>
            {
                ApplicationModel.Current.Server.Value.SetConnected(((IDatabaseChanges)sender).Connected);
                UpdateStatus();
            };

            RefreshStatistics();
        }