/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Log SafeBindForm(Lebi_Log model) { if (HttpContext.Current.Request["Admin_id"] != null) { model.Admin_id = LB.Tools.RequestTool.RequestInt("Admin_id", 0); } if (HttpContext.Current.Request["AdminName"] != null) { model.AdminName = LB.Tools.RequestTool.RequestSafeString("AdminName"); } if (HttpContext.Current.Request["Content"] != null) { model.Content = LB.Tools.RequestTool.RequestSafeString("Content"); } if (HttpContext.Current.Request["Description"] != null) { model.Description = LB.Tools.RequestTool.RequestSafeString("Description"); } if (HttpContext.Current.Request["IP_Add"] != null) { model.IP_Add = LB.Tools.RequestTool.RequestSafeString("IP_Add"); } if (HttpContext.Current.Request["Keyid"] != null) { model.Keyid = LB.Tools.RequestTool.RequestSafeString("Keyid"); } if (HttpContext.Current.Request["RefererURL"] != null) { model.RefererURL = LB.Tools.RequestTool.RequestSafeString("RefererURL"); } if (HttpContext.Current.Request["Supplier_id"] != null) { model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0); } if (HttpContext.Current.Request["Supplier_SubName"] != null) { model.Supplier_SubName = LB.Tools.RequestTool.RequestSafeString("Supplier_SubName"); } if (HttpContext.Current.Request["TableName"] != null) { model.TableName = LB.Tools.RequestTool.RequestSafeString("TableName"); } if (HttpContext.Current.Request["Time_Add"] != null) { model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now); } if (HttpContext.Current.Request["URL"] != null) { model.URL = LB.Tools.RequestTool.RequestSafeString("URL"); } if (HttpContext.Current.Request["User_id"] != null) { model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0); } if (HttpContext.Current.Request["UserName"] != null) { model.UserName = LB.Tools.RequestTool.RequestSafeString("UserName"); } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Log ReaderBind(IDataReader dataReader) { Lebi_Log model = new Lebi_Log(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = Convert.ToInt32(ojb); } ojb = dataReader["Admin_id"]; if (ojb != null && ojb != DBNull.Value) { model.Admin_id = Convert.ToInt32(ojb); } model.AdminName = dataReader["AdminName"].ToString(); model.Content = dataReader["Content"].ToString(); model.Description = dataReader["Description"].ToString(); model.IP_Add = dataReader["IP_Add"].ToString(); model.Keyid = dataReader["Keyid"].ToString(); model.RefererURL = dataReader["RefererURL"].ToString(); ojb = dataReader["Supplier_id"]; if (ojb != null && ojb != DBNull.Value) { model.Supplier_id = Convert.ToInt32(ojb); } model.Supplier_SubName = dataReader["Supplier_SubName"].ToString(); model.TableName = dataReader["TableName"].ToString(); ojb = dataReader["Time_Add"]; if (ojb != null && ojb != DBNull.Value) { model.Time_Add = (DateTime)ojb; } model.URL = dataReader["URL"].ToString(); ojb = dataReader["User_id"]; if (ojb != null && ojb != DBNull.Value) { model.User_id = Convert.ToInt32(ojb); } model.UserName = dataReader["UserName"].ToString(); return(model); }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Log GetModel(string strWhere, int seconds = 0) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para, seconds)); } string strTableName = TableName; string strFieldShow = "*"; string cachekey = ""; string cachestr = ""; if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0) { cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds; cachekey = LB.Tools.Utils.MD5(cachestr); var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey); if (obj != null) { return(obj as Lebi_Log); } } Lebi_Log model = null; using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null)) { if (dataReader == null) { return(null); } while (dataReader.Read()) { model = ReaderBind(dataReader); if (cachekey != "") { LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Log", model.id, cachestr, seconds); } return(model); } } return(null); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Log model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + TableName + " ("); strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("AdminName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IP_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Keyid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("RefererURL") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("TableName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("URL") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + ")"); strSql.Append(" values ("); strSql.Append("@Admin_id,@AdminName,@Content,@Description,@IP_Add,@Keyid,@RefererURL,@Supplier_id,@Supplier_SubName,@TableName,@Time_Add,@URL,@User_id,@UserName);select @@identity;"); SqlParameter[] parameters = { new SqlParameter("@Admin_id", model.Admin_id), new SqlParameter("@AdminName", model.AdminName), new SqlParameter("@Content", model.Content), new SqlParameter("@Description", model.Description), new SqlParameter("@IP_Add", model.IP_Add), new SqlParameter("@Keyid", model.Keyid), new SqlParameter("@RefererURL", model.RefererURL), new SqlParameter("@Supplier_id", model.Supplier_id), new SqlParameter("@Supplier_SubName", model.Supplier_SubName), new SqlParameter("@TableName", model.TableName), new SqlParameter("@Time_Add", model.Time_Add), new SqlParameter("@URL", model.URL), new SqlParameter("@User_id", model.User_id), new SqlParameter("@UserName", model.UserName) }; object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Log model) { D_Lebi_Log.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Log model) { return(D_Lebi_Log.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Log SafeBindForm(Lebi_Log model) { return(D_Lebi_Log.Instance.SafeBindForm(model)); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Log model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + TableName + " set "); List <string> cols = new List <string>(); if (("," + model.UpdateCols + ",").IndexOf(",Admin_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "= @Admin_id"); } if (("," + model.UpdateCols + ",").IndexOf(",AdminName,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("AdminName") + "= @AdminName"); } if (("," + model.UpdateCols + ",").IndexOf(",Content,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "= @Content"); } if (("," + model.UpdateCols + ",").IndexOf(",Description,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "= @Description"); } if (("," + model.UpdateCols + ",").IndexOf(",IP_Add,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IP_Add") + "= @IP_Add"); } if (("," + model.UpdateCols + ",").IndexOf(",Keyid,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Keyid") + "= @Keyid"); } if (("," + model.UpdateCols + ",").IndexOf(",RefererURL,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("RefererURL") + "= @RefererURL"); } if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id"); } if (("," + model.UpdateCols + ",").IndexOf(",Supplier_SubName,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "= @Supplier_SubName"); } if (("," + model.UpdateCols + ",").IndexOf(",TableName,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("TableName") + "= @TableName"); } if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add"); } if (("," + model.UpdateCols + ",").IndexOf(",URL,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("URL") + "= @URL"); } if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id"); } if (("," + model.UpdateCols + ",").IndexOf(",UserName,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + "= @UserName"); } strSql.Append(string.Join(",", cols)); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", model.id), new SqlParameter("@Admin_id", model.Admin_id), new SqlParameter("@AdminName", model.AdminName), new SqlParameter("@Content", model.Content), new SqlParameter("@Description", model.Description), new SqlParameter("@IP_Add", model.IP_Add), new SqlParameter("@Keyid", model.Keyid), new SqlParameter("@RefererURL", model.RefererURL), new SqlParameter("@Supplier_id", model.Supplier_id), new SqlParameter("@Supplier_SubName", model.Supplier_SubName), new SqlParameter("@TableName", model.TableName), new SqlParameter("@Time_Add", model.Time_Add), new SqlParameter("@URL", model.URL), new SqlParameter("@User_id", model.User_id), new SqlParameter("@UserName", model.UserName) }; LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters); }