private void InternalInsertDocuments()
        {
            TabViewModel tabVm = new TabViewModel();

            tabVm.Database          = this.Database.Name;
            tabVm.Service           = this.Database.Server.MongoDbService;
            tabVm.Collection        = this.Name;
            tabVm.Name              = this.Name;
            tabVm.SelectedOperation = tabVm.InsertOperation;
            Messenger.Default.Send(new NotificationMessage <TabViewModel>(tabVm, Constants.OpenTab));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            _activeConnections = new ObservableCollection <MongoDbServerViewModel>();
            _tabs          = new ObservableCollection <TabViewModel>();
            LogEvents      = LoggerHelper.LogEvents;
            ViewLogDetails = new RelayCommand <log4net.Core.LoggingEvent>((param) =>
            {
                Messenger.Default.Send(new NotificationMessage <log4net.Core.LoggingEvent>(param, Constants.ShowLogDetailsMessage));
            });
            Messenger.Default.Register <NotificationMessage <ConnectionInfo> >(this, (message) => LoggingInMessageHandler(message));
            Messenger.Default.Register <NotificationMessage <TabViewModel> >(this, (message) => TabMessageHandler(message));
            Messenger.Default.Register <NotificationMessage <MongoDbServerViewModel> >(this, (message) => MongoDbServerMessageHandler(message));

            if (IsInDesignModeStatic)
            {
                var _mongoDbService             = GalaSoft.MvvmLight.Ioc.SimpleIoc.Default.GetInstanceWithoutCaching <IMongoDbService>();
                MongoDbServerViewModel serverVm = new MongoDbServerViewModel(_mongoDbService);
                serverVm.Name = "127.0.0.1:27017";

                ActiveConnections.Add(serverVm);
                var task = _mongoDbService.ConnectAsync(new ConnectionInfo());
                task.Wait();
                var serverInfo = task.Result;
                serverVm.LoadDatabases(serverInfo.Databases);

                TabViewModel tabDesign1 = SimpleIoc.Default.GetInstanceWithoutCaching <TabViewModel>();
                tabDesign1.Name = "Collection1";
                tabDesign1.SelectedOperation = tabDesign1.FindOperation;
                this.Tabs.Add(tabDesign1);
                this.SelectedTab = tabDesign1;
                TabViewModel tabDesign2 = SimpleIoc.Default.GetInstanceWithoutCaching <TabViewModel>();
                tabDesign2.Name = "localhost:27017";
                tabDesign2.SelectedOperation = tabDesign2.AggregateOperation;
                this.Tabs.Add(tabDesign2);

                LogEvents = new ObservableCollection <log4net.Core.LoggingEvent>();
                LogEvents.Add(new log4net.Core.LoggingEvent(new log4net.Core.LoggingEventData()
                {
                    Level = log4net.Core.Level.Debug, Message = "Test debug message", TimeStamp = DateTime.Parse("2015/11/09 00:01:00")
                }));
                LogEvents.Add(new log4net.Core.LoggingEvent(new log4net.Core.LoggingEventData()
                {
                    Level = log4net.Core.Level.Info, Message = "Test info message", TimeStamp = DateTime.Parse("2015/11/09 00:02:00")
                }));
                LogEvents.Add(new log4net.Core.LoggingEvent(new log4net.Core.LoggingEventData()
                {
                    ExceptionString = "TestException", Level = log4net.Core.Level.Warn, Message = "Test warn message", TimeStamp = DateTime.Parse("2015/11/09 00:03:00")
                }));
                LogEvents.Add(new log4net.Core.LoggingEvent(new log4net.Core.LoggingEventData()
                {
                    ExceptionString = "TestException", Level = log4net.Core.Level.Error, Message = "Test error message", TimeStamp = DateTime.Parse("2015/11/09 00:04:00")
                }));
            }
        }
        private void InternalOpenTab()
        {
            TabViewModel tabVm = SimpleIoc.Default.GetInstanceWithoutCaching <TabViewModel>();

            tabVm.Database          = this.Database.Name;
            tabVm.Service           = this.Database.Server.MongoDbService;
            tabVm.Collection        = this.Name;
            tabVm.Name              = this.Name;
            tabVm.ExecuteOnOpen     = true;
            tabVm.SelectedOperation = tabVm.FindOperation;
            Messenger.Default.Send(new NotificationMessage <TabViewModel>(tabVm, Constants.OpenTab));
        }
        private void InnerOpenRunCommand(DatabaseCommand param)
        {
            TabViewModel tabVm = SimpleIoc.Default.GetInstanceWithoutCaching <TabViewModel>();

            tabVm.SelectedOperation = tabVm.CommandOperation;
            tabVm.Database          = this.Name;
            tabVm.Service           = this.Server.MongoDbService;
            tabVm.Name = this.Name;
            if (param == null)
            {
                tabVm.CommandOperation.Command = "{}";
            }
            else
            {
                tabVm.CommandOperation.Command = param.Command;
                tabVm.ExecuteOnOpen            = param.ExecuteImmediately;
            }
            Messenger.Default.Send(new NotificationMessage <TabViewModel>(tabVm, Constants.OpenTab));
        }
 public ResultsViewModel(List <BsonDocument> documents, TabViewModel owner)
 {
     _documents  = documents;
     Owner       = owner;
     LazyLoading = true;
 }
 private void InternalInsertDocuments()
 {
     TabViewModel tabVm = new TabViewModel();
     tabVm.Database = this.Database.Name;
     tabVm.Service = this.Database.Server.MongoDbService;
     tabVm.Collection = this.Name;
     tabVm.Name = this.Name;
     tabVm.SelectedOperation = tabVm.InsertOperation;
     Messenger.Default.Send(new NotificationMessage<TabViewModel>(tabVm, Constants.OpenTab));
 }
 public ResultsViewModel(List<BsonDocument> documents, TabViewModel owner)
 {
     _documents = documents;
     Owner = owner;
     LazyLoading = true;
 }