/// <summary> /// 操作日志写入方法 /// </summary> /// <param name="summary">日志摘要</param> /// <param name="message">日志详情</param> public void Log(string summary, string message) { var mLocuserlog = new JMP.MDL.jmp_businessuserlog(); var bllLocuserlog = new JMP.BLL.jmp_businessuserlog(); mLocuserlog.l_user_id = UserInfo.UserId; mLocuserlog.l_logtype_id = 3; mLocuserlog.l_ip = RequestHelper.GetClientIp(); mLocuserlog.l_location = ""; mLocuserlog.l_info = message; mLocuserlog.l_sms = summary; mLocuserlog.l_time = DateTime.Now; bllLocuserlog.Add(mLocuserlog); }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_businessuserlog GetModel(int l_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select l_id, l_user_id, l_logtype_id, l_ip, l_location, l_info, l_sms, l_time "); strSql.Append(" from jmp_businessuserlog "); strSql.Append(" where l_id=@l_id"); SqlParameter[] parameters = { new SqlParameter("@l_id", SqlDbType.Int, 4) }; parameters[0].Value = l_id; JMP.MDL.jmp_businessuserlog model = new JMP.MDL.jmp_businessuserlog(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["l_id"].ToString() != "") { model.l_id = int.Parse(ds.Tables[0].Rows[0]["l_id"].ToString()); } if (ds.Tables[0].Rows[0]["l_user_id"].ToString() != "") { model.l_user_id = int.Parse(ds.Tables[0].Rows[0]["l_user_id"].ToString()); } if (ds.Tables[0].Rows[0]["l_logtype_id"].ToString() != "") { model.l_logtype_id = int.Parse(ds.Tables[0].Rows[0]["l_logtype_id"].ToString()); } model.l_ip = ds.Tables[0].Rows[0]["l_ip"].ToString(); model.l_location = ds.Tables[0].Rows[0]["l_location"].ToString(); model.l_info = ds.Tables[0].Rows[0]["l_info"].ToString(); model.l_sms = ds.Tables[0].Rows[0]["l_sms"].ToString(); if (ds.Tables[0].Rows[0]["l_time"].ToString() != "") { model.l_time = DateTime.Parse(ds.Tables[0].Rows[0]["l_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_businessuserlog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_businessuserlog set "); strSql.Append(" l_user_id = @l_user_id , "); strSql.Append(" l_logtype_id = @l_logtype_id , "); strSql.Append(" l_ip = @l_ip , "); strSql.Append(" l_location = @l_location , "); strSql.Append(" l_info = @l_info , "); strSql.Append(" l_sms = @l_sms , "); strSql.Append(" l_time = @l_time "); strSql.Append(" where l_id=@l_id "); SqlParameter[] parameters = { new SqlParameter("@l_id", SqlDbType.Int, 4), new SqlParameter("@l_user_id", SqlDbType.Int, 4), new SqlParameter("@l_logtype_id", SqlDbType.Int, 4), new SqlParameter("@l_ip", SqlDbType.NVarChar, -1), new SqlParameter("@l_location", SqlDbType.NVarChar, -1), new SqlParameter("@l_info", SqlDbType.NVarChar, -1), new SqlParameter("@l_sms", SqlDbType.NVarChar, -1), new SqlParameter("@l_time", SqlDbType.DateTime) }; parameters[0].Value = model.l_id; parameters[1].Value = model.l_user_id; parameters[2].Value = model.l_logtype_id; parameters[3].Value = model.l_ip; parameters[4].Value = model.l_location; parameters[5].Value = model.l_info; parameters[6].Value = model.l_sms; parameters[7].Value = model.l_time; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_businessuserlog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_businessuserlog("); strSql.Append("l_user_id,l_logtype_id,l_ip,l_location,l_info,l_sms,l_time"); strSql.Append(") values ("); strSql.Append("@l_user_id,@l_logtype_id,@l_ip,@l_location,@l_info,@l_sms,@l_time"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@l_user_id", SqlDbType.Int, 4), new SqlParameter("@l_logtype_id", SqlDbType.Int, 4), new SqlParameter("@l_ip", SqlDbType.NVarChar, -1), new SqlParameter("@l_location", SqlDbType.NVarChar, -1), new SqlParameter("@l_info", SqlDbType.NVarChar, -1), new SqlParameter("@l_sms", SqlDbType.NVarChar, -1), new SqlParameter("@l_time", SqlDbType.DateTime) }; parameters[0].Value = model.l_user_id; parameters[1].Value = model.l_logtype_id; parameters[2].Value = model.l_ip; parameters[3].Value = model.l_location; parameters[4].Value = model.l_info; parameters[5].Value = model.l_sms; parameters[6].Value = model.l_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }