/// <summary> /// The update data source. /// </summary> private void UpdateDataSource() { Logger.Trace("Started UpdateDataSource()"); if (DataSource != null) { this.loading = true; sourceType = ScaffoldConfig.ReturnSourceType(DataSource.SourceTypeId); ITableHierarchyService applicationService = new TempateHierarchyService(); List <Hierarchy> hierarchy = applicationService.ReturnHierarchyFromList(DataSource.Tables, true, true, true); AddNodes("Models", DomainTreeView, hierarchy, applicationService); this.loading = false; } else { Logger.Trace("Data Source not updated as domain is null "); } Logger.Trace("Completed UpdateDataSource()"); }
/// <summary> /// The add nodes. /// </summary> /// <param name="parentName"> /// The parent name. /// </param> /// <param name="treeView"> /// The tree view. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> public void AddNodes(string parentName, TreeView treeView, List <Hierarchy> hierarchy) { ITableHierarchyService applicationService = new TempateHierarchyService(); treeView.Nodes.Clear(); treeView.Nodes.Add(new TreeNode { Text = parentName }); treeView.Nodes[0].Nodes.AddRange(applicationService.ConvertHierarchyToNodes(hierarchy).ToArray()); treeView.Nodes[0].Expand(); }
/// <summary> /// The update data source. /// </summary> private void UpdateDataSource() { if (DataSource != null) { DataType.DomainDefinition = DataSource; ITableHierarchyService applicationService = new TempateHierarchyService(); List <Hierarchy> hierarchy = applicationService.ReturnSelectedHierarchyFromList( DataSource.Tables, SelectedContext?.Models ?? null, false, false); AddNodes("Models", TreeviewContextModels, hierarchy, applicationService); } }
/// <summary> /// The update Application Service. /// </summary> private void UpdateApplicationService() { if (SelectedApplicationService == null) { return; } SelectedApplicationService.OutputFolder = OutputFolder.Text; SelectedApplicationService.Namespace = Namespace.Text; SelectedApplicationService.ApplicationServiceName = ApplicationServiceName.Text; SelectedApplicationService.InheritFrom = InheritFrom.Text; SelectedApplicationService.OutputPath = OutputPath.Text; SelectedApplicationService.Models.Clear(); SelectedApplicationService.OutputFolderInterface = OutputFolderInterface.Text; SelectedApplicationService.NamespaceInterface = NamespaceInterface.Text; SelectedApplicationService.InheritFromInterface = InheritFromInterface.Text; SelectedApplicationService.OutputPathInterface = OutputPathInterface.Text; if (TreeviewContextModels.Nodes.Count > 0) { ITableHierarchyService applicationService = new TempateHierarchyService(); var tables = applicationService.ReturnTables(TreeviewContextModels.Nodes[0]); if (tables != null && tables.Any()) { foreach (var table in tables) { SelectedApplicationService.Models.Add(new Table { TableName = table.TableName, SchemaName = table.SchemaName, EnabledForCodeGeneration = table.EnabledForCodeGeneration, Columns = table.Columns }); } } } }
/// <summary> /// The update context. /// </summary> private void UpdateContext() { if (SelectedContext == null) { return; } SelectedContext.OutputFolder = OutputFolder.Text; SelectedContext.Namespace = Namespace.Text; SelectedContext.ContextName = ContextName.Text; SelectedContext.InheritFrom = InheritFromInterface.Text; SelectedContext.CustomConnectionName = txtCustomConnectionName.Text; SelectedContext.OutputPath = OutputPath.Text; SelectedContext.IsDefault = chkIsDefault.Checked || !(DataType as ContextDataType).Contexts.Any(o => o.IsDefault); SelectedContext.Models.Clear(); if (TreeviewContextModels.Nodes.Count > 0) { ITableHierarchyService applicationService = new TempateHierarchyService(); var tables = applicationService.ReturnTables(TreeviewContextModels.Nodes[0]); if (tables != null && tables.Any()) { foreach (var table in tables) { SelectedContext.Models.Add(new Table { TableName = table.TableName, SchemaName = table.SchemaName, EnabledForCodeGeneration = table.EnabledForCodeGeneration }); } } } }
/// <summary> /// The save. /// </summary> public void Save() { ITableHierarchyService applicationService = new TempateHierarchyService(); List <Table> addTables = applicationService.ReturnTables(this.TreeViewAdd.Nodes[0]); List <Table> removeTables = applicationService.ReturnTables(this.TreeViewDelete.Nodes[0]); List <Table> refreshedTables = applicationService.ReturnTables(this.TreeViewRefresh.Nodes[0]); if (addTables.Count > 0 || removeTables.Count > 0 || refreshedTables.Count > 0) { List <Table> newTables = applicationService.DoTableCollectionDiff( this.DataSource.Tables, addTables, removeTables, refreshedTables, this.differences); this.sourceType.Fix(newTables); this.DataSource.Tables = newTables; } this.sourceType.Fix(this.DataSource.Tables); }
/// <summary> /// The update data source. /// </summary> private void UpdateDataSource() { Logger.Trace("Started UpdateDataSource()"); if (this.DataSource != null) { this.sourceType = ScaffoldConfig.ReturnSourceType(this.DataSource.SourceTypeId); var sourceOptions = this.sourceType.Load(this.SavePath); if (this.sourceType.Test(sourceOptions)) { this.StartSplashScreen(); Thread.Sleep(100); SplashScreen.UdpateStatusText("Loading schema information"); this.sourceDomain = this.sourceType.Import(sourceOptions); IApplicationTableCollectionDifference differenceService = new ApplicationTableCollectionDifference(new ApplicationTableDifference()); this.differences = differenceService.CompareTables(this.DataSource.Tables, this.sourceDomain.Tables); ITableHierarchyService applicationService = new TempateHierarchyService(); List <Hierarchy> hierarchy = applicationService.ReturnHierarchyFromList( this.differences.FirstExtraTables, false, false, false); this.AddNodes("Models", this.TreeViewAdd, hierarchy, applicationService); hierarchy = applicationService.ReturnHierarchyFromList(this.differences.RefreshTable, false, false, false); this.AddNodes("Models", this.TreeViewRefresh, hierarchy, applicationService); hierarchy = applicationService.ReturnHierarchyFromList( this.differences.FirstMissingTables, false, false, false); this.AddNodes("Models", this.TreeViewDelete, hierarchy, applicationService); this.Valid = true; Thread.Sleep(100); this.CloseSplashScreen(false); } else { MessageBox.Show( "Invalid configuration. Please update source configuration.", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Valid = false; } } else { this.Valid = false; Logger.Trace("Data Source not updated as domain is null "); } Logger.Trace("Completed UpdateDataSource()"); }