public void TestParseEmbeddedConnectionString() { var conn = new Connection("EmbeddedTest", "type=embedded;storesdirectory=c:\\brightstar;"); Assert.AreEqual("c:\\brightstar", conn.DirectoryPath); Assert.IsNull(conn.ServerEndpoint); Assert.AreEqual("EmbeddedTest", conn.Name); }
public void TestParseRestConnectionString() { var conn = new Connection("RestTest", "type=rest;endpoint=http://localhost:8090/brightstar"); Assert.AreEqual("http://localhost:8090/brightstar", conn.ServerEndpoint); Assert.IsNull(conn.DirectoryPath); Assert.AreEqual("RestTest", conn.Name); }
public Store(Connection source, string location) { ValidationMessages = new ObservableCollection<string>(); _location = location; Source = source; Validate(); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { StoreSources = new ObservableCollection<Connection>(); if (IsInDesignMode) { // Code runs in Blend --> create design time data. Configuration = new PolarisConfigurationModel(); Configuration.ConnectionStrings.Add(new NamedConnectionString { Name = "Local", ConnectionString = "type=embedded;storesDirectory=c:\\brightstar" }); Configuration.ConnectionStrings.Add(new NamedConnectionString { Name="Remote", ConnectionString = "type=http;endpoint=http://invalid/url" }); } else { // Code runs "for real" if (!PolarisConfigurationModel.Exists && PolarisConfigurationModel.LegacyPathExists) { Configuration = PolarisConfigurationModel.ImportLegacyConfiguration(); } else { Configuration = PolarisConfigurationModel.Load(); } } foreach(var namedConnection in Configuration.ConnectionStrings) { var connection = new Connection(namedConnection.Name, namedConnection.ConnectionString); connection.TryConnect(); StoreSources.Add(connection); } TabItems = new ObservableCollection<TabItemViewModel>(); NewSparqlQueryCommand = new RelayCommand<Store>((s)=>NewSparqlQuery(s)); NewSparqlUpdateCommand = new RelayCommand<Store>((s) => NewSparqlUpdate(s)); NewImportJobCommand = new RelayCommand<Store>(s=>NewImportJob(s)); NewExportJobCommand = new RelayCommand<Store>(s => NewExportJob(s)); NewTransactionCommand = new RelayCommand<Store>(s=>NewTransaction(s)); TabItemChangedCommand = new RelayCommand<TabItemViewModel>(DisplayTabItemToolbars); // KA: Not currently supported for the b-plus tree store // AnalyzeStoreCommand = new RelayCommand<Store>(s=>AnalyzeStore(s)); NewConnectionCommand=new RelayCommand(NewConnection); ServerRefreshCommand = new RelayCommand<Connection>(ServerRefresh); ServerEditCommand = new RelayCommand<Connection>(ServerEdit); ServerDisconnectCommand = new RelayCommand<Connection>(ServerDisconnect); ServerCreateStoreCommand = new RelayCommand<Connection>(ServerCreateStore); StoreDeleteCommand = new RelayCommand<Store>(StoreDelete); NewHistoryViewCommand = new RelayCommand<Store>(NewHistoryView); NewStatisticsViewCommand = new RelayCommand<Store>(NewStatisticsView); AboutClickCommand = new RelayCommand(About); ExitCommand = new RelayCommand(Exit); PrefixSettingsCommand = new RelayCommand(PrefixSettings); }
public void TestParseHttpConnectionString() { var conn = new Connection("HttpTest", "type=http;endpoint=http://localhost:8090"); Assert.IsNull(conn.DirectoryPath); Assert.AreEqual("localhost",conn.ServerName); Assert.AreEqual("/", conn.ServerPath); Assert.AreEqual("8090", conn.ServerPort); Assert.IsNull(conn.PipeName); Assert.AreEqual("HttpTest", conn.Name); }
public void TestParseTcpConnectionString() { var conn = new Connection("TcpTest", "type=tcp;endpoint=net.tcp://localhost:8095/brightstar"); Assert.IsNull(conn.DirectoryPath); Assert.AreEqual("localhost", conn.ServerName); Assert.AreEqual("/brightstar", conn.ServerPath); Assert.AreEqual("8095", conn.ServerPort); Assert.IsNull(conn.PipeName); Assert.AreEqual("TcpTest", conn.Name); }
public void TestParseNamedPipeConnectionString() { var conn = new Connection("NamedPipeTest", "type=namedpipe;endpoint=net.pipe://localhost/brightstar"); Assert.IsNull(conn.DirectoryPath); Assert.AreEqual("localhost", conn.ServerName); Assert.IsNull(conn.ServerPath); Assert.IsNull(conn.ServerPort); Assert.AreEqual("brightstar", conn.PipeName); Assert.AreEqual("NamedPipeTest", conn.Name); }
public void TestParseNamedPipeConnectionString() { var conn = new Connection("NamedPipeTest", "type=namedpipe;endpoint=net.pipe://localhost/brightstar"); }
public void ServerEdit(Connection serverConnection) { var msg = new ShowWindowMessage {Name = "EditConnection", ViewModel = serverConnection}; Messenger.Default.Send(msg); }
public void ServerCreateStore(Connection serverConnection) { var msg = new ShowWindowMessage {Name = "CreateStore", ViewModel = serverConnection, Continuation = ContinueCreateStore}; Messenger.Default.Send(msg); }
public void ServerRefresh(Connection connectionToRefresh) { connectionToRefresh.TryConnect(); }
private void HandleServerDisconnectDialog(Connection connectionToRemove, MessageBoxResult result) { if (result == MessageBoxResult.Yes) { Configuration.ConnectionStrings.RemoveAll(x => x.Name.Equals(connectionToRemove.Name)); StoreSources.Remove(connectionToRemove); Configuration.Save(); } }
public void ServerDisconnect(Connection connectionToRemove) { var msg = String.Format( Strings.DisconnectServerDialogContent, connectionToRemove.Name); Messenger.Default.Send( new ShowDialogMessage( Strings.DisconnectServerDialogTitle, msg, MessageBoxImage.Question, MessageBoxButton.YesNo, result => HandleServerDisconnectDialog(connectionToRemove, result)), "MainWindow" ); }
private void HandleShowWindowMessage(ShowWindowMessage msg) { switch (msg.Name) { case "NewConnection": { var connectionModel = new Connection(); var newConnectionDialog = new ConnectionPropertiesDialog {DataContext = connectionModel}; var dlgResult = newConnectionDialog.ShowDialog(); if (dlgResult.HasValue && dlgResult.Value) { var model = DataContext as MainViewModel; if (model != null) { model.StoreSources.Add(connectionModel); model.AddConnectionConfiguration(connectionModel.Name, connectionModel.ConnectionString, connectionModel.RequiresAuthentication); } } break; } case "EditConnection": { var connectionModel = msg.ViewModel as Connection; if (connectionModel != null) { var editModel = connectionModel.Clone(); var dlg = new ConnectionPropertiesDialog {DataContext = editModel}; var dlgResult = dlg.ShowDialog(); if (dlgResult.HasValue && dlgResult.Value) { var oldName = connectionModel.Name; connectionModel.CopyFrom(editModel); var mvm = DataContext as MainViewModel; if (mvm != null) { mvm.ServerRefresh(connectionModel); } // Update configuration var model = DataContext as MainViewModel; if (model != null) { model.UpdateConnectionConfiguration(oldName, connectionModel.Name, connectionModel.ConnectionString, connectionModel.RequiresAuthentication); } } } break; } case "PrefixesDialog": { var configuration = msg.ViewModel as PolarisConfigurationModel; if (configuration != null) { var oldPrefixes = new List<PrefixConfiguration>(configuration.Prefixes); var dlg = new PrefixesDialog { DataContext = configuration }; var dlgResult = dlg.ShowDialog(); if (dlgResult.HasValue && dlgResult.Value) { configuration.Save(); } else { configuration.Prefixes = oldPrefixes; } } break; } case "CreateStore": { var connection = msg.ViewModel as Connection; if (connection != null) { var storeModel = new Store(connection, Guid.NewGuid().ToString()); var storePropertiesDialog = new StorePropertiesDialog {DataContext = storeModel, Title = "New Store Properties"}; var dlgResult = storePropertiesDialog.ShowDialog(); if (dlgResult.HasValue && dlgResult.Value && msg.Continuation != null) { msg.Continuation(storePropertiesDialog.DataContext); } } break; } case "AboutDialog": { var dlg = new AboutDialog {DataContext = msg.ViewModel}; dlg.ShowDialog(); break; } } }
public Connection Clone() { var ret = new Connection(this.Name, this.ConnectionString.ToString()); ret.ParseConnectionString(); return ret; }
public void TestParseTcpConnectionString() { var conn = new Connection("TcpTest", "type=tcp;endpoint=net.tcp://localhost:8095/brightstar"); }
public void TestParseHttpConnectionString() { var conn = new Connection("HttpTest", "type=http;endpoint=http://localhost:8090"); }