using Cksoft.Data; using Cksoft.Data.Repository; using DllEapEntity; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DllEapDal { public class StaffMachineDal { private IDatabase CurrDb; public StaffMachineDal(IDatabase db) { CurrDb = db; } public string GetFilter(string staffCode, ref string errorinfo) { using(IDatabase db = DbFactory.Base("ufp")) { var sql = $"select * from staff where fcode='{staffCode}'"; var staff = db.FindList(sql).FirstOrDefault(); if (staff != null && staff.IsSA == 1) { return string.Empty; } else { sql = $"select b.* from staffrole a left join role b on a.roleid=b.id where a.staffcode='{staffCode}'"; var roles = db.FindList(sql); if (roles.Any(c => c.FCode.Contains("SuperAdmin"))) { return string.Empty; } } } var ids = CurrDb.FindListForCondition($" and StaffCode='{staffCode}'", ref errorinfo)?.Select(c => c.MacId); string filter = string.Empty; if (ids != null && ids.Count() > 0) { filter = $" and a.id in ({string.Join(",", ids)})"; } else { filter = " and a.id <0"; } return filter; } } }