/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_app_request_audit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_app_request_audit set "); strSql.Append(" app_name = @app_name , "); strSql.Append(" message = @message , "); strSql.Append(" created_on = @created_on , "); strSql.Append(" is_processed = @is_processed , "); strSql.Append(" processed_time = @processed_time , "); strSql.Append(" processed_by = @processed_by , "); strSql.Append(" processed_result = @processed_result,"); strSql.Append(" is_send_message = @is_send_message,"); strSql.Append(" message_send_time = @message_send_time"); strSql.Append(" type = @type"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@app_id", SqlDbType.Int, 4), new SqlParameter("@app_name", SqlDbType.NVarChar, -1), new SqlParameter("@message", SqlDbType.NVarChar, -1), new SqlParameter("@created_on", SqlDbType.DateTime), new SqlParameter("@is_processed", SqlDbType.Int, 4), new SqlParameter("@processed_time", SqlDbType.DateTime), new SqlParameter("@processed_by", SqlDbType.NVarChar, 30), new SqlParameter("@processed_result", SqlDbType.NVarChar, -1), new SqlParameter("@is_send_message", SqlDbType.Int, 4), new SqlParameter("@message_send_time", SqlDbType.DateTime), new SqlParameter("@type", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.app_id; parameters[2].Value = model.app_name; parameters[3].Value = model.message; parameters[4].Value = model.created_on; parameters[5].Value = model.is_processed; parameters[6].Value = model.processed_time; parameters[7].Value = model.processed_by; parameters[8].Value = model.processed_result; parameters[9].Value = model.is_send_message; parameters[10].Value = model.message_send_time; parameters[11].Value = model.type; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(JMP.MDL.jmp_app_request_audit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_app_request_audit("); strSql.Append("app_id,app_name,message,created_on,is_processed,processed_time,processed_by,processed_result,is_send_message,message_send_time,type"); strSql.Append(") values ("); strSql.Append("@app_id,@app_name,@message,@created_on,@is_processed,@processed_time,@processed_by,@processed_result,@is_send_message,@message_send_time,@type"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@app_id", SqlDbType.Int, 4), new SqlParameter("@app_name", SqlDbType.NVarChar, -1), new SqlParameter("@message", SqlDbType.NVarChar, -1), new SqlParameter("@created_on", SqlDbType.DateTime), new SqlParameter("@is_processed", SqlDbType.Int, 4), new SqlParameter("@processed_time", SqlDbType.DateTime), new SqlParameter("@processed_by", SqlDbType.NVarChar, 30), new SqlParameter("@processed_result", SqlDbType.NVarChar, -1), new SqlParameter("@is_send_message", SqlDbType.Int, 4), new SqlParameter("@message_send_time", SqlDbType.DateTime), new SqlParameter("@type", SqlDbType.Int, 4) }; parameters[0].Value = model.app_id; parameters[1].Value = model.app_name; parameters[2].Value = model.message; parameters[3].Value = model.created_on; parameters[4].Value = model.is_processed; parameters[5].Value = model.processed_time; parameters[6].Value = model.processed_by; parameters[7].Value = model.processed_result; parameters[8].Value = model.is_send_message; parameters[9].Value = model.message_send_time; parameters[10].Value = model.type; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
protected override void Persistent() { var bll = new JMP.BLL.jmp_app_request_audit(); foreach (var o in AllowSenders) { if (o.AppId <= 0) { continue; } var audit = new JMP.MDL.jmp_app_request_audit { app_id = o.AppId, app_name = o.AppName, created_on = DateTime.Now, is_send_message = 1, message_send_time = DateTime.Now, message = string.Format("应用[{0}:{1}]已有{2}无订单产生,上次订单时间[{3}],请核实!", o.AppId, o.AppName, DateTime.Now.AddSeconds(-o.LatestOrderTimespan).TimeAgo(""), o.LatestPayTime) }; bll.Add(audit); } DoingWork("数据持久化完成,准备筛选..."); }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_app_request_audit GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, app_id, app_name, message, created_on, is_processed, processed_time, processed_by, processed_result,is_send_message,message_send_time,type"); strSql.Append(" from jmp_app_request_audit "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; JMP.MDL.jmp_app_request_audit model = new JMP.MDL.jmp_app_request_audit(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["app_id"].ToString() != "") { model.app_id = int.Parse(ds.Tables[0].Rows[0]["app_id"].ToString()); } model.app_name = ds.Tables[0].Rows[0]["app_name"].ToString(); model.message = ds.Tables[0].Rows[0]["message"].ToString(); if (ds.Tables[0].Rows[0]["created_on"].ToString() != "") { model.created_on = DateTime.Parse(ds.Tables[0].Rows[0]["created_on"].ToString()); } if (ds.Tables[0].Rows[0]["is_processed"].ToString() != "") { model.is_processed = int.Parse(ds.Tables[0].Rows[0]["is_processed"].ToString()); } if (ds.Tables[0].Rows[0]["processed_time"].ToString() != "") { model.processed_time = DateTime.Parse(ds.Tables[0].Rows[0]["processed_time"].ToString()); } model.processed_by = ds.Tables[0].Rows[0]["processed_by"].ToString(); model.processed_result = ds.Tables[0].Rows[0]["processed_result"].ToString(); if (ds.Tables[0].Rows[0]["message_send_time"].ToString() != "") { model.message_send_time = DateTime.Parse(ds.Tables[0].Rows[0]["message_send_time"].ToString()); } if (ds.Tables[0].Rows[0]["is_send_message"].ToString() != "") { model.is_send_message = int.Parse(ds.Tables[0].Rows[0]["is_send_message"].ToString()); } if (ds.Tables[0].Rows[0]["type"].ToString() != "") { model.type = int.Parse(ds.Tables[0].Rows[0]["type"].ToString()); } return(model); } else { return(null); } }