/// <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, "SHOP_ACCOUNT", sortName, "Id"))
            {
                //判断是否启用缓存
                if (CommonBll.IsUseCache())
                {
                    //删除所有缓存
                    DelAllCache();
                    //重新载入缓存
                    GetList();
                }

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

                return(true);
            }

            return(false);
        }
        /// <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", "SHOP_ACCOUNT", strWhere, isExistsMoreLv, pid, fieldName, fieldParentId))
            {
                //判断是否启用缓存
                if (CommonBll.IsUseCache())
                {
                    //删除所有缓存
                    DelAllCache();
                    //重新载入缓存
                    GetList();
                }

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

                return(true);
            }

            return(false);
        }
Exemple #3
0
        /***********************************************************************
        * 自定义函数                                                          *
        ***********************************************************************/
        #region 自定义函数

        #region 添加用户登陆日志
        /// <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;
                //当前用户ID
                loginlog.Manager_Id = ConvertHelper.Cint0(OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.Manager_Id));

                //当前用户名称
                loginlog.Manager_CName = OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.Manager_CName) + "";
                //当前用户IP
                loginlog.Ip = OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.LoginIp) + "";
                //日志记录说明
                loginlog.Notes = String.Format(notes, loginlog.Manager_CName, CommonBll.LoginDuration(OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.LoginTime)));

                loginlog.Save();
            }
            catch (Exception) { }
        }
        /// <summary>
        /// 绑定信息分类下拉列表——显示所有
        /// </summary>
        public void BandDropDownListShowAll(Page page, FineUI.DropDownList ddl)
        {
            //设置排序
            var sortList = new List <string>();

            sortList.Add(InformationClassTable.Depth);
            sortList.Add(InformationClassTable.Sort);

            //筛选记录
            var dt = GetDataTable(false, 0, null, 0, 0, null, sortList);

            try
            {
                //整理出有层次感的数据
                dt = DataTableHelper.DataTableTidyUp(dt, InformationClassTable.Id, InformationClassTable.ParentId, 0);

                ddl.EnableSimulateTree = true;

                //显示值
                ddl.DataTextField = InformationClassTable.Name;
                //绑定Id
                ddl.DataValueField = InformationClassTable.Id;
                //数据层次
                ddl.DataSimulateTreeLevelField = InformationClassTable.Depth;
                //绑定数据源
                ddl.DataSource = dt;
                ddl.DataBind();
                ddl.SelectedIndex = 0;

                ddl.Items.Insert(0, new FineUI.ListItem("请选择信息分类", "0"));
                ddl.SelectedValue = "0";
            }
            catch (Exception e)
            {
                // 记录日志
                CommonBll.WriteLog("", e);
            }
        }
Exemple #5
0
        public void BandDropDownList(Page page, FineUI.DropDownList ddl, string shop_id)
        {
            //在内存中筛选记录
            var dt = (DataTable)SPs.GET_ORDER_DEP00_ORDER_DEP01_LIST(shop_id).ExecuteDataTable();

            try
            {
                //显示值
                ddl.DataTextField = ORDER_DEP00Table.ORDDEP_NAME; //SHOP00Table.SHOP_NAME1;
                //显示key
                ddl.DataValueField = ORDER_DEP00Table.ORDDEP_ID;
                //数据层次
                //绑定数据源
                ddl.DataSource = dt;
                ddl.DataBind();
                ddl.SelectedIndex = 0;
            }
            catch (Exception e)
            {
                // 记录日志
                CommonBll.WriteLog("", e);
            }
        }
Exemple #6
0
        /// <summary>
        /// 删除HEAD_SHOP_PAY_HISTORY表记录
        /// </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}", HEAD_SHOP_PAY_HISTORYTable.TableName, HEAD_SHOP_PAY_HISTORYTable.Id, id);

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

            delete.Delete(sql);

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

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了HEAD_SHOP_PAY_HISTORY表id为【" + id + "】的记录!");
            }
        }
        /// <summary>
        /// 更新在线用户缓存表中最后在线时间
        /// </summary>
        public void UpdateTime()
        {
            try
            {
                //设置更新字段
                var dic = new Dictionary <string, object>();
                dic.Add(OnlineUsersTable.UpdateTime, DateTime.Now);
                //条件
                List <ConditionFun.SqlqueryCondition> wheres = null;
                wheres = new List <ConditionFun.SqlqueryCondition>();
                wheres.Add(new ConditionFun.SqlqueryCondition(ConstraintType.And, OnlineUsersTable.UserHashKey, Comparison.Equals, GetUserHashKey()));
                //更新
                UpdateValue(null, dic, wheres, "更新{0}最后在线时间");

                //修改在线缓存表中的用户最后在线时间
                UpdateUserOnlineInfo(GetUserHashKey(), OnlineUsersTable.UpdateTime, DateTime.Now);
            }
            catch (Exception e)
            {
                //记录出错日志
                CommonBll.WriteLog("", e);
            }
        }
        /// <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表所有记录!");
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns>DataAccess.Model.WebConfig</returns>
        public DataAccess.Model.WebConfig GetModelForCache(long id)
        {
            try
            {
                //从缓存中读取指定Id记录
                var model = GetModelForCache(x => x.Id == id);

                if (model == null)
                {
                    //从数据库中读取
                    var tem = WebConfig.SingleOrDefault(x => x.Id == id);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);
                        SetModelForCache(model);
                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取WebConfig表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 判断用户是否被强迫离线[true是;false否]
        /// </summary>
        public bool IsOffline(Page page)
        {
            try
            {
                //获取当前用户Id
                var userinfoId = GetManagerId();

                //判断当前用户是否已经被系统清除
                if (userinfoId == 0)
                {
                    //通知用户
                    FineUI.Alert.Show("您太久没有操作已退出系统,请重新登录!", "检测通知", MessageBoxIcon.Information, "window.location.href='/WebManage/Login.aspx';");
                    return(true);
                }
                else
                {
                    //判断在线用户的Md5与当前用户存储的Md5是否一致
                    if (GenerateMd5() != CookieHelper.GetCookieValue(OnlineUsersTable.Md5))
                    {
                        CommonBll.WriteLog("当前帐号已经下线,用户Id【" + userinfoId + "】");

                        //通知用户
                        FineUI.Alert.Show("您的账号已经在另一处登录,当前账号已经下线!", "检测通知", MessageBoxIcon.Information, "window.location.href='/WebManage/Login.aspx';");
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                CommonBll.WriteLog("Logic.Systems.Manager.CheckIsOffline出现异常", ex);

                FineUI.Alert.Show("系统已经开始更新维护,请稍后重新登录!", "检测通知", MessageBoxIcon.Information, "window.location.href='/WebManage/Login.aspx';");
                return(true);
            }
        }
Exemple #11
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.SHOP_PRICE_AREA</returns>
        public DataAccess.Model.SHOP_PRICE_AREA GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.SHOP_PRICE_AREA           model      = null;
                Expression <Func <SHOP_PRICE_AREA, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "PRCAREA_ID":
                    model      = list.SingleOrDefault(x => x.PRCAREA_ID == (string)value);
                    expression = x => x.PRCAREA_ID == (string)value;
                    break;

                case "PRCAREA_NAME":
                    model      = list.SingleOrDefault(x => x.PRCAREA_NAME == (string)value);
                    expression = x => x.PRCAREA_NAME == (string)value;
                    break;

                case "ENABLE":
                    model      = list.SingleOrDefault(x => x.ENABLE == (byte)value);
                    expression = x => x.ENABLE == (byte)value;
                    break;

                case "PRCAREA_MEMO":
                    model      = list.SingleOrDefault(x => x.PRCAREA_MEMO == (string)value);
                    expression = x => x.PRCAREA_MEMO == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (byte)value);
                    expression = x => x.STATUS == (byte)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = SHOP_PRICE_AREA.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取SHOP_PRICE_AREA表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.V_TAKEIN11_PRODUCT00</returns>
        public DataAccess.Model.V_TAKEIN11_PRODUCT00 GetModelForCache(string conditionColName, object value)
        {
		try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.V_TAKEIN11_PRODUCT00 model = null;
                Expression<Func<V_TAKEIN11_PRODUCT00, bool>> expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
					case "Id" :
						model = list.SingleOrDefault(x => x.Id == (int)value);
                        expression = x => x.Id == (int)value;
                        break;
					case "SHOP_ID" :
						model = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                        expression = x => x.SHOP_ID == (string)value;
                        break;
					case "TAKEIN_ID" :
						model = list.SingleOrDefault(x => x.TAKEIN_ID == (string)value);
                        expression = x => x.TAKEIN_ID == (string)value;
                        break;
					case "SNo" :
						model = list.SingleOrDefault(x => x.SNo == (int)value);
                        expression = x => x.SNo == (int)value;
                        break;
					case "PROD_ID" :
						model = list.SingleOrDefault(x => x.PROD_ID == (string)value);
                        expression = x => x.PROD_ID == (string)value;
                        break;
					case "QUANTITY" :
						model = list.SingleOrDefault(x => x.QUANTITY == (decimal)value);
                        expression = x => x.QUANTITY == (decimal)value;
                        break;
					case "STD_UNIT" :
						model = list.SingleOrDefault(x => x.STD_UNIT == (string)value);
                        expression = x => x.STD_UNIT == (string)value;
                        break;
					case "STD_CONVERT" :
						model = list.SingleOrDefault(x => x.STD_CONVERT == (int)value);
                        expression = x => x.STD_CONVERT == (int)value;
                        break;
					case "STD_QUAN" :
						model = list.SingleOrDefault(x => x.STD_QUAN == (decimal)value);
                        expression = x => x.STD_QUAN == (decimal)value;
                        break;
					case "STD_PRICE" :
						model = list.SingleOrDefault(x => x.STD_PRICE == (decimal)value);
                        expression = x => x.STD_PRICE == (decimal)value;
                        break;
					case "Tax" :
						model = list.SingleOrDefault(x => x.Tax == (decimal)value);
                        expression = x => x.Tax == (decimal)value;
                        break;
					case "QUAN1" :
						model = list.SingleOrDefault(x => x.QUAN1 == (decimal)value);
                        expression = x => x.QUAN1 == (decimal)value;
                        break;
					case "QUAN2" :
						model = list.SingleOrDefault(x => x.QUAN2 == (decimal)value);
                        expression = x => x.QUAN2 == (decimal)value;
                        break;
					case "Item_DISC_Amt" :
						model = list.SingleOrDefault(x => x.Item_DISC_Amt == (decimal)value);
                        expression = x => x.Item_DISC_Amt == (decimal)value;
                        break;
					case "MEMO" :
						model = list.SingleOrDefault(x => x.MEMO == (string)value);
                        expression = x => x.MEMO == (string)value;
                        break;
					case "BAT_NO" :
						model = list.SingleOrDefault(x => x.BAT_NO == (string)value);
                        expression = x => x.BAT_NO == (string)value;
                        break;
					case "Exp_DateTime" :
						model = list.SingleOrDefault(x => x.Exp_DateTime == (DateTime)value);
                        expression = x => x.Exp_DateTime == (DateTime)value;
                        break;
					case "PROD_NAME1" :
						model = list.SingleOrDefault(x => x.PROD_NAME1 == (string)value);
                        expression = x => x.PROD_NAME1 == (string)value;
                        break;
					case "STD_UNIT_NAME" :
						model = list.SingleOrDefault(x => x.STD_UNIT_NAME == (string)value);
                        expression = x => x.STD_UNIT_NAME == (string)value;
                        break;
					case "SUP_COST" :
						model = list.SingleOrDefault(x => x.SUP_COST == (decimal)value);
                        expression = x => x.SUP_COST == (decimal)value;
                        break;
					case "SUP_COST1" :
						model = list.SingleOrDefault(x => x.SUP_COST1 == (decimal)value);
                        expression = x => x.SUP_COST1 == (decimal)value;
                        break;
					case "SUP_COST2" :
						model = list.SingleOrDefault(x => x.SUP_COST2 == (decimal)value);
                        expression = x => x.SUP_COST2 == (decimal)value;
                        break;
					case "UNIT_NAME" :
						model = list.SingleOrDefault(x => x.UNIT_NAME == (string)value);
                        expression = x => x.UNIT_NAME == (string)value;
                        break;
					case "UNIT_NAME1" :
						model = list.SingleOrDefault(x => x.UNIT_NAME1 == (string)value);
                        expression = x => x.UNIT_NAME1 == (string)value;
                        break;
					case "UNIT_NAME2" :
						model = list.SingleOrDefault(x => x.UNIT_NAME2 == (string)value);
                        expression = x => x.UNIT_NAME2 == (string)value;
                        break;
					case "PROD_CONVERT1" :
						model = list.SingleOrDefault(x => x.PROD_CONVERT1 == (int)value);
                        expression = x => x.PROD_CONVERT1 == (int)value;
                        break;
					case "PROD_CONVERT2" :
						model = list.SingleOrDefault(x => x.PROD_CONVERT2 == (int)value);
                        expression = x => x.PROD_CONVERT2 == (int)value;
                        break;
					case "PRCAREA_ID" :
						model = list.SingleOrDefault(x => x.PRCAREA_ID == (string)value);
                        expression = x => x.PRCAREA_ID == (string)value;
                        break;
					case "TAX_TYPE" :
						model = list.SingleOrDefault(x => x.TAX_TYPE == (byte)value);
                        expression = x => x.TAX_TYPE == (byte)value;
                        break;
					case "Tax_Num" :
						model = list.SingleOrDefault(x => x.Tax_Num == (int)value);
                        expression = x => x.Tax_Num == (int)value;
                        break;
					case "SHOP_NAME1" :
						model = list.SingleOrDefault(x => x.SHOP_NAME1 == (string)value);
                        expression = x => x.SHOP_NAME1 == (string)value;
                        break;

                    default :
                        return null;
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = V_TAKEIN11_PRODUCT00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return null;
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return model;
                    }
                }
                else
                {
                    return model;
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取V_TAKEIN11_PRODUCT00表记录时出现异常", e);

                return null;
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.UploadType</returns>
        public DataAccess.Model.UploadType GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.UploadType           model      = null;
                Expression <Func <UploadType, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "TypeKey":
                    model      = list.SingleOrDefault(x => x.TypeKey == (string)value);
                    expression = x => x.TypeKey == (string)value;
                    break;

                case "Name":
                    model      = list.SingleOrDefault(x => x.Name == (string)value);
                    expression = x => x.Name == (string)value;
                    break;

                case "Ext":
                    model      = list.SingleOrDefault(x => x.Ext == (string)value);
                    expression = x => x.Ext == (string)value;
                    break;

                case "IsSys":
                    model      = list.SingleOrDefault(x => x.IsSys == (byte)value);
                    expression = x => x.IsSys == (byte)value;
                    break;

                case "Manager_Id":
                    model      = list.SingleOrDefault(x => x.Manager_Id == (int)value);
                    expression = x => x.Manager_Id == (int)value;
                    break;

                case "Manager_CName":
                    model      = list.SingleOrDefault(x => x.Manager_CName == (string)value);
                    expression = x => x.Manager_CName == (string)value;
                    break;

                case "UpdateDate":
                    model      = list.SingleOrDefault(x => x.UpdateDate == (DateTime)value);
                    expression = x => x.UpdateDate == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = UploadType.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取UploadType表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.MenuInfo</returns>
        public DataAccess.Model.MenuInfo GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.MenuInfo           model      = null;
                Expression <Func <MenuInfo, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "Name":
                    model      = list.SingleOrDefault(x => x.Name == (string)value);
                    expression = x => x.Name == (string)value;
                    break;

                case "Url":
                    model      = list.SingleOrDefault(x => x.Url == (string)value);
                    expression = x => x.Url == (string)value;
                    break;

                case "ParentId":
                    model      = list.SingleOrDefault(x => x.ParentId == (int)value);
                    expression = x => x.ParentId == (int)value;
                    break;

                case "Sort":
                    model      = list.SingleOrDefault(x => x.Sort == (int)value);
                    expression = x => x.Sort == (int)value;
                    break;

                case "Depth":
                    model      = list.SingleOrDefault(x => x.Depth == (int)value);
                    expression = x => x.Depth == (int)value;
                    break;

                case "IsDisplay":
                    model      = list.SingleOrDefault(x => x.IsDisplay == (byte)value);
                    expression = x => x.IsDisplay == (byte)value;
                    break;

                case "IsMenu":
                    model      = list.SingleOrDefault(x => x.IsMenu == (byte)value);
                    expression = x => x.IsMenu == (byte)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = MenuInfo.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取MenuInfo表记录时出现异常", e);

                return(null);
            }
        }
Exemple #15
0
        /// <summary>
        /// 从IIS缓存中获取HEAD_SHOP_PAY_HISTORY表记录
        /// </summary>
        /// <param name="isCache">是否从缓存中读取</param>
        public IList <DataAccess.Model.HEAD_SHOP_PAY_HISTORY> GetList(bool isCache = true)
        {
            try
            {
                //判断是否使用缓存
                if (CommonBll.IsUseCache() && isCache)
                {
                    //检查指定缓存是否过期——缓存当天有效,第二天自动清空
                    if (CommonBll.CheckCacheIsExpired(const_CacheKey_Date))
                    {
                        //删除缓存
                        DelAllCache();
                    }

                    //从缓存中获取DataTable
                    var obj = CacheHelper.GetCache(const_CacheKey);
                    //如果缓存为null,则查询数据库
                    if (obj == null)
                    {
                        var list = GetList(false);

                        //将查询出来的数据存储到缓存中
                        CacheHelper.SetCache(const_CacheKey, list);
                        //存储当前时间
                        CacheHelper.SetCache(const_CacheKey_Date, DateTime.Now);

                        return(list);
                    }
                    //缓存中存在数据,则直接返回
                    else
                    {
                        return((IList <DataAccess.Model.HEAD_SHOP_PAY_HISTORY>)obj);
                    }
                }
                else
                {
                    //定义临时实体集
                    IList <DataAccess.Model.HEAD_SHOP_PAY_HISTORY> list = null;

                    //获取全表缓存加载条件表达式
                    var exp = GetExpression <HEAD_SHOP_PAY_HISTORY>();
                    //如果条件为空,则查询全表所有记录
                    if (exp == null)
                    {
                        //从数据库中获取所有记录
                        var all = HEAD_SHOP_PAY_HISTORY.All();
                        list = all == null ? null : Transform(all.ToList());
                    }
                    else
                    {
                        //从数据库中查询出指定条件的记录,并转换为指定实体集
                        var all = HEAD_SHOP_PAY_HISTORY.Find(exp);
                        list = all == null ? null : Transform(all);
                    }

                    return(list);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取HEAD_SHOP_PAY_HISTORY表记录时出现异常", e);
            }

            return(null);
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.TAKEIN00</returns>
        public DataAccess.Model.TAKEIN00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.TAKEIN00           model      = null;
                Expression <Func <TAKEIN00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "TAKEIN_ID":
                    model      = list.SingleOrDefault(x => x.TAKEIN_ID == (string)value);
                    expression = x => x.TAKEIN_ID == (string)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (int)value);
                    expression = x => x.STATUS == (int)value;
                    break;

                case "INPUT_DATE":
                    model      = list.SingleOrDefault(x => x.INPUT_DATE == (DateTime)value);
                    expression = x => x.INPUT_DATE == (DateTime)value;
                    break;

                case "STOCK_ID":
                    model      = list.SingleOrDefault(x => x.STOCK_ID == (string)value);
                    expression = x => x.STOCK_ID == (string)value;
                    break;

                case "USER_ID":
                    model      = list.SingleOrDefault(x => x.USER_ID == (string)value);
                    expression = x => x.USER_ID == (string)value;
                    break;

                case "APP_USER":
                    model      = list.SingleOrDefault(x => x.APP_USER == (string)value);
                    expression = x => x.APP_USER == (string)value;
                    break;

                case "APP_DATETIME":
                    model      = list.SingleOrDefault(x => x.APP_DATETIME == (DateTime)value);
                    expression = x => x.APP_DATETIME == (DateTime)value;
                    break;

                case "RELATE_ID":
                    model      = list.SingleOrDefault(x => x.RELATE_ID == (string)value);
                    expression = x => x.RELATE_ID == (string)value;
                    break;

                case "Memo":
                    model      = list.SingleOrDefault(x => x.Memo == (byte)value);
                    expression = x => x.Memo == (byte)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "Trans_STATUS":
                    model      = list.SingleOrDefault(x => x.Trans_STATUS == (byte)value);
                    expression = x => x.Trans_STATUS == (byte)value;
                    break;

                case "TAKEIN_TYPE":
                    model      = list.SingleOrDefault(x => x.TAKEIN_TYPE == (byte)value);
                    expression = x => x.TAKEIN_TYPE == (byte)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = TAKEIN00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取TAKEIN00表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.RECEIVABLES00</returns>
        public DataAccess.Model.RECEIVABLES00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.RECEIVABLES00           model      = null;
                Expression <Func <RECEIVABLES00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (long)value);
                    expression = x => x.Id == (long)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "OUT_ID":
                    model      = list.SingleOrDefault(x => x.OUT_ID == (string)value);
                    expression = x => x.OUT_ID == (string)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (int)value);
                    expression = x => x.STATUS == (int)value;
                    break;

                case "INPUT_DATE":
                    model      = list.SingleOrDefault(x => x.INPUT_DATE == (DateTime)value);
                    expression = x => x.INPUT_DATE == (DateTime)value;
                    break;

                case "IN_SHOP":
                    model      = list.SingleOrDefault(x => x.IN_SHOP == (string)value);
                    expression = x => x.IN_SHOP == (string)value;
                    break;

                case "USER_ID":
                    model      = list.SingleOrDefault(x => x.USER_ID == (string)value);
                    expression = x => x.USER_ID == (string)value;
                    break;

                case "APP_USER":
                    model      = list.SingleOrDefault(x => x.APP_USER == (string)value);
                    expression = x => x.APP_USER == (string)value;
                    break;

                case "APP_DATETIME":
                    model      = list.SingleOrDefault(x => x.APP_DATETIME == (DateTime)value);
                    expression = x => x.APP_DATETIME == (DateTime)value;
                    break;

                case "MEMO":
                    model      = list.SingleOrDefault(x => x.MEMO == (string)value);
                    expression = x => x.MEMO == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "BILL_AMOUNT":
                    model      = list.SingleOrDefault(x => x.BILL_AMOUNT == (decimal)value);
                    expression = x => x.BILL_AMOUNT == (decimal)value;
                    break;

                case "BILL_COST":
                    model      = list.SingleOrDefault(x => x.BILL_COST == (decimal)value);
                    expression = x => x.BILL_COST == (decimal)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = RECEIVABLES00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取RECEIVABLES00表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.UseLog</returns>
        public DataAccess.Model.UseLog GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.UseLog           model      = null;
                Expression <Func <UseLog, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "AddDate":
                    model      = list.SingleOrDefault(x => x.AddDate == (DateTime)value);
                    expression = x => x.AddDate == (DateTime)value;
                    break;

                case "Manager_Id":
                    model      = list.SingleOrDefault(x => x.Manager_Id == (int)value);
                    expression = x => x.Manager_Id == (int)value;
                    break;

                case "Manager_CName":
                    model      = list.SingleOrDefault(x => x.Manager_CName == (string)value);
                    expression = x => x.Manager_CName == (string)value;
                    break;

                case "Ip":
                    model      = list.SingleOrDefault(x => x.Ip == (string)value);
                    expression = x => x.Ip == (string)value;
                    break;

                case "MenuInfo_Id":
                    model      = list.SingleOrDefault(x => x.MenuInfo_Id == (int)value);
                    expression = x => x.MenuInfo_Id == (int)value;
                    break;

                case "MenuInfo_Name":
                    model      = list.SingleOrDefault(x => x.MenuInfo_Name == (string)value);
                    expression = x => x.MenuInfo_Name == (string)value;
                    break;

                case "Notes":
                    model      = list.SingleOrDefault(x => x.Notes == (string)value);
                    expression = x => x.Notes == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = UseLog.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取UseLog表记录时出现异常", e);

                return(null);
            }
        }
Exemple #19
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.COMPONENT00</returns>
        public DataAccess.Model.COMPONENT00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.COMPONENT00           model      = null;
                Expression <Func <COMPONENT00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "COM_ID":
                    model      = list.SingleOrDefault(x => x.COM_ID == (string)value);
                    expression = x => x.COM_ID == (string)value;
                    break;

                case "PROD_ID":
                    model      = list.SingleOrDefault(x => x.PROD_ID == (string)value);
                    expression = x => x.PROD_ID == (string)value;
                    break;

                case "Num":
                    model      = list.SingleOrDefault(x => x.Num == (int)value);
                    expression = x => x.Num == (int)value;
                    break;

                case "WEIGHT":
                    model      = list.SingleOrDefault(x => x.WEIGHT == (decimal)value);
                    expression = x => x.WEIGHT == (decimal)value;
                    break;

                case "DefaultCOM":
                    model      = list.SingleOrDefault(x => x.DefaultCOM == (byte)value);
                    expression = x => x.DefaultCOM == (byte)value;
                    break;

                case "QUAN1":
                    model      = list.SingleOrDefault(x => x.QUAN1 == (int)value);
                    expression = x => x.QUAN1 == (int)value;
                    break;

                case "QUAN2":
                    model      = list.SingleOrDefault(x => x.QUAN2 == (int)value);
                    expression = x => x.QUAN2 == (int)value;
                    break;

                case "DefQuan":
                    model      = list.SingleOrDefault(x => x.DefQuan == (int)value);
                    expression = x => x.DefQuan == (int)value;
                    break;

                case "BOM_Cost":
                    model      = list.SingleOrDefault(x => x.BOM_Cost == (decimal)value);
                    expression = x => x.BOM_Cost == (decimal)value;
                    break;

                case "ExpDateTime":
                    model      = list.SingleOrDefault(x => x.ExpDateTime == (DateTime)value);
                    expression = x => x.ExpDateTime == (DateTime)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = COMPONENT00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取COMPONENT00表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.WebConfig</returns>
        public DataAccess.Model.WebConfig GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.WebConfig           model      = null;
                Expression <Func <WebConfig, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "WebName":
                    model      = list.SingleOrDefault(x => x.WebName == (string)value);
                    expression = x => x.WebName == (string)value;
                    break;

                case "WebDomain":
                    model      = list.SingleOrDefault(x => x.WebDomain == (string)value);
                    expression = x => x.WebDomain == (string)value;
                    break;

                case "WebEmail":
                    model      = list.SingleOrDefault(x => x.WebEmail == (string)value);
                    expression = x => x.WebEmail == (string)value;
                    break;

                case "LoginLogReserveTime":
                    model      = list.SingleOrDefault(x => x.LoginLogReserveTime == (int)value);
                    expression = x => x.LoginLogReserveTime == (int)value;
                    break;

                case "UseLogReserveTime":
                    model      = list.SingleOrDefault(x => x.UseLogReserveTime == (int)value);
                    expression = x => x.UseLogReserveTime == (int)value;
                    break;

                case "EmailSmtp":
                    model      = list.SingleOrDefault(x => x.EmailSmtp == (string)value);
                    expression = x => x.EmailSmtp == (string)value;
                    break;

                case "EmailUserName":
                    model      = list.SingleOrDefault(x => x.EmailUserName == (string)value);
                    expression = x => x.EmailUserName == (string)value;
                    break;

                case "EmailPassWord":
                    model      = list.SingleOrDefault(x => x.EmailPassWord == (string)value);
                    expression = x => x.EmailPassWord == (string)value;
                    break;

                case "EmailDomain":
                    model      = list.SingleOrDefault(x => x.EmailDomain == (string)value);
                    expression = x => x.EmailDomain == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = WebConfig.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取WebConfig表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 判断用户是否超时退出(退出情况:1.系统更新,2.用户自动退出)
        /// </summary>
        public void IsTimeOut()
        {
            if (HttpContext.Current.Session == null || HttpContext.Current.Session[OnlineUsersTable.UserHashKey] == null)
            {
                try
                {
                    //不存在则表示Session失效了,重新从Cookies中加载
                    var userHashKey = CookieHelper.GetCookieValue(OnlineUsersTable.UserHashKey);
                    var md5         = CookieHelper.GetCookieValue(OnlineUsersTable.Md5);

                    //判断Cookies是否存在,存在则查询在线列表,重新获取用户信息
                    if (userHashKey.Length > 0 && md5.Length == 32)
                    {
                        //读取当前用户在线实体
                        var model = GetOnlineUsersModel(userHashKey);
                        //当前用户存在在线列表中
                        if (model != null)
                        {
                            //计算用户md5值
                            var key = GenerateMd5(model);

                            //判断用户的md5值是否正确
                            if (md5 == key)
                            {
                                //将UserHashKey存储到缓存中
                                HttpContext.Current.Session[OnlineUsersTable.UserHashKey] = userHashKey;
                                //获取用户权限并存储到用户Session里
                                PositionBll.GetInstence().SetUserPower(model.Position_Id);
                                //更新用户当前SessionId到在线表中
                                //UpdateUserOnlineInfo(model.Id + "", OnlineUsersTable.SessionId, HttpContext.Current.Session.SessionID);

                                return;
                            }
                            //添加用户下线记录
                            LoginLogBll.GetInstence().Save(model.Id, "用户【{0}】的账号已经在另一处登录,本次登陆下线!在线时间【{1}】");

                            //清除在线表里与当前用户同名的记录
                            Delete(null, x => x.Id == model.Id);

                            //清空Session
                            SessionHelper.RemoveSession(OnlineUsersTable.UserHashKey);
                            SessionHelper.RemoveSession(OnlineUsersTable.Md5);
                            SessionHelper.RemoveSession(PositionTable.PagePower);
                            SessionHelper.RemoveSession(PositionTable.ControlPower);
                            //删除Cookies
                            CookieHelper.ClearCookie(OnlineUsersTable.UserHashKey);
                            CookieHelper.ClearCookie(OnlineUsersTable.Md5);
                        }
                        else
                        {
                            //删除数据库记录与IIS缓存
                            Delete(null, x => x.UserHashKey == userHashKey);
                            //清空Session
                            SessionHelper.RemoveSession(OnlineUsersTable.UserHashKey);
                            SessionHelper.RemoveSession(OnlineUsersTable.Md5);
                            SessionHelper.RemoveSession(PositionTable.PagePower);
                            SessionHelper.RemoveSession(PositionTable.ControlPower);
                            //删除Cookies
                            CookieHelper.ClearCookie(OnlineUsersTable.UserHashKey);
                            CookieHelper.ClearCookie(OnlineUsersTable.Md5);
                        }
                    }
                }
                catch (Exception e)
                {
                    //出现异常,保存出错日志信息
                    CommonBll.WriteLog("", e);
                }

                //用户不存在,直接退出
                //FineUI.Alert.Show("当前用户登录已经过时或系统已更新,请重新登录!", "检测通知", MessageBoxIcon.Information, "top.location='Login.aspx'");
                //DotNet.Utilities.JsHelper.AlertAndParentUrl("当前用户登录已经过时或系统已更新,请重新登录!", "Login.aspx");
                HttpContext.Current.Response.Redirect("/WebManage/Login.aspx");
                HttpContext.Current.Response.End();
            }
        }
Exemple #22
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.OUT_BACK01</returns>
        public DataAccess.Model.OUT_BACK01 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.OUT_BACK01           model      = null;
                Expression <Func <OUT_BACK01, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "BK_ID":
                    model      = list.SingleOrDefault(x => x.BK_ID == (string)value);
                    expression = x => x.BK_ID == (string)value;
                    break;

                case "SNo":
                    model      = list.SingleOrDefault(x => x.SNo == (int)value);
                    expression = x => x.SNo == (int)value;
                    break;

                case "PROD_ID":
                    model      = list.SingleOrDefault(x => x.PROD_ID == (string)value);
                    expression = x => x.PROD_ID == (string)value;
                    break;

                case "QUANTITY":
                    model      = list.SingleOrDefault(x => x.QUANTITY == (double)value);
                    expression = x => x.QUANTITY == (double)value;
                    break;

                case "STD_TYPE":
                    model      = list.SingleOrDefault(x => x.STD_TYPE == (string)value);
                    expression = x => x.STD_TYPE == (string)value;
                    break;

                case "STD_UNIT":
                    model      = list.SingleOrDefault(x => x.STD_UNIT == (string)value);
                    expression = x => x.STD_UNIT == (string)value;
                    break;

                case "STD_CONVERT":
                    model      = list.SingleOrDefault(x => x.STD_CONVERT == (int)value);
                    expression = x => x.STD_CONVERT == (int)value;
                    break;

                case "STD_QUAN":
                    model      = list.SingleOrDefault(x => x.STD_QUAN == (decimal)value);
                    expression = x => x.STD_QUAN == (decimal)value;
                    break;

                case "STD_PRICE":
                    model      = list.SingleOrDefault(x => x.STD_PRICE == (decimal)value);
                    expression = x => x.STD_PRICE == (decimal)value;
                    break;

                case "COST":
                    model      = list.SingleOrDefault(x => x.COST == (decimal)value);
                    expression = x => x.COST == (decimal)value;
                    break;

                case "QUAN1":
                    model      = list.SingleOrDefault(x => x.QUAN1 == (decimal)value);
                    expression = x => x.QUAN1 == (decimal)value;
                    break;

                case "QUAN2":
                    model      = list.SingleOrDefault(x => x.QUAN2 == (decimal)value);
                    expression = x => x.QUAN2 == (decimal)value;
                    break;

                case "REASON_ID":
                    model      = list.SingleOrDefault(x => x.REASON_ID == (string)value);
                    expression = x => x.REASON_ID == (string)value;
                    break;

                case "MEMO":
                    model      = list.SingleOrDefault(x => x.MEMO == (string)value);
                    expression = x => x.MEMO == (string)value;
                    break;

                case "BAT_NO":
                    model      = list.SingleOrDefault(x => x.BAT_NO == (string)value);
                    expression = x => x.BAT_NO == (string)value;
                    break;

                case "Exp_DateTime":
                    model      = list.SingleOrDefault(x => x.Exp_DateTime == (DateTime)value);
                    expression = x => x.Exp_DateTime == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = OUT_BACK01.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取OUT_BACK01表记录时出现异常", e);

                return(null);
            }
        }
Exemple #23
0
        /***********************************************************************
        * 自定义函数                                                          *
        ***********************************************************************/
        #region 自定义函数

        #region 添加用户操作日志
        /// <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);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.STOCK01</returns>
        public DataAccess.Model.STOCK01 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.STOCK01           model      = null;
                Expression <Func <STOCK01, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "STOCK_ID":
                    model      = list.SingleOrDefault(x => x.STOCK_ID == (string)value);
                    expression = x => x.STOCK_ID == (string)value;
                    break;

                case "PROD_ID":
                    model      = list.SingleOrDefault(x => x.PROD_ID == (string)value);
                    expression = x => x.PROD_ID == (string)value;
                    break;

                case "STOCK_UNIT_QUAN":
                    model      = list.SingleOrDefault(x => x.STOCK_UNIT_QUAN == (decimal)value);
                    expression = x => x.STOCK_UNIT_QUAN == (decimal)value;
                    break;

                case "STOCK_UNIT1_QUAN":
                    model      = list.SingleOrDefault(x => x.STOCK_UNIT1_QUAN == (decimal)value);
                    expression = x => x.STOCK_UNIT1_QUAN == (decimal)value;
                    break;

                case "STOCK_UNIT2_QUAN":
                    model      = list.SingleOrDefault(x => x.STOCK_UNIT2_QUAN == (decimal)value);
                    expression = x => x.STOCK_UNIT2_QUAN == (decimal)value;
                    break;

                case "USABLE":
                    model      = list.SingleOrDefault(x => x.USABLE == (byte)value);
                    expression = x => x.USABLE == (byte)value;
                    break;

                case "Meno":
                    model      = list.SingleOrDefault(x => x.Meno == (string)value);
                    expression = x => x.Meno == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = STOCK01.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取STOCK01表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.CONTRACT00</returns>
        public DataAccess.Model.CONTRACT00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.CONTRACT00           model      = null;
                Expression <Func <CONTRACT00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "CONTRACT_ID":
                    model      = list.SingleOrDefault(x => x.CONTRACT_ID == (string)value);
                    expression = x => x.CONTRACT_ID == (string)value;
                    break;

                case "CONTRACT_TITLE":
                    model      = list.SingleOrDefault(x => x.CONTRACT_TITLE == (string)value);
                    expression = x => x.CONTRACT_TITLE == (string)value;
                    break;

                case "CONTRACTP_SIGN":
                    model      = list.SingleOrDefault(x => x.CONTRACTP_SIGN == (DateTime)value);
                    expression = x => x.CONTRACTP_SIGN == (DateTime)value;
                    break;

                case "CONTRACTP_STARTTIME":
                    model      = list.SingleOrDefault(x => x.CONTRACTP_STARTTIME == (DateTime)value);
                    expression = x => x.CONTRACTP_STARTTIME == (DateTime)value;
                    break;

                case "CONTRACTP_ENDTIME":
                    model      = list.SingleOrDefault(x => x.CONTRACTP_ENDTIME == (DateTime)value);
                    expression = x => x.CONTRACTP_ENDTIME == (DateTime)value;
                    break;

                case "USABLE":
                    model      = list.SingleOrDefault(x => x.USABLE == (byte)value);
                    expression = x => x.USABLE == (byte)value;
                    break;

                case "LOCK":
                    model      = list.SingleOrDefault(x => x.LOCK == (byte)value);
                    expression = x => x.LOCK == (byte)value;
                    break;

                case "FIRST_PARTY":
                    model      = list.SingleOrDefault(x => x.FIRST_PARTY == (string)value);
                    expression = x => x.FIRST_PARTY == (string)value;
                    break;

                case "SECEND_PARTY":
                    model      = list.SingleOrDefault(x => x.SECEND_PARTY == (string)value);
                    expression = x => x.SECEND_PARTY == (string)value;
                    break;

                case "Meno":
                    model      = list.SingleOrDefault(x => x.Meno == (string)value);
                    expression = x => x.Meno == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (byte)value);
                    expression = x => x.STATUS == (byte)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = CONTRACT00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取CONTRACT00表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.SUPPLIERS</returns>
        public DataAccess.Model.SUPPLIERS GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.SUPPLIERS           model      = null;
                Expression <Func <SUPPLIERS, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SUP_ID":
                    model      = list.SingleOrDefault(x => x.SUP_ID == (string)value);
                    expression = x => x.SUP_ID == (string)value;
                    break;

                case "SUP_NAME":
                    model      = list.SingleOrDefault(x => x.SUP_NAME == (string)value);
                    expression = x => x.SUP_NAME == (string)value;
                    break;

                case "SUP_NICKNAME":
                    model      = list.SingleOrDefault(x => x.SUP_NICKNAME == (string)value);
                    expression = x => x.SUP_NICKNAME == (string)value;
                    break;

                case "SUP_TYPE":
                    model      = list.SingleOrDefault(x => x.SUP_TYPE == (int)value);
                    expression = x => x.SUP_TYPE == (int)value;
                    break;

                case "SUP_ADD":
                    model      = list.SingleOrDefault(x => x.SUP_ADD == (string)value);
                    expression = x => x.SUP_ADD == (string)value;
                    break;

                case "SUP_TEL":
                    model      = list.SingleOrDefault(x => x.SUP_TEL == (string)value);
                    expression = x => x.SUP_TEL == (string)value;
                    break;

                case "SUP_Email":
                    model      = list.SingleOrDefault(x => x.SUP_Email == (string)value);
                    expression = x => x.SUP_Email == (string)value;
                    break;

                case "SUP_ZIP":
                    model      = list.SingleOrDefault(x => x.SUP_ZIP == (string)value);
                    expression = x => x.SUP_ZIP == (string)value;
                    break;

                case "SUP_Contact":
                    model      = list.SingleOrDefault(x => x.SUP_Contact == (string)value);
                    expression = x => x.SUP_Contact == (string)value;
                    break;

                case "SUP_Mobile":
                    model      = list.SingleOrDefault(x => x.SUP_Mobile == (string)value);
                    expression = x => x.SUP_Mobile == (string)value;
                    break;

                case "SUP_CODE_ID":
                    model      = list.SingleOrDefault(x => x.SUP_CODE_ID == (string)value);
                    expression = x => x.SUP_CODE_ID == (string)value;
                    break;

                case "SUP_BankName":
                    model      = list.SingleOrDefault(x => x.SUP_BankName == (string)value);
                    expression = x => x.SUP_BankName == (string)value;
                    break;

                case "SUP_BankID":
                    model      = list.SingleOrDefault(x => x.SUP_BankID == (string)value);
                    expression = x => x.SUP_BankID == (string)value;
                    break;

                case "SUP_PASSWORD":
                    model      = list.SingleOrDefault(x => x.SUP_PASSWORD == (string)value);
                    expression = x => x.SUP_PASSWORD == (string)value;
                    break;

                case "Send_DAY":
                    model      = list.SingleOrDefault(x => x.Send_DAY == (int)value);
                    expression = x => x.Send_DAY == (int)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = SUPPLIERS.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取SUPPLIERS表记录时出现异常", e);

                return(null);
            }
        }
Exemple #27
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.HEAD_SHOP_PAY_HISTORY</returns>
        public DataAccess.Model.HEAD_SHOP_PAY_HISTORY GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.HEAD_SHOP_PAY_HISTORY           model      = null;
                Expression <Func <HEAD_SHOP_PAY_HISTORY, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "BILL_AMOUNT":
                    model      = list.SingleOrDefault(x => x.BILL_AMOUNT == (decimal)value);
                    expression = x => x.BILL_AMOUNT == (decimal)value;
                    break;

                case "SUP_ID":
                    model      = list.SingleOrDefault(x => x.SUP_ID == (string)value);
                    expression = x => x.SUP_ID == (string)value;
                    break;

                case "BILL_ID":
                    model      = list.SingleOrDefault(x => x.BILL_ID == (string)value);
                    expression = x => x.BILL_ID == (string)value;
                    break;

                case "PAY_AMOUNT":
                    model      = list.SingleOrDefault(x => x.PAY_AMOUNT == (decimal)value);
                    expression = x => x.PAY_AMOUNT == (decimal)value;
                    break;

                case "PAY_METHOD":
                    model      = list.SingleOrDefault(x => x.PAY_METHOD == (byte)value);
                    expression = x => x.PAY_METHOD == (byte)value;
                    break;

                case "BILL_DATE":
                    model      = list.SingleOrDefault(x => x.BILL_DATE == (DateTime)value);
                    expression = x => x.BILL_DATE == (DateTime)value;
                    break;

                case "PAY_DATE":
                    model      = list.SingleOrDefault(x => x.PAY_DATE == (DateTime)value);
                    expression = x => x.PAY_DATE == (DateTime)value;
                    break;

                case "Memo":
                    model      = list.SingleOrDefault(x => x.Memo == (string)value);
                    expression = x => x.Memo == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = HEAD_SHOP_PAY_HISTORY.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取HEAD_SHOP_PAY_HISTORY表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.PARAMETER</returns>
        public DataAccess.Model.PARAMETER GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.PARAMETER           model      = null;
                Expression <Func <PARAMETER, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "KEY":
                    model      = list.SingleOrDefault(x => x.KEY == (string)value);
                    expression = x => x.KEY == (string)value;
                    break;

                case "VALUE":
                    model      = list.SingleOrDefault(x => x.VALUE == (string)value);
                    expression = x => x.VALUE == (string)value;
                    break;

                case "KEY_CN":
                    model      = list.SingleOrDefault(x => x.KEY_CN == (string)value);
                    expression = x => x.KEY_CN == (string)value;
                    break;

                case "MEMO":
                    model      = list.SingleOrDefault(x => x.MEMO == (string)value);
                    expression = x => x.MEMO == (string)value;
                    break;

                case "Area_Id":
                    model      = list.SingleOrDefault(x => x.Area_Id == (string)value);
                    expression = x => x.Area_Id == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = PARAMETER.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取PARAMETER表记录时出现异常", e);

                return(null);
            }
        }
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.V_PROD_DEP</returns>
        public DataAccess.Model.V_PROD_DEP GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.V_PROD_DEP           model      = null;
                Expression <Func <V_PROD_DEP, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "DEP_ID":
                    model      = list.SingleOrDefault(x => x.DEP_ID == (string)value);
                    expression = x => x.DEP_ID == (string)value;
                    break;

                case "DEP_NAME":
                    model      = list.SingleOrDefault(x => x.DEP_NAME == (string)value);
                    expression = x => x.DEP_NAME == (string)value;
                    break;

                case "ENABLE":
                    model      = list.SingleOrDefault(x => x.ENABLE == (byte)value);
                    expression = x => x.ENABLE == (byte)value;
                    break;

                case "KIND_ID":
                    model      = list.SingleOrDefault(x => x.KIND_ID == (string)value);
                    expression = x => x.KIND_ID == (string)value;
                    break;

                case "KIND_NAME":
                    model      = list.SingleOrDefault(x => x.KIND_NAME == (string)value);
                    expression = x => x.KIND_NAME == (string)value;
                    break;

                case "IsBool1":
                    model      = list.SingleOrDefault(x => x.IsBool1 == (byte)value);
                    expression = x => x.IsBool1 == (byte)value;
                    break;

                case "IsBool2":
                    model      = list.SingleOrDefault(x => x.IsBool2 == (byte)value);
                    expression = x => x.IsBool2 == (byte)value;
                    break;

                case "IsBool3":
                    model      = list.SingleOrDefault(x => x.IsBool3 == (byte)value);
                    expression = x => x.IsBool3 == (byte)value;
                    break;

                case "DEP_MEMO":
                    model      = list.SingleOrDefault(x => x.DEP_MEMO == (string)value);
                    expression = x => x.DEP_MEMO == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = V_PROD_DEP.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取V_PROD_DEP表记录时出现异常", e);

                return(null);
            }
        }
Exemple #30
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.V_COMPONENT01_PRODUCT00</returns>
        public DataAccess.Model.V_COMPONENT01_PRODUCT00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.V_COMPONENT01_PRODUCT00           model      = null;
                Expression <Func <V_COMPONENT01_PRODUCT00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "COM_ID":
                    model      = list.SingleOrDefault(x => x.COM_ID == (string)value);
                    expression = x => x.COM_ID == (string)value;
                    break;

                case "DETAIL_ID":
                    model      = list.SingleOrDefault(x => x.DETAIL_ID == (int)value);
                    expression = x => x.DETAIL_ID == (int)value;
                    break;

                case "PROD_ID":
                    model      = list.SingleOrDefault(x => x.PROD_ID == (string)value);
                    expression = x => x.PROD_ID == (string)value;
                    break;

                case "PROD_NAME1":
                    model      = list.SingleOrDefault(x => x.PROD_NAME1 == (string)value);
                    expression = x => x.PROD_NAME1 == (string)value;
                    break;

                case "QUANTITY":
                    model      = list.SingleOrDefault(x => x.QUANTITY == (decimal)value);
                    expression = x => x.QUANTITY == (decimal)value;
                    break;

                case "LQUANTITY":
                    model      = list.SingleOrDefault(x => x.LQUANTITY == (decimal)value);
                    expression = x => x.LQUANTITY == (decimal)value;
                    break;

                case "New_PROD_ID":
                    model      = list.SingleOrDefault(x => x.New_PROD_ID == (string)value);
                    expression = x => x.New_PROD_ID == (string)value;
                    break;

                case "New_PROD_NAME1":
                    model      = list.SingleOrDefault(x => x.New_PROD_NAME1 == (string)value);
                    expression = x => x.New_PROD_NAME1 == (string)value;
                    break;

                case "IsScales":
                    model      = list.SingleOrDefault(x => x.IsScales == (byte)value);
                    expression = x => x.IsScales == (byte)value;
                    break;

                case "PrtTag":
                    model      = list.SingleOrDefault(x => x.PrtTag == (byte)value);
                    expression = x => x.PrtTag == (byte)value;
                    break;

                case "IsFlag":
                    model      = list.SingleOrDefault(x => x.IsFlag == (byte)value);
                    expression = x => x.IsFlag == (byte)value;
                    break;

                case "Memo":
                    model      = list.SingleOrDefault(x => x.Memo == (string)value);
                    expression = x => x.Memo == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = V_COMPONENT01_PRODUCT00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取V_COMPONENT01_PRODUCT00表记录时出现异常", e);

                return(null);
            }
        }