Esempio n. 1
0
        void LoadSavedQuerys()
        {
            System.Text.StringBuilder sqlCommand = new StringBuilder();
            System.Reflection.Assembly appDll = System.Reflection.Assembly.GetExecutingAssembly();
            using (System.IO.Stream stream = appDll.GetManifestResourceStream(COMMAND_TXT_NAME))
            {
                bool findCommand = false;
                ToolStripMenuItem item = null;
                using (System.IO.StreamReader reader = new StreamReader(stream))
                {
                    string line = reader.ReadLine();

                    while (line != null)
                    {

                        // command file end
                        if (line.Equals(END_ALL))
                            break;

                        if (!findCommand && line.StartsWith(COMMAND_BEGIN))
                        {
                            findCommand = true;
                            item = new ToolStripMenuItem();
                            item.Text = line.Substring(COMMAND_START_INDEX);
                            line = reader.ReadLine();
                            continue;
                        }

                        line = line.Trim();

                        // find empty line
                        if (line.Length == 0)
                        {
                            line = reader.ReadLine();
                            continue;
                        }

                        // find command end
                        if (findCommand && line.Equals(COMMAND_END))
                        {
                            findCommand = false;
                            item.Tag = sqlCommand.ToString();
                            sqlCommand.Remove(0, sqlCommand.Length);
                            item.Click += delegate(object sender, EventArgs ea)
                            {
                                ToolStripMenuItem i = (ToolStripMenuItem)sender;
                                //string sql = (string)i.Tag;
                                FrmDataGridView gv = new FrmDataGridView();
                                gv.LoadData((string)i.Tag);
                                gv.ShowDialog(this);
                                GC.Collect();
                            };

                            //this.mnQueue.MenuItems.Add(item);
                            //item
                            btnQuerys.DropDownItems.Add(item);
                            line = reader.ReadLine();
                            continue;
                        }

                        // find comments line
                        if (line.StartsWith("--"))
                        {
                            line = reader.ReadLine();
                            continue;
                        }
                        sqlCommand.Append(line);
                        // add return character
                        sqlCommand.Append("\r\n");

                        // move to next command
                        line = reader.ReadLine();
                    }

                }
                stream.Close();
            }

            GC.Collect();
        }
Esempio n. 2
0
        void LoadSavedQuerys()
        {
            System.Text.StringBuilder  sqlCommand = new StringBuilder();
            System.Reflection.Assembly appDll     = System.Reflection.Assembly.GetExecutingAssembly();
            using (System.IO.Stream stream = appDll.GetManifestResourceStream(COMMAND_TXT_NAME))
            {
                bool findCommand       = false;
                ToolStripMenuItem item = null;
                using (System.IO.StreamReader reader = new StreamReader(stream))
                {
                    string line = reader.ReadLine();

                    while (line != null)
                    {
                        // command file end
                        if (line.Equals(END_ALL))
                        {
                            break;
                        }

                        if (!findCommand && line.StartsWith(COMMAND_BEGIN))
                        {
                            findCommand = true;
                            item        = new ToolStripMenuItem();
                            item.Text   = line.Substring(COMMAND_START_INDEX);
                            line        = reader.ReadLine();
                            continue;
                        }

                        line = line.Trim();

                        // find empty line
                        if (line.Length == 0)
                        {
                            line = reader.ReadLine();
                            continue;
                        }

                        // find command end
                        if (findCommand && line.Equals(COMMAND_END))
                        {
                            findCommand = false;
                            item.Tag    = sqlCommand.ToString();
                            sqlCommand.Remove(0, sqlCommand.Length);
                            item.Click += delegate(object sender, EventArgs ea)
                            {
                                ToolStripMenuItem i = (ToolStripMenuItem)sender;
                                //string sql = (string)i.Tag;
                                FrmDataGridView gv = new FrmDataGridView();
                                gv.LoadData((string)i.Tag);
                                gv.ShowDialog(this);
                                GC.Collect();
                            };

                            //this.mnQueue.MenuItems.Add(item);
                            //item
                            btnQuerys.DropDownItems.Add(item);
                            line = reader.ReadLine();
                            continue;
                        }

                        // find comments line
                        if (line.StartsWith("--"))
                        {
                            line = reader.ReadLine();
                            continue;
                        }
                        sqlCommand.Append(line);
                        // add return character
                        sqlCommand.Append("\r\n");

                        // move to next command
                        line = reader.ReadLine();
                    }
                }
                stream.Close();
            }

            GC.Collect();
        }