Пример #1
0
 public ActionResult PostRegister(Register model)
 {
     if (ModelState.IsValid)
     {
         AccountProvider provider = new AccountProvider();
         Account         account  = new Account();
         account.CreateTime = DateTime.Now;
         account.Email      = model.Email;
         account.Fullname   = model.Fullname;
         account.IsActive   = true;
         account.IsDeleted  = false;
         account.IsLocked   = false;
         account.Password   = NDK.ApplicationCore.Extensions.Hepler.StringHelper.CreateMD5(model.Password);
         account.Role       = RoleManager.Member;
         account.Username   = model.Username;
         AccessEntityResult result = provider.Register(account);
         if (result.Status == AccessEntityStatusCode.OK)
         {
             TempData["Success"] = result.Message;
             return(RedirectToAction("Login"));
         }
         else
         {
             ModelState.AddModelError("registerError", result.Message);
         }
     }
     else
     {
         ModelState.AddModelError("registerError", MessageManager.GetErrorMessage(ModuleType.Register, MessageType.Register_ModelFailed));
     }
     return(View("Register", model));
 }
        async Task<Session> GetSession (AccountProvider provider, bool isLast, LoginOptions options, CancellationToken token)
        {
            if (!SessionManager.NetworkMonitor.IsNetworkAvailable)
                throw new OfflineException ();

            var account = await GetAccount (provider, !isLast, options);
            if (account == null)
                throw new Exception ("The user chose to skip this provider.");

            var service = provider.Service;
            var session = new Session (service, account);

            if (service.SupportsVerification) {
                // For services that support verification, do it now
                try {
                    await service.VerifyAsync (account, token);
                } catch (TaskCanceledException) {
                    throw;
                } catch (Exception ex) {
                    throw new InvalidOperationException ("Account verification failed.", ex);
                }
            }

            return session;
        }
Пример #3
0
        public string GetDerivedAccountProviderId(AccountProvider provider)
        {
            string result = string.Empty;

            if (this.externalAccountInfo == null)
            {
                return(result);
            }
            if (provider == AccountProvider.RECOVERY)
            {
                result = this.externalAccountInfo.DerivedRecoveryId;
            }
            else if (provider == AccountProvider.FACEBOOK)
            {
                result = this.externalAccountInfo.DerivedFacebookAccountId;
            }
            else if (provider == AccountProvider.GAMECENTER)
            {
                result = this.externalAccountInfo.DerivedGameCenterAccountId;
            }
            else if (provider == AccountProvider.GOOGLEPLAY)
            {
                result = this.externalAccountInfo.DerivedGooglePlayAccountId;
            }
            return(result);
        }
Пример #4
0
        public static void RunBetterMt()
        {
            HttpClient httpClient = new HttpClient {
                Timeout = TimeSpan.FromSeconds(10)
            };
            string             baseAddress        = "http://95.217.177.249/casino";
            ConnectionSettings connectionSettings = new ConnectionSettings(
                baseAddress: baseAddress,
                createAccAddress: $"{baseAddress}/createacc",
                playAddress: $"{baseAddress}/play");

            string           baseFilePath    = $"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent}\\Data";
            string           accountFilePath = $"{baseFilePath}\\my_account_data.json";
            IAccountProvider accountProvider = new AccountProvider(
                playerId: PlayerId,
                httpClient,
                connectionSettings,
                accountFilePath);
            string playStateFilePath = $"{baseFilePath}\\current_better_mt_play_state.json";
            Player betterMtPlayer    = new BetterMtPlayer(
                accountProvider,
                httpClient,
                connectionSettings,
                playStateFilePath: playStateFilePath,
                accountFilePath: accountFilePath,
                betPersentage: 1);

            betterMtPlayer.Play().Wait();
        }
Пример #5
0
        public async Task <IActionResult> Details(int messageId, CancellationToken cancellationToken)
        {
            var message = await MailAppDbContext.Messages
                          .Include(x => x.MessageAttachments)
                          .Include(x => x.MessagePersons)
                          .ThenInclude(x => x.Account)
                          .Include(x => x.MessagePersons)
                          .ThenInclude(x => x.Type)
                          .SingleOrDefaultAsync(x => x.Id == messageId, cancellationToken);

            if (message == null)
            {
                return(NotFound());
            }

            var currentAccount = await AccountProvider.GetAccountForCurrentUser(cancellationToken);

            message.MarkAsRead(currentAccount);

            await MailAppDbContext.SaveChangesAsync(cancellationToken);

            var viewModel = new MessageViewModel(message, currentAccount);

            return(PartialView(viewModel));
        }
Пример #6
0
        public IHttpActionResult Blob(string path, string accountName)
        {
            if (String.IsNullOrEmpty(path) ||
                String.IsNullOrEmpty(accountName))
            {
                return(Unauthorized());
            }

            // When linking to a blob, we must resolve the account name to handle cases
            // where multiple storage accounts are being used.
            CloudStorageAccount account = AccountProvider.GetAccountByName(accountName);

            if (account == null)
            {
                return(Unauthorized());
            }

            BlobPath            parsed     = BlobPath.Parse(path);
            LocalBlobDescriptor descriptor = new LocalBlobDescriptor
            {
                ContainerName = parsed.ContainerName,
                BlobName      = parsed.BlobName
            };
            var blob = descriptor.GetBlockBlob(account);

            // Get a SAS for the next 10 mins
            string sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions            = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
            });

            // Redirect to it
            return(Redirect(blob.Uri.AbsoluteUri + sas));
        }
        async Task <Session> GetSession(AccountProvider provider, bool isLast, LoginOptions options, CancellationToken token)
        {
            if (!SessionManager.NetworkMonitor.IsNetworkAvailable)
            {
                throw new OfflineException();
            }

            var account = await GetAccount(provider, !isLast, options);

            if (account == null)
            {
                throw new Exception("The user chose to skip this provider.");
            }

            var service = provider.Service;
            var session = new Session(service, account);

            if (service.SupportsVerification)
            {
                // For services that support verification, do it now
                try {
                    await service.VerifyAsync(account, token);
                } catch (TaskCanceledException) {
                    throw;
                } catch (Exception ex) {
                    throw new InvalidOperationException("Account verification failed.", ex);
                }
            }

            return(session);
        }
        public async Task <Session> Login(LoginOptions options, string [] scope, CancellationToken token)
        {
            List <AccountProvider> providers = GetProviderChain(options, scope).ToList();

            options.TryReportProgress(LoginProgress.Authorizing);

            var providerExceptions = new List <Exception> ();

            // Try each provider in turn
            foreach (var pi in providers.Select((p, i) => new { Provider = p, Index = i }))
            {
                bool            isLast   = (pi.Index == providers.Count - 1);
                AccountProvider provider = pi.Provider;

                token.ThrowIfCancellationRequested();

                try {
                    return(await GetSession(provider, isLast, options, token));
                } catch (TaskCanceledException) {
                    throw;
                } catch (Exception ex) {
                    providerExceptions.Add(ex);
                }
            }

            // Neither provider worked
            throw new AggregateException("Could not obtain session via either provider.", providerExceptions);
        }
Пример #9
0
        public async Task <int> UpdateAccountProvider(int accountid, UpdateAccountProviderViewModel model, string username)
        {
            var filter          = new AccountProviderSpecification(model.Provider, model.ProviderId);
            var accountprovider = await _accountProviderRepository.GetSingleBySpecAsync(filter);

            if (accountprovider != null)
            {
                if (accountprovider.AccountId != accountid)
                {
                    return(-1);
                }
                return(1);
            }

            accountprovider = new AccountProvider()
            {
                AccountId   = accountid,
                Email       = model.Email,
                Name        = model.Name,
                Provider    = model.Provider,
                ProviderId  = model.ProviderId,
                AccessToken = model.AccessToken,
                Expired     = DateTime.Now.AddHours(1)
            };
            await _accountProviderRepository.AddAsync(accountprovider);

            return(2);
        }
Пример #10
0
        public AccountProvider GetAccountProviderByAppID(string AppID)
        {
            AccountProvider provider = null;

            string sqlCommandText = ModuleConfiguration.SQL_CMD_SelectAccountProviderByAppId;

            IList <IDictionary <string, object> > dbResult = this.dmlOperable.ExeReader(sqlCommandText, new Dictionary <string, object>()
            {
                { "@AppId", AppID }
            });

            if (dbResult != null && dbResult.Count == 1)
            {
                provider = new AccountProvider()
                {
                    ID                = (string)dbResult[0]["Id"],                                                                                                                                                   //reader.GetString("Id"),
                    Name              = (string)dbResult[0]["Name"],                                                                                                                                                 //reader.GetString("Name"),
                    AppID             = (string)dbResult[0]["AppId"],                                                                                                                                                //reader.IsDBNull(reader.GetOrdinal("AppId")) ? null : reader.GetString("AppId"),
                    AppSecret         = (string)dbResult[0]["AppSecret"],                                                                                                                                            //reader.IsDBNull(reader.GetOrdinal("AppSecret")) ? null : reader.GetString("AppSecret"),
                    DynamicProperties = JsonUtility.JsonDeserialize(Encoding.UTF8.GetBytes((string)dbResult[0]["AdditionalInfo"]), typeof(Dictionary <string, object>), null, "root") as Dictionary <string, object> //reader.IsDBNull(reader.GetOrdinal("AdditionalInfo")) ? null : JsonUtility.JsonDeserialize(Encoding.UTF8.GetBytes(reader.GetString("AdditionalInfo")), typeof(Dictionary<string, object>), null, "root") as Dictionary<string, object>,
                };
            }

            return(provider);
        }
Пример #11
0
        public async Task <JsonResult> GetByID(int id)
        {
            AccountProvider accountProvider = new AccountProvider();
            var             d = await accountProvider.GetByIDAsync(id);

            return(Json(d, JsonRequestBehavior.AllowGet));
        }
Пример #12
0
        public async Task <AuthViewModel> GetAuth(LoginProviderViewModel model)
        {
            var filter          = new AccountProviderSpecification(model.Provider, model.ProviderId);
            var accountprovider = await _accountProviderRepository.GetSingleBySpecAsync(filter);

            if (accountprovider == null)
            {
                var account = await _accountRepository.GetAccount(model.Email);

                if (account == null)
                {
                    account = new Account()
                    {
                        DateCreated  = DateTime.Now,
                        DateModified = DateTime.Now,
                        Email        = model.Email,
                        Name         = model.Name,
                        Password     = "",
                        Actived      = true,
                        UserCreated  = model.Email,
                        UserModified = model.Email,
                        Address      = string.Empty,
                        Phone        = string.Empty,
                        Avatar       = model.Image,
                        Salt         = SecurityHelper.GenerateSalt(),
                        CityId       = null,
                        Deleted      = false,
                        DistrictId   = null,
                        Type         = AccountType.HotMom
                    };
                    await _accountRepository.AddAsync(account);

                    await _walletRepository.CreateWallet(EntityType.Account, account.Id);
                }


                accountprovider = new AccountProvider()
                {
                    AccountId   = account.Id,
                    Email       = model.Email,
                    Name        = model.Name,
                    Provider    = model.Provider,
                    ProviderId  = model.ProviderId,
                    AccessToken = model.AccessToken,
                    Expired     = DateTime.Now.AddHours(1),
                    Link        = string.Empty
                };
                await _accountProviderRepository.AddAsync(accountprovider);

                return(GetAuth(account));
            }
            else
            {
                accountprovider.AccessToken = model.AccessToken;
                await _accountProviderRepository.UpdateAsync(accountprovider);

                return(await GetAuth(accountprovider.AccountId));
            }
        }
Пример #13
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            await AccountProvider.SaveAccountToStorage();

            deferral.Complete();
        }
Пример #14
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            FeedbackProvider = new FeedbackEntryProvider(await AccountProvider.GetActiveAccount());
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            // Set theme for our app
            switch (ApplicationData.Current.LocalSettings.Values["theme"]?.ToString())
            {
            case "1":
                rootFrame.RequestedTheme = ElementTheme.Light;
                break;

            case "2":
                rootFrame.RequestedTheme = ElementTheme.Dark;
                break;

            case "0":
                rootFrame.RequestedTheme = ElementTheme.Default;
                break;

            default:     // Our default theme is dark
                rootFrame.RequestedTheme = ElementTheme.Dark;
                ApplicationData.Current.LocalSettings.Values["theme"] = "2";
                break;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), "AutoLogin");
                }

                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Пример #15
0
        private static void LoginIn()
        {
            LoginInParam _LoginInParam = new LoginInParam();

            _LoginInParam.Param1 = "test2";
            _LoginInParam.Param2 = GetBase64String("123456");
            AccountProvider _AccountProvider = new AccountProvider();
            var             result           = _AccountProvider.CheckIn(_LoginInParam);
        }
Пример #16
0
        /// <summary>
        /// 注册用户
        /// </summary>
        private static void RegUser()
        {
            AccountProvider _AccountProvider = new AccountProvider();
            User            _User            = new User();

            _User.loginName = "test2";
            _User.password  = GetBase64String("123456");
            _AccountProvider.RegUser(_User);
        }
Пример #17
0
        private Account SetAccount(string serviceUri)
        {
            IAccountProvider accountFactory =
                ClientCore.Factory.SignalingFactory.Singleton.CreateIAccountProvider();

            AccountProvider accountProvider = (AccountProvider)accountFactory;

            return((Account)accountProvider.GetAccount(serviceUri, _signaler.LocalPeer.Name, _signaler));
        }
Пример #18
0
        public FindProviderToAddQueryHandlerTestsFixture SetAccountProvider()
        {
            Account         = EntityActivator.CreateInstance <Account>().Set(a => a.Id, Query.AccountId);
            AccountProvider = EntityActivator.CreateInstance <AccountProvider>().Set(ap => ap.Id, 1).Set(ap => ap.AccountId, Account.Id).Set(ap => ap.ProviderUkprn, Provider.Ukprn);

            Db.AccountProviders.Add(AccountProvider);
            Db.SaveChanges();

            return(this);
        }
Пример #19
0
 public AccountProviderViewModel(AccountProvider accountProvider)
 {
     Id          = accountProvider.Id;
     AccountId   = accountProvider.AccountId;
     AccessToken = accountProvider.AccessToken;
     Expired     = accountProvider.Expired;
     ProviderId  = accountProvider.ProviderId;
     Name        = accountProvider.Name;
     Email       = accountProvider.Email;
 }
Пример #20
0
        private static void BindMember()
        {
            BindMemberParam _BindMemberParam = new BindMemberParam();

            _BindMemberParam.MemberCode = "E281600750M";
            _BindMemberParam.UserName   = "******";
            _BindMemberParam.UserKey    = "3487f43f-b514-11e6-a9fa-00ffc891ca91";
            AccountProvider _AccountProvider = new AccountProvider();

            _AccountProvider.BindMember(_BindMemberParam);
        }
Пример #21
0
        private static void Login()
        {
            AccountProvider _Provider = new AccountProvider();

            byte[]       password = Encoding.UTF8.GetBytes("123456");
            LoginInParam _Param   = new LoginInParam();

            _Param.Param1 = "test1";
            _Param.Param2 = Convert.ToBase64String(password);// "123456"
            _Provider.CheckIn(_Param);
        }
Пример #22
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if ((string)e.Parameter == CommonPageCommand.CannotGoBackLoginPage)
            {
                btnGoBack.Visibility = Visibility.Collapsed;
            }

            webLogin.Navigate(new Uri(GoogleLoginLink));
            savedLogin.SetAccountPool(await AccountProvider.GetAccounts());
        }
Пример #23
0
 public AccountProviderViewModel(AccountProvider accountProvider)
 {
     Id            = accountProvider.Id;
     AccountId     = accountProvider.AccountId;
     AccessToken   = accountProvider.AccessToken;
     Expired       = accountProvider.Expired;
     ProviderId    = accountProvider.ProviderId;
     Name          = accountProvider.Name;
     Email         = accountProvider.Email;
     FbProfileLink = accountProvider.Link;
     FriendsCount  = accountProvider.FriendsCount;
 }
Пример #24
0
        public void Register(SharedAccount sAccount)
        {
            Debug.WriteLine(AccountProvider.GetFeaturesByAppId("tlwr"));
            Account account = Account.CreateAccount();

            account.UserName    = sAccount.name;
            account.DisplayName = sAccount.displayName;
            account.DomainName  = sAccount.domainName;
            account.EmailId     = sAccount.email;
            account.IconPath    = sAccount.iconPath;
            AccountService.AddAccount(account);
        }
        public async void Should_set_account_provider(string auth0UserId, AccountProvider expectedProvider)
        {
            // Set up
            Auth0UserId             = auth0UserId;
            TestAccount.Auth0UserId = Auth0UserId;
            SetUpLoggedInUser(_controller);

            // Act
            var user = await _controller.Get();

            // Assert
            user.AccountProvider.Should().Be(expectedProvider);
        }
Пример #26
0
        private static IEnumerable <Account.Account> GetActiveAccounts(bool isActive)
        {
            var depOne            = new Mock <IDependencyOne>();
            var depTwo            = new Mock <IDependencyTwo>();
            var dbProvider        = new Mock <IDbProvider>();
            var userProvider      = new UserProvider(depOne.Object, depTwo.Object, dbProvider.Object);
            var anyPositiveAmount = 2;
            var money             = new Money(anyPositiveAmount);

            var activeAccounts = new AccountProvider().GetAccounts(userProvider, money, isActive);

            return(activeAccounts);
        }
Пример #27
0
        public UpdatePermissionsCommandHandlerTestsFixture SetAccountProviderLegalEntity()
        {
            AccountProviderLegalEntity = EntityActivator.CreateInstance <AccountProviderLegalEntity>()
                                         .Set(aple => aple.Id, 4)
                                         .Set(aple => aple.AccountProviderId, AccountProvider.Id)
                                         .Set(aple => aple.AccountLegalEntityId, AccountLegalEntity.Id);

            AccountProvider.Add(ap => ap.AccountProviderLegalEntities, AccountProviderLegalEntity);

            Db.SaveChanges();

            return(this);
        }
        public void GetAccounts_ReturnsExpectedResults()
        {
            // TODO: add a couple env accounts and verify
            Environment.SetEnvironmentVariable("MyStorageAccount", "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=GTfc0SIUd4Mg6n8wBzCRy29wnx2VVd+90MQKnJtgoCj4rB8LAIQ==");

            var accounts = AccountProvider.GetAccounts();

            Assert.True(accounts.ContainsKey("AzureWebJobsStorage"));
            Assert.True(accounts.ContainsKey("AzureWebJobsDashboard"));

            var account = accounts["MyStorageAccount"];

            Assert.Equal("myaccount", account.Credentials.AccountName);
        }
Пример #29
0
        public async Task <IActionResult> Index(MessagesQuery query, CancellationToken cancellationToken)
        {
            var senders = await MailAppDbContext.Accounts
                          .ToArrayAsync(cancellationToken);

            var owner = await AccountProvider.GetAccountForCurrentUser(cancellationToken);

            var messages = await MailAppDbContext.Messages
                           .Include(x => x.MessagePersons)
                           .ThenInclude(x => x.Account)
                           .ToArrayAsync(cancellationToken);

            messages = messages
                       .Where(x => query.SenderId == null || x.Sender.Id == query.SenderId)
                       .Where(x => x.MessagePersons.Any(y => y.Type != MessagePersonType.Sender && y.Account == owner))
                       .ToArray();

            if (!String.IsNullOrEmpty(query.Search))
            {
                foreach (var part in query.Search.Split(" "))
                {
                    messages = messages.Where(x => (x.Subject + x.Text).Contains(part)).ToArray();
                }
            }

            messages = query.Sort switch
            {
                MessagesQuery.SortingOptions.Subject => messages.OrderBy(x => x.Subject).ToArray(),
                MessagesQuery.SortingOptions.Date => messages.OrderBy(x => x.SentDate).ToArray(),
                MessagesQuery.SortingOptions.Nick => messages.OrderBy(x => x.Sender.Nick).ToArray(),
                _ => messages.OrderBy(x => x.SentDate).ToArray()
            };

            var viewModel = new MessagesListViewModel
            {
                SenderId = query.SenderId,
                Senders  = senders
                           .Select(x => new AccountViewModel(x))
                           .ToArray(),
                MessageList = new MessageListViewModel
                {
                    Messages = messages
                               .Select(x => new MessageViewModel(x, owner))
                               .ToArray(),
                }
            };

            return(View(viewModel));
        }
Пример #30
0
        public ActionResult Send(AccountModel viewModel)
        {
            viewModel.Header = Resources.ResultsHeader;
            try
            {
                var webApiAddress = ConfigurationManager.AppSettings["WebApiAddress"];

                viewModel.Results = AccountProvider.Save(webApiAddress, viewModel.Data);
            }
            catch (Exception ex)
            {
                viewModel.ErrorMessage = ex.GetBaseException().Message;
            }
            return(View("Index", viewModel));
        }
Пример #31
0
 public HttpResponseMessage GetBranchList()
 {
     try
     {
         AccountProvider _Provider = new AccountProvider();
         var             result    = _Provider.GetBranchList();
         return(Request.CreateResponse(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "获取专业分会", "GetBranchList", ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
        async Task<Account> GetAccount (AccountProvider provider, bool allowFallback, LoginOptions options)
        {
            List<Account> accounts;

            options.TryReportProgress (provider.ProgressWhileAuthenticating);
            try {
                // Now, let's get accounts for current provider.
                // For different services and login methods, this may launch Safari, show iOS 6 prompt or just query ACAccounts.
                accounts = (await provider.GetAccounts ()).ToList ();
            } finally {
                options.TryReportProgress (LoginProgress.Authorizing);
            }

            if (accounts.Count == 0)
                throw new InvalidOperationException ("No accounts found for this service.");

            if (accounts.Count == 1)
                return accounts [0];

            // If there is more than a single account, present an interface to choose one.
            // If fallback is available, add it to the list of options with null value.

            var choiceUI = options.AccountChoiceProvider;
            if (choiceUI == null)
                throw new InvalidOperationException ("There is more than one account, but no accountChoiceProvider was specified.");

            // Add "Other" option that falls back to next provider
            if (allowFallback)
                accounts.Add (null);

            // Show chooser interface
            options.TryReportProgress (LoginProgress.PresentingAccountChoice);
            try {
                return await choiceUI.ChooseAsync (accounts, a => (a != null) ? a.Username : "******");
            } finally {
                options.TryReportProgress (LoginProgress.Authorizing);
            }
        }
Пример #33
0
        public MainWindowViewModel()
        {
            this.IsTopmost = Settings.Settings.IsTopLevel;
            this.Title = "X-NowPlaying";
            this.Music = "Loading...";
            this.Album = "Loading...";
            this.Artist = "Loading...";

            //for Croudia
            this.CroudiaAccountProvider = new AccountProvider();
            this.CroudiaAccountProvider.ConsumerKey = Settings.Settings.CroudiaConsumerKey;
            this.CroudiaAccountProvider.ConsumerSecret = Settings.Settings.CroudiaConsumerSecret;
            if (!String.IsNullOrEmpty(Settings.Settings.CroudiaAccessToken) && !String.IsNullOrEmpty(Settings.Settings.CroudiaRefreshToken))
            {
                this.CroudiaAccountProvider.AccessToken = Settings.Settings.CroudiaAccessToken;
                this.CroudiaAccountProvider.RefreshToken = Settings.Settings.CroudiaRefreshToken;
            }

            //for Twitter
            if (!String.IsNullOrEmpty(Settings.Settings.TwitterAccessToken) && !String.IsNullOrEmpty(Settings.Settings.TwitterAccessTokenSecet))
            {
                this.TwitterTokens = Tokens.Create(Settings.Settings.TwitterConsumerKey, Settings.Settings.TwitterConsumerSecret, Settings.Settings.TwitterAccessToken, Settings.Settings.TwitterAccessTokenSecet);
            }
        }