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

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

            return(single);
        }
Пример #4
0
        public static UseLog SingleOrDefault(Expression <Func <UseLog, bool> > expression)
        {
            var    repo    = GetRepo();
            var    results = repo.Find(expression);
            UseLog single  = null;

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

            return(single);
        }
Пример #5
0
 void Init()
 {
     TestMode      = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
     _dirtyColumns = new List <IColumn>();
     if (TestMode)
     {
         UseLog.SetTestRepo();
         _repo = _testRepo;
     }
     else
     {
         _repo = new SubSonicRepository <UseLog>(_db);
     }
     tbl = _repo.GetTable();
     SetIsNew(true);
     OnCreated();
 }
Пример #6
0
        internal static IRepository <UseLog> 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 <UseLog> _repo;

            if (db.TestMode)
            {
                UseLog.SetTestRepo();
                _repo = _testRepo;
            }
            else
            {
                _repo = new SubSonicRepository <UseLog>(db);
            }
            return(_repo);
        }
Пример #7
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         UseLog item=new UseLog();
         _testRepo._items.Add(item);
     }
 }
Пример #8
0
 public static void Setup(UseLog item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Пример #9
0
 public static void Setup(UseLog item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Пример #10
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(UseLog model)
 {
     SetModelForCache(Transform(model));
 }
Пример #11
0
        /// <summary>
        /// 添加与编辑UseLog记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">UseLog表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, UseLog 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 ? "添加" : "编辑") + "UseLog记录成功,ID为【" + model.Id + "】";
                    }

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

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
Пример #12
0
        /// <summary>
        /// 将UseLog记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.UseLog)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.UseLog</returns>
        public DataAccess.Model.UseLog Transform(UseLog model)
        {
            if (model == null)
                return null;

            return new DataAccess.Model.UseLog
            {
                Id = model.Id,
                AddDate = model.AddDate,
                Manager_Id = model.Manager_Id,
                Manager_CName = model.Manager_CName,
                Ip = model.Ip,
                MenuInfo_Id = model.MenuInfo_Id,
                MenuInfo_Name = model.MenuInfo_Name,
                Notes = model.Notes,
            };
        }
Пример #13
0
        /// <summary>
        /// 添加用户操作日志
        /// </summary>
        /// <param name="page">页面指针</param>
        /// <param name="useLogOccurrence">用户操作内容备注,{0}=用户名称,{1}=当前页面名称</param>
        public void Save(Page page, string useLogOccurrence)
        {
            try
            {
                //创建用户操作日志对象
                var uselog = new UseLog();
                //记录登录时间
                uselog.AddDate = DateTime.Now;
                //获取用户在线实体
                var model = OnlineUsersBll.GetInstence().GetOnlineUsersModelForLog();
                if (model != null)
                {
                    //当前用户ID
                    uselog.Manager_Id = model.Manager_Id;
                    //当前用户名称
                    uselog.Manager_CName = model.Manager_CName;
                }
                else
                {
                    //当前用户ID
                    uselog.Manager_Id = 0;
                    //当前用户名称
                    uselog.Manager_CName = "";
                }
                if (page != null)
                {
                    //当前页面ID
                    var menu = MenuInfoBll.GetInstence().GetMenuInfo(page.Request.Url.AbsolutePath);
                    if (menu == null)
                    {
                        uselog.MenuInfo_Id = 0;
                    }
                    else
                    {
                        uselog.MenuInfo_Id = menu.Id;
                        //当前页面名称
                        uselog.MenuInfo_Name = menu.Name;
                    }

                    //判断是否为首页
                    if (uselog.MenuInfo_Id == 0)
                    {
                        if (page.Request.Url.AbsolutePath.Equals("/WebManage/Main.aspx"))
                        {
                            //当前页面名称
                            uselog.MenuInfo_Name = "首页";
                        }
                    }
                }

                //当前用户IP
                uselog.Ip = IpHelper.GetUserIp();

                //操作内容
                uselog.Notes = StringHelper.FilterSql(String.Format(useLogOccurrence, uselog.Manager_CName, uselog.MenuInfo_Name));
                //插入记录
                uselog.Save();
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("添加用户操作日志时出现异常", e);
            }
        }