Пример #1
0
        public watchList getWatchList(string site, string username)
        {
            List <watchedUser> userList = new List <watchedUser>();
            string             site_id  = createSite(site);
            watchList          WL       = new watchList();

            WL.site          = site;
            WL.watchlistUser = username;
            try
            {
                cnn.Open();
                string        str = string.Format("SELECT author, done FROM watchlist WHERE site_id = '{0}' AND watchlist_user = '******'", site_id, username);
                SQLiteCommand cmd = new SQLiteCommand(str, cnn);
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        watchedUser usr = new watchedUser();

                        usr.user = reader[0].ToString().TrimEnd(' ');
                        string done = reader[1].ToString();

                        if (done.ToLower() == "true")
                        {
                            usr.done = true;
                        }
                        else
                        {
                            usr.done = false;
                        }

                        userList.Add(usr);
                        //string user = reader[0].ToString();
                        //user = user.TrimEnd(' ');
                        //watchlist.Add(user);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                cnn.Close();
            }

            WL.users = userList;
            return(WL);
        }
Пример #2
0
        private watchList makeWatchListFromUserStrings(List <string> userList, string site, string username)
        {
            watchList newWatchList = new watchList();

            newWatchList.site          = site;
            newWatchList.watchlistUser = username;
            newWatchList.users         = new List <watchedUser>();
            foreach (string user in userList)
            {
                watchedUser usr = new watchedUser {
                    user = user, done = false
                };
                newWatchList.users.Add(usr);
            }
            return(newWatchList);
        }