85 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
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
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 添加操作日志
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="systemId">所属模块</param>
 | 
						|
        /// <param name="projectId">所属项目</param>
 | 
						|
        /// <param name="userId">用户</param>
 | 
						|
        /// <param name="opLog">操作日志</param>
 | 
						|
        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();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据人员Id查询所有日志信息的数量
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="userId">人员Id</param>
 | 
						|
        /// <returns>日志信息的数量</returns>
 | 
						|
        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();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据人员Id删除所有相关日志信息
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="userId"></param>
 | 
						|
        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();
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |