namespace BLL { using System; using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Data.Linq; using System.Web; using System.Web.Security; using System.Web.UI.WebControls; using System.Net; using Model; using BLL; using System.Collections.Generic; public static class Sys_LogService { /// /// 添加操作日志 /// /// 所属模块 /// 所属项目 /// 用户 /// 操作日志 public static void AddLog(string systemId, string projectId, string userId,string menuId,string buttonName,string tokeyId) { //SetOvertime(userId); Model.HJGLDB db = Funs.DB; Model.Sys_Log log = new Model.Sys_Log(); log.LogId = SQLHelper.GetNewID(typeof(Model.Sys_Log)); log.HostName = Dns.GetHostName(); IPAddress[] ips = Dns.GetHostAddresses(log.HostName); if (ips.Length > 0) { foreach (IPAddress ip in ips) { if (ip.ToString().IndexOf('.') != -1) { log.Ip = ip.ToString(); } } } log.OperationTime = DateTime.Now; //log.OperationLog = opLog; log.UserId = userId; log.ProjectId = projectId; log.SystemId = systemId; log.MenuId = menuId; log.ButtonName = buttonName; log.ToKeyId = tokeyId; log.DataFrom = "0"; db.Sys_Log.InsertOnSubmit(log); db.SubmitChanges(); } /// /// 根据人员Id查询所有日志信息的数量 /// /// 人员Id /// 日志信息的数量 public static int GetLogCountByUserId(string userId) { var q = (from x in Funs.DB.Sys_Log where x.UserId == userId select x).ToList(); return q.Count(); } /// /// 根据人员Id删除所有相关日志信息 /// /// public static void DeleteLogByUserId(string userId) { Model.HJGLDB db = Funs.DB; var q = (from x in db.Sys_Log where x.UserId == userId select x).ToList(); if (q != null) { db.Sys_Log.DeleteAllOnSubmit(q); db.SubmitChanges(); } } } }