public static void Setup(int testItems) { SetTestRepo(); for (int i = 0; i < testItems; i++) { PagePowerSign item = new PagePowerSign(); _testRepo._items.Add(item); } }
public override bool Equals(object obj) { if (obj.GetType() == typeof(PagePowerSign)) { PagePowerSign compare = (PagePowerSign)obj; return(compare.KeyValue() == this.KeyValue()); } else { return(base.Equals(obj)); } }
public static PagePowerSign SingleOrDefault(Expression <Func <PagePowerSign, bool> > expression, string connectionString, string providerName) { var repo = GetRepo(connectionString, providerName); var results = repo.Find(expression); PagePowerSign single = null; if (results.Count() > 0) { single = results.ToList()[0]; } return(single); }
public static PagePowerSign SingleOrDefault(Expression <Func <PagePowerSign, bool> > expression) { var repo = GetRepo(); var results = repo.Find(expression); PagePowerSign single = null; if (results.Count() > 0) { single = results.ToList()[0]; single.OnLoaded(); single.SetIsLoaded(true); single.SetIsNew(false); } return(single); }
void Init() { TestMode = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase); _dirtyColumns = new List <IColumn>(); if (TestMode) { PagePowerSign.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <PagePowerSign>(_db); } tbl = _repo.GetTable(); SetIsNew(true); OnCreated(); }
internal static IRepository <PagePowerSign> GetRepo(string connectionString, string providerName) { Solution.DataAccess.DataModel.SolutionDataBaseDB db; if (String.IsNullOrEmpty(connectionString)) { db = new Solution.DataAccess.DataModel.SolutionDataBaseDB(); } else { db = new Solution.DataAccess.DataModel.SolutionDataBaseDB(connectionString, providerName); } IRepository <PagePowerSign> _repo; if (db.TestMode) { PagePowerSign.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <PagePowerSign>(db); } return(_repo); }
/// <summary> /// 将PagePowerSign记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.PagePowerSign) /// </summary> /// <param name="model">SubSonic插件生成的实体</param> /// <returns>DataAccess.Model.PagePowerSign</returns> public DataAccess.Model.PagePowerSign Transform(PagePowerSign model) { if (model == null) return null; return new DataAccess.Model.PagePowerSign { Id = model.Id, PagePowerSignPublic_Id = model.PagePowerSignPublic_Id, CName = model.CName, EName = model.EName, MenuInfo_Id = model.MenuInfo_Id, }; }
/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(PagePowerSign model) { SetModelForCache(Transform(model)); }
/// <summary> /// 添加与编辑PagePowerSign记录 /// </summary> /// <param name="page">当前页面指针</param> /// <param name="model">PagePowerSign表实体</param> /// <param name="content">更新说明</param> /// <param name="isCache">是否更新缓存</param> /// <param name="isAddUseLog">是否添加用户操作日志</param> public void Save(Page page, PagePowerSign 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 ? "添加" : "编辑") + "PagePowerSign记录成功,ID为【" + model.Id + "】"; } //添加用户访问记录 UseLogBll.GetInstence().Save(page, content); } } catch (Exception e) { var result = "执行PagePowerSignBll.Save()函数出错!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } }
/// <summary> /// 页面绑定控件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonEmpower_Click(object sender, EventArgs e) { //获取当前选择的菜单项 var index = ConvertHelper.Cint0(hidId.Text); //获取当前用户选择的全部记录Id var id = GridViewHelper.GetSelectedKeyIntArray(Grid1); //如果没有选择项,则直接退出 if (index == 0 || id == null || id.Length == 0) return; //添加到绑定表中 foreach (var i in id) { //检查当前控件是否已添加 //添加前判断一下本权限标签是否已添加过了,没有则进行添加 if (!PagePowerSignBll.GetInstence().Exist(x => x.MenuInfo_Id == index && x.PagePowerSignPublic_Id == i)) { var ppsp = PagePowerSignPublicBll.GetInstence().GetModelForCache(i); if (ppsp == null) { continue; } var model = new PagePowerSign(); model.MenuInfo_Id = index; model.PagePowerSignPublic_Id = i; model.CName = ppsp.CName; model.EName = ppsp.EName; PagePowerSignBll.GetInstence().Save(this, model); } } BindGrid(); }
public static void Setup(int testItems) { SetTestRepo(); for(int i=0;i<testItems;i++){ PagePowerSign item=new PagePowerSign(); _testRepo._items.Add(item); } }
public static void Setup(PagePowerSign item) { SetTestRepo(); _testRepo._items.Add(item); }