/// <summary> /// 所有数据字典信息 /// </summary> /// <returns></returns> public static List <TB_System_Dictionary> GetAllDictionaries() { List <TB_System_Dictionary> list = new List <TB_System_Dictionary>(); if (CachesHelper.GetCache(CacheNames.AllDictionaries.ToStr()) != null) { list = (List <TB_System_Dictionary>)CachesHelper.GetCache(CacheNames.AllDictionaries.ToStr()); } else { list = SystemService.DictionaryService.Search().OrderBy(r => r.OrderBy).ToList(); CachesHelper.AddCache(CacheNames.AllDictionaries.ToStr(), list, null); } return(list); }
/// <summary> /// 获取所有权限资源 /// </summary> /// <returns></returns> public static List <TB_Admin_Resources> GetPermission() { List <TB_Admin_Resources> list = new List <TB_Admin_Resources>(); if (CachesHelper.GetCache(CacheNames.AllResources.ToStr()) != null) { list = (List <TB_Admin_Resources>)CachesHelper.GetCache(CacheNames.AllResources.ToStr()); } else { list = AdminService.ResourcesService.Search().OrderBy(r => r.OrderBy).ToList(); CachesHelper.AddCache(CacheNames.AllResources.ToStr(), list, null); } return(list); }
//删除 protected void ButtonDelete_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in RepList.Items) { CheckBox cb = ((CheckBox)ri.FindControl("CheckBoxChoose")); int ID = Convert.ToInt32(((HiddenField)ri.FindControl("HiddenFieldID")).Value); if (cb.Checked == true) { SystemService.DictionaryTypeService.Delete(ID); } } CachesHelper.RemoveCache(DataToCacheHelper.CacheNames.AllDictionaries.ToStr()); //重新加载 LoadDataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { idc = DescriptionAttributeHelper.GetEnumDescriptions <DataToCacheHelper.CacheNames>(); } string name = Request["name"]; if (!string.IsNullOrEmpty(name)) { CachesHelper.RemoveCache(name); MessageDiv.InnerHtml = CommonClass.Alert("清理成功"); } }
/// <summary> /// 获取商品类别 /// </summary> /// <param name="level"></param> /// <returns></returns> public static List <TB_Product_Categorys> GetProductCategory() { List <TB_Product_Categorys> list = new List <TB_Product_Categorys>(); if (CachesHelper.GetCache(CacheNames.ProductCategorys.ToStr()) != null) { list = (List <TB_Product_Categorys>)CachesHelper.GetCache(CacheNames.ProductCategorys.ToStr()); } else { List <Expression> express = new List <Expression>(); express.Add(new Expression("IsDelete", "=", "0")); express.Add(new Expression("IsHidden", "=", "0")); list = ProductService.CategoryService.Search(express, "OrderBy asc"); CachesHelper.AddCache(CacheNames.ProductCategorys.ToStr(), list, null); } return(list); }
//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_Admin_Resources model = new TB_Admin_Resources(); if (ViewState["id"] != null) { model = AdminService.ResourcesService.Get(ViewState["id"]); } model.ResourceName = TbResourceName.Text; model.ParentID = DDLParent.SelectedValue.ToInt(); model.Url = TbUrl.Text; model.Creater = AdminUserName; model.OrderBy = TbOrderBy.Text.ToInt(); model.IsShow = CheckIsShow.Checked; model.AddDate = DateTime.Now; IAdmin_Resources Resources = AdminService.ResourcesService; if (ViewState["id"] == null) { if (Resources.Insert(model) == 1) { CachesHelper.RemoveCache(DataToCacheHelper.CacheNames.AllResources.ToStr()); MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (Resources.Update(model) == 1) { CachesHelper.RemoveCache(DataToCacheHelper.CacheNames.AllResources.ToStr()); MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }
/// <summary> /// 获取首页商品推荐 /// </summary> /// <returns></returns> public static List <List <TB_Product_Products> > GetIndexVouchProducts() { List <List <TB_Product_Products> > list = new List <List <TB_Product_Products> >(); if (CachesHelper.GetCache(CacheNames.IndexVouch.ToStr()) != null) { list = (List <List <TB_Product_Products> >)CachesHelper.GetCache(CacheNames.IndexVouch.ToStr()); } else { List <Expression> express = new List <Expression>(); express.Add(new Expression("Mark", "=", "2")); express.Add(new Expression("IsDelete", "=", "0")); int recordCount = 0; list.Add(ProductService.ProductsService.Search(6, 1, express, ref recordCount)); list.Add(ProductService.ProductsService.Search(6, 2, express, ref recordCount)); list.Add(ProductService.ProductsService.Search(6, 3, express, ref recordCount)); list.Add(ProductService.ProductsService.Search(6, 4, express, ref recordCount)); CachesHelper.AddCache(CacheNames.IndexVouch.ToStr(), list, null); } return(list); }
/// <summary> /// 执行 /// </summary> /// <typeparam name="Tentity"></typeparam> /// <returns></returns> public static Tentity New <Tentity>() where Tentity : class, new() { Tentity result = new Tentity(); Type entityType = typeof(Tentity); //文件名为源类的命名空间+类名 string fileName = (entityType.Namespace + "." + entityType.Name).Replace(".", "_"); //代理类的全称 string loadClassFullName = "YK.Common.Proxy.GenerateClass." + fileName + "." + entityType.Name; object cacheValue = CachesHelper.GetCache(loadClassFullName); if (cacheValue != null) { return((Tentity)System.Activator.CreateInstance(cacheValue.GetType())); } string generateCode = GenerateCode <Tentity>(fileName, loadClassFullName); result = GetTentity <Tentity>(generateCode, loadClassFullName); CachesHelper.AddCache(loadClassFullName, result); return((Tentity)System.Activator.CreateInstance(result.GetType())); }
/// <summary> /// 租户实体对象 /// </summary> /// <returns></returns> internal List <OrganizationEntity> GetOrganizationEntitys() { List <OrganizationEntity> list = (List <OrganizationEntity>)CachesHelper.Get("OrganizationsEntitys"); //存在缓存则直接返回,否则实例化对象 if (list == null) { list = new List <OrganizationEntity>(); } else { return(list); } string fileUrl = Path.Combine(Directory.GetCurrentDirectory(), "/App_Data/Organization.xml"); XmlDocument xd = new XmlDocument(); xd.Load(fileUrl); XmlNodeList xmlNodeList = xd.SelectSingleNode("Organizations").ChildNodes; //循环遍历租户 foreach (XmlNode item in xmlNodeList) { //如果是注释节点则跳出 if (item.NodeType == XmlNodeType.Comment) { continue; } OrganizationEntity entity = new OrganizationEntity(); #region 获取节点实体 foreach (XmlNode childItem in item.ChildNodes) { #region Tenants对象赋值 string value = childItem.InnerText; switch (childItem.Name.ToLower()) { case "name": entity.Name = value; break; case "code": entity.Code = value; break; case "provider": entity.Provider = value; break; case "connectionstring": entity.Connectionstring = value; break; case "state": entity.State = value.ToInt(); break; case "slaves": entity.Slaves = new List <OrganizationSalves>(); foreach (XmlNode interfaceItem in childItem.ChildNodes) { #region InterfacePostData实体赋值 OrganizationSalves model = new OrganizationSalves(); foreach (XmlNode interfaceChildItem in interfaceItem) { switch (interfaceChildItem.Name.ToLower()) { case "connectionstring": model.Connectionstring = interfaceChildItem.ChildNodes[0].InnerText; break; case "proportion": model.Proportion = interfaceChildItem.ChildNodes[0].InnerText.ToDecimal(); break; case "state": model.State = value.ToInt(); break; } } entity.Slaves.Add(model); #endregion } break; } #endregion } #endregion list.Add(entity); } CachesHelper.Set("OrganizationsEntitys", list); return(list); }
//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_System_Dictionary model = new TB_System_Dictionary(); if (ViewState["id"] != null) { model = SystemService.DictionaryService.Get(ViewState["id"]); if (model.Code != TbCode.Text.TrimEnd()) { List <Expression> express = new List <Expression>(); express.Add(new Expression("Code", "=", TbCode.Text.TrimEnd())); express.Add(new Expression("TypeCode", "=", model.TypeCode)); var list = SystemService.DictionaryService.Search(express); if (list.Count > 0) { MessageDiv.InnerHtml = CommonClass.Alert("当前标识已存在,请重新输入"); return; } } } else { List <Expression> express = new List <Expression>(); express.Add(new Expression("Code", "=", TbCode.Text.TrimEnd())); express.Add(new Expression("TypeCode", "=", DDLModel.SelectedValue)); var list = SystemService.DictionaryService.Search(express); if (list.Count > 0) { MessageDiv.InnerHtml = CommonClass.Alert("当前标识已存在,请重新输入"); return; } } model.TypeCode = DDLModel.SelectedValue; model.Name = TbName.Text.Trim(); model.Code = TbCode.Text; model.Remark = TbRemark.Text; model.OrderBy = TbOrderBy.Text.ToInt(); model.Creater = AdminUserName; model.AddDate = DateTime.Now; ISystem_Dictionary Dictionary = SystemService.DictionaryService; if (ViewState["id"] == null) { if (Dictionary.Insert(model) == 1) { CachesHelper.RemoveCache(DataToCacheHelper.CacheNames.AllDictionaries.ToStr()); MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (Dictionary.Update(model) == 1) { CachesHelper.RemoveCache(DataToCacheHelper.CacheNames.AllDictionaries.ToStr()); MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }