Ejemplo n.º 1
0
        public static void DeleteBlackWord(string typeStr, string word)
        {
            BlackWordType type;

            if (!BlackWordType.TryParse(typeStr, true, out type))
            {
                return;
            }

            var wordStruct = Words.FirstOrDefault(wordS => wordS.Type == type && word.Contains(wordS.Word));

            if (string.IsNullOrEmpty(wordStruct.Word))
            {
                return;
            }

            Words.Remove(wordStruct);
            using (var adapter = Azure.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery("DELETE FROM server_blackwords WHERE word = @word AND type = @type");
                adapter.AddParameter("word", word);
                adapter.AddParameter("type", typeStr);
                adapter.RunQuery();
            }
        }
Ejemplo n.º 2
0
        public static void AddBlackWord(string typeStr, string word)
        {
            BlackWordType type;

            if (!BlackWordType.TryParse(typeStr, true, out type))
            {
                return;
            }

            if (Words.Any(wordStruct => wordStruct.Type == type && word.Contains(wordStruct.Word)))
            {
                return;
            }

            using (var adapter = Azure.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery("INSERT INTO server_blackwords VALUES (null, @word, @type)");
                adapter.AddParameter("word", word);
                adapter.AddParameter("type", typeStr);
                adapter.RunQuery();
            }

            AddPrivateBlackWord(typeStr, word);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        public static void Load()
        {
            using (var adapter = Azure.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery("SELECT * FROM server_blackwords");
                var table = adapter.GetTable();
                if (table == null)
                {
                    return;
                }

                foreach (DataRow row in table.Rows)
                {
                    var word    = row["word"].ToString();
                    var typeStr = row["type"].ToString();


                    AddPrivateBlackWord(typeStr, word);
                }
            }

            // Out.WriteLine(Words.Count + " BlackWords Loaded -> READY!", "");
            Console.WriteLine();
        }