예제 #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);
        }
예제 #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);
        }
예제 #3
0
        string testItemOnList(string title, int list)
        {
            listMatch lm = matchesList(title, list);

            if (lm.Success)
            {
                return(Program.getFormatMessage(16200, title, lm.matchedItem, friendlyList(list), lm.matchedReason));
            }
            else
            {
                return(Program.getFormatMessage(16201, title, friendlyList(list)));
            }
        }
예제 #4
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;
        }
예제 #5
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;
        }