Пример #1
0
        public static List <ApkCommand> GetCommands()
        {
            var apkCommands = new List <ApkCommand>();

            using (var dbConnection = new SQLiteConnection(DataSource))
            {
                dbConnection.Open();
                using (var transaction = dbConnection.BeginTransaction())
                {
                    using (var command = new SQLiteCommand(dbConnection))
                    {
                        command.CommandText = "SELECT command_name, command_value FROM command";

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (reader["command_name"] != null && !Convert.IsDBNull(reader["command_name"]) && reader["command_value"] != null && !Convert.IsDBNull(reader["command_value"]))
                                {
                                    var apkCommand = new ApkCommand
                                    {
                                        Title   = Convert.ToString(reader["command_name"]),
                                        Command = Convert.ToString(reader["command_value"])
                                    };
                                    apkCommands.Add(apkCommand);
                                }
                            }
                        }
                    }
                    transaction.Commit();
                }
            }

            return(apkCommands);
        }
Пример #2
0
        private static void MigrateCommands(string path)
        {
            var lstCommands = new List <ApkCommand>();

            var fs      = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            var oXmlDoc = new XmlDocument();

            oXmlDoc.Load(fs);

            var xmlNodes = oXmlDoc.GetElementsByTagName("item");

            foreach (XmlNode oNode in xmlNodes)
            {
                var co = new ApkCommand();

                co.Title   = oNode.ChildNodes[0].InnerText;
                co.Command = oNode.ChildNodes[1].InnerText;

                lstCommands.Add(co);
            }

            fs.Close();
            fs.Dispose();

            SqliteConnector.SetCommands(lstCommands);

            File.Delete(path);
        }
Пример #3
0
        private void NewSearchProviderForm_OnCommandAdded(object sender, ApkCommand cmd)
        {
            var ci = new ListViewItem(cmd.Title);

            ci.Tag = cmd;
            ci.SubItems.Add(cmd.Command);
            lvwCommands.Items.Add(ci);

            SaveCommands();
        }
Пример #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if ((txtTitle.Text != string.Empty) && (txtCommand.Text != string.Empty))
            {
                var apkCommand = new ApkCommand
                {
                    Title   = txtTitle.Text,
                    Command = txtCommand.Text
                };

                OnCommandAdded?.Invoke(this, apkCommand);

                Close();
            }
            else
            {
                MessageBox.Show("Please fill in all fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }