Пример #1
0
        /// <summary>
        /// 添加与编辑RefTable记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">RefTable表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, RefTable model, string content = null, bool isCache = true, bool isAddUseLog = true)
        {
            try {
                //保存
                model.Save();

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

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

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

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
Пример #2
0
        public void Write(GameBoxWriter w, ClassIDRemap remap)
        {
            using (MemoryStream ms = new MemoryStream())
                using (GameBoxWriter bodyW = new GameBoxWriter(ms))
                {
                    (Body as ILookbackable).IdWritten = false;
                    (Body as ILookbackable).IdStrings.Clear();
                    Body.AuxilaryNodes.Clear();

                    Log.Write("Writing the body...");

                    Body.Write(bodyW, remap); // Body is written first so that the aux node count is determined properly

                    Log.Write("Writing the header...");

                    (Header as ILookbackable).IdWritten = false;
                    (Header as ILookbackable).IdStrings.Clear();
                    Header.Write(w, Body.AuxilaryNodes.Count + 1, remap);

                    Log.Write("Writing the reference table...");

                    if (RefTable == null)
                    {
                        w.Write(0);
                    }
                    else
                    {
                        RefTable.Write(w);
                    }

                    w.Write(ms.ToArray(), 0, (int)ms.Length);
                }
        }
Пример #3
0
 /// <summary>
 /// 获取指定Id记录
 /// </summary>
 /// <param name="id">主键Id</param>
 /// <param name="isCache">是否从缓存中读取</param>
 /// <returns>DataAccess.Model.RefTable</returns>
 public DataAccess.Model.RefTable GetModel(long id, bool isCache = true)
 {
     //判断是否使用缓存
     if (CommonBll.IsUseCache() && isCache)
     {
         //从缓存中获取List
         var list = GetList();
         if (list == null || list.Count == 0)
         {
             return(null);
         }
         else
         {
             //在List查询指定主键Id的记录
             return(list.SingleOrDefault(x => x.Id == id));
         }
     }
     else
     {
         //从数据库中直接读取
         var model = RefTable.SingleOrDefault(x => x.Id == id);
         if (model == null)
         {
             return(null);
         }
         else
         {
             //对查询出来的实体进行转换
             return(Transform(model));
         }
     }
 }
Пример #4
0
        /// <summary>
        /// 从IIS缓存中获取指定条件的记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.RefTable</returns>
        public DataAccess.Model.RefTable GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.RefTable           model      = null;
                Expression <Func <RefTable, bool> > expression = null;

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

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


                default:
                    return(null);
                }

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

                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// 将RefTable记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.RefTable)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.RefTable</returns>
        public DataAccess.Model.RefTable Transform(RefTable model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new DataAccess.Model.RefTable
            {
                Taxa_Id = model.Taxa_Id,

                Article_Id = model.Article_Id,
            });
        }
Пример #6
0
        /// <summary>
        /// 判断指定主键Id的记录是否存在——在IIS缓存或数据库中查找
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns></returns>
        public bool Exist(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                return(Exist(x => x.Id == id));
            }

            //从数据库中查找
            return(RefTable.Exists(x => x.Id == id));
        }
Пример #7
0
        public bool AddReferal(JobReferalViewModel jobReferal)
        {
            RefTable refTablev = new RefTable()
            {
                // pEmployeId = jobReferal.pEmployeId,
                JobId     = jobReferal.JobId,
                pEmailId  = jobReferal.pEmailId,
                pLocation = jobReferal.pLocation,
                pJobName  = jobReferal.pJobName,
                pPhoneNo  = jobReferal.pPhoneNo,
                pSkillSet = jobReferal.pSkillSet,
                pName     = jobReferal.pName
            };

            db.RefTables.Add(refTablev);
            db.SaveChanges();
            return(true);
        }
Пример #8
0
        public override int GetHashCode()
        {
            int hashCode = 17; // we *know* we are using this in a dictionary, so pre-compute this

            hashCode = hashCode * 23 + Id.GetHashCode();
            hashCode = hashCode * 23 + (Fid == null ? 0 : Fid.GetHashCode());
            hashCode = hashCode * 23 + (EnableDate == null ? 0 : EnableDate.GetHashCode());
            hashCode = hashCode * 23 + (DisableDate == null ? 0 : DisableDate.GetHashCode());
            hashCode = hashCode * 23 + Dr.GetHashCode();
            hashCode = hashCode * 23 + Ts.GetHashCode();
            hashCode = hashCode * 23 + (CreateBy == null ? 0 : CreateBy.GetHashCode());
            hashCode = hashCode * 23 + (CreateDate == null ? 0 : CreateDate.GetHashCode());
            hashCode = hashCode * 23 + (CreateName == null ? 0 : CreateName.GetHashCode());
            hashCode = hashCode * 23 + (UpdateBy == null ? 0 : UpdateBy.GetHashCode());
            hashCode = hashCode * 23 + (UpdateDate == null ? 0 : UpdateDate.GetHashCode());
            hashCode = hashCode * 23 + (UpdateName == null ? 0 : UpdateName.GetHashCode());
            hashCode = hashCode * 23 + (TableName == null ? 0 : TableName.GetHashCode());
            hashCode = hashCode * 23 + (ColName == null ? 0 : ColName.GetHashCode());
            hashCode = hashCode * 23 + (ColComment == null ? 0 : ColComment.GetHashCode());
            hashCode = hashCode * 23 + (ColDefault == null ? 0 : ColDefault.GetHashCode());
            hashCode = hashCode * 23 + (ColType == null ? 0 : ColType.GetHashCode());
            hashCode = hashCode * 23 + ColProperty.GetHashCode();
            hashCode = hashCode * 23 + ColLength.GetHashCode();
            hashCode = hashCode * 23 + DisplayWidth.GetHashCode();
            hashCode = hashCode * 23 + ColOrder.GetHashCode();
            hashCode = hashCode * 23 + ColPrecision.GetHashCode();
            hashCode = hashCode * 23 + NullAble.GetHashCode();
            hashCode = hashCode * 23 + ShowAble.GetHashCode();
            hashCode = hashCode * 23 + IsDefaultCol.GetHashCode();
            hashCode = hashCode * 23 + (CtrlType == null ? 0 : CtrlType.GetHashCode());
            hashCode = hashCode * 23 + (RefTable == null ? 0 : RefTable.GetHashCode());
            hashCode = hashCode * 23 + (RefID == null ? 0 : RefID.GetHashCode());
            hashCode = hashCode * 23 + (RefCode == null ? 0 : RefCode.GetHashCode());
            hashCode = hashCode * 23 + (RefName == null ? 0 : RefName.GetHashCode());
            hashCode = hashCode * 23 + (RefCondition == null ? 0 : RefCondition.GetHashCode());
            hashCode = hashCode * 23 + (RefCols == null ? 0 : RefCols.GetHashCode());
            hashCode = hashCode * 23 + (RefType == null ? 0 : RefType.GetHashCode());
            hashCode = hashCode * 23 + (MainTable == null ? 0 : RefType.GetHashCode());
            hashCode = hashCode * 23 + (MainTableCol == null ? 0 : MainTableCol.GetHashCode());
            hashCode = hashCode * 23 + (CalculationExpr == null ? 0 : CalculationExpr.GetHashCode());
            return(hashCode);
        }
Пример #9
0
        /// <summary>
        /// 删除RefTable表记录——如果使用了缓存,删除成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="expression">条件语句</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, Expression <Func <RefTable, bool> > expression, bool isAddUseLog = true)
        {
            //执行删除
            RefTable.Delete(expression);

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

            if (isAddUseLog)
            {
                //添加用户操作记录
                CommonBll.WriteLog("{0}删除了RefTable表记录!");
                //UseLogBll.GetInstence().Save(page, "{0}删除了RefTable表记录!");
            }
        }
Пример #10
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns>DataAccess.Model.RefTable</returns>
        public DataAccess.Model.RefTable GetModelForCache(long id)
        {
            try
            {
                //从缓存中读取指定Id记录
                var model = GetModelForCache(x => x.Id == id);

                if (model == null)
                {
                    //从数据库中读取
                    var tem = RefTable.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缓存中获取RefTable表记录时出现异常", e);

                return(null);
            }
        }
Пример #11
0
        /// <summary>
        /// 从IIS缓存中获取RefTable表记录
        /// </summary>
        /// <param name="isCache">是否从缓存中读取</param>
        public IList <DataAccess.Model.RefTable> 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.RefTable>)obj);
                    }
                }
                else
                {
                    //定义临时实体集
                    IList <DataAccess.Model.RefTable> list = null;

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

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

            return(null);
        }
Пример #12
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(RefTable model)
 {
     SetModelForCache(Transform(model));
 }