Beispiel #1
0
 private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
 {
     if (FChangeExecuting)
     {
         return;
     }
     FChangeExecuting      = true;
     LeftTree.SelectedNode = e.Node;
     LeftTree.BeginUpdate();
     CheckAllChildNodes(e.Node, e.Node.Checked);
     LeftTree.EndUpdate();
     FChangeExecuting = false;
 }
Beispiel #2
0
        private void CompileButton_Click(object sender, EventArgs e)
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode, xmlCheck;

            FTokenLst.Clear();
            string StartupPath = Application.StartupPath;

            if (StartupPath[StartupPath.Length - 1] != '\\')
            {
                StartupPath += '\\';
            }
            FileStream fs = new FileStream(StartupPath + "SQLScriptSorterConfig.xml", FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode = xmldoc.GetElementsByTagName("SQLScript");
            for (int i = 0; i < xmlnode.Count; i++)
            {
                XmlNode  XmlN  = xmlnode[i];
                TreeNode TreeN = LeftTree.Nodes.Add(XmlN.Attributes["TreeName"].Value);
                switch (XmlN.Attributes["TreeKey"].Value.ToUpper())
                {
                case "FUN":
                    TreeN.ImageIndex = 0;
                    break;

                case "VIEW":
                    TreeN.ImageIndex = 3;
                    break;

                case "TABLE":
                    TreeN.ImageIndex = 2;
                    break;

                case "PROC":
                    TreeN.ImageIndex = 1;
                    break;
                }
                TreeN.StateImageIndex = TreeN.SelectedImageIndex = TreeN.ImageIndex;
                FTokenLst.Add(new TokenItem(TreeN, XmlN.InnerText));
            }

            xmlCheck = xmldoc.GetElementsByTagName("MissObject");

            for (int i = 0; i < xmlCheck.Count; i++)
            {
                XmlNode CheckXml = xmlCheck[i];

                for (int j = 0; j < xmlnode.Count; j++)
                {
                    XmlNode XmlN = xmlnode[j];
                    if (CheckXml.Attributes["TreeKey"].Value == XmlN.Attributes["TreeKey"].Value)
                    {
                        NotCheckedId.Add(XmlN.Attributes["TreeName"].Value);
                        break;
                    }
                }
                eScript.Text += NotCheckedId[i].ToString() + "\n";
                NotCheckedValue.Add(CheckXml.InnerText);
                eScript.Text += NotCheckedValue[i].ToString() + "\n";
            }
            fs.Close();

            string     ScriptTxt = "";
            ScriptItem ScriptI   = null;

            for (int i = 0; i < SQLFileList.Count; i++)
            {
                string LineTxt    = SQLFileList[i].ToUpper();
                string ScriptName = SQLFileList[i];
                if (LineTxt.Length > 6 && LineTxt.Substring(0, 6) == "CREATE")
                {
                    ScriptTxt = "";
                    string t1 = LineTxt.Remove(0, 7);
                    ScriptName = ScriptName.Remove(0, 7);
                    int SpacePos = t1.IndexOf(" ");
                    if (SpacePos > 0)
                    {
                        string    TokenKind = t1.Substring(0, SpacePos);
                        TokenItem TokenI    = FTokenLst.GetItem(TokenKind);
                        if (TokenI != null)
                        {
                            ScriptI = new ScriptItem(ScriptName);
                            TokenI.Scripts.Add(ScriptI);
                        }
                    }
                }
                if (SQLFileList[i].Trim() != "")
                {
                    if (ScriptTxt != "")
                    {
                        ScriptTxt += Environment.NewLine;
                    }
                    ScriptTxt += SQLFileList[i];
                }
                if (SQLFileList[i] == "GO")
                {
                    if (ScriptI != null)
                    {
                        ScriptI.Text = ScriptTxt;
                    }
                    ScriptI   = null;
                    ScriptTxt = "";
                }
            }
            LeftTree.BeginUpdate();
            FTokenLst.BuildTree();
            foreach (TreeNode N in LeftTree.Nodes)
            {
                N.Expand();
            }
            LeftTree.EndUpdate();
            SaveCompileTextButton.Enabled = true;
            CompileButton.Enabled         = false;
        }