public DatabaseWindow() { InitializeComponent(); Databasevm = new DatabaseViewModel(); DataContext = Databasevm; Model = new HongKongModel(); }
private void CreateGraphToVisualize(DatabaseViewModel databaseViewModel) { var g = new BidirectionalGraph <object, IEdge <object> >(); foreach (var tab in databaseViewModel.agdsModel.GetTables()) { g.AddVertex(tab.TableName); foreach (var attr in databaseViewModel.agdsModel.GetAttributes(tab)) { g.AddVertex(attr.ColumnName); g.AddEdge(new Edge <object>(tab.TableName, attr.ColumnName)); foreach (var attrVal in databaseViewModel.agdsModel.GetAttributeValues(attr)) { g.AddVertex(attrVal.Value.ToString()); g.AddEdge(new Edge <object>(attr.ColumnName, attrVal.Value.ToString())); foreach (var item in databaseViewModel.agdsModel.GetItems(attrVal)) { g.AddVertex(item.Print()); g.AddEdge(new Edge <object>(attrVal.Value.ToString(), item.Print())); foreach (var it in databaseViewModel.agdsModel.GetAssociatedItems(item)) { g.AddVertex(it.Print()); g.AddEdge(new Edge <object>(item.Print(), it.Print())); g.AddEdge(new Edge <object>(it.Print(), item.Print())); } } } } } graphToVisualize = g; }
/// <summary> /// Export the database as CSV file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_exportCSV_Click(object sender, RoutedEventArgs e) { var dlg = new SaveFileDialog { FileName = "databaseCSV", // Default file name DefaultExt = ".txt", // Default file extension Filter = "All Files (*.*)|*.*" // Filter files by extension }; var result = dlg.ShowDialog(); if (result == true) { txtBlock_exportPathCSV.Text = dlg.FileName; if (DatabaseViewModel.exportDatabaseAsCSV(dlg.FileName)) { MessageBox.Show("Database successfully exported as CSV to : " + dlg.FileName); } else { MessageBox.Show("Database failed to export."); } } }
private async void UpdateButton_Click(object sender, RoutedEventArgs e) { await DatabaseViewModel.Initialise(); ItemModels = DatabaseViewModel.ItemViewModels; ItemsList.ItemsSource = ItemModels; }
public void TestBlankViewModelCreation() { // This test is trivial. Add your own tests for the logic you add to the ViewModel. var vm = new DatabaseViewModel(); Assert.IsNotNull(vm); }
public AppViewModel(IEventAggregator eventAggregator, IWindowManager windowManager) { DisplayName = "Redis Explorer"; //SetTheme(); this.eventAggregator = eventAggregator; eventAggregator.Subscribe(this); this.windowManager = windowManager; Servers = new BindableCollection <RedisServer>(); KeyViewModel = new KeyViewModel(eventAggregator); KeyViewModel.ConductWith(this); DefaultViewModel = new DefaultViewModel(); DefaultViewModel.ConductWith(this); ServerViewModel = new ServerViewModel(eventAggregator); ServerViewModel.ConductWith(this); DatabaseViewModel = new DatabaseViewModel(eventAggregator); DatabaseViewModel.ConductWith(this); ActivateItem(DefaultViewModel); LoadServers(); }
public IActionResult Database([FromBody] DatabaseViewModel databaseForm, [FromServices] IApplicationLifetime applicationLifetime) { string connectionString = _configuration.GetConnectionString("DefaultConnection"); if (!String.IsNullOrEmpty(connectionString) || DatabaseExists(connectionString)) { return(BadRequest()); } // Create connexion string connectionString = GenerateConnectionString(databaseForm.DatabaseServer, databaseForm.DatabaseName, databaseForm.DatabaseLogin, databaseForm.DatabasePassword, databaseForm.IntegratedSecurity); try { if (!DatabaseExists(connectionString)) { return(BadRequest("Cannot connect to the database")); } SaveConnectionString(connectionString); } catch (Exception ex) { return(BadRequest(ex.Message)); } // Restart application applicationLifetime.StopApplication(); return(Ok()); }
public ActionResult Index() { var Employees = new RootModel(); StreamReader jsonFile = new StreamReader(Server.MapPath("~/Models/DataBase.json")); //SAVE DataBase.json in ISS var jsonString = jsonFile.ReadToEnd(); Employees = JsonConvert.DeserializeObject <RootModel>(jsonString); jsonFile.Close(); if (TempData["shortMessage"] == null) { ViewBag.Message = null; } else { ViewBag.Message = TempData["shortMessage"].ToString(); } var viewModel = new DatabaseViewModel { RootModel = Employees, }; return(View(viewModel)); }
/// <summary> /// Encrypts the unencrypted values on the viewmodel and sets them on the entity /// </summary> /// <param name="database"></param> /// <param name="viewModel"></param> private void AddEncryptedValues(Database database, DatabaseViewModel viewModel) { database.Host = _encrypter.Encrypt(viewModel.Host, database.EncryptionKey); database.Port = _encrypter.Encrypt(viewModel.Port, database.EncryptionKey); database.User = _encrypter.Encrypt(viewModel.User, database.EncryptionKey); database.Password = _encrypter.Encrypt(viewModel.Password, database.EncryptionKey); }
public ActionResult <ApiResult <string> > SaveDatabase([FromForm] DatabaseViewModel model) { JsonResult errorResult = base.ValidateModel(model.Id); if (errorResult != null) { return(errorResult); } var saveObject = base.mapper.Map <Database>(model); var result = new ApiResult <string>(); int dbid = 0; if (saveObject.Id == 0) { saveObject.ChangeTime = DateTime.Now; saveObject.IsDeleted = false; dbid = databaseDb.InsertReturnIdentity(saveObject); result.IsSuccess = true; result.Data = Pubconst.MESSAGEADDSUCCESS; } else { saveObject.ChangeTime = DateTime.Now; saveObject.IsDeleted = false; databaseDb.Update(saveObject); dbid = saveObject.Id; result.IsSuccess = true; result.Data = Pubconst.MESSAGEADDSUCCESS; } base.CreateDatebase(dbid); return(result); }
private void MenuNew_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.Filter = "ACCDB Files (*.accdb)|*.accdb|all Files (*.)|*"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); string filename = dlg.FileName; // Get the selected file name and display in a TextBox if (filename.EndsWith(".accdb")) { Graph.Visibility = Visibility.Visible; databaseViewModel = new DatabaseViewModel(filename); if (!filename.EndsWith("BazaStudenci.accdb")) { path = "Orders"; Graph.Visibility = Visibility.Hidden; } TreeViewCreator(databaseViewModel); ErrorInfo.DataContext = databaseViewModel; } else { MessageBox.Show("Wrong database format."); Application.Current.Shutdown(110); } }
public MainWindow() { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.Filter = "ACCDB Files (*.accdb)|*.accdb|all Files (*.)|*"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); string filename = dlg.FileName; // Get the selected file name and display in a TextBox if (filename.EndsWith(".accdb")) { // Open document databaseViewModel = new DatabaseViewModel(filename); if (filename.EndsWith("BazaStudenci.accdb")) { CreateGraphToVisualize(databaseViewModel); } path = "Studenci"; InitializeComponent(); TreeViewCreator(databaseViewModel); ErrorInfo.DataContext = databaseViewModel; } else { MessageBox.Show("Wrong database format."); Application.Current.Shutdown(110); } }
public static void AddDocuments() { _globalVM = new GlobalViewModel(VM); _configVM = new ConfigurationViewModel(VM); _clearConfigButton.Command = new RelayCommand(_configVM.ClearConfig, ReturnTrue); _loadXmlConfigButton.Command = new RelayCommand(_configVM.LoadXmlConfig, _configVM.ReturnTrue); _saveXmlConfigButton.Command = new RelayCommand(_configVM.SaveXmlConfig, _configVM.ReturnTrue); _loadIniConfigButton.Command = new RelayCommand(_configVM.LoadIniConfig, _configVM.ReturnTrue); _saveIniConfigButton.Command = new RelayCommand(_configVM.SaveIniConfig, _configVM.ReturnTrue); _dbVM = new DatabaseViewModel(VM); _httpVM = new HttpServerViewModel(VM); _tcpVM = new TcpServerViewModel(VM); _reportingVM = new ReportingViewModel(VM); _propertyVM = new PropertyViewModel(VM); VM.Documents.Add(_globalVM); VM.Documents.Add(_configVM); VM.Documents.Add(_dbVM); VM.Documents.Add(_httpVM); VM.Documents.Add(_tcpVM); VM.Documents.Add(_reportingVM); VM.Tools.Add(_propertyVM); }
public void TVDisplayData_DatabaseWithNoSchemasTestLoader() { DatabaseViewModel v = GenerateNewViewModel_DatabaseWithNoSchemasTestLoader(); List <TVDisplayData> t = v.TVDisplayData; Assert.IsNotNull(t); Assert.AreEqual(0, t.Count); }
private async void UpdateButton_Click(object sender, RoutedEventArgs e) { await DatabaseViewModel.Initialise(); ItemModels = DatabaseViewModel.ItemViewModels; ItemsList.ItemsSource = ItemModels; await SynchronisationHandler.PushModifiedItemsToTheCLoud(); }
public void QueryExecuted_NoSubscribers() { bool eventOccurred = false; DatabaseViewModel v = GenerateNewViewModel_DatabaseWithNoSchemasTestLoader(); //Do not subscribe to the v.QueryExecuted event List <TVDisplayData> t = v.TVDisplayData; //Triggers QueryExecuted event Assert.IsFalse(eventOccurred, "QueryExecuted event should not have occurred"); }
protected void Page_Load(object sender, EventArgs e) { vm = new DatabaseViewModel(GetMetaLoader(), conn_id); vm.QueryExecuted += base.OnQueryExecuted; if (!IsPostBack) { reload(); } }
public IActionResult Update(long id, [FromBody] DatabaseViewModel toUpdate, long environmentId = -1) { toUpdate.DatabaseId = id; if (environmentId != -1) { toUpdate.EnvironmentId = environmentId; } return(Ok(_databaseService.Update(toUpdate))); }
public List <DatabaseViewModel> GetDbList(string connectionString, int settingHeaderId = 0) { var dbList = new List <DatabaseViewModel>(); var settings = new List <Setting>(); try { if (settingHeaderId != 0) { using (var db = new ScriptRunnerDbEntities()) { settings = db.Settings.Where(t => t.HeaderId == settingHeaderId).ToList(); } } using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand("SELECT name from sys.databases", con)) { using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { string dbName = dr[0].ToString(); if (dbName != "master" && dbName != "tempdb" && dbName != "model" && dbName != "msdb") { var dbVm = new DatabaseViewModel() { IsSelected = false, Name = dr[0].ToString() }; if (settingHeaderId != 0) { var matchedDb = settings.FirstOrDefault(t => t.DbName == dbName); if (matchedDb != null) { dbVm.IsSelected = true; dbVm.Id = matchedDb.Id; } } dbList.Add(dbVm); } } } } } } catch (Exception ex) { throw ex; } return(dbList); }
public void Is_added_person_without_properties_null() { DatabaseViewModel dvm = new DatabaseViewModel(); dvm.SendCommand.Execute(null); Assert.AreEqual(dvm.Firstname, null); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { await DatabaseViewModel.Initialise(); ItemModels = DatabaseViewModel.ItemViewModels; ItemsList.ItemsSource = ItemModels; encryptor = new Encryptor(); await encryptor.Initialise("12345"); }
private void btnClose_Click(object sender, EventArgs e) { if (ReloadButtonClicked == true) { databaseViewModel = _databaseViewModel; } this.Close(); }
public ActionResult Database() { var model = new DatabaseViewModel { CreateScript = GenerateCreateScript(typeof(PlaceEnvelope), typeof(ProfileEnvelope), typeof(TrackBoundaryView), typeof(UserView), typeof(MigrationVersion)) }; return(View(model)); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var model = new DatabaseViewModel(); new DatabaseWindow { DataContext = model }.Show(); }
public ActionResult Index() { DatabaseViewModel model = new DatabaseViewModel { Backups = Directory.GetFiles(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "*.bak") .Select(x => new KeyValuePair <string, DateTime>(Path.GetFileName(x), System.IO.File.GetCreationTime(x))) .ToDictionary(x => x.Key, x => x.Value) }; return(View("Index", model)); }
public ShellViewModel( IServer server, ServerUriProvider uriProvider, NavigationViewModel navigation, NotificationsViewModel notifications, BusyStatusViewModel busyStatus, SelectDatabaseViewModel start, DatabaseViewModel databaseScreen, IKeyboardShortcutBinder binder, IEventAggregator events) { this.navigation = navigation; this.notifications = notifications; this.busyStatus = busyStatus; navigation.SetGoHome(() => { this.TrackNavigationTo(start, events); navigation.Breadcrumbs.Clear(); }); this.databaseScreen = databaseScreen; this.binder = binder; this.events = events; this.server = server; events.Subscribe(this); Items.Add(start); Items.Add(databaseScreen); serverUri = new Uri(uriProvider.GetServerUri()); events.Publish(new WorkStarted("Connecting to server")); server.Connect(serverUri, () => { events.Publish(new WorkCompleted("Connecting to server")); switch (server.Databases.Count()) { case 0: //NOTE: perhaps we should display a retry button? break; case 1: ActivateItem(databaseScreen); break; default: ActivateItem(start); break; } }); }
public void TestCannotCreateDatabaseWithoutName() { var viewModel = new DatabaseViewModel() { Host = "localhost", Port = "3306", Password = "******", User = "******" }; Assert.Throws <EntityValidationException>(() => subject.Create(viewModel)); }
public void TestCannotCreateDatabaseWithTooLongName() { var viewModel = new DatabaseViewModel() { Name = "very long string here. too much work to create a random string generator so I will just keep typing stuff until it seems we are over 100 characters", Host = "localhost", Port = "3306", Password = "******", User = "******" }; Assert.Throws <EntityValidationException>(() => subject.Create(viewModel)); }
private void AddDatabase(PcDatabase db) { // In reallity use the factory pattern to resolve the depencency of the ViewModel and assing the // database to it var viewModel = new DatabaseViewModel(eventAggregator) { Database = db }; // Register to the close command of all TabItem ViewModels, so we can close then all with a single command CloseAllCommand.RegisterCommand(viewModel.CloseCommand); Databases.Add(viewModel); }
public Database Update(DatabaseViewModel toUpdate) { var database = GetOrException(toUpdate.DatabaseId); ValidationUtils.ValidateViewModel(toUpdate); database.Name = toUpdate.Name; database.Type = toUpdate.Type; AddEncryptedValues(database, toUpdate); _db.SaveChanges(); return(database.Decrypt(_encrypter)); }
public ActionResult Databases() { // TODO: Find types from all assemblies var contexts = this.GetType() .Assembly .GetTypes() .Where(t => typeof(DbContext).IsAssignableFrom(t)); var result = new List<DatabaseViewModel>(); foreach (var context in contexts) { // TODO: Deal with non-default ctors using (var db = (DbContext)Activator.CreateInstance(context)) { var model = new DatabaseViewModel { ContextName = context.Name, ContextAssemblyQualifiedName = context.AssemblyQualifiedName, DatabaseExists = db.Database.Exists() }; var configBaseType = typeof(DbMigrationsConfiguration<>).MakeGenericType(context); var configType = context.Assembly.GetTypes().SingleOrDefault(t => configBaseType.IsAssignableFrom(t)); if(configType != null) { model.MigrationsEnabled = true; model.MigrationsConfigurationAssemblyQualifiedName = configType.AssemblyQualifiedName; var config = (DbMigrationsConfiguration)Activator.CreateInstance(configType); var migrator = new DbMigrator(config); model.PendingMigrations = migrator.GetPendingMigrations(); // We can only check for model changes if the database exists // This restriction should be removed in EF7 as we can just check the snapshot file if(model.DatabaseExists) { model.PendingModelChanges = !db.Database.CompatibleWithModel(throwIfNoMetadata: false); } } result.Add(model); } } return View(result); }
public OpenErrorsScreen(DatabaseViewModel database, ErrorsViewModel errors) { this.database = database; this.errors = errors; }