Exemple #1
0
 public void CreateNewObject()
 {
     if (m_conn.DatabaseCaps.ExecuteSql)
     {
         OpenQueryParameters pars    = new OpenQueryParameters();
         IPhysicalConnection newconn = GetConnection().Clone();
         string dbname = TreeNodeExtension.GetDatabaseName(this);
         if (dbname != null)
         {
             newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
         }
         pars.GenerateSql = delegate(IPhysicalConnection conn)
         {
             return(m_dbtype.GenerateCreateNew(conn.SystemConnection, TreeNodeExtension.GetAnyObjectPath(this)));
         };
         pars.HideDesign       = true;
         pars.ExecutedCallback = this.CompleteRefresh;
         MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars));
     }
     else
     {
         string sql  = m_dbtype.GenerateCreateNew(m_conn.Connection.SystemConnection, TreeNodeExtension.GetAnyObjectPath(this));
         var    pars = new ObjectEditorPars {
             SavedCallback = this.CompleteRefresh
         };
         var frm = new SpecificObjectFrame(m_conn, m_repr.ObjectType, sql, pars);
         MainWindow.Instance.OpenContent(frm);
     }
 }
Exemple #2
0
        //public static void ClearCache(this IPhysicalConnection conn)
        //{
        //    lock (conn.CachedData) conn.CachedData.Clear();
        //}

        public static void SetOnOpenDatabase(this IPhysicalConnection conn, string dbname)
        {
            if (!String.IsNullOrEmpty(dbname))
            {
                conn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
            }
        }
Exemple #3
0
        public ITabularDataStore GetDataStoreAndClone()
        {
            IPhysicalConnection conn = m_conn.Clone();

            if (!String.IsNullOrEmpty(m_dbname))
            {
                conn.AfterOpen += ConnTools.ChangeDatabaseCallback(m_dbname);
            }
            return(new GenericTabularDataStore(conn, m_dbname, m_schema, m_viewname));
        }
Exemple #4
0
        public ITabularDataStore GetStoreAndClone(TableDataSetProperties props)
        {
            IPhysicalConnection conn = m_conn.Clone();

            if (!String.IsNullOrEmpty(m_dbname))
            {
                conn.AfterOpen += ConnTools.ChangeDatabaseCallback(m_dbname);
            }
            return(new GenericQueryDataStore(conn, m_dbname, GetQuery(props, QueryType.SelectVisible)));
        }
        public override void CreateNew(AppObject appobj, ConnectionPack connpack)
        {
            var tp = _Type;

            if (tp.ObjectType == "table")
            {
                var pars = new AlterTableEditorPars {
                    SavedCallback = RefreshList
                };
                MainWindow.Instance.OpenContent(new TableEditFrame(appobj.CreateDatabaseConnection(), null, pars));
            }
            else
            {
                var dbconn = appobj.FindDatabaseConnection(connpack);
                var dbtype = dbconn.Dialect.GetSpecificObjectType(tp.ObjectType);
                if (dbconn.DatabaseCaps.ExecuteSql)
                {
                    OpenQueryParameters pars    = new OpenQueryParameters();
                    IPhysicalConnection newconn = dbconn.Connection.Clone();
                    string dbname = appobj.FindDatabaseName();
                    if (dbname != null)
                    {
                        newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
                    }
                    pars.GenerateSql = delegate(IPhysicalConnection conn)
                    {
                        return(dbtype.GenerateCreateNew(conn.SystemConnection, appobj.GetObjectPath()));
                    };
                    pars.HideDesign       = true;
                    pars.ExecutedCallback = RefreshList;
                    MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars));
                }
                else
                {
                    string sql  = dbtype.GenerateCreateNew(dbconn.Connection.SystemConnection, appobj.GetObjectPath());
                    var    pars = new ObjectEditorPars {
                        SavedCallback = RefreshList
                    };
                    var frm = new SpecificObjectFrame(dbconn, tp.ObjectType, sql, pars);
                    MainWindow.Instance.OpenContent(frm);
                }
            }
        }
        public void Edit()
        {
            if (!EditEnabled())
            {
                return;
            }
            var dbconn = this.FindDatabaseConnection(ConnPack);

            if (dbconn.DatabaseCaps.ExecuteSql)
            {
                OpenQueryParameters pars    = new OpenQueryParameters();
                IPhysicalConnection newconn = Connection.CreateConnection();
                string dbname = DatabaseName;
                if (dbname != null)
                {
                    newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
                }
                pars.GenerateSql = delegate(IPhysicalConnection conn)
                {
                    var props = new SqlFormatProperties {
                        OmitVersionTests = true
                    };
                    var dbs = conn.PhysicalFactory.CreateDatabaseSource(conn, dbname);
                    var so  = new SpecificObjectStructure(dbs.LoadSpecificObjectDetail(DbObjectType, DbObjectName));
                    if (dbconn.Dialect != null)
                    {
                        so.CreateSql = dbconn.Dialect.ReformatSpecificObject(so.ObjectType, so.CreateSql);
                    }
                    string drop   = newconn.Dialect.GenerateScript(dmp => { dmp.DropSpecificObject(so); }, props);
                    string create = newconn.Dialect.GenerateScript(dmp => { dmp.CreateSpecificObject(so); }, props);
                    return(drop + "\n\nGO\n\n" + create);
                };
                MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars));
            }
            else
            {
                var frm = new SpecificObjectFrame(dbconn.CloneSource(), LoadStructure(), new ObjectEditorPars {
                });
                MainWindow.Instance.OpenContent(frm);
            }
        }
Exemple #7
0
        public void EditScript()
        {
            if (QueryFrame.FindOpenedFile(m_file.DataDiskPath))
            {
                return;
            }
            IPhysicalConnection conn = MainWindowExtension.SelectedConnection;

            if (conn != null)
            {
                conn = conn.Clone();
            }
            OpenQueryParameters pars = new OpenQueryParameters();
            string dbname            = MainWindowExtension.SelectedDatabaseName;

            pars.File           = m_file;
            pars.DisableContext = m_conn != null;
            if (dbname != null && conn != null)
            {
                conn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
            }
            MainWindow.Instance.OpenContent(new QueryFrame(conn, pars));
        }