public void CloseAccount(string accountNo) { IAccountData objAccountData = null; try { objAccountData = Builder.AccountData(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { if (!objAccountData.CheckAccount(accountNo)) { throw new Exception("Account not found."); } if (!objAccountData.DeleteAccount(accountNo)) { throw new Exception("Error: Can not delete data."); } scope.Complete(); } } catch { throw; } finally { if (objAccountData != null) { objAccountData.Dispose(); } } }
public void OpenNewAccount(string accountNo) { IAccountData objAccountData = null; try { objAccountData = Builder.AccountData(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { if (objAccountData.CheckAccount(accountNo)) { throw new Exception("Already account."); } if (!objAccountData.AddAccount(accountNo, 0)) { throw new Exception("Error: Can not add data"); } scope.Complete(); } } catch { throw; } finally { if (objAccountData != null) { objAccountData.Dispose(); } } }
public void InsertToken(IAccountData account, string token, Action doneCallback) { account.Token = token; _accounts.Update(account as AccountData); doneCallback.Invoke(); }
/// <summary> /// Triggers the <see cref="EmailConfirmed"/> event /// </summary> protected void TriggerEmailConfirmed(IAccountData account) { if (EmailConfirmed != null) { EmailConfirmed.Invoke(account); } }
/// <summary> /// Triggers the <see cref="Registered"/> event /// </summary> protected void TriggerRegisteredEvent(IPeer peer, IAccountData account) { if (Registered != null) { Registered.Invoke(peer, account); } }
public void InsertNewAccount(IAccountData account, Action <long> doneCallback) { account.UserId = userId++; SaveCurMaxUserID(userId); _accounts.Insert(account as AccountData); doneCallback.Invoke(account.UserId); }
public ListModel(IBlogData blogData, IBlogTypeData typeData, IAccountData accountData) { this.blogData = blogData; this.typeData = typeData; this.accountData = accountData; start = 0; }
public void InsertNewAccount(IAccountData acc) { var account = acc as SqlAccountData; using (var con = new NpgsqlConnection(_connectionString)) using (var cmd = new NpgsqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = "INSERT INTO accounts (username, password, email, is_admin, is_guest, is_email_confirmed) " + "VALUES (@username, @password, @email, @is_admin, @is_guest, @is_email_confirmed) RETURNING account_id"; cmd.Parameters.AddWithValue("@username", account.Username); cmd.Parameters.AddWithValue("@password", account.Password); cmd.Parameters.AddWithValue("@email", account.Email); cmd.Parameters.AddWithValue("@is_admin", account.IsAdmin); cmd.Parameters.AddWithValue("@is_guest", account.IsGuest); cmd.Parameters.AddWithValue("@is_email_confirmed", account.IsEmailConfirmed); Debug.WriteLine("InsertNewAccount - Query:\n" + cmd.CommandText); var id = cmd.ExecuteScalar() as int?; if (id.HasValue) { account.AccountId = id.Value; } } }
public void UpdateAccount(IAccountData acc) { var account = acc as SqlAccountData; using (var con = new NpgsqlConnection(_connectionString)) using (var cmd = new NpgsqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = "UPDATE accounts " + "SET password = @password, " + "email = @email, " + "is_admin = @is_admin, " + "is_guest = @is_guest, " + "is_email_confirmed = @is_email_confirmed " + "WHERE account_id = @account_id"; cmd.Parameters.AddWithValue("@password", account.Password); cmd.Parameters.AddWithValue("@email", account.Email); cmd.Parameters.AddWithValue("@is_admin", account.IsAdmin); cmd.Parameters.AddWithValue("@is_guest", account.IsGuest); cmd.Parameters.AddWithValue("@is_email_confirmed", account.IsEmailConfirmed); cmd.Parameters.AddWithValue("@account_id", account.AccountId); cmd.ExecuteNonQuery(); } }
public void Deposit(string accountNo, decimal money) { IAccountData objAccountData = null; try { objAccountData = Builder.AccountData(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { System.Data.DataSet ds = objAccountData.GetAccount(accountNo); if (ds.Tables[0].Rows.Count == 0) { throw new Exception("Account not found."); } money = (ds.Tables[0].Rows[0]["Balance"] == DBNull.Value) ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[0]["Balance"]) + money; if (!objAccountData.UpdateAccount(accountNo, money)) { throw new Exception("Error: Can not update data."); } scope.Complete(); } } catch { throw; } finally { if (objAccountData != null) { objAccountData.Dispose(); } } }
public AnswerQuestionModel(IExpertAnswerData answerData, IExpertQuestionData questionData, IExpertData expertData, UserManager <UserProfile> userManager, IAccountData accountData) { this.answerData = answerData; this.questionData = questionData; this.expertData = expertData; this.userManager = userManager; this.accountData = accountData; }
public const string RegistrationUrl = @"https://www.facebook.com/r.php"; //https://m.facebook.com/ https://www.facebook.com/ #endregion public FacebookRegistration(IAccountData data, ISmsService smsService, IChromiumSettings chromiumSettings) : base(data, smsService, chromiumSettings) { var proxy = _chromiumSettings.GetProxy(ServiceCode.Facebook); if (!string.IsNullOrEmpty(proxy)) { _chromiumSettings.Proxy = proxy; } }
public DetailModel(ITalkData talkData, ITalkCommentData commentData, IAccountData accountData) { this.talkData = talkData; this.commentData = commentData; this.accountData = accountData; if (Comment == null) { Comment = new TalkComment(); } }
public WriteBlogModel(IBlogData blogData, IBlogTypeData typeData, IAccountData accountData, IWebHostEnvironment hostEnvironment) { this.blogData = blogData; this.typeData = typeData; this.accountData = accountData; this.hostEnvironment = hostEnvironment; if (Blog == null) { Blog = new Blog(); } }
public void SavePasswordResetCode(IAccountData account, string code) { // Delete older codes _resetCodes.Delete(Query.EQ("Email", account.Email.ToLower())); _resetCodes.Insert(new PasswordResetData() { Email = account.Email, Code = code }); }
public void SavePasswordResetCode(IAccountData account, string code, Action doneCallback) { // Delete older codes _resetCodes.Delete(Query.EQ("Email", account.Email.ToLower())); _resetCodes.Insert(new PasswordResetData { Email = account.Email, Code = code }); doneCallback.Invoke(); }
public AccountEntity[] SearchAccountAndBalance(string accountNo, string balance) { try { using (IAccountData accountData = Builder.AccountData()) { return(this.ConvertDataTableToEntities(accountData.ListAccount(accountNo, balance).Tables[0])); } } catch (Exception ex) { throw new BSLException("SearchAccountAndBalance event occurs an error.[" + ex.Message + "]", ex, true); } }
public bool UpdateAccount(string accountNo, decimal balance) { try { using (IAccountData accountData = Builder.AccountData()) { return(accountData.UpdateAccount(accountNo, balance)); } } catch (Exception ex) { throw new BSLException("UpdateAccount event occurs an error.[" + ex.Message + "]", ex, true); } }
public bool CheckAccount(string accountNo) { try { using (IAccountData accountData = Builder.AccountData()) { return(accountData.CheckAccount(accountNo)); } } catch (Exception ex) { throw new BSLException("CheckAccount event occurs an error.[" + ex.Message + "]", ex, true); } }
public AccountEntity[] Search(string search) { try { using (IAccountData accountData = Builder.AccountData()) { Entities.AccountEntity ac = new AccountEntity(); ac.Equals(""); return(this.ConvertDataTableToEntities(accountData.ListAccount(search).Tables[0])); } } catch (Exception ex) { throw new BSLException("Search event occurs an error.[" + ex.Message + "]", ex, true); } }
public static async Task <string> Auth(Page page, IAccountData accountData) { if (accountData == null) { return(string.Empty); } try { await page.GoToAsync($"https://www.facebook.com/"); var selectorLogin = "******"; await page.ClickAsync(selectorLogin); await page.TypeAsync(selectorLogin, accountData.Phone); var selectorPassword = "******"; await page.ClickAsync(selectorPassword); await page.TypeAsync(selectorPassword, accountData.Password); if (await page.QuerySelectorAsync("input[type='submit']") != null) { await page.ClickAsync("input[type='submit']"); } if (await page.QuerySelectorAsync("button[name='login']") != null) { await page.ClickAsync("button[name='login']"); } var response = await page.WaitForNavigationAsync(); var profile = await page.QuerySelectorAsync("a[title = 'Profile']"); if (profile == null) { return(string.Empty); } var text = (await(await profile.GetPropertyAsync("href")).JsonValueAsync()).ToString(); return(text); //return page.Url; } catch (Exception exception) { Log.Error(exception); return(string.Empty); } }
public static async Task <string> Auth(Page page, IAccountData accountData) { if (accountData == null) { return(string.Empty); } try { await page.GoToAsync($"https://vk.com"); var loginSelectorVkAuthorization = "input#index_email"; await page.ClickAsync(loginSelectorVkAuthorization); await page.TypeAsync(loginSelectorVkAuthorization, accountData.Phone); var passwordSelectorVkAuthorization = "input#index_pass"; await page.ClickAsync(passwordSelectorVkAuthorization); await page.TypeAsync(passwordSelectorVkAuthorization, accountData.Password); await page.ClickAsync("div#index_expire"); await page.ClickAsync("button#index_login_button"); await page.WaitForNavigationAsync(); if (await page.QuerySelectorAsync("div.top_profile_name") == null) { return(string.Empty); } if (page.Url.ToLower().Contains("blocked")) { return(string.Empty); } await page.ClickAsync("li#l_pr"); await page.WaitForNavigationAsync(); return(page.Url); } catch (Exception exception) { Log.Error(exception); return(string.Empty); } }
public async Task <List <string> > RunScenario(IAccountData accountData, string[] vkAccountNames) { var result = new List <string>(); try { using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless())) using (var page = await browser.NewPageAsync()) { if (accountData != null) { var vkAuthorizationAuth = await VkAuthorization.Auth(page, accountData); Info($"Авторизация ВКонтакте успешна - {vkAuthorizationAuth}"); } else { Info("Нет данных для авторизация ВКонтакте"); } foreach (var vkAccountName in vkAccountNames) { if (string.IsNullOrEmpty(vkAccountName)) { continue; } var response = await page.GoToAsync($"https://vk.com/{vkAccountName}"); var checkVkAccountResult = new CheckVkAccountOutput { AccountName = vkAccountName, Available = response.Ok }; _progressResult?.Report(checkVkAccountResult); var text = JsonConvert.SerializeObject(checkVkAccountResult); Info(text); result.Add(text); } } } catch (Exception exception) { Error(exception.Message); } return(result); }
public async Task RunScenario(IAccountData accountData, string[] vkGroups, string message) { try { using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless())) using (var page = await browser.NewPageAsync()) { foreach (var vkGroup in vkGroups) { await VkAuthorization.Auth(page, accountData); await page.GoToAsync($"https://vk.com/{vkGroup}"); //await page.GoToAsync($"https://vk.com/club188446341"); await page.WaitForSelectorAsync("div.submit_post_field", new WaitForSelectorOptions { Timeout = 5000 }); await page.ClickAsync("div.submit_post_field"); await page.WaitForTimeoutAsync(500); //await page.TypeAsync("div.submit_post_field", "45", new TypeOptions { Delay = 50 }); await page.Keyboard.PressAsync($"{nameof(Key.Backspace)}"); await page.Keyboard.PressAsync($"{nameof(Key.Backspace)}"); await page.TypeAsync("div.submit_post_field", message, new TypeOptions { Delay = 50 }); await page.WaitForTimeoutAsync(500); await page.ClickAsync("#send_post"); await page.WaitForTimeoutAsync(500); //await page.Keyboard.PressAsync($"{nameof(Key.Enter)}"); //Report($"{text}"); } } } catch (Exception exception) { Error(exception.ToString()); } }
private bool generateAcountData(UserInfo storedInfo, out IAccountData accountData) { var db = Msf.Server.DbAccessors.GetAccessor <IAuthDatabase>(); accountData = db.CreateAccountObject(); accountData.Username = storedInfo.username; accountData.IsGuest = true; accountData.IsAdmin = false; accountData.Properties = new Dictionary <string, string> (); accountData.Properties.Add(AlbotDictKeys.icon, storedInfo.profilePic.ToString()); if (accountData == null) { return(false); } return(true); }
protected IAccountData StoreAccountData(IAccountData accountData) { using (var db = new LiteDatabase(ConnectionString)) { // Get a collection (or create, if doesn't exist) var col = db.GetCollection <IAccountData>("AccountsData"); if (accountData.Id != 0) { col.Update(accountData); } else { var id = col.Insert(accountData).AsInt32; accountData.Id = id; accountData.CreatedAt = DateTime.Now; } } return(accountData); }
public void InsertNewAccount(IAccountData account, Action <long> doneCallback) { account.UserId = userId++; SaveCurMaxUserID(userId); _accounts.Insert(account as AccountData); _gameData.Insert(new GameData() { Username = account.Username, UserId = account.UserId, Datas = new List <GameProperty>() { new GameProperty() { Name = "Padding" } } }); doneCallback.Invoke(account.UserId); }
public void SavePasswordResetCode(IAccountData account, string code) { using (var con = new NpgsqlConnection(_connectionString)) using (var cmd = new NpgsqlCommand()) { con.Open(); cmd.Connection = con; //cmd.CommandText = "INSERT INTO password_reset_codes (email, code) " + // "VALUES(@email, @code) " + // "ON DUPLICATE KEY UPDATE code = @code"; cmd.CommandText = "INSERT INTO password_reset_codes (email, code) " + "VALUES(@email, @code) " + "ON CONFLICT (email) DO UPDATE SET code = @code"; cmd.Parameters.AddWithValue("@email", account.Email); cmd.Parameters.AddWithValue("@code", code); cmd.ExecuteNonQuery(); } }
public bool AddAccount(string accountNo, decimal balance) { try { // Validation Exist AccountNo if (CheckAccount(accountNo)) { return(false); } using (IAccountData accountData = Builder.AccountData()) { return(accountData.AddAccount(accountNo, balance)); } } catch (Exception ex) { throw new BSLException("AddAccount event occurs an error.[" + ex.Message + "]", ex, true); } }
public AccountEntity LoadAccount(string accountNo) { IAccountData objAccountData = null; try { objAccountData = Builder.AccountData(); return(this.ConvertDataRowToEntity(objAccountData.GetAccount(accountNo).Tables[0].Rows[0])); } catch { throw; } finally { if (objAccountData != null) { objAccountData.Dispose(); } } }
public decimal GetBalanceForward( IAccountData account, DateTime asOfDate ) { Account a = (Account)account; decimal credits = 0; decimal debits = 0; foreach( Transaction trans in ledger.Transactions ) { if( trans.Date < asOfDate ) { credits += trans.GetAmountCredited( a ); debits += trans.GetAmountDebited( a ); } } if( a.IsAsset ) return a.StartingBalance + debits - credits; else if( a.IsLiability ) return a.StartingBalance + credits - debits; else throw new AccountException( "Balance can only be computed for Asset and Liability accounts." ); }
public decimal GetReconciledBalance( IAccountData account ) { Account a = (Account)account; decimal credits = 0; decimal debits = 0; foreach( Transaction trans in ledger.Transactions ) { foreach( LineItem item in trans.LineItems ) { if( item.IsReconciled ) { if( item.TransactionType == TransactionType.Credit ) credits += item.Amount; if( item.TransactionType == TransactionType.Debit ) debits += item.Amount; } } } if( a.IsAsset ) return a.StartingBalance + debits - credits; else if( a.IsLiability ) return a.StartingBalance + credits - debits; else throw new AccountException( "Reconciled Balance can only be computed for Asset and Liability accounts." ); }
public void SaveAccount( IAccountData account ) { Assert.PreCondition( ledger != null ); if( account.Id < 1 ) account.Id = GetNextAccountId(); saveOnClose = true; }
public void SaveAccount( IAccountData account ) { storage.SaveAccount( account ); }
public decimal GetBalanceForward( IAccountData account, DateTime asOfDate ) { return storage.GetBalanceForward( account, asOfDate ); }
/// <summary> /// Gets the balance of the given account. /// </summary> public decimal GetBalance( IAccountData account ) { return Storage.GetBalanceForward( account, DateTime.MaxValue ); }
/// <summary> /// Gets the balance of reconciled transactions in the given account. /// </summary> public decimal GetReconciledBalance( IAccountData account ) { return Storage.GetReconciledBalance( account ); }