本文整理汇总了C#中SES.Service.OrmliteConnection.SqlList方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.SqlList方法的具体用法?C# OrmliteConnection.SqlList怎么用?C# OrmliteConnection.SqlList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SES.Service.OrmliteConnection
的用法示例。
在下文中一共展示了OrmliteConnection.SqlList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
base.Initialize(requestContext);
if (this.User.Identity.IsAuthenticated)
{
IDbConnection dbConn = new OrmliteConnection().openConn();
lstAssetDefault = InitAssetDefault();
currentUser = dbConn.GetByIdOrDefault<Auth_User>(User.Identity.Name);
currentUserRole = dbConn.SqlList<Auth_Role>("EXEC p_Auth_UserInRole_Select_By_UserID @UserID", new { UserID = User.Identity.Name });
string controllerName = this.GetType().Name;
controllerName = controllerName.Substring(0, controllerName.IndexOf("Controller"));
var lstAsset = new List<Auth_Action>();
// Get MenuID from controller name
string menuID = dbConn.SingleOrDefault<Auth_Menu>("ControllerName = {0}", controllerName).MenuID;
foreach (var g in currentUserRole)
{
// Get List Asset
var temp = dbConn.Select<Auth_Action>(p => p.RoleID == g.RoleID && p.MenuID == menuID);
if (temp.Count > 0)
lstAsset.AddRange(temp);
}
if(lstAsset.Count == 0)
{
var item = new Auth_Action();
item.MenuID = menuID;
item.Note = "";
item.RowCreatedAt = DateTime.Now;
item.RowCreatedBy = "System";
if (currentUser.UserID == ConfigurationManager.AppSettings["superadmin"])
{
item.RoleID = 1;
item.IsAllowed = true;
foreach(var asset in lstAssetDefault)
{
item.Action = asset;
dbConn.Insert<Auth_Action>(item);
}
}
else
{
item.RoleID = currentUserRole.FirstOrDefault().RoleID;
item.IsAllowed = false;
foreach (var asset in lstAssetDefault)
{
item.Action = asset;
dbConn.Insert<Auth_Action>(item);
}
}
}
else
{
foreach (var g in currentUserRole)
{
// Asset
var lst = lstAsset.Where(p => p.RoleID == g.RoleID).ToList();
foreach(var item in lst)
{
if (!userAsset.ContainsKey(item.Action))
userAsset.Add(item.Action, item.IsAllowed);
else if(item.IsAllowed)
{
userAsset.Remove(item.Action);
userAsset.Add(item.Action, item.IsAllowed);
}
}
}
}
// Get Asset View Menu
foreach (var g in currentUserRole)
{
var lstView = dbConn.Select<Auth_Action>(p => p.RoleID == g.RoleID && p.Action == "View");
//var lstView = new Auth_Menu().GetMenuByRoleID(g.RoleID);
foreach (var i in lstView)
{
if (!dictView.ContainsKey("menu_" + i.MenuID))
{
if(i.IsAllowed)
{
dictView.Add("menu_" + i.MenuID, true);
}
}
}
}
ViewData["menuView"] = dictView;
dbConn.Close();
}
}
示例2: GetMenu
//public JsonResult GetMenu([DataSourceRequest] DataSourceRequest request)
//{
// IDbConnection db = new OrmliteConnection().openConn();
// try
// {
// var listMenu = db.Select<Auth_Menu>(p => p.IsVisible == true).OrderBy(p => p.MenuIndex).ToList();
// DataSourceResult dsr = new DataSourceResult();
// dsr.Data = listMenu;
// return Json(dsr, JsonRequestBehavior.AllowGet);
// }
// catch (Exception e)
// {
// return Json(new { success = false, message = e.Message });
// }
// finally { db.Close(); }
//}
//[HttpPost]
public JsonResult GetMenu(string action, int roleID)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
//select list menu cha
List<Auth_Menu> lstFirstMenu = db.Select<Auth_Menu>("IsVisible = 1 AND ParentMenuID ='' AND MenuID <> 'Home'").OrderBy(p => p.MenuIndex).ToList();
List<Auth_Menu> allAuthMenu = db.Select<Auth_Menu>("IsVisible = 1 AND MenuID <> 'Home'").OrderBy(p => p.MenuIndex).ToList();
var listAction = new List<Auth_Menu>();
if (!string.IsNullOrEmpty(action))
{
listAction = db.SqlList<Auth_Menu>("p_Auth_Menu_Select_By_Action '" + action + "', " + roleID);
}
List<AuthMenuViewModel> lstMenuView = new List<AuthMenuViewModel>();
foreach (Auth_Menu der in lstFirstMenu)
{
AuthMenuViewModel node = new AuthMenuViewModel();
node.id = der.MenuID;
node.text = der.MenuName;
node.items = new List<AuthMenuViewModel>();
AddChidrenNode(ref node, allAuthMenu,listAction);
lstMenuView.Add(node);
}
return Json(new { success = true, Data = lstMenuView });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例3: GetCustomerHirerachy
public JsonResult GetCustomerHirerachy(string customerid)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
//select list menu cha
List<CustomerHirerachy> lstFirstMenu = db.Select<CustomerHirerachy>("Status = 1 AND ParentCustomerHirerachyID ='' ").OrderBy(p => p.CustomerHirerachyIndex).ToList();
List<CustomerHirerachy> allCustomerHirerachy = db.Select<CustomerHirerachy>("Status = 1 ").OrderBy(p => p.CustomerHirerachyIndex).ToList();
var listCustomer = new List<CustomerHirerachy>();
if (!string.IsNullOrEmpty(customerid))
{
listCustomer = db.SqlList<CustomerHirerachy>("p_CustomerHirerachy_Select '" + customerid+"'");
}
List<CustomerHirerachyViewModel> lstMenuView = new List<CustomerHirerachyViewModel>();
foreach (CustomerHirerachy der in lstFirstMenu)
{
CustomerHirerachyViewModel node = new CustomerHirerachyViewModel();
node.id = der.CustomerHirerachyID;
node.text = der.CustomerHirerachyName;
node.items = new List<CustomerHirerachyViewModel>();
AddChildrenNode(ref node, allCustomerHirerachy, listCustomer);
lstMenuView.Add(node);
}
return Json(new { success = true, Data = lstMenuView });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}