//从缓存中获取K_SysModule表 public DataTable GetModeFromCache() { if (AppCache.IsExist("ModeCache")) { return((DataTable)AppCache.Get("ModeCache")); } else { DataTable dt = GetList("Cache", Utils.getOneParams("")); AppCache.Add("ModeCache", dt, "K_SysModule"); return(dt); } }
protected DataSet GetDataList() { if (AppCache.IsExist("SysMenuList")) { ds = (DataSet)AppCache.Get("SysMenuList"); } else { ds = bll.GetList(""); AppCache.AddCache("SysMenuList", ds); } return(ds); }
//从缓存中获取K_SysRolePermit表 public DataTable GetRolePermitFromCache() { if (AppCache.IsExist("RolePermitCache")) { return((DataTable)AppCache.Get("RolePermitCache")); } else { DataTable dt = GetList("Cache", Utils.getOneParams("")); AppCache.Add("RolePermitCache", dt, "K_SysRolePermit"); return(dt); } }
//操作缓存 public DataTable GetModuleActionFromCache() { if (AppCache.IsExist("ModuleActionCache")) { return((DataTable)AppCache.Get("ModuleActionCache")); } else { DataTable dt = GetList("ACTIONAll", Utils.getOneParams("")); AppCache.AddCache("ModuleActionCache", dt, 1440); return(dt); } }
//用户组角色 public DataTable GetUserGroupRoleFromCache() { if (AppCache.IsExist("UserGroupRoleCache")) { return((DataTable)AppCache.Get("UserGroupRoleCache")); } else { DataTable dt = GetList("GROUPROLEAll", Utils.getOneParams("")); AppCache.AddCache("UserGroupRoleCache", dt, 1440); return(dt); } }
public DataTable GetAccountPermitFromCache() { if (AppCache.IsExist("AccountPermitCache")) { return((DataTable)AppCache.Get("AccountPermitCache")); } else { DataTable dt = GetList("USERPERMITAll", Utils.getOneParams("")); AppCache.AddCache("AccountPermitCache", dt, 1440); return(dt); } }
protected void SaveRightDate(string strNodeID) { //得到操作列表 KingTop.BLL.SysManage.ActionPermit bllActionPer = new ActionPermit(); DataTable dt2 = bllActionPer.GetList("MODULE", Utils.getOneParams(ddlModel.SelectedValue)); if (AppCache.IsExist("ModuleActionCache")) { AppCache.Remove("ModuleActionCache"); } //if (AppCache.IsExist("ModeNodeAndModuleCache")) //{ // AppCache.Remove("ModeNodeAndModuleCache"); //} if (AppCache.IsExist("UserGroupPermitCache")) { AppCache.Remove("UserGroupPermitCache"); } for (int i = 0; i < grvRight.Rows.Count; i++) { ArrayList arrRightSet = new ArrayList(); foreach (DataRow dr in dt2.Rows) { string ckbid = "ckb" + dr["ID"].ToString(); CheckBox ckb = (CheckBox)grvRight.Rows[i].FindControl(ckbid); if (ckb.Checked && ckb.Enabled == true) { arrRightSet.Add(dr["ID"].ToString()); } } //更新权限 if (arrRightSet.Count > 0) { ColumnRightTool coluRightTool = new ColumnRightTool(); string strUserGroupCode = grvRight.Rows[i].Cells[0].Text; coluRightTool.SaveData(strUserGroupCode, arrRightSet, strNodeID); } } }
/// <summary> /// 获取菜单个 /// </summary> /// <returns></returns> public DataTable GetSysmenu() { DataTable dt = new DataTable(); try { if (AppCache.IsExist("SysmenuList")) { dt = (DataTable)AppCache.Get("SysmenuList"); } else { dt = bll.GetList("sysmenutab", " scode,surl ", "scode", 1000, 1, 0, 0, ""); AppCache.AddCache("SysmenuList", dt, 1); } } catch { dt = null; } return(dt); }
/// <summary> /// 获取权限表 /// </summary> /// <returns></returns> public DataTable GetSyspermission() { DataTable dt = new DataTable(); try { if (AppCache.IsExist("SyspermissionList")) { dt = (DataTable)AppCache.Get("SyspermissionList"); } else { dt = bll.GetList("syspermissiontab", " roleid,spcode ", "roleid", 1000, 1, 0, 0, ""); AppCache.AddCache("SyspermissionList", dt, 1); } } catch { dt = null; } return(dt); }
/// <summary> /// 获取用户组,采用缓存cache /// </summary> /// <returns></returns> public DataTable GetSystem() { DataTable dt = new DataTable(); try { if (AppCache.IsExist("SystemList")) { dt = (DataTable)AppCache.Get("SystemList"); } else { dt = bll.GetList("system", "employeeid,tem", "employeeid", 1000, 1, 0, 0, ""); AppCache.AddCache("SystemList", dt, 1); } } catch { dt = null; } return(dt); }
public string GetManageDir() { string re = ""; if (AppCache.IsExist("CacheManageDir")) { re = KingTop.Common.AppCache.Get("CacheManageDir").ToString(); } else { string siteParamPath = Server.MapPath("/sysadmin/Configuraion/SiteInfoManage.config"); re = Utils.XmlRead(siteParamPath, "/SiteInfoManage/ManageDir", "").ToLower(); AppCache.AddCache("CacheManageDir", re, 144000); } if (re != "") { re = "../" + re + "/"; } return(re); }
/// <summary> /// 获取所有菜单,采用缓存cache /// </summary> /// <returns></returns> public DataTable GetMenuCompetence() { DataTable dt = new DataTable(); try { if (AppCache.IsExist("MemberMenu")) { dt = (DataTable)AppCache.Get("MemberMenu"); } else { dt = dal.GetList("*", "MenuTab", "where MCheck=1 and MCode like 'M%' order by Sort "); AppCache.AddCache("MemberMenu", dt, 24) ; } } catch { dt = null; } return dt; }
/// <summary> /// 取出所有权限,放入cache /// </summary> /// <returns></returns> public DataTable GetMemberCompetenceAll() { DataTable dt = new DataTable(); try { if (AppCache.IsExist("MemberCompetenceAll")) { dt = (DataTable)AppCache.Get("MemberCompetenceAll"); } else { dt = dal.GetList("PCode,ManageTypeID,MemberGradeID", "SystemPermissionTab", ""); AppCache.AddCache("MemberCompetenceAll", dt, 24); } } catch { dt = null; } return dt; }
private void On_Upload(HttpPostedFile file) { if (file != null && file.ContentLength > 0) { #region 变量 strParam = Request.QueryString["InitParam"]; initArr = Utils.strSplit(strParam, "_tp_"); SiteDir = GetUrlParam("SiteDir", initArr); SaveFileKey = GetUrlParam("CacheKey", initArr); string ImgSet = GetUrlParam("ImgSet", initArr); string[] arrImgSet = ImgSet.Split(','); thumbWidth = Utils.ParseInt(arrImgSet[0], 0); thumbHeight = Utils.ParseInt(arrImgSet[1], 0); IsWater = Utils.ParseInt(arrImgSet[2], 0); string UPType = GetUrlParam("UpType", initArr); if (string.IsNullOrEmpty(UPType)) { UPType = "image"; } string saveType = GetUrlParam("SaveType", initArr); // 保存文件名类型,1=用上传文件名保存,否则用系统时间重命名保存 string noExt = SystemConst.NOT_ALLOWED_UPLOAD_TYPE; // 不允许上传类型 string fileName = string.Empty; // 文件名 string saveName = DateTime.Now.ToString("yyyyMMddHHmmss"); // 上传文件名 string fileExt = string.Empty; // 上传文件扩展名 fileName = Path.GetFileName(file.FileName); fileExt = Path.GetExtension(fileName).ToLower(); //上传文件扩展名 #endregion if (noExt.IndexOf(fileExt) != -1) { System.Web.HttpContext.Current.Response.Write("改文件类型不允许上传!"); System.Web.HttpContext.Current.Response.End(); } SavePath = string.IsNullOrEmpty(SiteDir) == true ? uploadobj.ImageSavePath + "/" + UPType + "s" : uploadobj.ImageSavePath + "/" + SiteDir + "/" + UPType + "s"; URL = GetUploadUrl(uploadobj.ImageUrl, UPType + "s", SavePath); string reFilePath = URL; // 返回文件路径,如果保存路径填写的是 if (SavePath.IndexOf(":") == -1) //判断输入的是虚拟路径 { SavePath = Server.MapPath(GetVirtualPath + SavePath); } SavePath = SavePath + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } if (saveType == "1") //使用原文件名进行保存到服务器 { int fileNameLength = fileName.LastIndexOf("."); saveName = fileName.Substring(0, fileNameLength); } fileName = SavePath + saveName + fileExt; URL = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + saveName + fileExt; if (File.Exists(fileName) && saveType == "1") { File.Delete(fileName); } try { file.SaveAs(fileName); //保存至服务器 if (thumbWidth > 0 || thumbHeight > 0) //判断是否上传的是否需生成缩略图 { string thumbMode = "HW"; if (thumbWidth > 0 && thumbHeight == 0) { thumbMode = "W"; } else if (thumbWidth == 0 && thumbHeight > 0) { thumbMode = "H"; } KingTop.WEB.SysAdmin.UploadBase.MakeThumbnail(fileName, fileName + ".gif", thumbWidth, thumbHeight, thumbMode); // 生成缩略图方法 } if (IsWater == 1) //如果上传图片,则判断是否需要打水印 { KingTop.WEB.SysAdmin.UploadBase.ImageWater(uploadobj, fileName); } } catch (Exception ex) { ex.ToString(); } //缓存返回值 string returnStr; if (AppCache.IsExist(SaveFileKey)) { returnStr = AppCache.Get(SaveFileKey) + "," + URL; AppCache.Remove(SaveFileKey); } else { returnStr = URL; } AppCache.AddCache(SaveFileKey, returnStr, 1200); } }
protected void Page_Load(object sender, EventArgs e) { string fileExt = string.Empty; string fileName = string.Empty; string originalName = null; Response.ContentType = "text/plain"; Response.Expires = -1; //如果设置了水印和缩略图,则先将设置保存到cache,在上传图片 string paramValue = Request["paramValue"]; string paramKey = Request["paramKey"]; if (!string.IsNullOrEmpty(paramValue) && !string.IsNullOrEmpty(paramKey)) { AppCache.AddCache(paramKey, paramValue, 60); Response.Write("OK"); return; } //图片上传 try { HttpPostedFile postedFile = Request.Files[0]; SiteDir = GetUrlParam("SiteDir"); string saveType = GetUrlParam("SaveType"); string key = GetUrlParam("param1"); string ImgSet = GetUrlParam("param2"); if (!string.IsNullOrEmpty(key) && AppCache.IsExist(key)) { ImgSet = AppCache.Get(key).ToString(); } if (string.IsNullOrEmpty(ImgSet)) { ImgSet = "0,0,0"; // } string[] arrImgSet = ImgSet.Split(','); thumbWidth = Utils.ParseInt(arrImgSet[0], 0); thumbHeight = Utils.ParseInt(arrImgSet[1], 0); IsWater = Utils.ParseInt(arrImgSet[2], 0); string UPType = GetUrlParam("UpType"); fileName = postedFile.FileName; originalName = fileName; fileExt = Path.GetExtension(fileName).ToLower(); string saveName = DateTime.Now.ToString("yyyyMMddhhmmsfff"); // 上传文件名 if (string.IsNullOrEmpty(UPType)) { UPType = "image"; } uploadobj = KingTop.Config.Upload.GetConfig(GetUploadImgPath); //上传设置信息 if (uploadobj.IsEnableUpload != "1") // 判断是否允许上传 { state = "已经关闭上传功能,请联系管理员"; } SavePath = "{0}"; //文件保存在站点目录下,用下面代码,注释后将不分站点保存 //if (!string.IsNullOrEmpty(SiteDir)) //{ // SavePath += "/" + SiteDir; //} SavePath += "{1}"; switch (UPType) { case "media": //视频,flash SavePath = string.Format(SavePath, uploadobj.MediaSavePath, "/Medias"); URL = GetUploadUrl(uploadobj.MediaUrl, "Medias", SavePath); AllowExt = "*.wav;*.avi;*.mpg;*.mpeg;*.wma;*.flv;*.swf"; MaxSize = 100; break; case "file": //文件 SavePath = string.Format(SavePath, uploadobj.FileSavePath, "/Files"); URL = GetUploadUrl(uploadobj.FileUrl, "Files", SavePath); AllowExt = uploadobj.UploadFilesType; break; case "image": //图片 SavePath = string.Format(SavePath, uploadobj.ImageSavePath, "/Images"); URL = GetUploadUrl(uploadobj.ImageUrl, "Images", SavePath); AllowExt = uploadobj.UploadImageType; break; case "flash": //flash SavePath = string.Format(SavePath, uploadobj.MediaSavePath, "/Medias"); URL = GetUploadUrl(uploadobj.MediaUrl, "Medias", SavePath); AllowExt = uploadobj.UploadMediaType; break; default: break; } if (AllowExt.IndexOf(fileExt.Replace(".", "")) == -1) { state = "文件类型不允许上传!"; } if (SystemConst.NOT_ALLOWED_UPLOAD_TYPE.IndexOf(fileExt.Replace(".", "")) != -1) { state = "文件类型不允许上传!"; } if (postedFile.ContentLength > MaxSize * 1024 * 1024) { state = "文件大小超出网站限制!"; } string reFilePath = URL; // 返回文件路径,如果保存路径填写的是绝对地址,则返回文件路径为域名+系统创建路径,如果为相对地址,则为:域名+相对路径+系统创建路径 if (SavePath.IndexOf(":") == -1) //判断输入的是虚拟路径 { SavePath = Server.MapPath(GetVirtualPath + SavePath); } SavePath = SavePath + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } if (saveType == "1") //使用原文件名进行保存到服务器 { int fileNameLength = fileName.LastIndexOf("."); saveName = fileName.Substring(0, fileNameLength); } fileName = SavePath + saveName + fileExt; URL += DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + saveName + fileExt; if (File.Exists(fileName) && saveType == "1") { File.Delete(fileName); } postedFile.SaveAs(fileName); //保存至服务器 if (thumbWidth > 0 || thumbHeight > 0) //判断是否上传的是否需生成缩略图 { string thumbMode = "HW"; if (thumbWidth > 0 && thumbHeight == 0) { thumbMode = "W"; } else if (thumbWidth == 0 && thumbHeight > 0) { thumbMode = "H"; } KingTop.WEB.SysAdmin.UploadBase.MakeThumbnail(fileName, fileName + ".gif", thumbWidth, thumbHeight, thumbMode); // 生成缩略图方法 } if (IsWater == 1) //如果上传图片,则判断是否需要打水印 { KingTop.WEB.SysAdmin.UploadBase.ImageWater(uploadobj, fileName); } } catch (Exception ex) { state = ex.Message; } if (Request["action"] == "tmpImg") { Response.Write("<script>alert('bbbb');parent.ue_callback('" + URL + "','" + state + "')</script>");//回调函数 } else { Response.Write("{'state':'" + state + "','url':'" + URL + "','fileType':'" + fileExt + "','original':'" + originalName + "'}"); //向浏览器返回数据json数据 } }