本文整理汇总了C#中ICustomer.login方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomer.login方法的具体用法?C# ICustomer.login怎么用?C# ICustomer.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICustomer
的用法示例。
在下文中一共展示了ICustomer.login方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: login
/// <summary>
/// Logs user in/authenticates against StockTrader database.
/// </summary>
/// <param name="userid">User id to authenticate.</param>
/// <param name="password">Password for authentication</param>
public AccountDataModel login(string userid, string password)
{
//Create instance of a DAL, which could be designed for any type of DB backend.
dalCustomer = Trade.DALFactory.Customer.Create(Settings.DAL);
//As feature of the StockTrader DAL, you will see dal.Open, dal.BeginTransaction, dal.CommitTransaction,
//dal.AbortTransaction and dal.Close methods being invoked in the BSL. The pattern within this BSL is:
//a) Create an instance of the DAL;
//b) Open the DAL;
//c) Start a transaction only if necessary (more than one update/insert/delete involved);
//d) You get to pick ADO.NET transaction or System.Transactions or ServicedComponent, it will work with
// all of the above; StockTrader lets you choose ADO.NET txs or System.Transactions via config.
//e) Close the DAL. This releases the DAL's internal connection back to the connection pool.
//The implementation "hides" the type of database being used from the BSL, so this BSL will work
//with any type of database you create a DAL for, with no changes in the BSL whatsoever.
//System.Transactions and SQL Server 2005 and above and Oracle databases work together
//with a new feature called "lightweight transactions"; which means you do not need to have the
//same performance penalty you got with Serviced Components for always invoking the tx as a full
//two-phase operation with DTC logging. If operating against a single database to SQL Server or Oracle,
//across one or more connections involved in a tx, System.Transactions will not promote to a DTC-coordinated tx; and hence will be much faster.
//If there are mulitple databases or multiple resources (for example, MSMQ and a database)
//used with a System.Transaction tx, on the other hand, the tx will be automatically promoted to the required distributed tx, two-phase commit
//with DTC logging required. Our StockTrader DAL is designed to:
// 1. Hide DB implementation from BSL so we maintain clean separation of BSL from DAL.
// 2. Let you freely call into the DAL from BSL methods as many times as you want *without*
// creating new separate DB connections
// 3. As a by-product, it also helps you use ADO.NET transactions without worrying about
// passing DB connections/transaction objects between tiers; maintaining cleaner separation
// of BSL from DAL. If using ADO.NET txs; you can accomplish DB-implementation isolation also with
// the Provider Factories introduced with ADO.NET 2.0/.NET 2.0: see for details:
// http://msdn2.microsoft.com/en-us/library/ms379620(VS.80).aspx
//Note Open() is not really necessary, since the DAL will open a new connection automatically
//if its internal connection is not already open. It's also free to open up more connections, if desired.
//We use Open() to stick with a consistent pattern in this application, since the Close() method IS
//important. Look for this pattern in all BSL methods below; with a transaction scope defined
//only for operations that actually require a transaction per line (c) above.
dalCustomer.Open(Settings.TRADEDB_SQL_CONN_STRING);
try
{
return dalCustomer.login(userid, password, Settings.USE_SALTEDHASH_PASSWORDS);
}
catch
{
throw;
}
finally
{
//Always close the DAL, this releases its primary DB connection.
dalCustomer.Close();
}
}