Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        private static frmScriptEditor CheckEditorAlreadyExits(string windowId, string windowTitle, string newContent)
        {
            string input1 = String.Empty;
            string input2 = String.Empty;

            frmScriptEditor frm = null;

            if (!String.IsNullOrEmpty(windowId) && ScriptEditorManager.Contains(windowId))
            {
                frm    = ScriptEditorManager.Get(windowId);
                input1 = !String.IsNullOrEmpty(frm.Content) ? frm.Content.Replace("\r", String.Empty) : String.Empty;
                input2 = !String.IsNullOrEmpty(newContent) ? newContent.Replace("\r", String.Empty) : String.Empty;

                if (!input1.Equals(input2, StringComparison.InvariantCultureIgnoreCase) &&
                    Utils.AskYesNoQuestion(String.Format(Properties.Resources.CanReloadScriptEditorContent, windowTitle), MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    frm.ScriptText      = newContent;
                    frm.ContentModified = false;
                }
            }

            return(frm);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }