示例#1
0
        internal static frmScriptEditor Create(string caption, string script, NodeData data)
        {
            if (data == null)
            {
                throw new NullParameterException("NodeData paremeter is null!");
            }

            frmScriptEditor frm      = null;
            string          windowId = ScriptEditorManager.ProduceWindowId(caption, data.ID, data.Type, data.ConnParams.Server, data.DBName);

            frm = CheckEditorAlreadyExits(windowId, caption, script);
            if (frm != null)
            {
                return(frm);
            }

            frm = new frmScriptEditor();
            frm.InitializeScriptEditor(caption, script, data.ID, data.Type, data.ConnParams, data.DBName);
            return(frm);
        }
示例#2
0
        internal static frmScriptEditor OpenSharedScript(SharedScriptsItemData itemData, ConnectionParams cp)
        {
            string dbName  = String.Empty;
            string caption = String.Empty;
            string script  = String.Empty;

            if (itemData == null)
            {
                throw new NullParameterException("ItemData is null!");
            }


            caption = itemData.Name;
            script  = itemData.Script;
            if (cp != null)
            {
                dbName = cp.Database;
            }

            frmScriptEditor frm      = null;
            string          windowId = ScriptEditorManager.ProduceWindowId(itemData.Name, itemData.ID ?? -1, DBObjectType.SharedScript, cp.Server, dbName);

            frm = CheckEditorAlreadyExits(windowId, caption, script);
            if (frm != null)
            {
                return(frm);
            }


            frm      = new frmScriptEditor();
            frm.Icon = PragmaSQL.Properties.Resources.sharedScript;

            frm.ContentPersister          = new SharedScriptContentPersister();
            frm.ContentPersister.Data     = itemData;
            frm.ContentPersister.Hint     = "This is a shared script: " + itemData.Name;
            frm.ContentInfo               = frm.ContentPersister.Hint;
            frm.ContentPersister.FilePath = itemData.Name;
            frm.InitializeScriptEditor(caption, script, itemData.ID ?? -1, DBObjectType.SharedScript, cp, dbName);

            return(frm);
        }
示例#3
0
        internal static frmScriptEditor Create(ObjectInfo objInfo, ConnectionParams cp, string dBName)
        {
            if (objInfo == null)
            {
                throw new InvalidOperationException("ObjectInfo parameter is null!");
            }

            if (cp == null)
            {
                throw new NullParameterException("ConnectionParams paremeter is null!");
            }


            ConnectionParams tmp = cp.CreateCopy();

            if (!String.IsNullOrEmpty(dBName))
            {
                tmp.Database = dBName;
            }

            string script  = ScriptingHelper.GetAlterScript(tmp, objInfo.ObjectID, objInfo.ObjectType);
            string caption = objInfo.ObjectName;

            frmScriptEditor frm      = null;
            string          windowId = ScriptEditorManager.ProduceWindowId(objInfo.ObjectName, objInfo.ObjectID, objInfo.ObjectType, cp.Server, dBName);

            frm = CheckEditorAlreadyExits(windowId, caption, script);
            if (frm != null)
            {
                return(frm);
            }

            frm = new frmScriptEditor();
            frm.InitializeScriptEditor(caption, script, objInfo.ObjectID, objInfo.ObjectType, cp, String.IsNullOrEmpty(dBName) ? cp.Database : dBName);
            return(frm);
        }
示例#4
0
        internal static frmScriptEditor Create(string caption, string script, long objectId, int objectType, ConnectionParams cp, string dBName, string filePath)
        {
            if (cp == null)
            {
                throw new NullParameterException("ConnectionParams paremeter is null!");
            }

            frmScriptEditor frm      = null;
            string          windowId = ScriptEditorManager.ProduceWindowId(caption, objectId, objectType, cp.Server, dBName);

            frm = CheckEditorAlreadyExits(windowId, caption, script);
            if (frm != null)
            {
                return(frm);
            }

            frm = new frmScriptEditor();
            frm.InitializeScriptEditor(caption, script, objectId, objectType, cp, dBName);
            if (!String.IsNullOrEmpty(filePath))
            {
                frm.SetFilePath(filePath);
            }
            return(frm);
        }