using System; using System.Collections.Generic; using FactorySystemCommon; using FactorySystemModel.SqlSugarModel; using SqlSugar; namespace FactorySystemBll { public class OperateLogBll { public object GetPageList(Dictionary inParam, out int totalCount, string orderBy = "a.FID desc") { totalCount = 0; int pageIndex = 1, pageSize = 10; List paramName = new List() { "FDeleted!=1" }; List paramVal = new List(); if (inParam != null && inParam.Count > 0) { foreach (var item in inParam) { if (item.Key == "FPageIndex" || item.Key == "PageIndex") { int.TryParse(item.Value.ToString(), out pageIndex); } else if (item.Key == "FPageSize" || item.Key == "PageSize") { int.TryParse(item.Value.ToString(), out pageSize); } else { try { //检索,全转成字符串 paramName.Add(item.Key + "=@" + item.Key); paramVal.Add(new SugarParameter("@" + item.Key, item.Value.ToString())); } catch (Exception) { } } } } SqlSugarClient db = AppSettingsHelper.GetSqlSugar(); var temp = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Left, a.FAddUser == b.FID)) .Where(string.Join(" and ", paramName), paramVal).OrderBy(orderBy).Select("a.*,b.FName as FOptUser"); return temp.ToPageList(pageIndex, pageSize, ref totalCount); } /// /// 保存日志 /// /// 协同ID /// 来源类型 /// 描述 /// 操作人 public static void Add(int teamId, int type, string desc, int userId) { var db = AppSettingsHelper.GetSqlSugar(); db.Insertable(new TFS_OperateLog { FTeamID = teamId, FType = type, FDesc = desc, FAddUser = userId, FAddDate = DateTime.Now }).ExecuteCommand(); } } }