ldj/WcfService1/PortalService.svc.cs

117 lines
3.1 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
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();
}
2024-02-06 19:36:47 +08:00
2023-05-23 16:13:17 +08:00
public int validUser(string userId, string passwd)
{
Employee emp = new Employee();
return emp.ValidUser(userId, passwd);
}
public Dictionary<String, List<String>> getCatedAuths(int userId)
{
Dictionary<String, List<String>> rs = new Dictionary<string, List<string>>();
Dictionary<String, List< Authority>> auths = new LAuthority().getCatedAuthorities(userId);
foreach (String cate in auths.Keys)
{
List<String> lst = new List<string>();
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<String> getSpecialAuths(int userId)
{
List<String> lst = new List<string>();
Dictionary<String, List<Authority>> 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();
}
2024-02-06 19:36:47 +08:00
2023-05-23 16:13:17 +08:00
}
}