Exemple #1
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for (int i = 0; i < testItems; i++)
     {
         LoginLog item = new LoginLog();
         _testRepo._items.Add(item);
     }
 }
Exemple #2
0
 public override bool Equals(object obj)
 {
     if (obj.GetType() == typeof(LoginLog))
     {
         LoginLog compare = (LoginLog)obj;
         return(compare.KeyValue() == this.KeyValue());
     }
     else
     {
         return(base.Equals(obj));
     }
 }
Exemple #3
0
        public static LoginLog SingleOrDefault(Expression <Func <LoginLog, bool> > expression, string connectionString, string providerName)
        {
            var      repo    = GetRepo(connectionString, providerName);
            var      results = repo.Find(expression);
            LoginLog single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
            }

            return(single);
        }
Exemple #4
0
        public static LoginLog SingleOrDefault(Expression <Func <LoginLog, bool> > expression)
        {
            var      repo    = GetRepo();
            var      results = repo.Find(expression);
            LoginLog single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
                single.OnLoaded();
                single.SetIsLoaded(true);
                single.SetIsNew(false);
            }

            return(single);
        }
Exemple #5
0
 void Init()
 {
     TestMode      = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
     _dirtyColumns = new List <IColumn>();
     if (TestMode)
     {
         LoginLog.SetTestRepo();
         _repo = _testRepo;
     }
     else
     {
         _repo = new SubSonicRepository <LoginLog>(_db);
     }
     tbl = _repo.GetTable();
     SetIsNew(true);
     OnCreated();
 }
Exemple #6
0
        /// <summary>
        /// 添加用户登陆日志
        /// </summary>
        /// <param name="userHashKey">登录用户在线列表的HashTable Key</param>
        /// <param name="notes">用户登录内容备注,{0}=用户名称,{1}=用户在线时间</param>
        public void Save(string userHashKey, string notes)
        {
            try
            {
                //创建登录日志对象,便于登录日志的添加
                var loginlog = new LoginLog();
                //记录登录时间
                loginlog.AddDate = DateTime.Now;
                //在线时长
                var loginDuration = "未知";

                //获取用户在线实体
                var model = OnlineUsersBll.GetInstence().GetOnlineUsersModel(userHashKey);
                if (model != null)
                {
                    //当前用户ID
                    loginlog.Manager_Id = model.Manager_Id;
                    //当前用户名称
                    loginlog.Manager_CName = model.Manager_CName;
                    //当前用户IP
                    loginlog.Ip = model.LoginIp;
                    //计算在线时长
                    loginDuration = CommonBll.LoginDuration(model.LoginTime, model.UpdateTime);
                }
                else
                {
                    //当前用户ID
                    loginlog.Manager_Id = 0;
                    //当前用户名称
                    loginlog.Manager_CName = "";
                    //当前用户IP
                    loginlog.Ip = IpHelper.GetUserIp();
                }

                //日志记录说明
                loginlog.Notes = String.Format(notes, loginlog.Manager_CName, loginDuration);

                loginlog.Save();
            }
            catch (Exception) { }
        }
Exemple #7
0
        /// <summary>
        /// 添加用户登陆日志
        /// </summary>
        /// <param name="managerId">登录用户ID</param>
        /// <param name="notes">用户登录内容备注</param>
        public void Save(int managerId, string notes)
        {
            try
            {
                //创建登录日志对象,便于登录日志的添加
                var loginlog = new LoginLog();
                //记录登录时间
                loginlog.AddDate = DateTime.Now;
                //当前用户ID
                loginlog.Manager_Id = managerId;

                //当前用户名称
                loginlog.Manager_CName = ManagerBll.GetInstence().GetCName(null, managerId);
                //当前用户IP
                loginlog.Ip = IpHelper.GetUserIp();
                //日志记录说明
                loginlog.Notes = notes;

                loginlog.Save();
            }
            catch (Exception) { }
        }
Exemple #8
0
        internal static IRepository <LoginLog> GetRepo(string connectionString, string providerName)
        {
            Solution.DataAccess.DataModel.SolutionDataBaseDB db;
            if (String.IsNullOrEmpty(connectionString))
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBaseDB();
            }
            else
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBaseDB(connectionString, providerName);
            }
            IRepository <LoginLog> _repo;

            if (db.TestMode)
            {
                LoginLog.SetTestRepo();
                _repo = _testRepo;
            }
            else
            {
                _repo = new SubSonicRepository <LoginLog>(db);
            }
            return(_repo);
        }
Exemple #9
0
 public static void Setup(LoginLog item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Exemple #10
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         LoginLog item=new LoginLog();
         _testRepo._items.Add(item);
     }
 }
Exemple #11
0
 public static void Setup(LoginLog item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Exemple #12
0
        /// <summary>
        /// 将LoginLog记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.LoginLog)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.LoginLog</returns>
        public DataAccess.Model.LoginLog Transform(LoginLog model)
        {
            if (model == null)
                return null;

            return new DataAccess.Model.LoginLog
            {
                Id = model.Id,
                AddDate = model.AddDate,
                Manager_Id = model.Manager_Id,
                Manager_CName = model.Manager_CName,
                Ip = model.Ip,
                Notes = model.Notes,
            };
        }
Exemple #13
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(LoginLog model)
 {
     SetModelForCache(Transform(model));
 }
Exemple #14
0
        /// <summary>
        /// 添加与编辑LoginLog记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">LoginLog表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, LoginLog model, string content = null, bool isCache = true, bool isAddUseLog = true)
        {
            try {
                //保存
                model.Save();

                //判断是否启用缓存
                if (CommonBll.IsUseCache() && isCache)
                {
                    SetModelForCache(model);
                }

                if (isAddUseLog)
                {
                    if (string.IsNullOrEmpty(content))
                    {
                        content = "{0}" + (model.Id == 0 ? "添加" : "编辑") + "LoginLog记录成功,ID为【" + model.Id + "】";
                    }

                    //添加用户访问记录
                    UseLogBll.GetInstence().Save(page, content);
                }
            }
            catch (Exception e) {
                var result = "执行LoginLogBll.Save()函数出错!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }