Esempio n. 1
0
 /// <summary>
 /// 获取本逻辑类单例
 /// </summary>
 /// <returns></returns>
 public static UseLogBll GetInstence()
 {
     if (_UseLogBll == null) {
         _UseLogBll = new UseLogBll();
     }
     return _UseLogBll;
 }
Esempio n. 2
0
        /// <summary>更新Inventory01表记录指定字段值,如果使用了缓存,保存成功后会清空本表的所有缓存记录,然后重新加载进缓存</summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="dic">需要更新的字段与值</param>
        /// <param name="wheres">条件</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否同步更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void UpdateValue(Page page, Dictionary <string, object> dic, List <ConditionFun.SqlqueryCondition> wheres = null, string content = "", bool isCache = true, bool isAddUseLog = true)
        {
            //更新
            var update = new UpdateHelper();

            update.Update <Inventory01>(dic, wheres);

            //判断是否启用缓存
            if (isCache && CommonBll.IsUseCache())
            {
                //删除全部缓存
                DelAllCache();
                //重新载入缓存
                GetList();
            }

            if (isAddUseLog)
            {
                if (string.IsNullOrEmpty(content))
                {
                    //添加用户操作记录
                    UseLogBll.GetInstence().Save(page, content != "" ? content : "{0}修改了Inventory01表记录。");
                }
                else
                {
                    //添加用户操作记录
                    UseLogBll.GetInstence().Save(page, content);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 添加与编辑Inventory01记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">Inventory01表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, Inventory01 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 ? "添加" : "编辑") + "Inventory01记录成功,ID为【" + model.Id + "】";
                    }

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

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
        /// <summary>
        /// 删除V_PRODUCT_COMPONENT00表记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public override void Delete(Page page, int[] id, bool isAddUseLog = true)
        {
            if (id == null)
            {
                return;
            }
            //将数组转为逗号分隔的字串
            var str = string.Join(",", id);

            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} in ({2})", V_PRODUCT_COMPONENT00Table.TableName, V_PRODUCT_COMPONENT00Table.Id, str);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(id.ToList());
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了V_PRODUCT_COMPONENT00表id为【" + str + "】的记录!");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 删除UseLog表指定MenuInfo_Id的字段值记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        public void DeleteByMenuInfo_Id(Page page, int[] id)
        {
            if (id == null)
            {
                return;
            }
            //将数组转为逗号分隔的字串
            var str = string.Join(",", id);

            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} in ({2})", UseLogTable.TableName, UseLogTable.MenuInfo_Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                var ids = id.ToList();
                foreach (var i in ids)
                {
                    //删除缓存
                    DelCache(x => x.MenuInfo_Id == i);
                }
            }

            //添加用户操作记录
            UseLogBll.GetInstence().Save(page, "{0}删除了UseLog表MenuInfo_Id值为【" + str + "】的记录!");
        }
 /// <summary>
 /// 获取本逻辑类单例
 /// </summary>
 /// <returns></returns>
 public static UseLogBll GetInstence()
 {
     if (_UseLogBll == null)
     {
         _UseLogBll = new UseLogBll();
     }
     return(_UseLogBll);
 }
        /// <summary>
        /// 添加用户访问页面记录
        /// </summary>
        public static void UserRecord(Page page)
        {
            //检查用户是否存在
            OnlineUsersBll.GetInstence().IsTimeOut();

            //获取当前用户的编号
            var userHashKey = OnlineUsersBll.GetInstence().GetUserHashKey();

            //获取当前页面名称
            var menuName = "";
            //取得当前页面实体
            var menu = MenuInfoBll.GetInstence().GetMenuInfo(page.Request.Url.AbsolutePath);

            if (menu != null)
            {
                menuName = menu.Name;
            }
            //判断是否为首页
            if (string.IsNullOrEmpty(menuName))
            {
                if (page.Request.Url.AbsolutePath.Equals("/WebManage/Main.aspx"))
                {
                    //当前页面名称
                    menuName = "首页";
                }
            }

            //更新当前用户所在页面路径
            OnlineUsersBll.GetInstence().UpdateUserOnlineInfo(userHashKey, OnlineUsersTable.CurrentPage, page.Request.Url.AbsolutePath);
            //更新当前用户所在页面名称
            OnlineUsersBll.GetInstence().UpdateUserOnlineInfo(userHashKey, OnlineUsersTable.CurrentPageTitle, menuName);
            //同步更新数据库
            //设置需要更新的字段
            var dic = new Dictionary <string, object>();

            dic.Add(OnlineUsersTable.CurrentPage, page.Request.Url.AbsolutePath);
            dic.Add(OnlineUsersTable.CurrentPageTitle, menuName);
            //设置更新条件
            var wheres = new List <ConditionFun.SqlqueryCondition>();

            wheres.Add(new ConditionFun.SqlqueryCondition(ConstraintType.And, OnlineUsersTable.UserHashKey, Comparison.Equals, userHashKey));
            //更新
            OnlineUsersBll.GetInstence().UpdateValue(page, dic, wheres, "", true, false);

            //添加用户访问记录
            UseLogBll.GetInstence().Save(page, "{0}进入了【{1}】页面");
        }
Esempio n. 8
0
        /// <summary>
        /// 判断当前用户是否有本页面的操作权限
        /// </summary>
        /// <returns></returns>
        public void CheckPagePower(Page page)
        {
            try
            {
                //获取当前访问页面的名称
                var currentPage = page.Request.Url.AbsolutePath;
                if (currentPage.Equals("/WebManage/Main.aspx"))
                {
                    return;
                }

                //检查是否从正确路径进入
                CheckPageEncrypt(page);


                //获取当前用户所有可以访问的页面ID
                var model = GetMenuInfo(currentPage);
                if (model != null)
                {
                    var menuId = GetMenuInfo(currentPage).Id + "";
                    if (CheckPagePower(menuId))
                    {
                        return;
                    }
                }

                //添加用户访问记录
                UseLogBll.GetInstence().Save(page, "{0}没有权限访问【{1}】页面");

                page.Response.Write("您没有访问该页面的权限!");
                page.Response.End();
                return;
            }
            catch (Exception e)
            {
                // 记录日志
                CommonBll.WriteLog("判断当前用户是否有当前页面操作权限", e);

                //添加用户访问记录
                UseLogBll.GetInstence().Save(page, "{0}没有权限访问【{1}】页面");

                page.Response.Write("您没有访问该页面的权限!");
                page.Response.End();
                return;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 添加用户访问页面记录
        /// </summary>
        public static void UserRecord(Page page)
        {
            //获取当前用户的编号
            var userHashKey = OnlineUsersBll.GetInstence().GetUserHashKey();

            //获取当前页面名称
            var menuName = "";
            //取得当前页面实体
            var menu = MenuInfoBll.GetInstence().GetMenuInfo(page.Request.Url.AbsolutePath);

            if (menu != null)
            {
                menuName = menu.Name;
            }
            //判断是否为首页
            if (string.IsNullOrEmpty(menuName))
            {
                if (page.Request.Url.AbsolutePath.Equals("/WebManage/Main.aspx"))
                {
                    //当前页面名称
                    menuName = "首页";
                }
            }

            //更新当前用户所在页面路径
            OnlineUsersBll.GetInstence()
            .UpdateUserOnlineInfo(userHashKey, OnlineUsersTable.CurrentPage, page.Request.Url.AbsolutePath);
            //更新当前用户所在页面名称
            OnlineUsersBll.GetInstence().UpdateUserOnlineInfo(userHashKey, OnlineUsersTable.CurrentPageTitle, menuName);

            //同步更新数据库与缓存
            //获取在线用户Id
            var id = OnlineUsersBll.GetInstence().GetOnlineUsersId();

            if (id > 0)
            {
                //更新
                OnlineUsersBll.GetInstence()
                .UpdateValue(page, id, OnlineUsersTable.CurrentPage, page.Request.Url.AbsolutePath,
                             OnlineUsersTable.CurrentPageTitle, menuName, "", true, false);
            }

            //添加用户访问记录
            UseLogBll.GetInstence().Save(page, "{0}进入了【{1}】页面");
        }
Esempio n. 10
0
        /// <summary>
        /// 删除UseLog表指定MenuInfo_Id的字段值记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        public void DeleteByMenuInfo_Id(Page page, int id)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} = {2}", UseLogTable.TableName, UseLogTable.MenuInfo_Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(x => x.MenuInfo_Id == id);
            }

            //添加用户操作记录
            UseLogBll.GetInstence().Save(page, "{0}删除了UseLog表MenuInfo_Id值为【" + id + "】的记录!");
        }
Esempio n. 11
0
        /// <summary>
        /// 获取数据表中的某个值——从数据库中查询,如果使用了缓存,删除成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="expression">条件语句</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, Expression <Func <HEAD_SHOP_PAY_HISTORY, bool> > expression, bool isAddUseLog = true)
        {
            //执行删除
            HEAD_SHOP_PAY_HISTORY.Delete(expression);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
                //重新载入缓存
                GetList();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了HEAD_SHOP_PAY_HISTORY表记录!");
            }
        }
        /// <summary>
        /// 获取数据表中的某个值——从数据库中查询,如果使用了缓存,删除成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="expression">条件语句</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, Expression <Func <SHOP_SUPPLIER_RELATION, bool> > expression, bool isAddUseLog = true)
        {
            //执行删除
            SHOP_SUPPLIER_RELATION.Delete(expression);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
                //重新载入缓存
                GetList();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了SHOP_SUPPLIER_RELATION表记录!");
            }
        }
        /// <summary>
        /// 获取数据表中的某个值——从数据库中查询,如果使用了缓存,删除成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="expression">条件语句</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, Expression <Func <CONTRACT00, bool> > expression, bool isAddUseLog = true)
        {
            //执行删除
            CONTRACT00.Delete(expression);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
                //重新载入缓存
                GetList();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了CONTRACT00表记录!");
            }
        }
		/// <summary>
		/// 保存列表排序,如果使用了缓存,保存成功后会清空本表的所有缓存记录,然后重新加载进缓存
		/// </summary>
		/// <param name="page">当前页面指针</param>
		/// <param name="grid1">页面表格</param>
		/// <param name="tbxSort">表格中绑定排序的表单名</param>
		/// <param name="sortName">排序字段名</param>
		/// <returns>更新成功返回true,失败返回false</returns>
		public override bool UpdateSort(Page page, FineUI.Grid grid1, string tbxSort, string sortName = "Sort")
	    {
		     //更新排序
			if (CommonBll.UpdateSort(page, grid1, tbxSort, "V_TAKEIN11_PRODUCT00", sortName, "Id"))
		    {
				//判断是否启用缓存
                if (CommonBll.IsUseCache())
                {
                    //删除所有缓存
                    DelAllCache();
                    //重新载入缓存
                    GetList();
                }
				
			    //添加用户操作记录
				UseLogBll.GetInstence().Save(page, "{0}更新了V_TAKEIN11_PRODUCT00表排序!");

			    return true;
		    }

			return false;
	    }
		/// <summary>
		/// 删除V_TAKEIN11_PRODUCT00表记录
		/// </summary>
		/// <param name="page">当前页面指针</param>
		/// <param name="id">记录的主键值</param>
		/// <param name="isAddUseLog">是否添加用户操作日志</param>
		public override void Delete(Page page, int id, bool isAddUseLog = true) 
		{
			//设置Sql语句
			var sql = string.Format("delete from {0} where {1} = {2}", V_TAKEIN11_PRODUCT00Table.TableName,  V_TAKEIN11_PRODUCT00Table.Id, id);

			//删除
			var delete = new DeleteHelper();
		    delete.Delete(sql);
			
			//判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(id);
            }
			
			if (isAddUseLog)
		    {
				//添加用户操作记录
				UseLogBll.GetInstence().Save(page, "{0}删除了V_TAKEIN11_PRODUCT00表id为【" + id + "】的记录!");
			}
		}
Esempio n. 16
0
        /// <summary>自动排序,如果使用了缓存,保存成功后会清空本表的所有缓存记录,然后重新加载进缓存</summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="strWhere">附加Where : " sid=1 "</param>
        /// <param name="isExistsMoreLv">是否存在多级分类,一级时,请使用false,多级使用true,(一级不包括ParentID字段)</param>
        /// <param name="pid">父级分类的ParentID</param>
        /// <param name="fieldName">字段名:"SortId"</param>
        /// <param name="fieldParentId">字段名:"ParentId"</param>
        /// <returns>更新成功返回true,失败返回false</returns>
        public override bool UpdateAutoSort(Page page, string strWhere = "", bool isExistsMoreLv = false, int pid = 0, string fieldName = "Sort", string fieldParentId = "ParentId")
        {
            //更新排序
            if (CommonBll.AutoSort("Id", "HEAD_SHOP_PAY_HISTORY", strWhere, isExistsMoreLv, pid, fieldName, fieldParentId))
            {
                //判断是否启用缓存
                if (CommonBll.IsUseCache())
                {
                    //删除所有缓存
                    DelAllCache();
                    //重新载入缓存
                    GetList();
                }

                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}对HEAD_SHOP_PAY_HISTORY表进行了自动排序操作!");

                return(true);
            }

            return(false);
        }
Esempio n. 17
0
        /// <summary>
        /// 保存列表排序,如果使用了缓存,保存成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="grid1">页面表格</param>
        /// <param name="tbxSort">表格中绑定排序的表单名</param>
        /// <param name="sortName">排序字段名</param>
        /// <returns>更新成功返回true,失败返回false</returns>
        public override bool UpdateSort(Page page, FineUI.Grid grid1, string tbxSort, string sortName = "Sort")
        {
            //更新排序
            if (CommonBll.UpdateSort(page, grid1, tbxSort, "HEAD_SHOP_PAY_HISTORY", sortName, "Id"))
            {
                //判断是否启用缓存
                if (CommonBll.IsUseCache())
                {
                    //删除所有缓存
                    DelAllCache();
                    //重新载入缓存
                    GetList();
                }

                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}更新了HEAD_SHOP_PAY_HISTORY表排序!");

                return(true);
            }

            return(false);
        }
Esempio n. 18
0
        /// <summary>
        /// 检查用户是否从正确的路径进入本页面,默认KEY为ID
        /// </summary>
        public void CheckPageEncrypt(Page page)
        {
            //当前用户md5
            var md5 = OnlineUsersBll.GetInstence().GetMd5();
            //Key,如果没有传递Key这个变量过来的,就读取id或ParentID做为Key使用
            var key = HttpContext.Current.Request["Id"];

            if (string.IsNullOrEmpty(key))
            {
                key = HttpContext.Current.Request["pid"];
            }
            if (string.IsNullOrEmpty(key))
            {
                key = HttpContext.Current.Request["ParentId"];
            }
            if (string.IsNullOrEmpty(key))
            {
                key = HttpContext.Current.Request["Key"];
            }
            //上一链接传过来的加密数据
            var keyEncrypt = HttpContext.Current.Request["KeyEncrypt"];

            //加密:md5+Key
            var encrypt = Encrypt.Md5(md5 + key);

            //再次加密:Key + Encrypt
            encrypt = Encrypt.Md5(key + encrypt);

            //检查是否有权限,没有权限的直接终止当前页面的运行
            if (keyEncrypt != encrypt || string.IsNullOrEmpty(key))
            {
                //添加用户访问记录
                UseLogBll.GetInstence().Save(page, "{0}没有权限访问【{1}】页面");

                HttpContext.Current.Response.Write("你从错误的路径进入当前页面!");
                HttpContext.Current.Response.End();
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 删除WebConfig表所有记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void DeleteAll(Page page, bool isAddUseLog = true)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0}", WebConfigTable.TableName);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了WebConfig表所有记录!");
            }
        }