using logtxtWrite;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using wcftest.EnumDefine.Sys;
|
using wcftest.orm;
|
|
namespace wcftest.BussinessExtension
|
{
|
public class SystemHelper
|
{
|
/// <summary>
|
/// 查询按钮权限字符串 【EditBy shaocx,2022-09-13】
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="roleId"></param>
|
/// <param name="menuIdEnum"></param>
|
/// <returns></returns>
|
public static List<string> QueryButtonPermission(int roleId, Menu_IdEnum menuIdEnum)
|
{
|
List<string> retList = new List<string>();
|
using (dbModel mod = new dbModel())
|
{
|
//使用权限
|
string roleSQL = "SELECT * FROM [YrtWMS_Siemens2].[dbo].[Sys_RoleAuth] where Menu_Id=" + (int)menuIdEnum + " and Role_Id=" + roleId;
|
var roleishave = mod.Database.SqlQuery<Sys_RoleAuth>(roleSQL).ToList();
|
if (roleishave.Count > 0)
|
{
|
//Browse=1,Search=1,Add=1,Update=0,Delete=0,Export=0
|
//因为字符串形式是这种形式,所以,我们后台需要将他解析出来
|
var str = roleishave[0].AuthValue;
|
if (!string.IsNullOrEmpty(str))
|
{
|
var arr = str.Split(',');
|
for (int i = 0; i < arr.Length; i++)
|
{
|
if (arr[i].IndexOf("=1") > -1)
|
{
|
retList.Add(arr[i].Substring(0, arr[i].IndexOf("=1")));//需要去掉=1
|
}
|
}
|
return retList;
|
}
|
return retList;
|
}
|
return retList;
|
}
|
}
|
|
/// <summary>
|
/// 增加用户操作日志
|
/// </summary>
|
/// <param name="userName">用户名</param>
|
/// <param name="operationInfo">操作内容</param>
|
/// <param name="OperateType">操作名称</param>
|
public static void addOperation(string userName, string operationInfo, string OperateType)
|
{
|
try
|
{
|
using (dbModel mod = new dbModel())
|
{
|
addOperation(mod, userName, operationInfo, OperateType);
|
}
|
}
|
catch (Exception)
|
{
|
|
logtxt.txtWrite("添加日志保存失败 用户名" + userName + "操作内容" + operationInfo, 2);
|
}
|
|
}
|
|
/// <summary>
|
/// 增加用户操作日志
|
/// </summary>
|
/// <param name="userName">用户名</param>
|
/// <param name="operationInfo">操作内容</param>
|
/// <param name="OperateType">操作名称</param>
|
public static void addOperation(dbModel mod, string userName, string operationInfo, string OperateType)
|
{
|
try
|
{
|
|
Sys_User_Log moveStocklog = new Sys_User_Log();
|
moveStocklog.UserTrueName = userName;
|
moveStocklog.OperateType = OperateType;
|
moveStocklog.Action = operationInfo;
|
moveStocklog.Creator = userName;
|
moveStocklog.CreateDate = DateTime.Now;
|
moveStocklog.UserProduct_Id = 1007;
|
moveStocklog.UserProductCode = "100000001";
|
mod.Sys_User_Log.Add(moveStocklog);
|
int result = mod.SaveChanges();
|
if (result == 0)//失败再保存一次
|
{
|
result = mod.SaveChanges();
|
if (result == 0)
|
{
|
logtxt.txtWrite("添加日志保存失败 用户名" + userName + "操作内容" + operationInfo, 2);
|
}
|
|
}
|
}
|
catch (Exception)
|
{
|
|
logtxt.txtWrite("添加日志保存失败 用户名" + userName + "操作内容" + operationInfo, 2);
|
}
|
|
}
|
}
|
}
|