narsil/Tanshu.Accounts.Repository/BusinessLayer/RoleBI.cs
unknown d8ecec8bb6 Added inverse Attribute to ProductGroup.
BillInventory Renamed.
Refactored Bill to be more usable.
Added Bill Detail Report.
Added Open Bill and Bill Details Roles.
Zero Rate Products have Yellow background Color.
Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI,
Cached the Products List.
Product and Product Group Form Working.
2011-06-23 18:17:48 +05:30

88 lines
2.5 KiB
C#

using System;
namespace Tanshu.Accounts.Repository
{
public delegate bool AuthenticateUser(out string userName);
public class RoleBI : IDisposable
{
readonly string _roleName;
int _userID;
readonly bool _isAllowed;
//bool elevated;
//AccountsPrincipal originalUser;
//AuthenticateUser authenticateUser;
public RoleBI(string roleName, int userID)
{
this._roleName = roleName;
this._userID = userID;
if (userID == 0)
_isAllowed = false;
else
_isAllowed = MembershipBI.IsUserInRole(userID, this._roleName);
disposed = false;
}
public bool IsAllowed
{ get { return _isAllowed; } }
//public bool IsElevated
//{
// get
// {
// return elevated;
// }
//}
//public void Evelvate(AuthenticateUser authenticateUser)
//{
// this.authenticateUser = authenticateUser;
// string userName;
// if (this.authenticateUser(out userName))
// {
// originalUser = (AccountsPrincipal)Thread.CurrentPrincipal;
// SetElevation(userName);
// }
//}
//private void SetElevation(string userName)
//{
// if (userName.Contains(":"))
// userName = userName.Substring(userName.IndexOf(":") + 1);
// Session.User = MembershipBI.GetUserFromName(userName));
// // bind the generic principal to the thread
// Thread.CurrentPrincipal = principal;
// userName = ((AccountsIdentity)principal.Identity).UserInfo.Name;
// userID = ((AccountsIdentity)principal.Identity).UserInfo.UserID;
// elevated = true;
//}
#region IDisposable
bool disposed;
~RoleBI()
{
// call Dispose with false. Since we're in the
// destructor call, the managed resources will be
// disposed of anyways.
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!this.disposed)
{
//if (elevated)
// Thread.CurrentPrincipal = originalUser;
// Note disposing has been done.
disposed = true;
}
}
#endregion
}
}