/// <summary> /// 数据保存 /// </summary> /// <returns></returns> public override string Save() { string result = string.Empty; try { #region 赋值 //获取实体 var model = new WebConfig(x => x.Id == id); model.WebName = StringHelper.Left(txtWebName.Text, 50); model.WebDomain = StringHelper.Left(txtWebDomain.Text, 50, true, false); model.WebEmail = StringHelper.Left(txtWebEmail.Text, 50, true, false); model.LoginLogReserveTime = ConvertHelper.Cint0(txtLoginLogReserveTime.Text); model.UseLogReserveTime = ConvertHelper.Cint0(txtUseLogReserveTime.Text); model.EmailSmtp = StringHelper.Left(txtEmailSmtp.Text, 50, true, false); model.EmailUserName = StringHelper.Left(txtEmailUserName.Text, 50); model.EmailPassWord = StringHelper.Left(txtEmailPassWord.Text, 50, true, false); #endregion //---------------------------------------------------------- //存储到数据库 WebConfigBll.GetInstence().Save(this, model); //------------------------------------ //测试邮件发送服务 if (chkSendTest.Checked && model.EmailSmtp.Length > 0 && model.EmailUserName.Length > 0) { var oMail = new MailBll(); string ss = oMail.TestMail(); if (ss.Length > 0) { return ("出错!" + ss); } else { return ("发送成功!"); } } return "修改成功!"; } catch (Exception e) { result = "保存失败!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } return result; }
internal static IRepository <WebConfig> 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 <WebConfig> _repo; if (db.TestMode) { WebConfig.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <WebConfig>(db); } return(_repo); }
public static void Setup(WebConfig item) { SetTestRepo(); _testRepo._items.Add(item); }
/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(WebConfig model) { SetModelForCache(Transform(model)); }
/// <summary> /// 添加与编辑WebConfig记录 /// </summary> /// <param name="page">当前页面指针</param> /// <param name="model">WebConfig表实体</param> /// <param name="content">更新说明</param> /// <param name="isCache">是否更新缓存</param> /// <param name="isAddUseLog">是否添加用户操作日志</param> public void Save(Page page, WebConfig 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 ? "添加" : "编辑") + "WebConfig记录成功,ID为【" + model.Id + "】"; } //添加用户访问记录 UseLogBll.GetInstence().Save(page, content); } } catch (Exception e) { var result = "执行WebConfigBll.Save()函数出错!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } }
/// <summary> /// 将WebConfig记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.WebConfig) /// </summary> /// <param name="model">SubSonic插件生成的实体</param> /// <returns>DataAccess.Model.WebConfig</returns> public DataAccess.Model.WebConfig Transform(WebConfig model) { if (model == null) return null; return new DataAccess.Model.WebConfig { Id = model.Id, WebName = model.WebName, WebDomain = model.WebDomain, WebEmail = model.WebEmail, LoginLogReserveTime = model.LoginLogReserveTime, UseLogReserveTime = model.UseLogReserveTime, EmailSmtp = model.EmailSmtp, EmailUserName = model.EmailUserName, EmailPassWord = model.EmailPassWord, EmailDomain = model.EmailDomain, }; }
public static void Setup(int testItems) { SetTestRepo(); for(int i=0;i<testItems;i++){ WebConfig item=new WebConfig(); _testRepo._items.Add(item); } }