public void TestInequality() { AccountCollection accountCol1 = TestObjectBuilder.GetAccountCollection(); AccountCollection accountCol2 = TestObjectBuilder.GetAccountCollection2(); Assert.AreNotEqual(accountCol1, accountCol2); }
public AccountCollection GetAccounts(User user) { AccountCollection collection = new AccountCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_Frank_TEST"; SqlParameter ColumnParam = command.Parameters.Add("@User_ID", System.Data.SqlDbType.Int); ColumnParam.Value = user.UserID; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Account account = new Account(); account.AccountName = reader["Name"].ToString(); account.AccountType = (AccountType)(Convert.ToInt32(reader["Type"])); account.BettingLimit = Convert.ToDecimal(reader["Betting_Limit"]); account.Status = (Status)(Convert.ToInt32(reader["Status"])); collection.Add(account); } } return collection; } }
private static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Gang of Four Design Pattern - Iterator"); Console.ForegroundColor = ConsoleColor.White; Container = ContainerConfiguration.ConfigureContainer(); var collection = new AccountCollection { [0] = new Account("Alice", 10.00m), [1] = new Account("Anthony", 20.00m), [2] = new Account("Bethany", 30.00m), [3] = new Account("Charles", 40.00m), [4] = new Account("DiAntonio", 50.00m), [5] = new Account("Freddy", 60.00m), [5] = new Account("Mike", 100.00m) }; var iterator = new AccountIterator(collection) { Step = 1 }; Console.WriteLine("Beginning iterating over collection..."); Console.ForegroundColor = ConsoleColor.Yellow; for (var account = iterator.First(); !iterator.IsDone; account = iterator.Next()) { Console.WriteLine(account.GetDetails()); } Console.ForegroundColor = ConsoleColor.White; }
public void Write3Remove1() { AddAccount("account1"); ExecuteConcurrently(ReadAccounts, () => AddAccount("account2")); ExecuteConcurrently(() => AddAccount("account3"), () => RemoveAccount("account2")); AccountCollection.Count().Should(Be.EqualTo(2)); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { _isNew = true; _isDirty = false; _accountCollection = new AccountCollection(); SetMainFormForNew(); }
public void ReadRead() { AddAccount("account1"); AddAccount("account2"); ExecuteConcurrently(ReadAccounts, ReadAccounts); AccountCollection.Count().Should(Be.EqualTo(2)); }
public void TestHashCodeInequality() { AccountCollection accountCol1 = TestObjectBuilder.GetAccountCollection(); AccountCollection accountCol2 = TestObjectBuilder.GetAccountCollection2(); Assert.AreNotEqual(accountCol1.GetHashCode(), accountCol2.GetHashCode()); }
public void TestUnsuccessfulLoadFile() { IFactory factory = new TestingFactory(PASSWORD, IV, SALT); ActionList actionList = factory.GetActionList(); IStorage storage = factory.GetStorage(); AccountCollection collection = TestObjectBuilder.GetAccountCollection(); string serialized = actionList.DoActions(collection); storage.StoreData("test", serialized); string fromStorage = storage.RetrieveData("test"); IFactory factory2 = new TestingFactory("wrong", IV, SALT); ActionList actionList2 = factory2.GetActionList(); try { AccountCollection deserialized = actionList2.ReverseActions <AccountCollection>(fromStorage); } catch (DeserializationException) { // Success return; } Assert.Fail("Exception should have been thrown because wrong password was used."); }
public void WriteOnceReadTwice() { int beforeProfileAdd = 0; int afterProfileAdded = 0; var account1Name = new AccountName("account1"); AccountCollection.GetOrCreate(account1Name); ExecuteConcurrently(() => { Interlocked.Increment(ref beforeProfileAdd); IAccount account = AccountCollection.GetOrCreate(account1Name); account.Profiles.Add(new ProfileCreationArgs(new ProfileName("~"), new object())); Interlocked.Increment(ref afterProfileAdded); }, () => { var accountFirstVersion = AccountCollection.GetOrCreate(account1Name); var accountSecondVersion = AccountCollection.GetOrCreate(account1Name); bool sameVersion = false; if (Interlocked.Increment(ref beforeProfileAdd) == 1) { sameVersion = (accountFirstVersion == accountSecondVersion); sameVersion.Should(Be.True); } if (Interlocked.Increment(ref afterProfileAdded) == 2) { IAccount latestAccountVersion = AccountCollection.GetOrCreate(account1Name); latestAccountVersion.Profiles.Count().Should(Be.EqualTo(1)); if (sameVersion) { (latestAccountVersion == accountFirstVersion).Should(Be.False); } } }); AccountCollection.GetOrCreate(account1Name).Profiles.Count().Should(Be.EqualTo(1)); }
public async Task <Customer> Get(Guid id) { using (IDbConnection db = new SqlConnection(_connectionString)) { string customerSQL = "SELECT * FROM Customer WHERE Id = @Id"; Entities.Customer customer = await db .QueryFirstOrDefaultAsync <Entities.Customer>(customerSQL, new { id }); if (customer == null) { return(null); } string accountSQL = "SELECT * FROM Account WHERE CustomerId = @Id"; IEnumerable <Guid> accounts = await db .QueryAsync <Guid>(accountSQL, new { id }); AccountCollection accountCollection = new AccountCollection(); foreach (Guid accountId in accounts) { accountCollection.Add(accountId); } Customer result = Customer.Load( customer.Id, customer.Name, customer.Aadhar, accountCollection); return(result); } }
public async Task <Customer> Get(Guid id) { Entities.Customer customer = await _context.Customers. Find(customer => customer.Id == id) .SingleOrDefaultAsync(); List <Guid> accountIds = await _context .Accounts .Find(account => account.CustomerId == id) .Project(p => p.Id) .ToListAsync(); AccountCollection accountCollection = new AccountCollection(); foreach (var accountId in accountIds) { accountCollection.Add(accountId); } return(Customer.Load( customer.Id, customer.Name, customer.Aadhar, accountCollection)); }
public void RefreshDisplay() { _lookup = Account.CollectAll(); _viewModel = new AccountViewModel { Collection = Account.CollectAll() }; DataContext = _viewModel; }
public static AccountCollection GetAccountCollection() { AccountCollection coll = new AccountCollection(); coll.Add(GetAccount1()); coll.Add(GetAccount2()); return(coll); }
public void ReadRead() { _account.Profiles.Add(new ProfileCreationArgs("Profile", new SampleJiraProfile { JiraLogin = "******" })); ExecuteConcurrently(ReadProfile, ReadProfile); AccountCollection.GetOrCreate(ACCOUNT_NAME).Profiles.Count().Should(Be.EqualTo(1)); }
private void ReadAccountProfiles(string accountName) { var account = AccountCollection.GetOrCreate(accountName); foreach (var profile in account.Profiles) { profile.Name.Value.Should(Be.StringContaining("profile")); } }
public Account(string username, string password, AccountTypes userType, bool isBanned) { this.username = username; this.password = password; this.accountType = userType; this.isBanned = isBanned; this.friends = new AccountCollection(); this.channelList = new ChannelCollection(); }
public Account(string username, string password, AccountTypes userType, bool isBanned, AccountCollection friends, ChannelCollection channelList) { this.username = username; this.password = password; this.accountType = userType; this.isBanned = isBanned; this.channelList = channelList; this.friends = friends; }
/// <summary> /// Get all accounts /// </summary> /// <returns>Collection of accounts</returns> public AccountCollection Get() { AccountCollection Accounts = new AccountCollection(); foreach (Account account in DB.Accounts) { Accounts.AddAccount(account); } return(Accounts); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { _accountCollection = OpenAccountCollection(); if (_accountCollection != null) { _isNew = false; _isDirty = false; SetMainFormForOpen(); } }
public static void Save(AccountCollection input) { XmlSerializer xml = new XmlSerializer(typeof(AccountCollection)); using (XmlWriter xwr = new XmlTextWriter(AccountSettingPath, Encoding.UTF8)) { xml.Serialize(xwr, input); xwr.Flush(); } }
// inform caller about new List private void OnAccountDeleted() { AccountCollection collection = new AccountCollection() { InvestorId = investorId, PeFundId = peFundId, Action = "Update", AccountList = myBankAccounts.ToList() }; eventAggregator.GetEvent <AccountCollectionEvent>().Publish(collection); }
private void OnAccountListChanged(AccountCollection collection) { if (!collection.Action.Equals("Update")) { return; } if (collection.InvestorId != Investor.Id) { return; } Investor.BankAccounts = collection.AccountList; }
public static IAccount Add(string userName, string password, string host, string email) { AccountCollection accounts = Read(); IAccount account = new Account(Guid.NewGuid(), userName, password, host, email); accounts.Accounts = accounts.Accounts.Concat(new Account[] { account as Account }).ToArray(); Save(accounts); return(account); }
private void OnAccountListChanged(AccountCollection collection) { if (!collection.Action.Equals("Update")) { return; } if (collection.PeFundId != SelectedFund.Id) { return; } SelectedFund.BankAccounts = new ObservableCollection <BankAccount>(collection.AccountList); }
public static AccountCollection GetAccountCollection2() { AccountCollection coll = new AccountCollection(); coll.Add(GetAccount1()); Account account = GetAccount2(); account.CredentialHistory.Add(GetCredential1()); coll.Add(account); return(coll); }
public void TestGetHashCodeWithNoAccounts() { AccountCollection collection = TestObjectBuilder.GetAccountCollectionWithNoAccounts(); try { int hashCode = collection.GetHashCode(); } catch (Exception ex) { Assert.Fail("There was an exception when generating a hash code for a collection with no accounts: " + ex.ToString()); } }
public bool AccountExists(long accountId, ref IAuctionTransaction trans) { using(var records = new AccountCollection()) { var filter = new PredicateExpression(AccountFields.Id == accountId); if(trans != null) { trans.Add(records); } return records.GetDbCount(filter) > 0; } }
//public static Account FindByCode(string accountCode) //{ // var sqlBuilder = new System.Text.StringBuilder(); // sqlBuilder.AppendLine("SELECT * FROM"); // sqlBuilder.AppendLine(TABLE_NAME); // sqlBuilder.AppendLine("WHERE CODE = ?CODE"); // var parameter = new SqlParameter("?CODE", accountCode); // DataTable dataTable = DatabaseController.ExecuteSelectQuery(sqlBuilder, parameter); // if (dataTable.Rows.Count == 0) return null; // var result = new Account(); // foreach (DataRow dataRow in dataTable.Rows) // { // result.SetPropertiesFromDataRow(dataRow); // } // return result; //} //public static Account FindByName(string accountTitle) //{ // var sqlBuilder = new System.Text.StringBuilder(); // sqlBuilder.AppendLine("SELECT * FROM"); // sqlBuilder.AppendLine(TABLE_NAME); // sqlBuilder.AppendLine("WHERE TITLE = ?TITLE"); // var parameter = new SqlParameter("?TITLE", accountTitle); // DataTable dataTable = DatabaseController.ExecuteSelectQuery(sqlBuilder, parameter); // if (dataTable.Rows.Count == 0) return null; // var result = new Account(); // foreach (DataRow dataRow in dataTable.Rows) // { // result.SetPropertiesFromDataRow(dataRow); // } // return result; //} internal static AccountCollection CollectAll() { var dataTable = DatabaseController.ExecuteSelectQuery("SELECT * FROM " + TABLE_NAME); var collection = new AccountCollection(); foreach (DataRow dataRow in dataTable.Rows) { var item = new Account(); item.SetPropertiesFromDataRow(dataRow); collection.Add(item); } return(collection); }
public int GetAllowableEventCount(long accountId, ref IAuctionTransaction trans) { using (var records = new AccountCollection()) { var filter = new PredicateExpression(AccountFields.Id == accountId); if (trans != null) { trans.Add(records); } records.GetMulti(filter, 1); return records.ToList().First().AllowableEvents; } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { User user = User.GetByUserName(username); bool result = false; try { if (user != null) { user.IsDeleted = true; user.IsApproved = false; user.Save(); if (deleteAllRelatedData) { UserRoleCollection roles = UserRole.Where(c => c.UserId == user.Id); AccountCollection accounts = Account.Where(c => c.UserId == user.Id); PasswordCollection passwords = Password.Where(c => c.UserId == user.Id); PasswordResetCollection resets = PasswordReset.Where(c => c.UserId == user.Id); PasswordFailureCollection failures = PasswordFailure.Where(c => c.UserId == user.Id); LockOutCollection lockouts = LockOut.Where(c => c.UserId == user.Id); LoginCollection logins = Login.Where(c => c.UserId == user.Id); PasswordQuestionCollection questions = PasswordQuestion.Where(c => c.UserId == user.Id); SettingCollection settings = Setting.Where(c => c.UserId == user.Id); SessionCollection session = Session.Where(c => c.UserId == user.Id); Database db = Db.For <User>(); SqlStringBuilder sql = db.ServiceProvider.Get <SqlStringBuilder>(); roles.WriteDelete(sql); accounts.WriteDelete(sql); passwords.WriteDelete(sql); resets.WriteDelete(sql); failures.WriteDelete(sql); lockouts.WriteDelete(sql); logins.WriteDelete(sql); questions.WriteDelete(sql); settings.WriteDelete(sql); session.WriteDelete(sql); sql.Execute(db); } } } catch (Exception ex) { result = false; Log.AddEntry("{0}.{1}::{2}", ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message); } return(result); }
public ActionResult Save(Bam.Net.UserAccounts.Data.Account[] values) { try { AccountCollection saver = new AccountCollection(); saver.AddRange(values); saver.Save(); return(Json(new { Success = true, Message = "", Dao = "" })); } catch (Exception ex) { return(GetErrorResult(ex)); } }
public void TestQueryForListWithResultObject() { AccountCollection accounts = new AccountCollection(); dataMapper.QueryForList("GetAllAccountsViaResultMap", null, accounts); AssertAccount1(accounts[0]); Assert.AreEqual(5, accounts.Count); Assert.AreEqual(1, accounts[0].Id); Assert.AreEqual(2, accounts[1].Id); Assert.AreEqual(3, accounts[2].Id); Assert.AreEqual(4, accounts[3].Id); Assert.AreEqual(5, accounts[4].Id); }
public Task <IAccountCollection> GetAccountsAsync(int accountingNumber, DateTime statusDate) { return(ExecuteAsync(async() => { using AccountModelHandler accountModelHandler = new AccountModelHandler(DbContext, AccountingModelConverter.Create(), _eventPublisher, statusDate, true, true); IAccountCollection accountCollection = new AccountCollection { await accountModelHandler.ReadAsync(accountModel => accountModel.AccountingIdentifier == accountingNumber, prepareReadState: new AccountingIdentificationState(accountingNumber)) }; return accountCollection; }, MethodBase.GetCurrentMethod())); }
public void RefreshDisplay() { //_lookup = Account.CollectAll(); var conditions = new Dictionary <string, object> { { "CODE1", _groupCode } }; _lookup = Account.Where(conditions); _viewModel = new AccountViewModel { Collection = Account.Where(conditions) }; DataContext = _viewModel; }
public long GetMainUserId(long accountId, ref IAuctionTransaction trans) { using (var records = new AccountCollection()) { var filter = new PredicateExpression(AccountFields.Id == accountId); if (trans != null) { trans.Add(records); } records.GetMulti(filter, 1); return 1; // return records.ToList().First().AdminUserId; } }
public bool DeleteBy(string id) { int index = 0; foreach (var account in AccountCollection) { if (account.Id.Equals(id)) { AccountCollection.RemoveAt(index); this.CurrentAccountId = string.Empty; return true; } index++; } return false; }
public UIBase() { this._controller = new Controller(); this._controller.message_pump.ui_event += new UIEvent(this.UpdateConnectionStatus); this._controller.message_pump.ui_event += new UIEvent(this.UpdateEncryptionStatus); this._controller.message_pump.ui_event += new UIEvent(this.ErrorWatch); this._controller.message_pump.ui_event += new UIEvent(this.MessageWatch); this._chat_list_store = new ListStore(typeof(string), typeof(string)); this._user_connections = new ConnectionCollection(); this._user_accounts = new AccountCollection(); this._user_chats = new Hashtable(); this._current_chat = ""; Application.Init(); this.gxml = new Glade.XML(null, "irisim.glade", "chatWindow", null); this.gxml.Autoconnect(this); this.chatListView.FixedHeightMode = false; this.chatListView.HeadersVisible = true; this.chatListView.AppendColumn("Chats", new CellRendererText(), "text", 0); this.chatListView.Model = this._chat_list_store; this.chatListView.Selection.Changed += this.on_chatListView_changed; this.chatListView.ShowAll(); Application.Run(); }
public Channel(string name, AccountCollection accounts) { this.name = name; this.accounts = accounts; }
public Channel(string name) { this.name = name; this.accounts = new AccountCollection(); }
public AccountCollection QueryAccount(string _accountName) { AccountCollection collection = new AccountCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_SEL_Table"; SqlParameter _param = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar); _param.Value = "Entity_Account"; SqlParameter _param2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); _param2.Value = "4"; SqlParameter _param3 = command.Parameters.Add("@value3", System.Data.SqlDbType.VarChar); _param3.Value = _accountName; SqlParameter _param4 = command.Parameters.Add("@order_by1", System.Data.SqlDbType.VarChar); _param4.Value = "1"; SqlParameter _param5 = command.Parameters.Add("@order_by2", System.Data.SqlDbType.TinyInt); _param5.Value = 0; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Account _account = new Account(); _account.ID = Convert.ToInt32(reader["ID"]); _account.EntityID = Convert.ToInt32(reader["Entity_ID"]); _account.Company = Convert.ToInt32(reader["Company"]); _account.AccountName = reader["Account_Name"].ToString(); _account.Password = reader["Password"].ToString(); _account.AccountType = (AccountType)Convert.ToInt32(reader["Account_Type"]); _account.BettingLimit = Convert.ToDecimal(reader["Betting_Limit"]); _account.Factor = reader["Factor"].ToString(); _account.DateOpen = reader["DateOpen"].ToString(); _account.Personnel = reader["Personnel"].ToString(); _account.IP = reader["IP"].ToString(); _account.Odds = reader["Odds"].ToString(); _account.IssuesConditions = reader["IssuesConditions"].ToString(); _account.RemarksAcc = reader["RemarksAcc"].ToString(); if (!reader["Perbet"].ToString().Equals("")) _account.Perbet = Convert.ToDecimal(reader["Perbet"]); else _account.Perbet = 0; _account.Status = (Status)Convert.ToDecimal(reader["Status"]); collection.Add(_account); } } reader.Close(); return collection; } }
public Connections(ConnectionCollection c, AccountCollection a, FormBase base_window) { this._ui_base = base_window; this._connectionCollection = c; }
public static long SendComment(long comment_id_parent, string content, Account commenter, Account receiver, string objectType, long objectID, string target_link, string target_object_name, int objecttypeID, string userAgent, string status, string UserHostName, bool for_group) { long commentID = 0; if (for_group) { AccountCollection listReceiver = new AccountCollection(); CommentCollection listOldComment = CommentDA.SelectByPerformOnObjectID(objectID); if (receiver.ID != commenter.ID) listReceiver.Add(receiver); foreach (Comment cm in listOldComment) { if (cm.AccountID != commenter.ID && cm.AccountID != receiver.ID) { Account a = AccountDA.SelectByID(cm.AccountID); if (a != null && (listReceiver.Find(l=>l.ID == a.ID)==null)) listReceiver.Add(a); } } content = content.Replace("\n", "<br />"); Comment c = new Comment(); c.AccountID = commenter.ID; c.Author_IP = UserHostName; c.Content = content; c.ObjID = objectID; c.ObjectType = objectType; c.ObjectType = objectType; c.Agent = userAgent; c.Status = status; c.ReceiverID = receiver.ID; //owner c.ReceiverUsername = receiver.Username; c.ParentID = comment_id_parent; c.Target_link = target_link; c.Target_object_name = target_object_name; c.Username = commenter.Username; commentID = CommentDA.Insert(c); List<long> emailed_accounts = new List<long>(); //Account commenter = AccountDA.SelectByID(senderID);//((Account)S-ession["Account"]); string emailcontent = commenter.Username + " đã viết lời bình luận <b>" + target_object_name + "</b><br/> " + "<br/><br/> \"" + c.Content + "\" <br/><br/>" + "Bạn có thể xem chi tiết và trả lời bằng cách sử dụng link dưới đây: <br/> <a href='" + target_link + " '> " + target_link + "</a>" + "<br/>" + DateTime.Now.ToString(); foreach (Account r in listReceiver) { //ActionLogDA.Add(receiver.ID, receiver.Username, // objecttypeID, // objectID, // "viết bình luận <a href='" + target_link + "'>" + target_object_name + "</a> của nhóm <a href='" + target_link + "'>" + team.Name + "</a>" // , r.ID // , "" // , "" // , ""//Request.RawUrl // , c.ObjectID.ToString() + "+" + ObjectTypeID.Goal.ToString() // ); ActionLog acl = new ActionLog(); acl.AuthorID = commentID; acl.Date = DateTime.Now; acl.TargetAccount = r.ID; acl.PerformOnObjectID = objectID; acl.Username = r.Username; acl.Href = " viết bình luận trên <a href='" + target_link + "' target='_blank'>" + target_object_name + "</a>"; acl.XCommentID = c.ObjID + "+" + objectType; acl.ShortDescription = "Bạn <a href='" + LinkBuilder.getLinkProfile(commenter) + "' target='_blank'>" + commenter.Username + "</a> vừa" + acl.Href; acl.ToUser = r.Username; ActionLogDA.Insert(acl); emailed_accounts.Add(r.ID); //notify to if (commenter.ID != r.ID) //SendMail.sendMail(emailcontent, commenter.Username + " viết lời bình luận " + target_object_name, commenter.Email, commenter.FirstName + " " + commenter.LastName, r.Email, r.FirstName + " " + r.LastName, email_type.goal_comment, r.ID); SendMail.SendNotification(emailcontent, commenter.Username + " viết lời bình luận " + target_object_name, commenter.Email, commenter.FullName, r.Email, r.FullName, email_type.goal_comment, r.ID); } } return commentID; }
public override void Dispose() { base.Dispose(); Accounts.Dispose(); Incomes.Dispose(); Packages.Dispose(); Categories.Dispose(); Accounts = new AccountCollection(); Incomes = new IncomeCollection(); Packages = new PackageCollection(); Categories = new CategoryCollection(); _BackgroundRun = null; _BackgroundUpdateBalances = null; }
protected void Page_Load(object sender, EventArgs e) { listNewAccount = AccountDA.SelectNewAccount(10); }