public static void Setup(int testItems) { SetTestRepo(); for (int i = 0; i < testItems; i++) { UploadType item = new UploadType(); _testRepo._items.Add(item); } }
public override bool Equals(object obj) { if (obj.GetType() == typeof(UploadType)) { UploadType compare = (UploadType)obj; return(compare.KeyValue() == this.KeyValue()); } else { return(base.Equals(obj)); } }
public static UploadType SingleOrDefault(Expression <Func <UploadType, bool> > expression, string connectionString, string providerName) { var repo = GetRepo(connectionString, providerName); var results = repo.Find(expression); UploadType single = null; if (results.Count() > 0) { single = results.ToList()[0]; } return(single); }
public static UploadType SingleOrDefault(Expression <Func <UploadType, bool> > expression) { var repo = GetRepo(); var results = repo.Find(expression); UploadType 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) { UploadType.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <UploadType>(_db); } tbl = _repo.GetTable(); SetIsNew(true); OnCreated(); }
internal static IRepository <UploadType> GetRepo(string connectionString, string providerName) { Solution.DataAccess.DataModel.SolutionDataBase_standardDB db; if (String.IsNullOrEmpty(connectionString)) { db = new Solution.DataAccess.DataModel.SolutionDataBase_standardDB(); } else { db = new Solution.DataAccess.DataModel.SolutionDataBase_standardDB(connectionString, providerName); } IRepository <UploadType> _repo; if (db.TestMode) { UploadType.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <UploadType>(db); } return(_repo); }
public static void Setup(UploadType item) { SetTestRepo(); _testRepo._items.Add(item); }
/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(UploadType model) { SetModelForCache(Transform(model)); }
/// <summary> /// 添加与编辑UploadType记录 /// </summary> /// <param name="page">当前页面指针</param> /// <param name="model">UploadType表实体</param> /// <param name="content">更新说明</param> /// <param name="isCache">是否更新缓存</param> /// <param name="isAddUseLog">是否添加用户操作日志</param> public void Save(Page page, UploadType 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 ? "添加" : "编辑") + "UploadType记录成功,ID为【" + model.Id + "】"; } //添加用户访问记录 UseLogBll.GetInstence().Save(page, content); } } catch (Exception e) { var result = "执行UploadTypeBll.Save()函数出错!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } }
/// <summary> /// 将UploadType记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.UploadType) /// </summary> /// <param name="model">SubSonic插件生成的实体</param> /// <returns>DataAccess.Model.UploadType</returns> public DataAccess.Model.UploadType Transform(UploadType model) { if (model == null) return null; return new DataAccess.Model.UploadType { Id = model.Id, TypeKey = model.TypeKey, Name = model.Name, Ext = model.Ext, IsSys = model.IsSys, Manager_Id = model.Manager_Id, Manager_CName = model.Manager_CName, UpdateDate = model.UpdateDate, }; }
public static void Setup(int testItems) { SetTestRepo(); for(int i=0;i<testItems;i++){ UploadType item=new UploadType(); _testRepo._items.Add(item); } }
public static void Setup(UploadType item) { SetTestRepo(); _testRepo._items.Add(item); }
/// <summary> /// 数据保存 /// </summary> /// <returns></returns> public override string Save() { string result = string.Empty; int id = ConvertHelper.Cint0(hidId.Text); try { #region 数据验证 if (string.IsNullOrEmpty(txtName.Text.Trim())) { return txtName.Label + "不能为空!"; } var sName = StringHelper.Left(txtName.Text, 50); if (UploadTypeBll.GetInstence().Exist(x => x.Name == sName && x.Id != id)) { return txtName.Label + "已存在!请重新输入!"; } if (string.IsNullOrEmpty(txtTypeKey.Text.Trim())) { return txtTypeKey.Label + "不能为空!"; } if (string.IsNullOrEmpty(txtExt.Text.Trim())) { return txtExt.Label + "不能为空!"; } #endregion #region 赋值 //获取实体 var model = new UploadType(x => x.Id == id); //系统默认 //model.IsSys = ConvertHelper.StringToByte(rblIsSys.SelectedValue); //判断是否有改变关键字 var sTypeKey = StringHelper.Left(txtTypeKey.Text, 20); if (id > 0 && model.IsSys == 1 && sTypeKey != model.TypeKey) { return "当前记录为系统默认,不能修改关键字!"; } //设置名称 model.Name = sName; //设置关键字 model.TypeKey = sTypeKey; //扩展名 model.Ext = StringHelper.Left(txtExt.Text, 0); //修改时间与管理员 model.UpdateDate = DateTime.Now; model.Manager_Id = OnlineUsersBll.GetInstence().GetManagerId(); model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName(); #endregion //---------------------------------------------------------- //存储到数据库 UploadTypeBll.GetInstence().Save(this, model); } catch (Exception e) { result = "保存失败!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } return result; }