コード例 #1
1
ファイル: ITOBBO.cs プロジェクト: ankitb/TweetOBox
 public TOBBaseObject(Account acc)
 {
     CryptoHelper cryptoHelper = new CryptoHelper();
     acc.DecryptedPassword = cryptoHelper.Decrypt(acc.Password);
     _acc = acc;
 }
コード例 #2
0
ファイル: OAuth.cs プロジェクト: ankitb/TweetOBox
        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;
        }
コード例 #3
0
ファイル: TOBTwitterO.cs プロジェクト: ankitb/TweetOBox
        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;
        }
コード例 #4
0
ファイル: NormalAuth.cs プロジェクト: ankitb/TweetOBox
        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;
        }
コード例 #5
0
ファイル: AccountManager.cs プロジェクト: ankitb/TweetOBox
        /// <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!");
            }
        }
コード例 #6
0
ファイル: AccountManager.cs プロジェクト: ankitb/TweetOBox
 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;
 }
コード例 #7
0
ファイル: AccountManager.cs プロジェクト: ankitb/TweetOBox
        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;
        }
コード例 #8
0
ファイル: AccountManager.cs プロジェクト: ankitb/TweetOBox
        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();
        }
コード例 #9
0
ファイル: TOBEntities.cs プロジェクト: ankitb/TweetOBox
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.AccountTypeAccountType = null;
		}
コード例 #10
0
ファイル: TOBEntities.cs プロジェクト: ankitb/TweetOBox
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.AccountTypeAccountType = this;
		}
コード例 #11
0
ファイル: TOBEntityBase.cs プロジェクト: ankitb/TweetOBox
 public void InternalSetAccount(Account acc)
 {
     this._Account.Entity = acc;
 }
コード例 #12
0
ファイル: TOBDAL.cs プロジェクト: ankitb/TweetOBox
partial         void UpdateAccount(Account instance);
コード例 #13
0
ファイル: TOBDAL.cs プロジェクト: ankitb/TweetOBox
partial         void InsertAccount(Account instance);
コード例 #14
0
ファイル: TOBDAL.cs プロジェクト: ankitb/TweetOBox
partial         void DeleteAccount(Account instance);
コード例 #15
0
ファイル: TOBTwitterO.cs プロジェクト: ankitb/TweetOBox
        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;
        }