Пример #1
0
 public static OAuthTokens getTokens(TwUser usr)
 {
     var tokens = new Twitterizer.OAuthTokens();
     tokens.AccessToken = usr.Token;
     tokens.AccessTokenSecret = usr.TokenSecret;
     tokens.ConsumerKey = ConfigurationManager.AppSettings["consumerkey"];
     tokens.ConsumerSecret = ConfigurationManager.AppSettings["consumersecret"];
     return tokens;
 }
Пример #2
0
        /// <summary>
        /// Create a new TwUser object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="email">Initial value of the Email property.</param>
        /// <param name="nickname">Initial value of the Nickname property.</param>
        /// <param name="password">Initial value of the Password property.</param>
        /// <param name="token">Initial value of the Token property.</param>
        /// <param name="tokenSecret">Initial value of the TokenSecret property.</param>
        /// <param name="twitterNick">Initial value of the TwitterNick property.</param>
        public static TwUser CreateTwUser(global::System.Int64 id, global::System.String name, global::System.String email, global::System.String nickname, global::System.String password, global::System.String token, global::System.String tokenSecret, global::System.String twitterNick)
        {
            TwUser twUser = new TwUser();

            twUser.Id          = id;
            twUser.Name        = name;
            twUser.Email       = email;
            twUser.Nickname    = nickname;
            twUser.Password    = password;
            twUser.Token       = token;
            twUser.TokenSecret = tokenSecret;
            twUser.TwitterNick = twitterNick;
            return(twUser);
        }
Пример #3
0
 public void UpdateTwitterAccount(OAuthTokenResponse atoken, TwUser usr)
 {
     usr.TokenSecret = atoken.TokenSecret;
         usr.Token = atoken.Token;
         db.SaveChanges();
 }
Пример #4
0
 public bool CreateUser(string userName, string nickname, string password, string email)
 {
     if (String.IsNullOrEmpty(userName))
             throw new ArgumentException("Value cannot be null or empty.", "userName");
         if (String.IsNullOrEmpty(nickname))
             throw new ArgumentException("Value cannot be null or empty.", "nickname");
         if (String.IsNullOrEmpty(password))
             throw new ArgumentException("Value cannot be null or empty.", "password");
         if (password.Length <= 4)
             throw new ArgumentException("Password too short, need more than 4 chars.", "password");
         if (String.IsNullOrEmpty(email))
             throw new ArgumentException("Value cannot be null or empty.", "email");
         if (db.UserSet.Any(u => u.Email == email))
             throw new ArgumentException("This email is already registred.", "email");
         if (db.UserSet.Any(u => u.Nickname == nickname))
             throw new ArgumentException("This nickname is already registred.", "nickname");
         try {
             var u = new TwUser();
             u.Name = userName;
             u.Nickname = nickname;
             u.Password = password;
             u.Email = email;
             u.TwitterNick = "";
             u.Token = "";
             u.TokenSecret = "";
             db.UserSet.AddObject(u);
             db.SaveChanges();
             return true;
         } catch (Exception e) {
             throw e;
         }
 }
Пример #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserSet(TwUser twUser)
 {
     base.AddObject("UserSet", twUser);
 }
Пример #6
0
 public List<TweetExtended> getTweetsFrom(string id, TwUser usr)
 {
     var tokens = TwitrucHelpers.getTokens(usr);
     var o = new Twitterizer.UserTimelineOptions();
     o.ScreenName = id;
     o.Count = 50;
     try {
         Twitterizer.TwitterResponse<Twitterizer.TwitterStatusCollection> userResponse = Twitterizer.TwitterTimeline.UserTimeline(tokens, o);
         if (userResponse.Content != null) {
             return userResponse.ResponseObject.Select(st => new TweetExtended(st)).ToList();
         }
     } catch (Exception) { }
     return db.TweetSet.Where(t => t.AuthorNick == id).ToArray().Select(t => new TweetExtended(t)).ToList();
 }
Пример #7
0
 public List<TweetExtended> getTimeline(TwUser usr)
 {
     var tokens = TwitrucHelpers.getTokens(usr);
     var o = new Twitterizer.TimelineOptions();
     o.Count = 60;
     try {
         Twitterizer.TwitterResponse<Twitterizer.TwitterStatusCollection> userResponse = Twitterizer.TwitterTimeline.HomeTimeline(tokens, o);
         if (userResponse.Content != null) {
             return userResponse.ResponseObject.Where(st => st != null).Select(st => new TweetExtended(st)).ToList();
         }
     } catch (Exception) { }
     return db.TweetSet.Where(t => t.AuthorNick == usr.Nickname).ToArray().Select(t => new TweetExtended(t)).ToList();
 }
Пример #8
0
 public Tweet CreateTweet(string content, TwUser u)
 {
     if (String.IsNullOrEmpty(content))
         throw new ArgumentException("Value cannot be null or empty.", "Content");
     var t = new Tweet();
     t.Content = content;
     t.TwitrucUser = u;
     t.AuthorNick = u.TwitterNick;
     t.Date = DateTime.Now;
     t.Sent = false;
     t.Public = false;
     db.TweetSet.AddObject(t);
     db.SaveChanges();
     return t;
 }
Пример #9
0
 /// <summary>
 /// Create a new TwUser object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="nickname">Initial value of the Nickname property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="token">Initial value of the Token property.</param>
 /// <param name="tokenSecret">Initial value of the TokenSecret property.</param>
 /// <param name="twitterNick">Initial value of the TwitterNick property.</param>
 public static TwUser CreateTwUser(global::System.Int64 id, global::System.String name, global::System.String email, global::System.String nickname, global::System.String password, global::System.String token, global::System.String tokenSecret, global::System.String twitterNick)
 {
     TwUser twUser = new TwUser();
     twUser.Id = id;
     twUser.Name = name;
     twUser.Email = email;
     twUser.Nickname = nickname;
     twUser.Password = password;
     twUser.Token = token;
     twUser.TokenSecret = tokenSecret;
     twUser.TwitterNick = twitterNick;
     return twUser;
 }
Пример #10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserSet(TwUser twUser)
 {
     base.AddObject("UserSet", twUser);
 }