Ejemplo n.º 1
0
        private async void SignUpButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            RegisterExternalUser registerExternalUser = new RegisterExternalUser()
            {
                UserName = this.UsernameTextBox.Text,
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.RegisterExternalAsync(registerExternalUser);
            }
            if (result.Succeeded)
            {
                // Need to login again now that we are registered - should happen with the existing cookie
                ExternalLoginResult externalLoginResult = await ExternalLoginManager.GetExternalAccessTokenAsync(externalLoginUri, silentMode : true);

                if (externalLoginResult.AccessToken != null)
                {
                    bool completed = accessTokenSource.TrySetResult(externalLoginResult.AccessToken);
                    this.Frame.Navigate(typeof(TodoPage));
                }
                else
                {
                    await ErrorDialog.ShowErrorAsync("Failed to register external account");
                }
            }
            else
            {
                DisplayErrors(result.Errors);
            }
        }
Ejemplo n.º 2
0
        public String GetAccountName(int AccountId)
        {
            AccountClient ac      = new AccountClient();
            Account       account = ac.Find(AccountId);

            return(account.Name);
        }
Ejemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            AccountClient client = new AccountClient();

            client.Delete(id);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            ExternalLoginsItemsControl.Items.Clear();

            HttpResult <ExternalLogin[]> result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.GetExternalLoginsAsync();
            }

            if (result.Succeeded)
            {
                ExternalLogin[] externalLogins = result.Content;
                ExternalLoginsPivotItem.Visibility = externalLogins.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
                foreach (ExternalLogin externalLogin in externalLogins)
                {
                    string  provider = externalLogin.Name;
                    Account account  = new Account()
                    {
                        Provider    = provider,
                        ProviderUri = externalLogin.Url,
                        Icon        = Account.GetAccountIcon(provider)
                    };
                    ExternalLoginsItemsControl.Items.Add(account);
                }
            }
            else
            {
                ExternalLoginsPivotItem.Visibility = Visibility.Collapsed;
                ErrorDialog.ShowErrors(result.Errors);
            }
        }
Ejemplo n.º 5
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            AccountsItemControl.Items.Clear();

            HttpResult <ManageInfo> result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.GetManageInfoAsync();
            }

            if (result.Succeeded)
            {
                ManageInfo manageInfo = result.Content;
                localProvider = manageInfo.LocalLoginProvider;
                foreach (UserLoginInfo userLoginInfo in manageInfo.Logins)
                {
                    Account account = new Account();
                    account.Provider    = userLoginInfo.LoginProvider;
                    account.ProviderKey = userLoginInfo.ProviderKey;
                    account.Icon        = Account.GetAccountIcon(userLoginInfo.LoginProvider);
                    AccountsItemControl.Items.Add(account);
                }
            }
            else
            {
                ErrorDialog.ShowErrors(result.Errors);
            }
        }
Ejemplo n.º 6
0
        private static void Main(string[] args)
        {
            //------------ sample B2B Client :
            var b2bClient = new MLBExchangesClient("d3cb4727cac14176ba67d97805f15588");
            var exchanges = b2bClient.GetExchanges().Result.ToList();


            foreach (var exchange in exchanges)
            {
                Console.WriteLine($"{exchange.FullName} - {exchange.EventId}");
            }

            // Console.ReadKey();

            //--------------sample Direct Client-------------------------


            var directAccountClient = new AccountClient(new ClientCredentials
            {
                UserName     = "******",
                Password     = "******",
                ClientId     = "DesktopApp",
                ClientSecret = "in-play"
            });



            Console.WriteLine($"{directAccountClient.GetUserInfo().Result.UserInfo.UserName}");

            Console.ReadKey();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Instantiates a new instance.
        /// </summary>
        /// <param name="apiKey">The API key to use to communicate with the Vultr
        /// API.</param>
        /// <param name="apiURL">The optional Vultr API URL to use. Set this if you want
        /// to override the default endpoint (e.g. for testing).</param>
        /// <exception cref="ArgumentNullException">If <paramref name="apiKey"/> is null
        /// or empty.</exception>
        public VultrClient(string apiKey, string apiURL = VultrApiURL)
        {
            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException("apiKey", "apiKey must not be null");
            }

            Account         = new AccountClient(apiKey, apiURL);
            Application     = new ApplicationClient(apiKey, apiURL);
            Auth            = new AuthClient(apiKey, apiURL);
            Backup          = new BackupClient(apiKey, apiURL);
            Block           = new BlockClient(apiKey, apiURL);
            DNS             = new DNSClient(apiKey, apiURL);
            Firewall        = new FirewallClient(apiKey, apiURL);
            ISOImage        = new ISOImageClient(apiKey, apiURL);
            Network         = new NetworkClient(apiKey, apiURL);
            OperatingSystem = new OperatingSystemClient(apiKey, apiURL);
            Plan            = new PlanClient(apiKey, apiURL);
            Region          = new RegionClient(apiKey, apiURL);
            ReservedIP      = new ReservedIPClient(apiKey, apiURL);
            Server          = new ServerClient(apiKey, apiURL);
            Snapshot        = new SnapshotClient(apiKey, apiURL);
            SSHKey          = new SSHKeyClient(apiKey, apiURL);
            StartupScript   = new StartupScriptClient(apiKey, apiURL);
            User            = new UserClient(apiKey, apiURL);
        }
Ejemplo n.º 8
0
        public ActionResult Create(Account OurAccount)
        {
            AccountClient client = new AccountClient();

            client.Create(OurAccount);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        private async void ChangePasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ResetDisplay();
            ChangePassword changePassword = new ChangePassword()
            {
                OldPassword     = OldPasswordBox.Password,
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.ChangePasswordAsync(changePassword);
            }

            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.ChangePasswordCredential(username, changePassword.NewPassword);
                DisplaySuccess();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
 public async Task<IList<MemberModel>> Test4()
 {
     using (var client = new AccountClient())
     {
         return await client.ListAllMembersAsync().ToResult<IList<MemberModel>>();
     }
 }
Ejemplo n.º 11
0
        public ActionResult Edit(Account CVM)
        {
            AccountClient client = new AccountClient();

            client.Edit(CVM);
            return(RedirectToAction("Index"));
        }
        private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ResetDisplay();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(this.username, setPassword.NewPassword);
                AccountsSettingsPane.Show();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
Ejemplo n.º 13
0
        private async void SignUpButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            RegisterExternalUser registerExternalUser = new RegisterExternalUser()
            {
                UserName = this.UsernameTextBox.Text,
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.RegisterExternalAsync(registerExternalUser);
            }

            if (result.Succeeded)
            {
                // Need to login again now that we are registered - should happen with the existing cookie
                ExternalLoginResult externalLoginResult = await ExternalLoginManager.GetExternalAccessTokenAsync(externalLoginUri);

                bool completed = AccessTokenProvider.AccessTokenSource.TrySetResult(externalLoginResult.AccessToken);
                this.NavigationService.Navigate(new Uri("/TodoPage.xaml", UriKind.Relative));
            }
            else
            {
                DisplayErrors(result.Errors);
            }
        }
 public IList<MemberModel> Test5()
 {
     using (var client = new AccountClient())
     {
         return client.ListAllMembers().ToResult<IList<MemberModel>>();
     }
 }
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     try
     {
         client?.Dispose();
         int timeout = GetPreferredTimeout();
         WriteDebug($"Cmdlet Timeout : {timeout} milliseconds.");
         client = new AccountClient(AuthProvider, new Oci.Common.ClientConfiguration
         {
             RetryConfiguration = retryConfig,
             TimeoutMillis      = timeout,
             ClientUserAgent    = PSUserAgent
         });
         string region = GetPreferredRegion();
         if (region != null)
         {
             WriteDebug("Choosing Region:" + region);
             client.SetRegion(region);
         }
         if (Endpoint != null)
         {
             WriteDebug("Choosing Endpoint:" + Endpoint);
             client.SetEndpoint(Endpoint);
         }
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }
Ejemplo n.º 16
0
        private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                this.NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
Ejemplo n.º 17
0
        internal List <Account> GetAccountIdList(string userId)
        {
            AccountClient         ac         = new AccountClient();
            IEnumerable <Account> enumerable = ac.GetAccountList(userId);

            return((List <Account>)enumerable);
        }
Ejemplo n.º 18
0
        public async Task<IList<vappevent>> ListTodayEvents(int memberId = -1)
        {
            try
            {
                var events = _appEventRepo.All().ToList().Where(c =>
                    (c.IsRepeatable && (c.EventDate - DateTime.Today).Days % c.RepeatInterval == 0) || c.EventDate == DateTime.Today);

                if (memberId != -1)
                {
                    var client = new AccountClient();
                    var member = await client.GetMemberAsync(memberId).ToResult<MemberModel>();

                    int[] groupIds = member.Groups.Select(c => c.GroupID).ToArray();

                    events = events.Where(c => ListEventGroups(c.ID).Intersect(groupIds).Count() > 0);
                }
                return events.ToList();
            }
            catch (HttpRequestException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 19
0
        private static void GetAccountHistory()
        {
            var accountClient = new AccountClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var request = new GetRequest()
                          .AddParam("account-id", Config.AccountId);
            var result = accountClient.GetAccountHistoryAsync(request).Result;

            _logger.StopAndLog();

            if (result != null)
            {
                switch (result.status)
                {
                case "ok":
                {
                    foreach (var h in result.data)
                    {
                        AppLogger.Info($"currency: {h.currency}, amount: {h.transactAmt}, type: {h.transactType}, time: {h.transactTime}");
                    }
                    AppLogger.Info($"There are total {result.data.Length} transactions");
                    break;
                }

                case "error":
                {
                    AppLogger.Info($"Get fail, error code: {result.errorCode}, error message: {result.errorMessage}");
                    break;
                }
                }
            }
        }
Ejemplo n.º 20
0
        public void refreshBalance(int id, decimal amount, decimal oldamount, char action) //action c=create e=edit d=delete
        {
            AccountClient ac      = new AccountClient();
            Account       account = ac.Find(id);

            if (action == 'c')
            {
                account.Expenses += amount;
                account.Balance  -= amount;
            }
            else
            {
                if (action == 'e')
                {
                    account.Expenses -= oldamount;
                    account.Balance  += oldamount;
                    account.Expenses += amount;
                    account.Balance  -= amount;
                }
                else
                {
                    if (action == 'd')
                    {
                        account.Expenses -= amount;
                        account.Balance  += amount;
                    }
                }
            }
            ac.Edit(account);
        }//refreshBalance()
Ejemplo n.º 21
0
        private static void GetSubuserAccountBalance()
        {
            var accountClient = new AccountClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var result = accountClient.GetSubUserAccountBalanceAsync(Config.SubUserId).Result;

            _logger.StopAndLog();

            if (result != null && result.data != null)
            {
                foreach (var a in result.data)
                {
                    int availableCount = 0;
                    AppLogger.Info($"account id: {a.id}, type: {a.type}");
                    foreach (var b in a.list)
                    {
                        if (Math.Abs(float.Parse(b.balance)) > 0.00001)
                        {
                            availableCount++;
                            AppLogger.Info($"currency: {b.currency}, type: {b.type}, balance: {b.balance}");
                        }
                    }
                    AppLogger.Info($"There are total {a.list.Length} accounts and available {availableCount} currencys in this account");
                }
                AppLogger.Info($"There are total {result.data.Length} accounts");
            }
        }
Ejemplo n.º 22
0
        private static void TransferCurrencyFromMasterToSub()
        {
            var accountClient = new AccountClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var result = accountClient.TransferCurrencyFromMasterToSubAsync(Config.SubUserId, "ht", 1).Result;

            _logger.StopAndLog();

            if (result != null)
            {
                switch (result.status)
                {
                case "ok":
                {
                    AppLogger.Info($"Transfer successfully, trade id: {result.data}");
                    break;
                }

                case "error":
                {
                    AppLogger.Info($"Transfer fail, error code: {result.errorCode}, error message: {result.errorMessage}");
                    break;
                }
                }
            }
        }
Ejemplo n.º 23
0
        private static void GetAccountLedger()
        {
            var client = new AccountClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            GetRequest request = new GetRequest()
                                 .AddParam("accountId", Config.AccountId);
            var result = client.GetAccountLedgerAsync(request).Result;

            _logger.StopAndLog();

            if (result != null)
            {
                if (result.code == (int)ResponseCode.Success && result.data != null)
                {
                    foreach (var l in result.data)
                    {
                        AppLogger.Info($"Get account ledger, accountId: {l.accountId}, currency: {l.currency}, amount: {l.transactAmt}, transferer: {l.transferer}, transferee: {l.transferee}");
                    }
                }
                else
                {
                    AppLogger.Info($"Get account ledger error: {result.message}");
                }
            }
        }
Ejemplo n.º 24
0
        private async void AddAccountButton_Click(object sender, RoutedEventArgs e)
        {
            Account account = (Account)((FrameworkElement)sender).DataContext;

            if (account.Provider == localProvider)
            {
                this.NavigationService.Navigate(new Uri("/SetPasswordPage.xaml", UriKind.Relative));
            }
            else
            {
                ExternalLoginResult loginExternalResult = await ExternalLoginManager.GetExternalAccessTokenAsync(account.ProviderUri);

                string accessToken = loginExternalResult.AccessToken;
                if (accessToken != null)
                {
                    HttpResult result;
                    using (AccountClient accountClient = ClientFactory.CreateAccountClient())
                    {
                        result = await accountClient.AddExternalLoginAsync(new AddExternalLogin()
                        {
                            ExternalAccessToken = accessToken
                        });
                    }

                    if (result.Succeeded)
                    {
                        this.NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
                    }
                    else
                    {
                        ErrorDialog.ShowErrors(result.Errors);
                    }
                }
            }
        }
        private IObservable <SearchResult> DoSearch(SearchParameter param)
        {
            return(Observable.Start(() =>
            {
                try
                {
                    var fromTransactionId = param.FromTransactionId;
                    var results = new List <SearchResultItem>();


                    IList <Transaction> transactions = new List <Transaction>();
                    while (results.Count < param.ResultSize)
                    {
                        if (!string.IsNullOrEmpty(param.AccountAddress) && param.TransactionFilter == TransactionFilter.Incoming)
                        {
                            var address = Address.CreateFromRawAddress(param.AccountAddress);

                            transactions = AccountClient.GetTransactions(param.TransactionFilter, BatchTransactionSize,
                                                                         address,
                                                                         fromTransactionId).Wait();
                        }
                        else if (!string.IsNullOrEmpty(param.AccountPublicKey))
                        {
                            var publicAccount = GetPublicAccount(param.AccountPrivateKey, param.AccountPublicKey, param.AccountAddress);

                            transactions = AccountClient.GetTransactions(param.TransactionFilter, BatchTransactionSize,
                                                                         publicAccount,
                                                                         fromTransactionId).Wait();
                        }

                        var resultSet = transactions.AsParallel()
                                        .Select(txn => ConvertToResultItemIfMatchingCriteria(txn, param))
                                        .Where(resultItem => resultItem != null)
                                        .Take(param.ResultSize - results.Count)
                                        .ToList();

                        results.AddRange(resultSet);

                        // if last fetch is full, there might be more transactions in account
                        // otherwise, search is done
                        if (transactions.Count == BatchTransactionSize)
                        {
                            fromTransactionId = transactions[transactions.Count - 1].TransactionInfo.Id;
                        }
                        else
                        {
                            break;
                        }
                    }

                    var toTransactionId = results.Count == 0 ? null : results[results.Count - 1].TransactionId;
                    return new SearchResult(results, param.FromTransactionId, toTransactionId);
                }
                catch (Exception ex)
                {
                    throw new SearchFailureException("Search failed.", ex);
                }
            }));
        }
 public AccountDetailForm(long id)
 {
     InitializeComponent();
     accountSV = new AccountClient();
     groupSV = new GroupClient();
     orderSV = new OrderClient();
     threadInit.RunWorkerAsync(id);
 }
Ejemplo n.º 27
0
        public ActionResult DeleteConfirmed(int id)
        {
            AccountClient accountClient = db.AccountClients.Find(id);

            db.AccountClients.Remove(accountClient);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 // constructor for unit testing purposes
 internal Searcher(NetworkType networkType,
                   AccountClient accountClient,
                   RetrieveProximaxMessagePayloadService retrieveProximaxMessagePayloadService)
 {
     NetworkType   = networkType;
     AccountClient = accountClient;
     RetrieveProximaxMessagePayloadService = retrieveProximaxMessagePayloadService;
 }
Ejemplo n.º 29
0
        public void test_account_client_connection()
        {
            // Arrange
            var proxy = new AccountClient();

            // Act & Assert
            proxy.Open();
        }
Ejemplo n.º 30
0
        private void clearAccountsButton_Click(object sender, EventArgs e)
        {
            LOGGER.Info($"Deleting all registered accounts");

            AccountClient.DeleteAllAccounts();

            ReloadAccounts();
        }
 public Searcher(ConnectionConfig connectionConfig)
 {
     NetworkType   = connectionConfig.BlockchainNetworkConnection.NetworkType;
     AccountClient =
         new AccountClient(connectionConfig.BlockchainNetworkConnection);
     RetrieveProximaxMessagePayloadService =
         new RetrieveProximaxMessagePayloadService(connectionConfig.BlockchainNetworkConnection);
 }
Ejemplo n.º 32
0
        public AccountForm()
        {
            InitializeComponent();

            accountSV = new AccountClient();
            threadInit.RunWorkerAsync();
            initComboBox();
        }
Ejemplo n.º 33
0
        private ListAccountsResponse GetAccounts()
        {
            var authContainer = GetAuthenticationContainer();
            var accountClient = new AccountClient(authContainer);
            var response      = accountClient.ListAccounts().Result;

            return(response);
        }
Ejemplo n.º 34
0
 public HomeController(ILogger <HomeController> logger,
                       HomeClient homeClient,
                       AccountClient accountClient)
 {
     _logger        = logger;
     _homeClient    = homeClient;
     _accountClient = accountClient;
 }
Ejemplo n.º 35
0
        public void ScreenImage(string baseAddress)
        {
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            binding.TransferMode           = TransferMode.StreamedResponse;
            binding.MaxReceivedMessageSize = 1024 * 1024 * 2;
            client = new AccountClient(binding, new EndpointAddress(baseAddress));
        }
Ejemplo n.º 36
0
        public AddOrder()
        {
            InitializeComponent();

            accountService = new AccountClient();
            orderService = new OrderClient();
            productService = new ProductClient();
            detail = new List<DetailOrder>();
        }
 public LoginPageViewModel()
 {
     Login = new RelayCommand((param) => LoginBody(param as string[]));
     accountService = new AccountClient();
     accountService.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(OnEndLogin);
     accountService.RegisterCompleted += new EventHandler<RegisterCompletedEventArgs>(OnEndRegister);
     _error = 0;
     _logued = false;
 }
 public async Task<IList<MemberModel>> Test2()
 {
     using (var client = new AccountClient())
     {
         var response = await client.ListAllMembersAsync();
         response.EnsureSuccessStatusCode();
         return await response.Content.ReadAsAsync<IList<MemberModel>>();
     }
 }
Ejemplo n.º 39
0
        public Order()
        {
            InitializeComponent();

            orderService = new OrderClient();
            accountService = new AccountClient();
            productService = new ProductClient();
            orders = new List<OrderModel>();
            threadInit.RunWorkerAsync();
        }
Ejemplo n.º 40
0
 //проверяет существование пользователя на сервере
 static public bool Exist()
 {
     try
     {
         AccountClient server = new AccountClient();
         return server.Exist(GetUserEmail(), GetUserPass());
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.ToString());
     }
 }
        protected async Task<MemberModel> CurrentChurchMember()
        {
            try
            {
                if (CurrentMemberID != 0)
                {
                    var client = new AccountClient();
                    var response = await client.GetMemberAsync(CurrentMemberID);
                    response.EnsureSuccessStatusCode();
                    _currentChurchMember = await response.Content.ReadAsAsync<MemberModel>();
                }

                return _currentChurchMember;
            }
            catch (HttpRequestException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 42
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     btnThem.Enabled = false;
     accountSV = new AccountClient();
     Account acc = new Account();
     acc.CreatedAt = DateTime.Now;
     acc.CreatedBy = CurrentUser.Username;
     acc.Email = txtEmail.Text;
     acc.Fullname = txtHoten.Text;
     acc.GroupId = groups[cbNhom.SelectedIndex].id;
     acc.Password = MD5Hash(txtMatkhau.Text);
     acc.Username = txtTaikhoan.Text;
     acc.Status = chbTrangthai.Checked;
     if (accountSV.insert(acc) > -1)
         MessageBox.Show("Thành công");
     else
         MessageBox.Show("Thất bại");
     btnThem.Enabled = true;
 }
Ejemplo n.º 43
0
        public void test_account_client_connection()
        {
            AccountClient proxy = new AccountClient();

            proxy.Open();
        }
 public override bool ValidateUser(string email, string password)
 {
     AccountClient accountClient = new AccountClient();
     return accountClient.Exist(email, password);
 }
Ejemplo n.º 45
0
    protected void Page_Load(object sender, EventArgs e)
    {
        curUser = Membership.GetUser();

        if (Request.PathInfo.StartsWith("/twitter/"))
        {
            var oauth = new OAuthConsumer();
            var requestToken = (RequestToken)Session["TwitterToken"];
            string verifier = Request.QueryString["oauth_verifier"];
            string tokenSecret = Request.QueryString["oauth_token"];
            AccessToken accessToken = oauth.GetOAuthAccessToken(appSettings["Twitter_AccessURL"],
                appSettings["Twitter_Realm"], appSettings["Twitter_ConsumerKey"],
                appSettings["Twitter_ConsumerSecret"], tokenSecret, verifier, requestToken.Token);
            string curUserId = curUser.ProviderUserKey.ToString();

            var oAuthParams = new OAuthParameters(appSettings["Twitter_ConsumerKey"],
                appSettings["Twitter_ConsumerSecret"], appSettings["Twitter_Realm"],
                accessToken.Token, accessToken.TokenSecret);

            Func<OAuthParameters> OAuthDirect = () => oAuthParams;
            var account = new AccountClient(OAuthDirect);

            var tUser = Json.Deserialize<Bridgeport.TwitterAPI.User>(account.VerifyCredentials().Data);

            using (var db = new Data.ToketeeData().Context)
            {
                var q = from u in db.User
                        where u.UserId == curUserId
                        select u;
                if (q.Any()) // User does not exist
                {

                    var user = new Data.Entities.User()
                    {
                        UserId = curUserId,
                    };
                    var twitterUser = new TwitterData.TwitterUser()
                        {
                            rUser = user,
                            Token = accessToken.Token,
                            Secret = accessToken.TokenSecret,
                            AuthAttemptCount = 0,
                            AuthStatus = 1,
                            AppUser = true,
                            AuthTime = DateTime.Now.ToUniversalTime()
                        };
                    UserOps.UserObjToTwitterUser(tUser, twitterUser);

                    db.User.Add(user);
                    db.TwitterUser.Add(twitterUser);
                }
                else // User exists
                {
                    var qry = q.Single();

                    TwitterData.TwitterUser tu;
                    if (qry.TwitterUsers.Count() != 0) // Twitter user exists
                    {
                        var q2 = from u in qry.TwitterUsers
                                 where u.Id == long.Parse(tUser.Id)
                                 select u;

                        tu = q2.Single();
                    }
                    else
                    {
                        tu = new TwitterData.TwitterUser() { rUser = qry };
                        db.TwitterUser.Add(tu);
                    }

                    tu.Token = accessToken.Token;
                    tu.Secret = accessToken.TokenSecret;
                    tu.AuthAttemptCount = 0;
                    tu.AuthStatus = 1;
                    tu.AppUser = true;
                    tu.AuthTime = DateTime.Now.ToUniversalTime();

                    UserOps.UserObjToTwitterUser(tUser, tu);
                }
                db.SaveChanges();
            }

        }
    }
 public ChangePassword(long id)
 {
     InitializeComponent();
     service = new AccountClient();
     this.id = id;
 }
Ejemplo n.º 47
0
 public void NewAccountAuthorizeClient(int accountId, int clientId)
 {
     var account = _repAccount.Fetch(m=>m.Id==accountId).SingleOrDefault();
     account.Clients=new List<AccountClient>();
     account.Roles = new List<int>();
     if (account.Clients != null && account.Clients.Select(c => c.ClientId).All(r => r != clientId))
     {
         var ac = new AccountClient() { AccountId = accountId, ClientId = clientId };
         account.Clients.Add(ac);
     }
     _repAccount.Update(account);
 }
Ejemplo n.º 48
0
 public void AuthorizeClient(int accountId, int clientId)
 {
     var account = GetAccountById(accountId);
     if (account.SystemAccount_N)
     {
         throw new QsTech.Framework.QsTechException(string.Format("系统用户[{0}],无需分配应用权限。", account.Name));
     }
     if (account.Clients != null && account.Clients.Select(c=>c.ClientId).All(r => r != clientId))
     {
         var ac = new AccountClient() { AccountId = accountId,ClientId = clientId};
         account.Clients.Add(ac);
     }
     _repAccount.Update(account);
     ReloadAccountData();
 }
Ejemplo n.º 49
0
 public void AuthorizeClients(int accountId, int[] clientIds)
 {
     foreach (var item in clientIds)
     {
         var ac = new AccountClient();
         ac.AccountId = accountId;
         ac.ClientId = item;
         _repAccountClient.Create(ac);
     }
     _repAccountClient.Flush();
     ReloadAccountData();
 }
Ejemplo n.º 50
0
 public HomeController(SecurityClient securityClient, AccountClient accountClient)
 {
     this.securityClient = securityClient;
     this.accountClient = accountClient;
 }
Ejemplo n.º 51
0
 public void Test_AccountClientClient_Connection()
 {
     var accountClient = new AccountClient();
     accountClient.Open();
 }
Ejemplo n.º 52
0
 public LoginForm()
 {
     InitializeComponent();
     serv = new AccountClient();
 }