Esempio n. 1
0
        /// <summary>
        /// 更新缓存
        /// </summary>
        internal void UpdateCache()
        {
            dtUpdate = DateTime.Now;
            DataSet ds = new DataSet();

            try
            {
                //ds = Data.SqlHelper.GetDataSet(DBName, Sqls);
                ds = new CacheSelectDB().GetDataSet(Sqls);
                string[] tbl = Tbls.Split(';');
                for (int i = 0; i < ds.Tables.Count; i++)
                {
                    ds.Tables[i].TableName = tbl[i];
                }

                //LocalCache.SaveCacheToLocalFile(ds, "Cache-" + this.CacheName);
            }
            catch (Exception e)
            {
                //ds = LocalCache.ReadCacheFromLocalFile("Cache-" + this.CacheName);
                SysLog.WriteException("HHTravel.Base.Common.Framework.Cache.UpdateCache", e);
                //如果从数据获取缓存失败,并且从本地文件恢复也失败,此时向上抛出异常
                if (ds == null)
                {
                    throw e;
                }
            }
            lock (dsCache)
            {
                dsCache = ds;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新缓存
        /// </summary>
        internal void UpdateCache()
        {
            dtUpdate = DateTime.Now;
            DataSet ds = new DataSet();
            try
            {
                //ds = Data.SqlHelper.GetDataSet(DBName, Sqls);
                ds = new CacheSelectDB().GetDataSet(Sqls);
                string[] tbl = Tbls.Split(';');
                for (int i = 0; i < ds.Tables.Count; i++)
                {
                    ds.Tables[i].TableName = tbl[i];
                }

                //LocalCache.SaveCacheToLocalFile(ds, "Cache-" + this.CacheName);
            }
            catch (Exception e)
            {
                //ds = LocalCache.ReadCacheFromLocalFile("Cache-" + this.CacheName);
                SysLog.WriteException("HHTravel.Base.Common.Framework.Cache.UpdateCache", e);
                //如果从数据获取缓存失败,并且从本地文件恢复也失败,此时向上抛出异常
                if (ds == null) throw e;
            }
            lock (dsCache)
            {
                dsCache = ds;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// find user url list by module list of one's permission
        /// </summary>
        private static IEnumerable <string> GetUrlListByUserId(int intUserId)
        {
            var roleId = 0;

            DataRow[] userRows = GetCache().Tables["Emp_User"].Select(string.Format(@"UserId='{0}'", intUserId));
            if (userRows.Length > 0)
            {
                int       groupId  = Convert.ToInt32(userRows[0]["GroupID"]);
                DataRow[] roleRows = GetCache().Tables["Admin_Role_Group"].Select(string.Format("GroupID={0}", groupId));
                foreach (DataRow roleItem in roleRows)
                {
                    roleId = Convert.ToInt32(roleItem["RoleId"]);
                }
            }
            var urlList = new List <string>();
            var Sqls    = new StringBuilder();

            Sqls.Append("SELECT Url FROM Admin_Permission WITH(NOLOCK) WHERE PermissionID in (");
            Sqls.AppendFormat("SELECT permissionid FROM Admin_RolePermissionRel WITH(NOLOCK) WHERE ROLEID={0}) and permissiontype=4", roleId);
            try
            {
                var ds = new CacheSelectDB().GetDataSet(Sqls.ToString());
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    var url = ds.Tables[0].Rows[i]["Url"].ToString().Trim();
                    urlList.Add(url);
                }
            }
            catch (Exception ex)
            {
                //Logging.SysLog.WriteException("Common.Framework.GetUrlListByUserId", ex);
                HHLogHelperV2.ERRORExecption("Common.Framework.GetUrlListByUserId", ex);
            }
            return(urlList);
        }
Esempio n. 4
0
 /// <summary>
 /// find user url list by module list of one's permission
 /// </summary>
 private static IEnumerable<string> GetUrlListByUserId(int intUserId)
 {
     var roleId = 0;
     DataRow[] userRows = GetCache().Tables["Emp_User"].Select(string.Format(@"UserId='{0}'", intUserId));
     if (userRows.Length > 0)
     {
         int groupId = Convert.ToInt32(userRows[0]["GroupID"]);
         DataRow[] roleRows = GetCache().Tables["Admin_Role_Group"].Select(string.Format("GroupID={0}", groupId));
         foreach (DataRow roleItem in roleRows)
         {
             roleId = Convert.ToInt32(roleItem["RoleId"]);
         }
     }
     var urlList = new List<string>();
     var Sqls = new StringBuilder();
     Sqls.Append("SELECT Url FROM Admin_Permission WITH(NOLOCK) WHERE PermissionID in (");
     Sqls.AppendFormat("SELECT permissionid FROM Admin_RolePermissionRel WITH(NOLOCK) WHERE ROLEID={0}) and permissiontype=4", roleId);
     try
     {
         var ds = new CacheSelectDB().GetDataSet(Sqls.ToString());
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             var url = ds.Tables[0].Rows[i]["Url"].ToString().Trim();
             urlList.Add(url);
         }
     }
     catch (Exception ex)
     {
         //Logging.SysLog.WriteException("Common.Framework.GetUrlListByUserId", ex);
         HHLogHelperV2.ERRORExecption("Common.Framework.GetUrlListByUserId", ex);
     }
     return urlList;
 }