You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
215 lines
7.1 KiB
215 lines
7.1 KiB
1 year ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Data;
|
||
|
using System.ServiceModel;
|
||
|
using SSWMS.Common;
|
||
|
|
||
|
namespace SSWMS.Server
|
||
|
{
|
||
|
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single,
|
||
|
ConcurrencyMode = ConcurrencyMode.Multiple, MaxItemsInObjectGraph = int.MaxValue, UseSynchronizationContext = false)]
|
||
|
public class S_SystemService : I_SystemService
|
||
|
{
|
||
|
#region SYS_LOG
|
||
|
public void AddLog(SYS_LOG sl)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
S_BaseService._P_Base_House.BeginTransaction();
|
||
|
if (string.IsNullOrWhiteSpace(sl.LOG_TIME))
|
||
|
{
|
||
|
sl.LOG_TIME = StringUtils.GetCurrentTime();
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(sl.OPERATOR))
|
||
|
{
|
||
|
sl.OPERATOR = "WMS";
|
||
|
}
|
||
|
S_BaseService._P_SYS_LOG.Add(sl);
|
||
|
S_BaseService._P_Base_House.CommitTransaction();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
S_BaseService._P_Base_House.RollBackTransaction();
|
||
|
MainWindow.log.Error($"AddLog 异常 {ex.Message}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void AddLog(string sLogType, string sLogText, string sOperator = "WMS")
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
S_BaseService._P_Base_House.BeginTransaction();
|
||
|
S_BaseService._P_SYS_LOG.Add(new SYS_LOG()
|
||
|
{
|
||
|
LOG_TYPE = sLogType,
|
||
|
LOG_TEXT = sLogText,
|
||
|
OPERATOR = sOperator,
|
||
|
LOG_TIME = StringUtils.GetCurrentTime(),
|
||
|
});
|
||
|
S_BaseService._P_Base_House.CommitTransaction();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
S_BaseService._P_Base_House.RollBackTransaction();
|
||
|
MainWindow.log.Error($"AddLog 异常 {ex.Message}");
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SYS_USER SYS_ROLE
|
||
|
public SYS_USER Login(string sUserCode, string sPassword)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
SYS_USER su = S_BaseService._P_SYS_USER.GetModelByUserCode(sUserCode);
|
||
|
if (su != null && su.USER_PASSWORD == sPassword)
|
||
|
{
|
||
|
return su;
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public bool ChangePassword(string sUserCode, string sOldPassword, string sNewPassword, out string sResult)
|
||
|
{
|
||
|
sResult = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
SYS_USER su = S_BaseService._P_SYS_USER.GetModelByUserCode(sUserCode);
|
||
|
if (su != null && su.USER_PASSWORD == sOldPassword)
|
||
|
{
|
||
|
su.USER_PASSWORD = sNewPassword;
|
||
|
S_BaseService._P_SYS_USER.Update(su);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sResult = "旧密码错误";
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
sResult = ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public IList<SYS_ROLE> GetSystemRole(int iUserID)
|
||
|
{
|
||
|
if (iUserID == 0)
|
||
|
{
|
||
|
return new List<SYS_ROLE> { S_BaseService._P_SYS_ROLE.GetModel(0) };
|
||
|
}
|
||
|
else if (iUserID == 1)
|
||
|
{
|
||
|
return new List<SYS_ROLE> { S_BaseService._P_SYS_ROLE.GetModel(1) };
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return S_BaseService._P_SYS_ROLE.GetListByUser(iUserID);
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SYS_MENU
|
||
|
public SYS_MENU GetSystemMenu(int iMenuID)
|
||
|
{
|
||
|
return S_BaseService._P_SYS_MENU.GetModel(iMenuID);
|
||
|
}
|
||
|
|
||
|
public IList<SYS_MENU> GetSystemMenuByUserID(int iUserID)
|
||
|
{
|
||
|
if (iUserID == 0 || iUserID == 1)
|
||
|
{
|
||
|
return S_BaseService._P_SYS_MENU.GetListByMenuFlag(SystemCode.FLAG.Enable);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return S_BaseService._P_SYS_MENU.GetListByUser(iUserID);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable GetSystemMenuDataTable(bool bIsParent)
|
||
|
{
|
||
|
return S_BaseService._P_Base_House.GetDataTable("select MENU_NAME as NAME,MENU_ID as VALUE from V_SYS_MENU where" +
|
||
|
$" {(bIsParent ? "MENU_IS_PARENT = '1'" : "MENU_IS_PARENT = '0' and MENU_PARENT_ID > 2")} order by MENU_ORDER");
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SYS_RELATION
|
||
|
public IList<SYS_RELATION> GetUserRelation(string sRelationType, int iUserID)
|
||
|
{
|
||
|
return S_BaseService._P_SYS_RELATION.GetListByUser(sRelationType, iUserID);
|
||
|
}
|
||
|
|
||
|
public IList<SYS_RELATION> GetRoleRelation(string sRelationType, int iRoleID)
|
||
|
{
|
||
|
return S_BaseService._P_SYS_RELATION.GetListByRole(sRelationType, iRoleID);
|
||
|
}
|
||
|
|
||
|
public bool UpdateRoleRelation(string sRelationType, int iRoleID, List<int> lRelationID2, out string sResult)
|
||
|
{
|
||
|
bool bResult = true;
|
||
|
sResult = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
S_BaseService._P_Base_House.BeginTransaction();
|
||
|
IList<SYS_RELATION> lRelation = S_BaseService._P_SYS_RELATION.GetListByRole(sRelationType, iRoleID);
|
||
|
foreach (SYS_RELATION sr in lRelation)
|
||
|
{
|
||
|
if (!lRelationID2.Exists(r => r == sr.RELATION_ID2))
|
||
|
{
|
||
|
S_BaseService._P_SYS_RELATION.Delete(sr.RELATION_ID);
|
||
|
}
|
||
|
}
|
||
|
foreach (int iRelationID2 in lRelationID2)
|
||
|
{
|
||
|
if (lRelation.FirstOrDefault(r => r.RELATION_ID2 == iRelationID2) == null)
|
||
|
{
|
||
|
S_BaseService._P_SYS_RELATION.Add(new SYS_RELATION
|
||
|
{
|
||
|
RELATION_TYPE = sRelationType,
|
||
|
RELATION_ID1 = iRoleID,
|
||
|
RELATION_ID2 = iRelationID2
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
S_BaseService._P_Base_House.CommitTransaction();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
S_BaseService._P_Base_House.RollBackTransaction();
|
||
|
bResult = false;
|
||
|
sResult = ex.Message;
|
||
|
}
|
||
|
return bResult;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SP_INIT_SYSTEM
|
||
|
public bool InitSystem(out string sResult)
|
||
|
{
|
||
|
sResult = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
S_BaseService._P_Base_House.BeginTransaction();
|
||
|
S_BaseService._P_Base_House.InitSystem();
|
||
|
S_BaseService._P_Base_House.CommitTransaction();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
S_BaseService._P_Base_House.RollBackTransaction();
|
||
|
sResult = ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|