Esempio n. 1
0
        /// <summary>
        /// 从缓存获取获取实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public static BaseDepartmentEntity GetObjectByCache(string id, bool fefreshCache = false)
        {
            BaseDepartmentEntity result = null;

            if (!string.IsNullOrEmpty(id))
            {
                string key = "D:" + id;

                if (!fefreshCache)
                {
                    result = GetCacheByKey(key);
                }

                if (result == null)
                {
                    BaseDepartmentManager manager = new BaseDepartmentManager();
                    result = manager.GetObject(id);
                    // 若是空的不用缓存,继续读取实体
                    if (result != null)
                    {
                        SetCache(result);
                    }
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseDepartmentEntity GetObject(BaseUserInfo userInfo, string id)
        {
            BaseDepartmentEntity result = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseDepartmentManager(dbHelper, userInfo);
                result      = manager.GetObject(id);
            });

            return(result);
        }