Example #1
0
        public listMatch matchesList(string title, int list)
        {
            listMatch lm = new listMatch();
            IDbCommand cmd = dbcon.CreateCommand();

            cmd.CommandText = "SELECT item, reason FROM items WHERE itemtype='" + list.ToString() + "' AND ((expiry > '"
                + DateTime.Now.Ticks.ToString() + "') OR (expiry = '0'))";
            lock (dbtoken)
            {
                IDataReader idr = cmd.ExecuteReader();
                while (idr.Read())
                {
                    if (Regex.IsMatch(title, idr.GetString(0), RegexOptions.IgnoreCase))
                    {
                        lm.Success = true;
                        lm.matchedItem = idr.GetString(0);
                        lm.matchedReason = idr.GetString(1);
                        idr.Close();
                        return lm;
                    }
                }
                idr.Close();
            }

            // Obviously, did not match anything
            lm.Success = false;
            lm.matchedItem = "";
            lm.matchedReason = "";
            return lm;
        }
Example #2
0
        public listMatch isWatchedArticle(string title, string project)
        {
            listMatch lm = new listMatch();
            lm.matchedItem = ""; //Unused
            IDbCommand cmd = dbcon.CreateCommand();

            cmd.CommandText = "SELECT reason FROM watchlist WHERE article='" + title.Replace("'", "''")
                + "' AND (project='" + project + "' OR project='') AND ((expiry > '"
                + DateTime.Now.Ticks.ToString() + "') OR (expiry = '0'))";
            lock (dbtoken)
            {
                IDataReader idr = cmd.ExecuteReader();
                if (idr.Read())
                {
                    // Matched; is on watchlist
                    lm.Success = true;
                    lm.matchedReason = idr.GetString(0);
                }
                else
                {
                    // Did not match anything
                    lm.Success = false;
                    lm.matchedReason = "";
                }
                idr.Close();
            }
            return lm;
        }