public void LoadFromXml(XmlElement xml) { this.LoadPropertiesCore(xml); IStoredConnection sconn = (IStoredConnection)StoredConnectionAddonType.Instance.LoadAddon(xml.FindElement("Connection")); m_conn = sconn.CreatePhysicalConnection(); }
public static void DropDbs() { foreach (var con in Config.Instance.Connections) { string fn = Path.Combine(Config.Instance.AppDataDirectory, "data/" + con.ConFileName); IStoredConnection sc = StoredConnection.LoadFromFile(fn); if (sc == null) { TestLog.Info("Cannot connect to database " + con.ConFileName); continue; } using (DbConnection dbconn = sc.CreateSystemConnection()) { dbconn.Open(); try { TestLog.Info("Deleting testing database"); dbconn.ExecuteNonQuery("DROP DATABASE testingdb", new GenericDialect()); } catch (Exception e) { TestLog.Error("Error creating database", e); } } } }
public ConnectionTreeNode(ITreeNode parent, IFileHandler fhandler, IStoredConnection stored, bool autoConnect) : base(parent, fhandler) { m_stored = stored; m_autoConnect = autoConnect; //Properties["connected"] = ""; //m_conn.DispatchGetConnectionProperties(Properties); }
public static bool Edit(IStoredConnection conn) { ConnWizardForm win = new ConnWizardForm(conn); if (win.ShowDialogEx() == DialogResult.OK) { return(true); } return(false); }
public static IStoredConnection LoadFromFile(string file) { XmlDocument doc = new XmlDocument(); doc.Load(file); IStoredConnection con = (IStoredConnection)StoredConnectionAddonType.Instance.LoadAddon(doc.DocumentElement); con.FileName = file; return(con); }
public GenericDbConnection(GenericDbConnectionFactory fact) : base(fact) { //m_conn = conn; //string connectionString, DbProviderFactory factory, string title, IDialectDetector dialectDetector, IStoredConnection storedConnection //m_title = storedConnection.ToString() .GetTitle(); m_storedConnection = fact.Stored; m_factory = m_storedConnection.GetFactory(); m_connectionString = m_storedConnection.GenerateConnectionString(true); m_dialectDetector = m_storedConnection.GetDialectDetector(); ProviderHooks = m_storedConnection.CreateHooks(); m_storedConnection.InstallHooks(this); }
public override string CreateHtml(AppObject appobj, ConnectionPack connpack, IDictionary <string, object> outnames) { HtmlGenerator gen = new HtmlGenerator(); IPhysicalConnection pconn = appobj.FindPhysicalConnection(connpack); string dbversion = null; if (pconn != null && pconn.SystemConnection != null) { try { dbversion = pconn.SystemConnection.ServerVersion; } catch { dbversion = null; } } IStoredConnection scon = pconn.StoredConnection; gen.BeginHtml(VersionInfo.ProgramTitle, HtmlGenerator.HtmlObjectViewStyle); gen.Heading(Texts.Get("s_properties"), 2); gen.PropsTableBegin(); if (scon != null) { gen.PropTableRow("s_path", scon.FileName); } var attr = XmlTool.GetRegisterAttr(scon); if (attr != null) { gen.PropTableRow("s_database_engine", attr.Title ?? attr.Name); } if (scon != null) { gen.PropTableRow("s_host", scon.GetDataSource()); gen.PropTableRow("s_database", scon.ExplicitDatabaseName); gen.PropTableRow("s_login", scon.GetLogin()); } else { gen.PropTableRow("s_path", pconn.PhysicalFactory.GetDataSource()); } if (dbversion != null) { gen.PropTableRow("s_version", dbversion); } gen.PropsTableEnd(); gen.EndHtml(); return(gen.HtmlText); }
public override bool Create(ITreeNode parent, string name) { IStoredConnection conn = CreateStoredConnection(); conn.FileName = System.IO.Path.Combine(parent.FileSystemPath, name + ".con"); Form wiz = CreateWizard(conn); wiz.ShowDialogEx(); if (wiz.DialogResult == System.Windows.Forms.DialogResult.OK) { conn.Save(); return(true); } return(false); }
public static ITreeNode FromStoredConnection(ITreeNode parent, IStoredConnection stored, IFileHandler fhandler) { IPhysicalConnection phys = stored.CreatePhysicalConnection(); if (stored.DatabaseMode == ConnectionDatabaseMode.All) { IServerSource conn = new GenericServerSource(phys); return(new Server_SourceConnectionTreeNode(conn, parent, fhandler, stored)); } else { string exdbname = stored.DatabaseMode == ConnectionDatabaseMode.Explicit ? stored.ExplicitDatabaseName : null; IDatabaseSource conn = new GenericDatabaseSource(null, phys, exdbname); return(new Database_SourceConnectionTreeNode(conn, parent, fhandler, stored, false)); } }
protected virtual Form CreateWizard(IStoredConnection conn) { return(new ConnWizardForm(conn)); }
public ConnWizardForm(IStoredConnection conn) { InitializeComponent(); m_conn = conn; int top = ClientSize.Height - (btnOk.Top + btnOk.Height); int left = ClientSize.Width - (btnOk.Left + btnOk.Width); int wi = ClientSize.Width - 2 * left; var tun = m_conn as ITunellableStoredConnection; var parent = Controls; TabControl pg = null; if (tun != null) { pg = new TabControl(); var pg1 = new TabPage { Text = Texts.Get("s_connection") }; var pg2 = new TabPage { Text = Texts.Get("s_tunnelling") }; pg.TabPages.Add(pg1); pg.TabPages.Add(pg2); pg.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; Controls.Add(pg); pg.Top = top; pg.Width = wi; pg.Left = left; m_tunCfg = new TunnelConfigFrame(); m_tunCfg.AllowDirectConnection = tun.AllowDirectConnection; m_tunCfg.SelectedDriver = tun.TunnelDriver; m_tunCfg.SelectedDriverChanged += new EventHandler(m_tunCfg_SelectedDriverChanged); pg2.Controls.Add(m_tunCfg); m_tunCfg.Dock = DockStyle.Fill; parent = pg1.Controls; top = 10; left = 10; wi = pg.Width - 20; pg.SelectedIndexChanged += pg_TabIndexChanged; } m_frame = m_conn.CreateEditor(); parent.Add(m_frame); m_frame.Left = left; m_frame.Top = top; m_frame.Width = wi; m_common = new CommonConnectionEditFrame(conn); parent.Add(m_common); m_common.Left = left; m_common.Top = m_frame.Height + top; m_common.Width = wi; m_common.LinkToSpecific(m_frame); Height = top + Height + m_frame.Height + m_common.Height + (tun != null ? 50 : 0); if (pg != null) { pg.Height = m_frame.Height + m_common.Height + 50; } Text = Texts.Get(m_conn.ConnectionTypeTitle); Translating.TranslateControl(this); btnAdvanced.Enabled = conn.ConnectionSettings != null; btnCtxhelp.Enabled = m_conn.HelpTopic != null; Usage["contype"] = conn.GetType().FullName; m_origHeight = Height; m_origWidth = Width; }
public RunSqlJobCommand(IStoredConnection conn, string db, string sql) { Connection = conn; Sql = sql; Database = db; }
public ConnectionEditFrame(IStoredConnection conn) { m_conn = conn; InitializeComponent(); }
public override ITreeNode CreateNode(ITreeNode parent) { IStoredConnection con = StoredConnection.LoadFromFile(m_file.DataDiskPath); return(ConnectionTreeNode.FromStoredConnection(parent, con, this)); }
protected override Form CreateWizard(IStoredConnection conn) { return(new TunnelConnWizard((GenericTunnelStoredConnection)conn)); }
//DatabaseMenuCommands m_commands; public Database_SourceConnectionTreeNode(IDatabaseSource conn, ITreeNode parent, IFileHandler fhandler, IStoredConnection stored, bool autoConnect) : base(parent, fhandler, stored, autoConnect) { m_conn = conn.ChangeConnection(ConnPack); SetConnection(m_conn.Connection); var appobj = new DatabaseAppObject(); appobj.FillFromDatabase(conn); SetAppObject(appobj); m_infoappobj = new DatabaseAppObject(); m_infoappobj.FillFromDatabase(conn); m_infoappobj.DisableAutoConnect = true; //m_commands = new DatabaseMenuCommands(m_conn, this); //Database_SourceTreeNode.CreateDbProperties(this, m_conn, null); }
public Server_SourceConnectionTreeNode(IServerSource conn, ITreeNode parent, IFileHandler fhandler, IStoredConnection stored) : base(parent, fhandler, stored, false) { m_conn = conn.ChangeConnection(ConnPack); SetConnection(m_conn.Connection); var appobj = new ServerAppObject(); appobj.FillFromUsage(conn); SetAppObject(appobj); m_infoappobj = new ServerAppObject(); m_infoappobj.FillFromUsage(m_conn); m_infoappobj.DisableAutoConnect = true; }
public CommonConnectionEditFrame(IStoredConnection conn) { InitializeComponent(); InitDialects(); Connection = conn; }
public GenericDbConnection(IStoredConnection sconn) : this(new GenericDbConnectionFactory { Stored = sconn }) { }
public static Job CreateJob(IStoredConnection conn, string db, string sql) { return(Job.FromCommand(new RunSqlJobCommand(conn, db, sql), new JobProperties())); }