using System;
using System.Data;
using System.Collections.Generic;
using WMS.Info;
using WMS.Util;
using System.Linq;
using SqlSugar;
namespace WMS.Core
{
///
/// 描 述:用户关系
///
public class ACLUserRelation
{
public List GetUserList(string objectno, EACLObjType eACLObjType)
{
try
{
var getAll8 = SysDbCore.GetDbCtx().Queryable().Where(it =>
SqlFunc.Subqueryable().Where(s => s.F_OBJTYPENUM == (int)eACLObjType && s.F_ITEMNO == objectno && s.F_USERNO == it.F_NO).Any()).ToList();
getAll8.ForEach(it =>
{
it.F_PASSWORD = "";
it.F_DATA = "";
});
return getAll8;
}
catch (Exception ex)
{
throw ex;
}
}
public void SaveEntityList(string objectno, EACLObjType eACLObjType,List UserNos)
{
try
{
void action(SqlSugarClient ctx)
{
ctx.Deleteable().Where(it => it.F_OBJTYPENUM == (int)eACLObjType && it.F_ITEMNO == objectno).ExecuteCommand();
if (UserNos != null && UserNos.Count > 0)
{
foreach (string s in UserNos)
{
ctx.Insertable(new ACL_USERRELATION()
{
F_ITEMNO = objectno,
F_NO = Guid.NewGuid().ToString(),
F_OBJTYPENUM = (int)eACLObjType,
F_USERNO = s
}).ExecuteCommand();
}
}
}
SysDbCore.DbTranExec(action);
}
catch (Exception ex)
{
throw ex;
}
}
}
}