Ejemplo n.º 1
0
        public ListMatch MatchesList(string title, int list)
        {
            ListMatch lm = new ListMatch();

            using (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)
                {
                    using (IDataReader idr = cmd.ExecuteReader())
                        while (idr.Read())
                        {
                            if (MatchesPattern(title, idr.GetString(0)))
                            {
                                lm.Success       = true;
                                lm.matchedItem   = idr.GetString(0);
                                lm.matchedReason = idr.GetString(1);
                                return(lm);
                            }
                        }
                }
            }

            // Obviously, did not match anything
            lm.Success       = false;
            lm.matchedItem   = "";
            lm.matchedReason = "";
            return(lm);
        }
Ejemplo n.º 2
0
        public ListMatch IsWatchedArticle(string title, string project)
        {
            ListMatch lm = new ListMatch();

            lm.matchedItem = ""; // Unused
            using (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)
                {
                    using (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 = "";
                        }
                    }
                }
            }
            return(lm);
        }
Ejemplo n.º 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));
            }

            return(Program.GetFormatMessage(16201, title, FriendlyList(list)));
        }