예제 #1
0
        private void wizard1_Finish(object sender, EventArgs e)
        {
            DatabaseConnectionControl1.PersistSettings();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #2
0
        private void wizard1_Finish(object sender, EventArgs e)
        {
            DatabaseConnectionControl1.PersistSettings();

            _currentTable.StaticData.Clear();
            var dt = (System.Data.DataTable) this.dataGridView1.DataSource;

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                var rowEntry   = new RowEntry(_currentTable.Root);
                var columnList = _currentTable.GetColumns().ToList();
                for (var ii = 0; ii < columnList.Count; ii++)
                {
                    var cellEntry = new CellEntry(_currentTable.Root);
                    cellEntry.ColumnRef = columnList[ii].CreateRef();
                    //if (dr[ii].GetType().ToString() == "System.Byte[]")
                    //{
                    //  cellEntry.Value = System.Text.ASCIIEncoding.ASCII.GetString((byte[])dr[ii]);
                    //}
                    //else
                    //{
                    cellEntry.Value = dr[ii].ToString();
                    //}
                    rowEntry.CellEntries.Add(cellEntry);
                }
                _currentTable.StaticData.Add(rowEntry);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #3
0
        private void ApplyChanges()
        {
            //Save the actual item
            using (var transaction = _store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString()))
            {
                #region Entity
                if (_modelElement is nHydrate.Dsl.Entity)
                {
                    var targetItem = _modelElement as nHydrate.Dsl.Entity;
                    var importItem = _importDomain.GetEntity(DatabaseConnectionControl1.ImportOptions.GetConnectionString(), (string)cboItem.SelectedItem, _auditFields);
                    targetItem.AllowCreateAudit = importItem.AllowCreateAudit;
                    targetItem.AllowModifyAudit = importItem.AllowModifyAudit;
                    targetItem.AllowTimestamp   = importItem.AllowTimestamp;
                    targetItem.IsTenant         = importItem.IsTenant;
                    DatabaseImportDomain.PopulateFields(_model, importItem, targetItem);
                    this.Text += " [Entity: " + targetItem.Name + "]";
                }
                #endregion

                #region View
                else if (_modelElement is nHydrate.Dsl.View)
                {
                    var targetItem = _modelElement as nHydrate.Dsl.View;
                    var importItem = _importDomain.GetView(DatabaseConnectionControl1.ImportOptions.GetConnectionString(), (string)cboItem.SelectedItem, _auditFields);
                    targetItem.SQL = importItem.SQL;
                    DatabaseImportDomain.PopulateFields(_model, importItem, targetItem);
                    this.Text += " [View: " + targetItem.Name + "]";
                }
                #endregion

                transaction.Commit();
            }

            DatabaseConnectionControl1.PersistSettings();
        }
예제 #4
0
        private void wizard1_BeforeSwitchPages(object sender, nHydrate.Wizard.Wizard.BeforeSwitchPagesEventArgs e)
        {
            if (e.OldIndex == 0)
            {
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    DatabaseConnectionControl1.PersistSettings();
                    var connectionString = DatabaseConnectionControl1.ImportOptions.GetConnectionString();

                    if (!SqlSchemaToModel.IsValidConnectionString(connectionString))
                    {
                        this.Cursor = Cursors.Default;
                        e.Cancel    = true;
                        MessageBox.Show("This not a valid connection string!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Setup new model
                    var project = new nHydrateGeneratorProject();
                    SqlSchemaToModel.SetupNewProject(project, connectionString);
                    this.NewDatabase = (project.Model as ModelRoot).Database;
                    SqlSchemaToModel.GetProjectFromSqlSchema(project, connectionString, false, chkInheritance.Checked);

                    //Load the tree
                    this.Populate();

                    if (!this.AreChanges())
                    {
                        this.Cursor = Cursors.Default;
                        e.Cancel    = true;
                        MessageBox.Show("This model is up-to-date. There are no changes to refresh.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
예제 #5
0
 private void cmdOK_Click(object sender, System.EventArgs e)
 {
     DatabaseConnectionControl1.PersistSettings();
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
예제 #6
0
        //private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        //{
        //  var d = e.Node.Tag as DataTreeItem;
        //  if (d == null) txtChanged.Text = "";
        //  else txtChanged.Text = d.GetChangeText();
        //}

        private void wizard1_BeforeSwitchPages(object sender, nHydrate.Wizard.Wizard.BeforeSwitchPagesEventArgs e)
        {
            if (wizard1.WizardPages[e.OldIndex] == pageConnection)
            {
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    var auditFields = new List <SpecialField>();
                    auditFields.Add(new SpecialField {
                        Name = _model.CreatedByColumnName, Type = SpecialFieldTypeConstants.CreatedBy
                    });
                    auditFields.Add(new SpecialField {
                        Name = _model.CreatedDateColumnName, Type = SpecialFieldTypeConstants.CreatedDate
                    });
                    auditFields.Add(new SpecialField {
                        Name = _model.ModifiedByColumnName, Type = SpecialFieldTypeConstants.ModifiedBy
                    });
                    auditFields.Add(new SpecialField {
                        Name = _model.ModifiedDateColumnName, Type = SpecialFieldTypeConstants.ModifiedDate
                    });
                    auditFields.Add(new SpecialField {
                        Name = _model.ConcurrencyCheckColumnName, Type = SpecialFieldTypeConstants.Timestamp
                    });
                    auditFields.Add(new SpecialField {
                        Name = _model.TenantColumnName, Type = SpecialFieldTypeConstants.Tenant
                    });

                    var pkey = ProgressHelper.ProgressingStarted("Importing...", true);
                    try
                    {
                        if (optDatabaseTypeSQL.Checked)
                        {
                            DatabaseConnectionControl1.PersistSettings();
                            var connectionString  = DatabaseConnectionControl1.ImportOptions.GetConnectionString();
                            var schemaModelHelper = new nHydrate.DataImport.SqlClient.SchemaModelHelper();

                            if (!schemaModelHelper.IsValidConnectionString(connectionString))
                            {
                                this.Cursor = Cursors.Default;
                                e.Cancel    = true;
                                MessageBox.Show("This not a valid connection string!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }

                            LoadSqlServer(connectionString, auditFields);
                            ProgressHelper.ProgressingComplete(pkey);
                        }
                        else if (optDatabaseTypePostgres.Checked)
                        {
                            var connectionString = txtConnectionStringPostgres.Text;

                            if (!DslPackage.Objects.Postgres.ImportDomain.TestConnection(connectionString))
                            {
                                this.Cursor = Cursors.Default;
                                e.Cancel    = true;
                                MessageBox.Show("This not a valid connection string!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }

                            var errorCount = LoadPostgres(connectionString, auditFields);
                            ProgressHelper.ProgressingComplete(pkey);
                            if (errorCount > 0)
                            {
                                MessageBox.Show("There were " + errorCount + " error on import.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Unknown database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    finally
                    {
                        ProgressHelper.ProgressingComplete(pkey);
                    }

                    if (!this.AreChanges())
                    {
                        this.Cursor = Cursors.Default;
                        e.Cancel    = true;
                        MessageBox.Show("This modelRoot is up-to-date. There are no changes to refresh.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
            else if (wizard1.WizardPages[e.OldIndex] == pageConnection && wizard1.WizardPages[e.NewIndex] == pageEntities)
            {
            }
            else if (wizard1.WizardPages[e.OldIndex] == pageEntities && wizard1.WizardPages[e.NewIndex] == pageSummary)
            {
                //If there are no entities selected and relations are still checked then prompt
                var nodeCheckedList = tvwAdd.Nodes[0].Nodes.AsEnumerable <TreeNode>().Where(x => x.Checked).ToList();
                nodeCheckedList.AddRange(tvwRefresh.Nodes[0].Nodes.AsEnumerable <TreeNode>().Where(x => x.Checked).ToList());
                nodeCheckedList.AddRange(tvwDelete.Nodes[0].Nodes.AsEnumerable <TreeNode>().Where(x => x.Checked).ToList());

                if (nodeCheckedList.Count == 0 && !chkIgnoreRelations.Checked)
                {
                    var result = MessageBox.Show("There are no entities selected but relations will be refreshed. Do you want to turn off relation refreshing?", "Ignore Relations", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        chkIgnoreRelations.Checked = true;
                    }
                    else if (result == System.Windows.Forms.DialogResult.No)
                    {
                        //Do Nothing
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        e.Cancel = true;
                        return;
                    }
                }

                //Moving the to the summary page
                CreateSummary();
            }
        }