/// <summary>
        /// New add-ins implementing this function should caste node to IOeNode.
        /// 
        /// Unfortunately base classes were included in the public interfaces. These can't be removed without breaking backwards compatibility.
        /// </summary>
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            var oeNode = (IOeNode) node;
            if (oeNode == null)
            {
                m_Provider.QueryWindow.OpenNew("null");
                m_LogMessage("This shouldn't happen unless you somehow have an ancient version of SIPFw installed.");
                return;
            }

            m_LogMessage(string.Format("Object explorer node clicked: {0}", oeNode.Name));
            IDatabaseObjectInfo databaseObjectInfo;
            IConnectionInfo connectionInfo;
            if (oeNode.TryGetDatabaseObject(out databaseObjectInfo) && oeNode.TryGetConnection(out connectionInfo))
            {
                using (var connection = new SqlConnection(connectionInfo.ConnectionString))
                {
                    connection.Open();
                    var sql = m_Provider.ServerManagementObjects.ScriptAsAlter(connection,
                                                                               databaseObjectInfo.DatabaseName,
                                                                               databaseObjectInfo.Schema,
                                                                               databaseObjectInfo.ObjectName);
                    m_Provider.QueryWindow.OpenNew(sql, databaseObjectInfo.ObjectName, connectionInfo.ConnectionString);
                }
            }
            else
                m_Provider.QueryWindow.OpenNew(string.Format("Name: {0}\nPath: {1}", oeNode.Name, oeNode.Path));
        }
Beispiel #2
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                ManaSQLConfig.Extract.ResetWhereSSP(false);
                ManaSQLConfig.Extract.AppendWhereSSP(DBI.ObjectName);

                if (ManaSQLConfig.IsWithExtract)
                {
                    //quick hack: reference to extract menu
                    var extractMenu = (ActionSimpleOeMenuItemBase)menu[0];
                    extractMenu.OnAction(node);
                }

                ManaProcess.runExe(
                    ManaSQLConfig.TProcPath
                    , TProcCommands.Add(ManaSQLConfig.Extract.FormSelectedSSPFilePaths().ToArray())
                    , false
                    );
                ManaProcess.runExe(
                    ManaSQLConfig.TProcPath
                    , TProcCommands.Commit(ManaSQLConfig.Extract.FormSelectedSSPFilePaths().ToArray())
                    , false
                    );
            }
        }
        /// <summary>
        /// New add-ins implementing this function should caste node to IOeNode.
        ///
        /// Unfortunately base classes were included in the public interfaces. These can't be removed without breaking backwards compatibility.
        /// </summary>
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            var oeNode = (IOeNode)node;

            if (oeNode == null)
            {
                m_Provider.QueryWindow.OpenNew("null");
                m_LogMessage("This shouldn't happen unless you somehow have an ancient version of SIPFw installed.");
                return;
            }

            m_LogMessage(string.Format("Object explorer node clicked: {0}", oeNode.Name));
            IDatabaseObjectInfo databaseObjectInfo;
            IConnectionInfo     connectionInfo;

            if (oeNode.TryGetDatabaseObject(out databaseObjectInfo) && oeNode.TryGetConnection(out connectionInfo))
            {
                using (var connection = new SqlConnection(connectionInfo.ConnectionString))
                {
                    connection.Open();
                    var sql = m_Provider.ServerManagementObjects.ScriptAsAlter(connection,
                                                                               databaseObjectInfo.DatabaseName,
                                                                               databaseObjectInfo.Schema,
                                                                               databaseObjectInfo.ObjectName);
                    m_Provider.QueryWindow.OpenNew(sql, databaseObjectInfo.ObjectName, connectionInfo.ConnectionString);
                }
            }
            else
            {
                m_Provider.QueryWindow.OpenNew(string.Format("Name: {0}\nPath: {1}", oeNode.Name, oeNode.Path));
            }
        }
 private static ObjectExplorerNodeDescriptorBase GetObjectDescriptor(ObjectExplorerNodeDescriptorBase node)
 {
     IOeNode oeNode = node as IOeNode;
     if (oeNode == null)
         return node;
     return oeNode.GetLegacyObjectDescriptor();
 }
Beispiel #5
0
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     var theNode = (IOeNode)oeNode;
     return
         ManaSQLConfig.SvnCommit
         && ManaSQLConfig.ValidGenPaths
         && ManaSQLConfig.IsAllowedGroupNode(theNode);
 }
Beispiel #6
0
 public override void OnAction(ObjectExplorerNodeDescriptorBase node)
 {
     ManaProcess.runExe(
         ManaSQLConfig.TProcPath
         , TProcCommands.Update(new string[] { ManaSQLConfig.Extract.FormRepoPath() })
         , false
         );
 }
Beispiel #7
0
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     var theNode = (IOeNode)oeNode;
     return
         ManaSQLConfig.ValidGenPaths
         && ManaSQLConfig.ShowCompareFile
         && ManaSQLConfig.IsAllowedSingleNode(theNode);
 }
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     var dbNode = oeNode as ObjectExplorerDatabaseNodeDescriptor;
     if (dbNode == null || dbNode.IsSystemNode) return false;
     return (!(oeNode is ObjectExplorerFolderNodeDescriptor) &&
            !(oeNode is ObjectExplorerObjectNodeDescriptor) &&
            !(oeNode is ObjectExplorerParameterNodeDescriptor) &&
            !(oeNode is ObjectExplorerColumnNodeDescriptor));
 }
Beispiel #9
0
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
     logger.LogVerbose("Extension.OnNodeChanged");
     currentNode = node;
     if (runCommand != null)
     {
         runCommand.SetSelectedDBNode(currentNode);
     }
     logger.LogVerbose("Extension.OnNodeChanged complete.");
 }
Beispiel #10
0
 public override void OnAction(ObjectExplorerNodeDescriptorBase node)
 {
     IOeNode theNode = (IOeNode)node;
     IDatabaseObjectInfo DBI;
     ManaSQLConfig.CompareFile1.UpdateVariables(theNode);
     if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
     {
         ManaSQLConfig.CompareFile1.AppendWhereSSP(DBI.ObjectName);
     }
 }
Beispiel #11
0
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
     logger.LogVerbose("Extension.OnNodeChanged");
     currentNode = node;
     if (runCommand != null)
     {
         runCommand.SetSelectedDBNode(currentNode);
     }
     logger.LogVerbose("Extension.OnNodeChanged complete.");
 }
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            ObjectExplorerDatabaseNodeDescriptor dbNode = node as ObjectExplorerDatabaseNodeDescriptor;
            if (dbNode == null)
            {
                return;
            }

            m_ExecuteAction();
        }
Beispiel #13
0
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     var theNode = (IOeNode)oeNode;
     return
         ManaSQLConfig.ValidGenPaths
         && ManaSQLConfig.Extract.ValidPaths
         && ManaSQLConfig.ShowExtract
         && ManaSQLConfig.IsAllowedGroupNode(theNode)
         && theNode.Type != "UserProgrammability"
         ;
 }
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            ObjectExplorerDatabaseNodeDescriptor dbNode = node as ObjectExplorerDatabaseNodeDescriptor;

            if (dbNode == null)
            {
                return;
            }

            m_ExecuteAction();
        }
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     foreach (var child in m_Children)
     {
         if (child.AppliesTo(oeNode))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #16
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                cmd.Execute();
                ManaSQLConfig.PageIndex = 0;
                ManaSQLConfig.Extract.AppendWhereSSP(DBI.ObjectName);
            }
        }
        public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
        {
            var dbNode = oeNode as ObjectExplorerDatabaseNodeDescriptor;

            if (dbNode == null || dbNode.IsSystemNode)
            {
                return(false);
            }
            return(!(oeNode is ObjectExplorerFolderNodeDescriptor) &&
                   !(oeNode is ObjectExplorerObjectNodeDescriptor) &&
                   !(oeNode is ObjectExplorerParameterNodeDescriptor) &&
                   !(oeNode is ObjectExplorerColumnNodeDescriptor));
        }
        public static string SerializeToTempFile(ObjectExplorerNodeDescriptorBase node)
        {
            node = GetObjectDescriptor(node);

            string tempFile = GetTempName();
            using (FileStream stream = new FileStream(tempFile, FileMode.CreateNew))
            {
                XmlSerializer xs = new XmlSerializer(node.GetType());
                xs.Serialize(stream, node);
                stream.Flush();
                stream.Close();
            }
            return tempFile;
        }
Beispiel #19
0
        public void SetSelectedDBNode(ObjectExplorerNodeDescriptorBase theSelectedNode)
        {
            currentNode = theSelectedNode;

            var objectExplorerNode = currentNode as IOeNode;
            IConnectionInfo ci = null;
            if (objectExplorerNode != null
                    && objectExplorerNode.HasConnection
                    && objectExplorerNode.TryGetConnection(out ci))
            {
                var w = TheWindow();
                if (w != null)
                {
                    w.SetConnection(new SqlConnectionStringBuilder(ci.ConnectionString));
                }
            }
        }
Beispiel #20
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                ManaSQLConfig.Extract.ResetWhereSSP(false);
                ManaSQLConfig.Extract.AppendWhereSSP(DBI.ObjectName);

                ManaProcess.runExe(
                    ManaSQLConfig.TProcPath
                    , TProcCommands.Update(ManaSQLConfig.Extract.FormSelectedSSPFilePaths().ToArray())
                    , false
                    );
            }
        }
Beispiel #21
0
        public void SetSelectedDBNode(ObjectExplorerNodeDescriptorBase theSelectedNode)
        {
            currentNode = theSelectedNode;

            var             objectExplorerNode = currentNode as IOeNode;
            IConnectionInfo ci = null;

            if (objectExplorerNode != null &&
                objectExplorerNode.HasConnection &&
                objectExplorerNode.TryGetConnection(out ci))
            {
                var w = TheWindow();
                if (w != null)
                {
                    w.SetConnection(new SqlConnectionStringBuilder(ci.ConnectionString));
                }
            }
        }
Beispiel #22
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                ManaSQLConfig.Extract.ResetWhereSSP(false);
                ManaSQLConfig.Extract.AppendWhereSSP(DBI.ObjectName);

                //add this command just in case SSP is new and not added
                ManaProcess.runExe(
                    ManaSQLConfig.TProcPath
                    , TProcCommands.Diff(ManaSQLConfig.Extract.FormSelectedSSPFilePaths()[0])
                    , false
                    );
            }
        }
Beispiel #23
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            ManaSQLConfig.PageIndex = 0;
            string args = ManaSQLConfig.Extract.CompileArgs(1);
            args = "data " + args;
            ManaProcess.runExe(ManaSQLConfig.ProgPath, args, false);

            if (ManaProcess.returnCode < 0)
            {
                Popups.ResetVars();
                Popups.message = "Error writing SQL(s) to file(s). View log?";
                Popups.Prompt();
                if (Popups.response == System.Windows.Forms.DialogResult.OK)
                {
                    ManaProcess.runExe("Explorer", ManaSQLConfig.Extract.GetLogPath(), false);
                }
            }
        }
Beispiel #24
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                cmd.Execute();
                ManaSQLConfig.PageIndex = 0;
                ManaSQLConfig.Extract.ResetWhereSSP(false);
                ManaSQLConfig.Extract.AppendWhereSSP(DBI.ObjectName);

                string args = ManaSQLConfig.Extract.CompileArgs();
                args = "data " + args;
                ManaProcess.runExe(ManaSQLConfig.ProgPath, args, false);

                if (ManaProcess.returnCode < 0)
                {
                    Popups.ResetVars();
                    Popups.message = "Error writing SQL to file. View log?";
                    Popups.Prompt();
                    if(Popups.response == System.Windows.Forms.DialogResult.OK)
                    {
                        ManaProcess.runExe("Explorer", ManaSQLConfig.Extract.GetLogPath(), false);
                    }
                }
                //else
                //{
                //    //add this command just in case SSP is new and not added
                //    ManaProcess.runExe(
                //        ManaSQLConfig.TProcPath
                //        , TProcCommands.Add(ManaSQLConfig.Extract.FormSelectedSSPFilePaths().ToArray())
                //        , false
                //        );
                //    ManaProcess.runExe(
                //        ManaSQLConfig.TProcPath
                //        , TProcCommands.Commit(ManaSQLConfig.Extract.FormSelectedSSPFilePaths().ToArray())
                //        , false
                //        );
                //}
            }
        }
Beispiel #25
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            IOeNode theNode = (IOeNode)node;
            IDatabaseObjectInfo DBI;

            ManaSQLConfig.UploadFile2.ResetMirrorVariables();
            ManaSQLConfig.CompareFile2.ResetMirrorVariables();

            cmd.Execute();
            ManaSQLConfig.PageIndex = 2;
            ManaSQLConfig.UploadFile2.UpdateVariables(theNode);
            if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
            {
                ManaSQLConfig.CompareFile2.ResetWhereSSP(false);
                ManaSQLConfig.CompareFile2.AppendWhereSSP(DBI.ObjectName,false);
                ManaSQLConfig.UploadFile2.ResetWhereFiles(false);
                ManaSQLConfig.UploadFile2.AppendWhereFile(string.Format("{0}.{1}", DBI.ObjectName, ManaSQLConfig.Extension), false);
            }
            ManaSQLConfig.CompareFile2.UpdateVariables(theNode);
        }
Beispiel #26
0
        public override void OnAction(ObjectExplorerNodeDescriptorBase node)
        {
            if (ManaSQLConfig.IsWithExtract)
            {
                //quick hack: reference to extract menu
                var extractMenu = (ActionSimpleOeMenuItemBase)menu[0];
                extractMenu.OnAction(node);
            }

            ManaProcess.runExe(
                ManaSQLConfig.TProcPath
                , TProcCommands.Add(new string[] { ManaSQLConfig.Extract.FormRepoPath() })
                , false
                );
            ManaProcess.runExe(
                ManaSQLConfig.TProcPath
                , TProcCommands.Commit(new string[] { ManaSQLConfig.Extract.FormRepoPath() })
                , false
                );
        }
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     IOeNode theNode = (IOeNode)oeNode;
     IDatabaseObjectInfo DBI;
     IConnectionInfo CON;
     bool hideFlag = true;
     bool validServer = false;
     if (theNode.IsDatabaseObject
         && theNode.TryGetDatabaseObject(out DBI)
         && theNode.TryGetConnection(out CON)
         )
     {
         validServer = q.Server == CON.Server
             || Util.GetMachine(q.Server) == CON.Server
             || Util.GetIP(q.Server) == CON.Server;
         hideFlag = (validServer && q.DB == DBI.DatabaseName)
             || q.Conn == null
             || !ManaSQLConfig.IsAllowedSingleNode(theNode)
             ;
     }
     return !hideFlag;
 }
 // TODO this should be IEnumerable, because that's covariant.
 public abstract SimpleOeMenuItemBase[] GetApplicableChildren(ObjectExplorerNodeDescriptorBase oeNode);
 public virtual bool CheckedFor(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return false;
 }
 public virtual bool EnabledFor(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return true;
 }
 /// <summary>
 /// Determines if this menu item should be displayed on this node's context menu.
 /// 
 /// Add-ins should cast oeNode to IOeNode.
 /// </summary>
 /// <param name="oeNode">The object explorer menu the user has right-clicked on.</param>
 /// <returns>true is the menu should be visible.</returns>
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return true;
 }
 public abstract void OnAction(ObjectExplorerNodeDescriptorBase node);
Beispiel #33
0
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
     NodeManager.CurrentNode = node;
 }
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
 }
        public override void OnAction(ObjectExplorerNodeDescriptorBase oeNode)
        {
            IOeNode theNode = (IOeNode)oeNode;
            IDatabaseObjectInfo DBI;
            IConnectionInfo CON;

            string tAuthString, tScript, wMessage = "", args, scriptBase = "";
            int tCount;

            if (theNode.IsDatabaseObject
                && theNode.TryGetDatabaseObject(out DBI)
                && theNode.TryGetConnection(out CON)
                )
            {
                tAuthString = Util.FormAuthString(q.Conn.ConnectionString, q.DB);
                if(theNode.Type == "StoredProcedure")
                {
                    scriptBase = SQLScripts.PeepSSP;
                }
                else if(theNode.Type == "UserDefinedFunction")
                {
                    scriptBase = SQLScripts.PeepFN;
                }
                else
                {
                    Popups.ResetVars();
                    Popups.message = "Unsupported object type compare";
                    Popups.Alert();
                }

                tScript = string.Format(scriptBase, DBI.ObjectName);

                using (SqlConnection tConn = new SqlConnection(tAuthString))
                {
                    tConn.Open();
                    SqlCommand tCommand = new SqlCommand(tScript, tConn);
                    tCount = (int)tCommand.ExecuteScalar();
                }

                if (tCount == 0)
                {
                    wMessage = string.Format("{0}/{1} has NO {2}:{3}"
                        , q.Conn.Server
                        , q.DB
                        , DBI.Type
                        , DBI.ObjectName);

                    Popups.ResetVars();
                    Popups.message = "Missing Obj in DB";
                    Popups.Alert();
                }
                else
                {
                    // emulate click on plugin
                    cmd.Execute();

                    // emulate click on file1
                    ManaSQLConfig.fakeCompare2 = true;
                    ManaSQLConfig.PageIndex = 2;
                    ManaSQLConfig.UploadFile1.UpdateVariables(theNode);
                    if (theNode.IsDatabaseObject && theNode.TryGetDatabaseObject(out DBI))
                    {
                        ManaSQLConfig.CompareFile1.ResetWhereSSP(false);
                        ManaSQLConfig.CompareFile1.AppendWhereSSP(DBI.ObjectName, false);
                        ManaSQLConfig.UploadFile1.ResetWhereFiles(false);
                        ManaSQLConfig.UploadFile1.AppendWhereFile(string.Format("{0}.{1}", DBI.ObjectName, ManaSQLConfig.Extension), false);
                    }
                    ManaSQLConfig.CompareFile1.UpdateVariables(theNode);

                    // emulate click on file2

                    //TODO: fake obj explorer node
                    ManaSQLConfig.fakie.Server = q.Server;
                    ManaSQLConfig.fakie.DB = q.DB;
                    ManaSQLConfig.fakie.Obj = DBI.ObjectName;
                    ManaSQLConfig.fakie.Type = DBI.Type;
                    ManaSQLConfig.fakie.Path = theNode.Path;

                    ManaSQLConfig.UploadFile2.MirrorVariables(ManaSQLConfig.fakie, q.Conn);

                    ManaSQLConfig.CompareFile2.ResetWhereSSP(false);
                    ManaSQLConfig.CompareFile2.AppendWhereSSP(DBI.ObjectName, false);
                    ManaSQLConfig.UploadFile2.ResetWhereFiles(false);
                    ManaSQLConfig.UploadFile2.AppendWhereFile(string.Format("{0}.{1}", DBI.ObjectName, ManaSQLConfig.Extension), false);

                    ManaSQLConfig.CompareFile2.MirrorVariables(ManaSQLConfig.fakie, q.Conn);

                    cmd.manaSettingsForm.ActionCompareFileWrite();
                    cmd.manaSettingsForm.ActionCompareFileCompare();
                }
            }
        }
 /// <summary>
 /// Determines if this menu item should be displayed on this node's context menu.
 ///
 /// Add-ins should cast oeNode to IOeNode.
 /// </summary>
 /// <param name="oeNode">The object explorer menu the user has right-clicked on.</param>
 /// <returns>true is the menu should be visible.</returns>
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return(true);
 }
 public abstract void OnAction(ObjectExplorerNodeDescriptorBase node);
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return GetApplicableChildren(oeNode).Length > 0;
 }
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
     m_SimpleSsmsAddin.OnNodeChanged(node);
 }
Beispiel #40
0
 public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
 {
 }
 public override bool AppliesTo(ObjectExplorerNodeDescriptorBase oeNode)
 {
     return(GetApplicableChildren(oeNode).Length > 0);
 }