Ejemplo n.º 1
1
 public TOBBaseObject(Account acc)
 {
     CryptoHelper cryptoHelper = new CryptoHelper();
     acc.DecryptedPassword = cryptoHelper.Decrypt(acc.Password);
     _acc = acc;
 }
Ejemplo n.º 2
0
        public Account ProcessAuthentication(string pin)
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            OAuthAccessToken access = service.GetAccessToken(_requestToken, pin);

            service.AuthenticateWith(access.Token, access.TokenSecret);

            var profile = service.GetUserProfile();

            Account account = AccountManager.Instance.GetCurrentAccounts().Where(acc => acc.Username == profile.ScreenName).FirstOrDefault();
            if (account != null)
            {
                throw new AuthFailureException("User " +account.Username +  " already has an account with TweetOBox.");
            }
            if (profile != null && account == null)
            {
                account = new Account();
                account.Username = profile.ScreenName;
               // account.Password = profile.p
                account.AccountType = (int)AccountTypeEnum.Twitter;
                account.AccessToken = access.Token;
                account.AccessTokenSecret = access.TokenSecret;
                account.IsOAuth = true;
                AccountManager.Instance.AddAccount(account,false);
            }
            else
            {
                throw new AuthFailureException(service.Response.StatusDescription);
            }

            return account;
        }
Ejemplo n.º 3
0
        public TOBTwitterO(Account acc)
            : base(acc)
        {
            _twitterClientInfo.ClientName = "TweetOBox";
            _twitterClientInfo.ClientUrl = "http://www.tweetobox.com";
            _twitterClientInfo.ClientVersion = "1.0.0.0";
            _twitterClientInfo.ConsumerKey = _consumerKey;
            _twitterClientInfo.ConsumerSecret = _consumerSecret;

            //FluentTwitter.SetClientInfo(_twitterClientInfo);

            if (LocalUserProfileBO.Get(s => s.ScreenName == acc.Username) == null)
            {
                GetUserProfile(acc.Username);
            }

            _updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
            _updateTimer.AutoReset = true;
        }
Ejemplo n.º 4
0
        public Account Authenticate(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("userName");
            }

            TwitterService service = new TwitterService(ConfigurationManager.AppSettings["ConsumerKey"],
                ConfigurationManager.AppSettings["ConsumerSecret"]);

            OAuthAccessToken access = service.GetAccessTokenWithXAuth(userName, password);

            service.AuthenticateWith(access.Token, access.TokenSecret);

            var profile = service.GetUserProfile();

            Account account = AccountManager.Instance.GetCurrentAccounts().Where(acc => acc.Username == profile.ScreenName).FirstOrDefault();
            if (account != null)
            {
                throw new AuthFailureException("User " + account.Username + " already has an account with TweetOBox.");
            }
            if (profile != null && account == null)
            {
                account = new Account();
                account.Username = profile.ScreenName;
                // account.Password = profile.p
                account.AccountType = (int)AccountTypeEnum.Twitter;
                account.AccessToken = access.Token;
                account.AccessTokenSecret = access.TokenSecret;
                account.IsOAuth = true;
                AccountManager.Instance.AddAccount(account, false);
            }
            else
            {
                throw new AuthFailureException(service.Response.StatusDescription);
            }

            return account;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add an account
        /// </summary>
        /// <param name="acc">Add account to be added</param>
        /// <param name="downloadIfNeeded">After adding an account if tweets to be downloaded or not</param>
        public void AddAccount(Account acc, bool downloadIfNeeded)
        {
            Account tempAcc = _accountBO.Get(ac => ac.Username == acc.Username);
            if (tempAcc == null)
            {
                _accountBO.Insert(acc);
                _accountBO.SaveChanges();

                _cachedAccountList = _accountBO.GetAll();

                //Call this function to create a TOBBaseObject corresponding to newly added account object
                PopulateTOBBaseObjectList();
                //Call Start to download all the tweets from the newly added account.
                if (downloadIfNeeded)
                {
                    Start();
                }
            }
            else
            {
                throw new AuthFailureException("User " + acc.Username + " already exists!");
            }
        }
Ejemplo n.º 6
0
 private TOBBaseObject CreateTOBObject(Account acc)
 {
     TOBBaseObject tobBaseObject = null;
     switch (acc.AccountType)
     {
         case 1:
             tobBaseObject = new TOBTwitterO(acc);
             break;
         case 2:
             tobBaseObject = new TOBTwitterO(acc);
             break;
     }
     return tobBaseObject;
 }
Ejemplo n.º 7
0
        public TOBBaseObject GetTOBObject(Account acc)
        {
            if (acc == null)
            {
                throw new ArgumentNullException("Account","Pease specify valid Account object");
            }
            if ( acc.Id == 0)
            {
                throw new ArgumentException("Opps. Account does not have valid accountid");
            }
            if (_tobObjects == null || _tobObjects.Count == 0)
            {
                throw new NullReferenceException("AccountManger is not initialized property. Could not find any account to Manage.");
            }

            TOBBaseObject tobBase = _tobObjects.Where(t => t.Acc.Id == acc.Id).FirstOrDefault();
            if (tobBase == null)
            {
                throw new Exception("Oops!!. Could find account with accountId = " + acc.Id);
            }
            return tobBase;
        }
Ejemplo n.º 8
0
        public void DeleteAccount(Account acc)
        {
            //Temp fix : Need to improve.
            UserProfileBO userProfileBO = new UserProfileBO();
            List<UserProfile> userProfileList = userProfileBO.GetAll().Where(user => user.AccountId == acc.Id).ToList();
            if (userProfileList.Count > 1)
            {
                userProfileBO.DeleteAll(userProfileList);
                userProfileBO.SaveChanges();
            }
            SavedFilterBO savedFilterBO = new SavedFilterBO();
            List<SavedFilter> savedFilterList = savedFilterBO.GetAll();
            foreach (SavedFilter sf in savedFilterList)
            {
                AccountFilterMappingBO accFilterBO = new AccountFilterMappingBO();
                AccountFilterMapping accFilter = accFilterBO.Get(af => af.FilterId == sf.Id);
                accFilterBO.Delete(accFilter);
                accFilterBO.SaveChanges();
            }
            foreach (SavedFilter sf in savedFilterList)
            {
                savedFilterBO.Delete(sf);
                savedFilterBO.SaveChanges();
            }
            SavedSearchBO savedSearchBO = new SavedSearchBO();
            List<SavedSearch> savedSearchList = savedSearchBO.GetAll();
            if (savedSearchList.Count > 1)
            {
                savedSearchBO.DeleteAll(savedSearchList);
                savedSearchBO.SaveChanges();
            }

            _accountBO.Delete(acc);
            _accountBO.SaveChanges();

            _cachedAccountList = _accountBO.GetAll();

            //Stop Temporary
            Stop();

            //Get TOBBaseOBject
            TOBBaseObject baseObj = GetTOBObject(acc);
            if (baseObj != null)
            {
                _tobObjects.Remove(baseObj);
                baseObj = null;
            }
            //Again Start the update operation
            Start();
        }
Ejemplo n.º 9
0
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.AccountTypeAccountType = null;
		}
Ejemplo n.º 10
0
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.AccountTypeAccountType = this;
		}
Ejemplo n.º 11
0
 public void InternalSetAccount(Account acc)
 {
     this._Account.Entity = acc;
 }
Ejemplo n.º 12
0
partial         void UpdateAccount(Account instance);
Ejemplo n.º 13
0
partial         void InsertAccount(Account instance);
Ejemplo n.º 14
0
partial         void DeleteAccount(Account instance);
Ejemplo n.º 15
0
        private TwitterService AuthenticateUser(Account account)
        {
            TwitterService request = null;
            if (account.IsOAuth == true)
            {
                request = new TwitterService(_consumerKey, _consumerSecret, account.AccessToken, account.AccessTokenSecret);
            }
            else
            {
                request = new TwitterService(_twitterClientInfo);
            }

            if (request == null)
            {
                Logger.TOBLogger.WriteDebugInfo("Request is null for the username = " + account.Username);
            }

            return request;
        }