12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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<DllUfpEntity.Staff>(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<DllUfpEntity.Role>(sql);
- if (roles.Any(c => c.FCode.Contains("SuperAdmin")))
- {
- return string.Empty;
- }
- }
- }
- var ids = CurrDb.FindListForCondition<StaffMachine>($" 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;
- }
- }
- }
|