private void MyMetaPluginUtility_Load(object sender, EventArgs e)
        {
            //dbRoot root = new dbRoot();
            foreach (IMyMetaPlugin plugin in dbRoot.Plugins.Values)
            {
                IMyMetaPlugin pluginTest = dbRoot.Plugins[plugin.ProviderUniqueKey] as IMyMetaPlugin;
                if (pluginTest == plugin)
                {
                    this.comboBoxPlugins.Items.Add(plugin.ProviderUniqueKey);
                }
            }
            dbRoot root = new dbRoot();
            foreach (string dbd in Enum.GetNames(typeof(dbDriver)))
            {
                if (!dbd.Equals("Plugin", StringComparison.CurrentCultureIgnoreCase))
                    this.comboBoxPlugins.Items.Add(dbd.ToUpper());
            }

            if (ConfigFile.Exists)
            {
                string[] lines = File.ReadAllLines(ConfigFile.FullName);
                if (lines.Length > 1)
                {
                    int idx = this.comboBoxPlugins.FindStringExact(lines[0]); 
                    if (idx >= 0) this.comboBoxPlugins.SelectedIndex = idx;
                    this.textBoxConnectionString.Text = lines[1];
                }
            }
        }
Exemplo n.º 2
0
		virtual public object Reconstitute(string source)
		{
			string[] items = source.Split(';');
			
			dbRoot myMeta = new dbRoot();

			if (items.Length >= 7) 
			{
				// DriverString, ConnectionString
				myMeta.Connect( 
						ReadableDeserialize(items[3]),
						ReadableDeserialize(items[0]) 
					);

				// DbTargetMappingFileName
				myMeta.DbTargetMappingFileName = ReadableDeserialize(items[1]);
			
				// DomainOverride
				myMeta.DomainOverride = Convert.ToBoolean(items[2]);
						
				// Language
				myMeta.Language = ReadableDeserialize(items[4]);
			
				// LanguageMappingFileName
				myMeta.LanguageMappingFileName = ReadableDeserialize(items[5]);
			
				// UserMetaDataFileName
				myMeta.UserMetaDataFileName = ReadableDeserialize(items[6]);
			}

			return myMeta;
		}
Exemplo n.º 3
0
 public TemplateConfig(dbRoot myMeta, IZeusInput zeusInput)
 {
     this.myMeta    = myMeta;
     this.zeusInput = zeusInput;
     InitializeComponent();
     zeusInput["outputpath"] = txtOutputPath.Text;
 }
Exemplo n.º 4
0
        public static void Test(IMyMetaTestContext criteria)
        {
            dbRoot root = null;

            if (!criteria.HasErrors)
            {
                root = new dbRoot();
                try
                {
                    root.Connect(criteria.ProviderType, criteria.ConnectionString);
                    root.ShowDefaultDatabaseOnly = true;
                    criteria.AppendLog("MyMeta dbRoot Connection Successful.");
                }
                catch (Exception ex)
                {
                    criteria.AppendLog("Error connecting to dbRoot", ex);
                }
            }

            TestDatabases(criteria, root);
            TestTables(criteria, root);
            TestViews(criteria, root);
            TestProcedures(criteria, root);
            TestSQL(criteria, root);
        }
Exemplo n.º 5
0
 public DotNetScriptTemplate(IZeusContext context)
     : base(context)
 {
     this.ui       = context.Objects["ui"] as Zeus.UserInterface.GuiController;
     this.MyMeta   = context.Objects["MyMeta"] as MyMeta.dbRoot;
     this.DnpUtils = context.Objects["DnpUtils"] as Dnp.Utils.Utils;
 }
Exemplo n.º 6
0
        public ConfigForm(dbRoot myMeta, IZeusInput zeusInput)
        {
            this.myMeta = myMeta;
            this.zeusInput = zeusInput;

            InitializeComponent();
            cbDatabase.DataSource = myMeta.Databases;
            cbDatabase.DisplayMember = "Name";
        }
        public List<ITable> GetAllExportTablesOrders()
        {
            dbRoot db = new dbRoot();

            db.Connect(dbDriver.SQL, this.Connstring);

            List<ITable> tables = TableGenerationHelper.GetAllExportDataOrderTables(db.DefaultDatabase);

            return tables;        
        }
Exemplo n.º 8
0
 public void TestConnection(IHost host)
 {
     var myMeta = new dbRoot();
     if (myMeta.Connect(dbDriver.SQL, ConnectionString))
     {
         MessageBox.Show("Connection was successful");
     }
     else
     {
         MessageBox.Show("Connection failed");
     }
 }
        public List<ITable> GetAllTables()
        {
            dbRoot db = new dbRoot();

            db.Connect(dbDriver.SQL, this.Connstring);

            List<ITable> tables = new List<ITable>();

            foreach (ITable table in db.DefaultDatabase.Tables)
            {
                tables.Add(table);
            }

            return tables;
        }
Exemplo n.º 10
0
        private void LoadStep2()
        {
            try
            {
                if (myMeta == null)
                {
                    myMeta = new MyMeta.dbRoot();
                }

                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents();
                if (myMeta.Connect(((Program.DriverData)cmbProvider.SelectedItem).driver, txtConnection.Text))
                {
                    tree.Nodes.Clear();

                    for (int i = 0; i < myMeta.Databases.Count; i++)
                    {
                        IDatabase db = myMeta.Databases[i];
                        TreeNode  tn = new TreeNode();
                        tn.Name = i.ToString();
                        tn.Text = db.Name;
                        //tn.ImageKey = "database";
                        tree.Nodes.Add(tn);
                        HideTreeNodeCheckBox(tn);
                        LoadTypes(tn, db);
                    }
                }
                else
                {
                    throw new ApplicationException("Cannot connect to the database.");
                }
            }
            catch (Exception ex)
            {
                MessageBoxError("Could not load database tables and views.\r\n\r\n" + ex.Message);
                PreviousStep();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                Application.DoEvents();
            }
        }
Exemplo n.º 11
0
        private bool ValidateStep1()
        {
            if (cmbProvider.SelectedIndex == -1)
            {
                MessageBoxError("Please select a provider.");
                return(false);
            }
            Program.DriverData driver = (Program.DriverData)cmbProvider.SelectedItem;

            IDbConnection connection = null;

            try
            {
                connection = new MyMeta.dbRoot().BuildConnection(driver.driver.ToString(), txtConnection.Text);
                connection.Open();

                Config.Driver = driver.driver;

                Config.Catalog          = txtCatalog.Text;
                Config.ConnectionString = txtConnection.Text;
                Config.Server           = txtServer.Text;
                Config.UserName         = txtUsername.Text;
                Config.Password         = txtPassword.Text;
                Config.Save();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBoxError("Could not open a connection with the specified settings.\r\nCheck your settings and network problems and try again.\r\n\r\n" + ex.Message);
                return(false);
            }
            finally
            {
                if (connection != null && connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
Exemplo n.º 12
0
        public dbRoot CurrentDbRoot()
        {
            dbRoot mymeta = null;

            try
            {
                mymeta = _mdi.PerformMdiFuntion(this.Parent as IMyGenContent, "getstaticdbroot") as dbRoot;
                _isUsingCurrentConnection = true;
                if (!(mymeta is dbRoot))
                {
                    mymeta = new dbRoot();
                    mymeta.Connect(DbDriver, ConnectionString);
                    _isUsingCurrentConnection = false;
                }
            }
            catch (Exception ex)
            {
                this._mdi.ErrorList.AddErrors(ex);
            }

            return mymeta;
        }
Exemplo n.º 13
0
        private static void TestDatabases(IMyMetaTestContext criteria, dbRoot root)
        {
            string garbage;
            
            if (!criteria.HasErrors)
            {
                try
                {
                    foreach (IDatabase db in root.Databases)
                    {
                        garbage = db.Name;
                        garbage = db.SchemaName;
                        garbage = db.SchemaOwner;
                    }

                    criteria.AppendLog(root.Databases.Count + " databases traversed successfully through MyMeta.");
                }
                catch (Exception ex)
                {
                    
                    criteria.AppendLog("Error traversing databases through MyMeta", ex);
                }
            }
        }
Exemplo n.º 14
0
 private static void TestSQL(IMyMetaTestContext criteria, dbRoot root)
 {
     IDbConnection conn = root.PluginSpecificData(root.DriverString, "internalconnection") as IDbConnection;
     if (conn != null)
     {
         IDbCommand cmd = conn.CreateCommand();
         cmd.CommandText = "select * from TEST_DATATYPES";
         IDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             for (int i = 0; i < reader.FieldCount; i++)
             {
                 try
                 {
                     string name = reader.GetName(i);
                     string dtname = reader.GetDataTypeName(i);
                     string dtname2 = reader.GetFieldType(i).Name;
                     criteria.AppendLog(name + "\t=\t" + dtname + "\t=\t" + dtname2);
                 }
                 catch { }
             }
         }
     }
 }
Exemplo n.º 15
0
        private static void TestTables(IMyMetaTestContext criteria, dbRoot root)
        {
            string garbage;

            if (criteria.IncludeTables && !criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    try
                    {
                        foreach (ITable tbl in db.Tables)
                        {
                            garbage = tbl.Name;
                            garbage = tbl.Schema;
                            garbage = tbl.DateCreated.ToString();
                            garbage = tbl.DateModified.ToString();
                            garbage = tbl.Description;
                            garbage = tbl.Guid.ToString();
                            garbage = tbl.PropID.ToString();
                            garbage = tbl.Type;
                        }

                        criteria.AppendLog(db.Tables.Count + " tables in database " + db.Name + " traversed successfully through MyMeta.");

                    }
                    catch (Exception ex)
                    {

                        criteria.AppendLog("Error traversing tables in database " + db.Name + " through MyMeta", ex);
                    }
                }
            }

            if (!criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    foreach (ITable table in db.Tables)
                    {
                        if (criteria.IncludeTableColumns)
                        {
                            try
                            {
                                foreach (IColumn column in table.Columns)
                                {
                                    garbage = column.AutoKeyIncrement.ToString();
                                    garbage = column.AutoKeySeed.ToString();
                                    garbage = column.CharacterMaxLength.ToString();
                                    garbage = column.CharacterOctetLength.ToString();
                                    garbage = column.CharacterSetCatalog;
                                    garbage = column.CharacterSetName;
                                    garbage = column.CharacterSetSchema;
                                    garbage = column.CompFlags.ToString();
                                    garbage = column.DataType.ToString();
                                    garbage = column.DataTypeName;
                                    garbage = column.DataTypeNameComplete;
                                    garbage = column.DateTimePrecision.ToString();
                                    garbage = column.DbTargetType;
                                    garbage = column.Default;
                                    garbage = column.Description;
                                    garbage = column.DomainCatalog;
                                    garbage = column.DomainName;
                                    garbage = column.DomainSchema;
                                    garbage = column.Flags.ToString();
                                    garbage = column.Guid.ToString();
                                    garbage = column.HasDefault.ToString();
                                    garbage = column.HasDomain.ToString();
                                    garbage = column.IsAutoKey.ToString();
                                    garbage = column.IsComputed.ToString();
                                    garbage = column.IsInForeignKey.ToString();
                                    garbage = column.IsInPrimaryKey.ToString();
                                    garbage = column.IsNullable.ToString();
                                    garbage = column.LanguageType;
                                    garbage = column.LCID.ToString();
                                    garbage = column.Name;
                                    garbage = column.NumericPrecision.ToString();
                                    garbage = column.NumericScale.ToString();
                                    garbage = column.Ordinal.ToString();
                                    garbage = column.PropID.ToString();
                                    garbage = column.SortID.ToString();
                                    //garbage = column.TDSCollation.ToString(); -- Null means empty?
                                    garbage = column.TypeGuid.ToString();
                                }
                                criteria.AppendLog(table.Columns.Count + " table columns in database " + db.Name + "." + table.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing table columns in " + db.Name + "." + table.Name + " through MyMeta", ex);
                            }
                        }

                        if (criteria.IncludeTableOther)
                        {
                            try
                            {
                                foreach (IForeignKey fk in table.ForeignKeys)
                                {
                                    garbage = fk.Deferrability;
                                    garbage = fk.DeleteRule;
                                    garbage = fk.Name;
                                    garbage = fk.PrimaryKeyName;
                                    garbage = fk.UpdateRule;
                                    garbage = fk.ForeignColumns.Count.ToString();
                                    garbage = fk.PrimaryColumns.Count.ToString();
                                    garbage = fk.ForeignTable.Name;
                                    garbage = fk.PrimaryTable.Name;
                                }

                                criteria.AppendLog(table.ForeignKeys.Count + " FKs in table " + db.Name + "." + table.Name + " traversed successfully through MyMeta.");

                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing FKs in table " + db.Name + "." + table.Name + " through MyMeta", ex);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="root"></param>
        /// <param name="criteria.HasErrors"></param>
        private static void TestProcedures(IMyMetaTestContext criteria, dbRoot root)
        {
            string garbage;

            if (criteria.IncludeProcedures && !criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    try
                    {
                        foreach (IProcedure procedure in db.Procedures)
                        {
                            garbage = procedure.Name;
                            garbage = procedure.Schema;
                            garbage = procedure.DateCreated.ToString();
                            garbage = procedure.DateModified.ToString();
                            garbage = procedure.Description;
                            garbage = procedure.ProcedureText;
                            garbage = procedure.Type.ToString();
                        }

                        criteria.AppendLog(db.Procedures.Count + " procedures in database " + db.Name + " traversed successfully through MyMeta.");

                    }
                    catch (Exception ex)
                    {
                        
                        criteria.AppendLog("Error traversing procedures in database " + db.Name + " through MyMeta", ex);
                    }
                }
            }

            if (!criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    foreach (IProcedure procedure in db.Procedures)
                    {
                        if (criteria.IncludeParameters)
                        {
                            try
                            {
                                foreach (IParameter parameter in procedure.Parameters)
                                {
                                    garbage = parameter.CharacterMaxLength.ToString();
                                    garbage = parameter.CharacterOctetLength.ToString();
                                    garbage = parameter.DataType.ToString();
                                    garbage = parameter.DataTypeNameComplete;
                                    garbage = parameter.DbTargetType;
                                    garbage = parameter.Default;
                                    garbage = parameter.Description;
                                    garbage = parameter.Direction.ToString();
                                    garbage = parameter.LocalTypeName.ToString();
                                    garbage = parameter.HasDefault.ToString();
                                    garbage = parameter.IsNullable.ToString();
                                    garbage = parameter.LanguageType;
                                    garbage = parameter.Name;
                                    garbage = parameter.NumericPrecision.ToString();
                                    garbage = parameter.NumericScale.ToString();
                                    garbage = parameter.Ordinal.ToString();
                                    garbage = parameter.TypeName.ToString();
                                }
                                criteria.AppendLog(procedure.Parameters.Count + " procedure parameters in " + db.Name + "." + procedure.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing procedure parameters in " + db.Name + "." + procedure.Name + " through MyMeta", ex);
                            }
                        }

                        if (criteria.IncludeProcOther)
                        {
                            try
                            {
                                foreach (IResultColumn column in procedure.ResultColumns)
                                {
                                    garbage = column.DataType.ToString();
                                    garbage = column.DataTypeName;
                                    garbage = column.DataTypeNameComplete;
                                    garbage = column.DbTargetType;
                                    garbage = column.LanguageType;
                                    garbage = column.Name;
                                    garbage = column.Ordinal.ToString();
                                }
                                criteria.AppendLog(procedure.ResultColumns.Count + " procedure result columns in " + db.Name + "." + procedure.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing procedure result columns in " + db.Name + "." + procedure.Name + " through MyMeta", ex);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="root"></param>
        /// <param name="criteria.HasErrors"></param>
        private static void TestViews(IMyMetaTestContext criteria, dbRoot root)
        {
            string garbage;

            if (criteria.IncludeViews && !criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    try
                    {
                        foreach (IView view in db.Views)
                        {

                            garbage = view.Name;
                            garbage = view.Schema;
                            garbage = view.DateCreated.ToString();
                            garbage = view.DateModified.ToString();
                            garbage = view.Description;
                            garbage = view.Guid.ToString();
                            garbage = view.PropID.ToString();
                            garbage = view.Type;
                            garbage = view.IsUpdateable.ToString();
                            garbage = view.CheckOption.ToString();
                            garbage = view.ViewText;
                        }

                        criteria.AppendLog(db.Views.Count + " views in database " + db.Name + " traversed successfully through MyMeta.");

                    }
                    catch (Exception ex)
                    {
                        
                        criteria.AppendLog("Error traversing views in database " + db.Name + " through MyMeta", ex);
                    }
                }
            }
      
            if (!criteria.HasErrors)
            {
                foreach (IDatabase db in root.Databases)
                {
                    foreach (IView view in db.Views)
                    {
                        if (criteria.IncludeViewColumns)
                        {
                            try
                            {
                                foreach (IColumn column in view.Columns)
                                {
                                    garbage = column.AutoKeyIncrement.ToString();
                                    garbage = column.AutoKeySeed.ToString();
                                    garbage = column.CharacterMaxLength.ToString();
                                    garbage = column.CharacterOctetLength.ToString();
                                    garbage = column.CharacterSetCatalog;
                                    garbage = column.CharacterSetName;
                                    garbage = column.CharacterSetSchema;
                                    garbage = column.CompFlags.ToString();
                                    garbage = column.DataType.ToString();
                                    garbage = column.DataTypeName;
                                    garbage = column.DataTypeNameComplete;
                                    garbage = column.DateTimePrecision.ToString();
                                    garbage = column.DbTargetType;
                                    garbage = column.Default;
                                    garbage = column.Description;
                                    garbage = column.DomainCatalog;
                                    garbage = column.DomainName;
                                    garbage = column.DomainSchema;
                                    garbage = column.Flags.ToString();
                                    garbage = column.Guid.ToString();
                                    garbage = column.HasDefault.ToString();
                                    garbage = column.HasDomain.ToString();
                                    garbage = column.IsAutoKey.ToString();
                                    garbage = column.IsComputed.ToString();
                                    garbage = column.IsInForeignKey.ToString();
                                    garbage = column.IsInPrimaryKey.ToString();
                                    garbage = column.IsNullable.ToString();
                                    garbage = column.LanguageType;
                                    garbage = column.LCID.ToString();
                                    garbage = column.Name;
                                    garbage = column.NumericPrecision.ToString();
                                    garbage = column.NumericScale.ToString();
                                    garbage = column.Ordinal.ToString();
                                    garbage = column.PropID.ToString();
                                    garbage = column.SortID.ToString();
                                    //garbage = column.TDSCollation.ToString(); -- Null means empty?
                                    garbage = column.TypeGuid.ToString();
                                }
                                criteria.AppendLog(view.Columns.Count + " view columns in database " + db.Name + "." + view.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing view columns in " + db.Name + "." + view.Name + " through MyMeta", ex);
                            }
                        }

                        if (criteria.IncludeViewOther)
                        {
                            try
                            {
                                foreach (ITable subtable in view.SubTables)
                                {
                                    garbage = subtable.Name;
                                    garbage = subtable.Schema;
                                    garbage = subtable.DateCreated.ToString();
                                    garbage = subtable.DateModified.ToString();
                                    garbage = subtable.Description;
                                    garbage = subtable.Guid.ToString();
                                    garbage = subtable.PropID.ToString();
                                    garbage = subtable.Type;
                                }
                                criteria.AppendLog(view.SubTables.Count + " view sub-tables in database " + db.Name + "." + view.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing view sub-tables in " + db.Name + "." + view.Name + " through MyMeta", ex);
                            }

                            try
                            {
                                foreach (IView subview in view.SubViews)
                                {
                                    garbage = subview.Name;
                                    garbage = subview.Schema;
                                    garbage = subview.DateCreated.ToString();
                                    garbage = subview.DateModified.ToString();
                                    garbage = subview.Description;
                                    garbage = subview.Guid.ToString();
                                    garbage = subview.PropID.ToString();
                                    garbage = subview.Type;
                                    garbage = subview.IsUpdateable.ToString();
                                    garbage = subview.CheckOption.ToString();
                                    garbage = subview.ViewText;
                                }
                                criteria.AppendLog(view.SubViews.Count + " view sub-views in database " + db.Name + "." + view.Name + " traversed successfully through MyMeta.");
                            }
                            catch (Exception ex)
                            {

                                criteria.AppendLog("Error traversing view sub-views in " + db.Name + "." + view.Name + " through MyMeta", ex);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
		public void InitializeTree(dbRoot myMeta, string error)
		{
			this.MyTree.BeginUpdate();

			this.MyTree.Nodes.Clear();
			this.myMeta = myMeta;

			string nodeText = error == "" ? myMeta.DriverString : error;

			TreeNode rootNode = new TreeNode("MyMeta (" + nodeText + ")");
			rootNode.Tag = new NodeData(NodeType.MYMETA, myMeta);
			rootNode.SelectedImageIndex = rootNode.ImageIndex = 21;
			this.MyTree.Nodes.Add(rootNode);

			if(error != "")
			{
				// There's an error when trying to connect, let's bail with the error
				// text in the node 
				rootNode.Expand();
				this.MyTree.EndUpdate();
				return;
			}

			// This is true for dbDriver = NONE
			if(myMeta.Databases == null)
			{
				this.MyTree.EndUpdate();				
				return;
			}

			try
			{
				TreeNode databasesNode = new TreeNode("Databases");
				databasesNode.Tag = new NodeData(NodeType.DATABASES, myMeta.Databases);
				databasesNode.SelectedImageIndex = databasesNode.ImageIndex = 0;

				rootNode.Nodes.Add(databasesNode);

				foreach(IDatabase database in myMeta.Databases)
				{
					TreeNode dbNode = new TreeNode(database.Name);
					dbNode.Tag =  new NodeData(NodeType.DATABASE, database);
					dbNode.SelectedImageIndex = dbNode.ImageIndex = 1;
					dbNode.Nodes.Add(this.BlankNode);
					databasesNode.Nodes.Add(dbNode);
				}

				rootNode.Expand();
				databasesNode.Expand();
				this.MyTree.EndUpdate();
			}
			catch(Exception ex)
			{
				if(rootNode != null)
				{
					rootNode.Text = "MyMeta (" + ex.Message + " )";
				}
			}
		}
        public void Populate()
        {
            myMeta = new dbRoot();
            this.defaultOleDbButtonColor = this.btnOleDb.BackColor;

            this.cboDbDriver.DisplayMember = "DISPLAY";
            this.cboDbDriver.ValueMember = "VALUE";
            this.cboDbDriver.DataSource = DriversTable;

            switch (settings.DbDriver)
            {
                case "PERVASIVE":
                case "POSTGRESQL":
                case "POSTGRESQL8":
                case "FIREBIRD":
                case "INTERBASE":
                case "SQLITE":
                case "MYSQL2":
#if !IGNORE_VISTA
                case "VISTADB":
#endif
                case "ISERIES":
                case "NONE":
                case "":
                    this.btnOleDb.Enabled = false;
                    break;
            }

            this.txtConnectionString.Enabled = true;

            this.cboDbDriver.SelectedValue = settings.DbDriver;
            this.txtConnectionString.Text = settings.ConnectionString;
            this.txtLanguageFile.Text = settings.LanguageMappingFile;
            this.txtDbTargetFile.Text = settings.DbTargetMappingFile;
            this.txtUserMetaDataFile.Text = settings.UserMetaDataFileName;

            myMeta.ShowDefaultDatabaseOnly = settings.ShowDefaultDatabaseOnly;
            myMeta.LanguageMappingFileName = settings.LanguageMappingFile;
            myMeta.DbTargetMappingFileName = settings.DbTargetMappingFile;

            this.cboLanguage.Enabled = true;
            this.cboDbTarget.Enabled = true;

            PopulateLanguages();
            PopulateDbTargets();

            this.cboLanguage.SelectedItem = settings.Language;
            this.cboDbTarget.SelectedItem = settings.DbTarget;

            this.textBoxDbUserMetaMappings.Text = settings.DatabaseUserDataXmlMappingsString;

            this.checkBoxClipboard.Checked = settings.EnableClipboard;
            this.checkBoxRunTemplatesAsync.Checked = settings.ExecuteFromTemplateBrowserAsync;
            this.checkBoxDefaultDBOnly.Checked = settings.ShowDefaultDatabaseOnly;
            this.checkBoxShowConsoleOutput.Checked = settings.ConsoleWriteGeneratedDetails;
            this.checkBoxDocumentStyleSettings.Checked = settings.EnableDocumentStyleSettings;
            this.checkBoxLineNumbers.Checked = settings.EnableLineNumbering;
            this.txtTabs.Text = settings.Tabs.ToString();
            this.txtDefaultTemplatePath.Text = settings.DefaultTemplateDirectory;
            this.textBoxOutputPath.Text = settings.DefaultOutputDirectory;

            this.chkForUpdates.Checked = settings.CheckForNewBuild;
            this.chkDomainOverride.Checked = settings.DomainOverride;

            int timeout = settings.ScriptTimeout;
            if (timeout == -1)
            {
                this.checkBoxDisableTimeout.Checked = true;
                this.checkBoxDisableTimeout_CheckedChanged(this, new EventArgs());
            }
            else
            {
                this.checkBoxDisableTimeout.Checked = false;
                this.checkBoxDisableTimeout_CheckedChanged(this, new EventArgs());
                this.textBoxTimeout.Text = timeout.ToString();
            }

            this.checkBoxUseProxyServer.Checked = settings.UseProxyServer;
            this.textBoxProxyServer.Text = settings.ProxyServerUri;
            this.textBoxProxyUser.Text = settings.ProxyAuthUsername;
            this.textBoxProxyPassword.Text = settings.ProxyAuthPassword;
            this.textBoxProxyDomain.Text = settings.ProxyAuthDomain;

            this.rebindSavedConns();

            EncodingInfo[] encodings = Encoding.GetEncodings();
            this.comboBoxCodePage.Items.Add(string.Empty);
            foreach (EncodingInfo encoding in encodings)
            {
                string windowsCodePage = encoding.CodePage.ToString() + ": " + encoding.DisplayName;
                int idx = this.comboBoxCodePage.Items.Add(windowsCodePage);

                if (encoding.CodePage == settings.CodePage)
                {
                    comboBoxCodePage.SelectedIndex = idx;
                }
            }

            this.textBoxFont.Text = this.settings.FontFamily;
        }
Exemplo n.º 20
0
 public frmMain(MyMeta.dbRoot myMeta)
     : this()
 {
     this.myMeta = myMeta;
 }
Exemplo n.º 21
0
		public void ExecuteTemplate(ZeusTemplate template) 
		{
			this.Cursor = Cursors.WaitCursor;

			DefaultSettings settings = new DefaultSettings();
			
			ZeusInput zin = new ZeusInput();
			ZeusOutput zout = new ZeusOutput();
			Hashtable objects = new Hashtable();
			ZeusGuiContext guicontext;
			ZeusTemplateContext bodycontext = null;

			dbRoot myMeta = new dbRoot();

			// Set the global variables for the default template/output paths
			zin["defaultTemplatePath"] = settings.DefaultTemplateDirectory;
			zin["defaultOutputPath"] = settings.DefaultOutputDirectory;

			string driver, connectionString;

			//if there is a connection string set, it in the input section here.
			if (settings.DbDriver != string.Empty) 
			{
				driver = settings.DbDriver;
				connectionString = settings.ConnectionString;

				zin["dbDriver"] = driver;
				zin["dbConnectionString"] = connectionString;
				
				try 
				{
					// Try to connect to the DB with MyMeta (using default connection info)
					myMeta.Connect(settings.DbDriver, settings.ConnectionString);
					
					// Set DB global variables and also input variables

					if (settings.DbTarget != string.Empty)				
						myMeta.DbTarget	= settings.DbTarget;

					if (settings.DbTargetMappingFile != string.Empty)
						myMeta.DbTargetMappingFileName = settings.DbTargetMappingFile;

					if (settings.LanguageMappingFile != string.Empty)
						myMeta.LanguageMappingFileName = settings.LanguageMappingFile;

					if (settings.DbTarget != string.Empty)
						myMeta.DbTarget	= settings.DbTarget;

					if (settings.Language != string.Empty)
						myMeta.Language = settings.Language;

					if (settings.UserMetaDataFileName != string.Empty)
						myMeta.UserMetaDataFileName = settings.UserMetaDataFileName;
				}
				catch 
				{
					// Give them an empty MyMeta
					myMeta = new dbRoot();
				}
			}

			bool exceptionOccurred = false;

			bool result = false;
			try 
			{
				// Add any objects here that need to be embedded in the script.
				objects.Add("MyMeta", myMeta);

				guicontext = new ZeusGuiContext(zin, new GuiController(), objects);

				template.GuiSegment.ZeusScriptingEngine.Executioner.ScriptTimeout = settings.ScriptTimeout;
				template.GuiSegment.ZeusScriptingEngine.Executioner.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display));
				result = template.GuiSegment.Execute(guicontext); 

				if (result) 
				{
					bodycontext = new ZeusTemplateContext(guicontext);
					result = template.BodySegment.Execute(bodycontext);
				}
			}
			catch (Exception ex)
			{
				ZeusDisplayError formError = new ZeusDisplayError(ex);
				formError.SetControlsFromException();			
				formError.ShowDialog(this);

				exceptionOccurred = true;
			}

			if (!exceptionOccurred && result)
			{
				MessageBox.Show("Successfully rendered template: " + template.Title);
			}

			this.Cursor = Cursors.Default;
		}
Exemplo n.º 22
0
		private void PopulateComboBox(DefaultSettings settings)
		{
			this.cboxLanguage.Items.Clear();

			// Populate the ComboBox
			dbRoot myMeta = new dbRoot();
			myMeta.LanguageMappingFileName	= settings.LanguageMappingFile;
			myMeta.Language					= settings.Language;

			string[] languages = myMeta.GetLanguageMappings(settings.DbDriver);

			if(null != languages)
			{
				for(int i = 0; i < languages.Length; i++)
				{
					this.cboxLanguage.Items.Add(languages[i]);
				}

				this.cboxLanguage.SelectedItem = myMeta.Language;

				if(this.cboxLanguage.SelectedIndex == -1)
				{
					// The default doesn't exist, set it to the first in the list
					this.cboxLanguage.SelectedIndex = 0;
				}
			}
		}
Exemplo n.º 23
0
		private void PopulateComboBox(DefaultSettings settings)
		{
			this.cboxDbTarget.Items.Clear();

			// Populate the ComboBox
			dbRoot myMeta = new dbRoot();
			myMeta.DbTargetMappingFileName	= settings.DbTargetMappingFile;
			myMeta.DbTarget					= settings.DbTarget;

			string[] targets = myMeta.GetDbTargetMappings(settings.DbDriver);

			if(null != targets)
			{
				for(int i = 0; i < targets.Length; i++)
				{
					this.cboxDbTarget.Items.Add(targets[i]);
				}

				this.cboxDbTarget.SelectedItem = myMeta.DbTarget;

				if(this.cboxDbTarget.SelectedIndex == -1)
				{
					// The default doesn't exist, set it to the first in the list
					this.cboxDbTarget.SelectedIndex = 0;
				}
			}
		}
Exemplo n.º 24
0
        private void Setup(DefaultSettings settings)
		{
			string error = string.Empty;

			try
			{
				myMeta = new dbRoot();
				this.Text = "MyMeta Browser (" + settings.DbDriver + ")";

				if (settings.DbDriver.ToUpper() != "NONE")
                {
#if !DEBUG
                    TestConnectionForm tcf = new TestConnectionForm(settings.DbDriver, settings.ConnectionString, true);
					if (isFirstRun) 
					{
						tcf.StartPosition = FormStartPosition.CenterScreen;
						isFirstRun = false;
					}
					tcf.ShowDialog(this.MdiParent);
					if (TestConnectionForm.State == ConnectionTestState.Error) 
					{
						if (TestConnectionForm.LastErrorMsg != null)
							error = TestConnectionForm.LastErrorMsg;
						else 
							error = "Connection Error...";
					}
					tcf = null;
#endif
				}

				if (error == string.Empty) 
				{
					myMeta.Connect(settings.DbDriver, settings.ConnectionString);
					myMeta.LanguageMappingFileName	= settings.LanguageMappingFile;
					myMeta.Language					= settings.Language;
					myMeta.DbTargetMappingFileName	= settings.DbTargetMappingFile;
					myMeta.DbTarget					= settings.DbTarget;
					myMeta.UserMetaDataFileName		= settings.UserMetaDataFileName;

					myMeta.DomainOverride			= settings.DomainOverride;

					myMeta.ShowSystemData			= chkSystem.Checked;
				}
			}
			catch(Exception ex)
			{
				error = ex.Message;
			}

			this.InitializeTree(myMeta, error);
		}
Exemplo n.º 25
0
        public void SyncFromDataSourceToTableModel(IHost host)
        {
            var myMeta = new dbRoot();
            myMeta.Connect(dbDriver.SQL, ConnectionString);

            try
            {
                Engine.MuteNotify();
                var tablesTrans = Tables.BeginTransaction();
                foreach (ITable metaTable in myMeta.DefaultDatabase.Tables)
                {
                    var table = tablesTrans.GetNamedChild<TableElement>(metaTable.Name);
                    Tables.AddChild(table);

                    var columnsTrans = table.Columns.BeginTransaction();
                    foreach (IColumn metaColumn in metaTable.Columns)
                    {
                        var column = columnsTrans.GetNamedChild<ColumnElement>(metaColumn.Name);

                        column.Name = metaColumn.Name;
                        column.IsNullable = metaColumn.IsNullable;
                        column.IsAutoKey = metaColumn.IsAutoKey;
                        column.IsInPrimaryKey = metaColumn.IsInPrimaryKey;
                        column.Default = metaColumn.Default;
                        column.Ordinal = metaColumn.Ordinal;
                        column.DbType = metaColumn.DataTypeName;
                        column.MaxLength = metaColumn.NumericPrecision;
                        column.AutoKeySeed = metaColumn.AutoKeySeed;
                        column.AutoKeyIncrement = metaColumn.AutoKeyIncrement;

                        table.Columns.AddChild(column);
                    }
                }

                //update foreign keys
                //must be done in a 2nd step since all columns are not available in the first loop
                foreach (ITable metaTable in myMeta.DefaultDatabase.Tables)
                {
                    var table = tablesTrans.GetNamedChild<TableElement>(metaTable.Name);
                    var foreignKeysTrans = table.ForeignKeys.BeginTransaction();
                    foreach (IForeignKey metaForeignKey in metaTable.ForeignKeys)
                    {
                        if (metaForeignKey.PrimaryTable.Name == metaTable.Name)
                            continue;

                        var foreignKey = foreignKeysTrans.GetNamedChild<ForeignKeyElement>(metaForeignKey.Name);
                        foreignKey.PrimaryTable = tablesTrans.GetNamedChild<TableElement>(metaForeignKey.PrimaryTable.Name);
                        table.ForeignKeys.AddChild(foreignKey);
                        var foreignKeyTrans = foreignKey.BeginTransaction();

                        for (int i = 0; i < metaForeignKey.ForeignColumns.Count; i++)
                        {
                            var columnPair = new ColumnPairElement();
                            columnPair.PrimaryColumn = foreignKey.PrimaryTable.Columns.GetNamedChild<ColumnElement>(((IColumn)metaForeignKey.PrimaryColumns[i]).Name);
                            columnPair.ForeignColumn = foreignKey.ForeignTable.Columns.GetNamedChild<ColumnElement>(((IColumn)metaForeignKey.ForeignColumns[i]).Name);

                            foreignKey.AddChild(columnPair);
                        }
                    }
                }

                var viewTrans = Views.BeginTransaction();
                foreach (IView metaView in myMeta.DefaultDatabase.Views)
                {
                    var view = viewTrans.GetNamedChild<ViewElement>(metaView.Name);

                    view.Name = metaView.Name;
                    Views.AddChild(view);
                }

                var procTrans = Procedures.BeginTransaction();
                foreach (IProcedure metaProcedure in myMeta.DefaultDatabase.Procedures)
                {
                    if (metaProcedure.Type == 3)
                        continue;

                    var procedure = procTrans.GetNamedChild<ProcedureElement>(metaProcedure.Name);

                    procedure.Name = metaProcedure.Name;
                    Procedures.AddChild(procedure);
                }

                Engine.EnableNotify();
                Engine.OnNotifyChange();
            }
            catch
            {
                MessageBox.Show("Connection failed");
            }

            host.RefreshProjectTree();
        }
Exemplo n.º 26
0
		private void OpenDataLinkDialog(string connection, dbDriver driver, string caption)
		{
			DataLinksClass dl = new MSDASC.DataLinksClass();

			ADODB.Connection conn = new ADODB.ConnectionClass();
			conn.ConnectionString = connection;

			object objCn = (object) conn;

			//	dl.PromptNew();
			if(dl.PromptEdit(ref objCn))
			{				
				this.Text = "MyMeta Browser " + caption;

				string error = "";
				try
				{
					myMeta = new dbRoot();
					myMeta.Connect(driver, conn.ConnectionString);
				}
				catch(Exception ex)
				{
					error = ex.Message;
				}

				this.InitializeTree(myMeta, error);
			}
		}
Exemplo n.º 27
0
        private void _ProcessMyMeta()
        {
            if (_argmgr.MergeMetaFiles)
            {
                try 
                {
                    dbRoot.MergeUserMetaDataFiles(_argmgr.MetaFile1, _argmgr.MetaDatabase1, _argmgr.MetaFile2, _argmgr.MetaDatabase2, _argmgr.MetaFileMerged);
                }
                catch (Exception ex)
                {
                    this._log.Write(ex);
                    this._log.Write("Merge UserMetaData files failed.");
                }
            }
            else
            {
                IDbConnection connection = null;
                try
                {
                    dbRoot mymeta = new dbRoot();
                    connection = mymeta.BuildConnection(_argmgr.ConnectionType, _argmgr.ConnectionString);
                    _log.Write("Beginning test for {0}: {1}", connection.GetType().ToString(), _argmgr.ConnectionString);
                    connection.Open();
                    connection.Close();
                    _log.Write("Test Successful");
                }
                catch (Exception ex)
                {
                    _log.Write("Test Failed");
                    if (_log != null) _log.Write(ex);
                    _returnValue = -1;
                }

                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
        }