using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; //using DeiNiu.wms.win.utils; using DeiNiu.Utils; using System.Configuration; using DeiNiu.wms.Logical; using WcfServiceAuthentication; using System.Threading; using System.Data; using DeiNiu.wms.Data.Model; using System.Management; namespace DeiNiu.Wcf { // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Setup”。 public class PortalService : IPortal { public string login(string account, string passwd) { Employee em = new Employee(); string token = null; if (em.login(account,passwd)) { token = em.token; AuthenticationInspector.authCach[em.ID] = token; } return em.ID + ":" + token + ":" + em.em_account + ":" + em.em_profile.Trim();// +":" + getHostIpName(); } public int validUser(string userId, string passwd) { Employee emp = new Employee(); return emp.ValidUser(userId, passwd); } public Dictionary> getCatedAuths(int userId) { Dictionary> rs = new Dictionary>(); Dictionary> auths = new LAuthority().getCatedAuthorities(userId); foreach (String cate in auths.Keys) { List lst = new List(); foreach (Authority link in auths[cate]) { if (string.IsNullOrEmpty(link.auth_class)) { continue; } lst.Add(link.auth_name +":"+ link.auth_class); } rs[cate] = lst; } return rs; } public List getSpecialAuths(int userId) { List lst = new List(); Dictionary> auths = new LAuthority().getCatedAuthorities(userId); foreach (String cate in auths.Keys) { foreach (Authority link in auths[cate]) { if ( link.auth_special) { lst.Add(link.auth_name); } } } return lst; } public bool haveSpecialAuth(string userId, string passwd, string spAuth) { int eid = validUser(userId, passwd); if (eid > 0) { return getSpecialAuths(eid).Contains(spAuth); } return false; } public void updateUserTheme(int userId, string theme) { Employee lem = new Employee(userId); lem.em_profile = theme.Trim(); lem.Update(); } } }