using System; using System.Data; using System.Collections.Generic; using WMS.Info; using WMS.Util; using SqlSugar; namespace WMS.Core { /// /// 描 述:权限分配 /// public class ACLAuthorize { public const string ALLAuthorize = "7DC7155C4A674050BD591CF74B800958"; public const string IcoAuthorize = "fa fa-align-justify"; /// /// 获取按钮列表树形数据(基于WebApp) /// /// public List GetWebAppTree() { try { List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_APPTYPENUM == (int)EAppType.PC).ToList(); List WebAppTree = new List(); foreach (var webitem in list) { TreeModel node = new TreeModel(); node.id = webitem.F_NO; node.text = webitem.F_NAME; node.value = webitem.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = webitem.F_PNO; WebAppTree.Add(node); } return WebAppTree.ToTree(); } catch (Exception ex) { throw ex; } } /// /// 获取按钮列表树形数据(基于OnLineRFApp) /// /// public List GetOnLineRFTree() { List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_APPTYPENUM == (int)EAppType.OnLineRF).ToList(); List OnRFAppTree = new List(); foreach (var OnRFitem in list) { TreeModel node = new TreeModel(); node.id = OnRFitem.F_NO; node.text = OnRFitem.F_NAME; node.value = OnRFitem.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = OnRFitem.F_PNO; OnRFAppTree.Add(node); } return OnRFAppTree.ToTree(); } public List GetItemIdList(string objectNo, EACLType eACLType, EACLObjType eACLObjType) { try { return SysDbCore.GetDbCtx().Queryable().Where(it => it.F_OBJNO == objectNo && it.F_ACLTYPENUM == (int)eACLType && it.F_OBJTYPENUM == (int)eACLObjType).Select(it => it.F_ITEMNO).ToList(); } catch (Exception ex) { throw ex; } } public void Authorize(AuthorizeInfo authorize) { try { void action(SqlSugarClient ctx) { ctx.Deleteable().Where(it => it.F_OBJNO == authorize.ObjectNo && it.F_OBJTYPENUM == (int)authorize.ObjTypeNum).ExecuteCommand(); if (authorize.WarehouseList != null) { foreach (var item in authorize.WarehouseList) { if (item == ACLAuthorize.ALLAuthorize) { continue; } if (item.Contains(BaseWarehouse.WarehouseHead)) { continue; } ACL_AUTHORIZE insobj = new ACL_AUTHORIZE() { F_OBJTYPENUM = (int)authorize.ObjTypeNum, F_ITEMNO = item, F_NO = Guid.NewGuid().ToString(), F_OBJNO = authorize.ObjectNo, F_ACLTYPENUM = (int)EACLType.Warehouse }; ctx.Insertable(insobj).ExecuteCommand(); } } if (authorize.WebAppNoList != null) { foreach (var item in authorize.WebAppNoList) { ACL_AUTHORIZE insobj = new ACL_AUTHORIZE() { F_OBJTYPENUM = (int)authorize.ObjTypeNum, F_ITEMNO = item, F_NO = Guid.NewGuid().ToString(), F_OBJNO = authorize.ObjectNo, F_ACLTYPENUM = (int)EACLType.WebApp }; ctx.Insertable(insobj).ExecuteCommand(); } } if (authorize.OnlineRFNoList != null) { foreach (var item in authorize.OnlineRFNoList) { ACL_AUTHORIZE insobj = new ACL_AUTHORIZE() { F_OBJTYPENUM = (int)authorize.ObjTypeNum, F_ITEMNO = item, F_NO = Guid.NewGuid().ToString(), F_OBJNO = authorize.ObjectNo, F_ACLTYPENUM = (int)EACLType.OnlineRF }; ctx.Insertable(insobj).ExecuteCommand(); } } }; SysDbCore.DbTranExec(action); } catch (Exception ex) { throw ex; } } public Dictionary GetAuthorize(LoginUserInfo loginUser) { try { Dictionary dics = new Dictionary(); if (loginUser.UserType == EUserType.User) { SysDbCore.GetDbCtx().Queryable().Where(it => it.USERNO == loginUser.UserNo && it.ACLTYPENUM == (int)EACLType.WebApp).ToList().ForEach(it => dics.Add(it.ITEMNO, it)); } return dics; } catch (Exception ex) { throw ex; } } public ACL_AUTHORIZE GetAuthorizeSupperNo(string queryJson) { try { var queryParam = queryJson.ToJObject(); if (queryParam["F_NO"].IsEmpty() || queryParam["F_OBJTYPENUM"].IsEmpty() || queryParam["F_ACLTYPENUM"].IsEmpty()) { throw SysExCore.ThrowFailException("参数不全,无法找到所属供应商"); } int F_OBJTYPENUM = int.Parse(queryParam["F_OBJTYPENUM"].ToString()); int F_ACLTYPENUM = int.Parse(queryParam["F_ACLTYPENUM"].ToString()); var GetE = SysDbCore.GetDbCtx().Queryable().Where(v => v.F_OBJNO == queryParam["F_NO"].ToString() && v.F_ACLTYPENUM == F_ACLTYPENUM && v.F_OBJTYPENUM == F_OBJTYPENUM).First(); if(GetE==null) throw SysExCore.ThrowFailException("所属供应商未赋值"); return GetE; } catch (Exception ex) { throw SysExCore.ThrowFailException(ex.Message); } } } }