ldj/WcfServicePortal/PortalService.svc.cs

147 lines
3.8 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.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 int validUser(string userId, string passwd)
{
Employee emp = new Employee();
return emp.ValidUser(userId, passwd);
}
public Dictionary<String, List<String>> getCatedAuths(int userId ,int warehouse)
{
Dictionary<String, List<String>> rs = new Dictionary<string, List<string>>();
Dictionary<String, List<Authority>> auths = new LAuthority().getCatedAuthorities(userId, warehouse);
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,int warehouse)
{
List<String> lst = new List<string>();
Dictionary<String, List<Authority>> auths = new LAuthority().getCatedAuthorities(userId, warehouse);
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,-1).Contains(spAuth);
}
return false;
}
/*
public DataTable getDictionary()
{
return new lNode().QueryByFlags();
}
*/
public void updateUserTheme(int userId, string theme)
{
Employee lem = new Employee(userId);
lem.em_profile = theme.Trim();
lem.Update();
}
static List<String> warehousenames ;
public List<String> getWareHouses(string mgrAddress)
{
//if (warehousenames == null || warehousenames.Count==0)
{
warehousenames = new List<string>();
DataTable dt = new LDepartment().getWareHouse(mgrAddress);
foreach (DataRow dr in dt.Rows)
{
warehousenames.Add(dr["dep_name"].ToString() + WmsConstants.SPLIT + dr["id"].ToString()
+ ":" + dr["svrAdress"].ToString());
}
}
return warehousenames;
}
/*
static List<String> warehouseMgrs;
public List<String> getWareHouseMgrs()
{
if (warehouseMgrs == null)
{
warehouseMgrs = new List<string>();
DataTable dt = new LDepartment().getWareHouseMrgDept();
foreach (DataRow dr in dt.Rows)
{
warehouseMgrs.Add(dr["dep_name"].ToString() + WmsConstants.SPLIT + dr["id"].ToString());
}
}
return warehouseMgrs;
}
*/
}
}