public ActionResult Update(int id) { using (DbConn conn = DbConfig.CreateConn(DataConfig.MqManage)) { conn.Open(); tb_producter_model model = dal.Get(conn, id); return(View(model)); } }
public ActionResult Update(tb_producter_model model) { using (DbConn conn = DbConfig.CreateConn(DataConfig.MqManage)) { conn.Open(); tb_producter_model result = dal.Get(conn, model.id); if (result != null) { result.mqpathid = model.mqpathid; result.productername = model.productername; result.ip = model.ip; if (dal.Edit(conn, result)) { return(RedirectToAction("index")); } } ModelState.AddModelError("Error", "更新错误"); return(View(result)); } }
public virtual tb_producter_model CreateModel(DataRow dr) { var o = new tb_producter_model(); // if (dr.Table.Columns.Contains("id")) { o.id = dr["id"].Toint(); } //生产者临时id(消费者启动后唯一,Guid转long) if (dr.Table.Columns.Contains("tempid")) { o.tempid = dr["tempid"].Tolong(); } //生产者名称 if (dr.Table.Columns.Contains("productername")) { o.productername = dr["productername"].Tostring(); } //ip地址 if (dr.Table.Columns.Contains("ip")) { o.ip = dr["ip"].Tostring(); } //队列id if (dr.Table.Columns.Contains("mqpathid")) { o.mqpathid = dr["mqpathid"].Toint(); } //生产者最后心跳时间 if (dr.Table.Columns.Contains("lastheartbeat")) { o.lastheartbeat = dr["lastheartbeat"].ToDateTime(); } //生产者创建时间 if (dr.Table.Columns.Contains("createtime")) { o.createtime = dr["createtime"].ToDateTime(); } return(o); }
public virtual bool Add(DbConn PubConn, tb_producter_model model) { List <ProcedureParameter> Par = new List <ProcedureParameter>() { //生产者临时id(消费者启动后唯一,Guid转long) new ProcedureParameter("@tempid", model.tempid), //生产者名称 new ProcedureParameter("@productername", model.productername), //ip地址 new ProcedureParameter("@ip", model.ip), //队列id new ProcedureParameter("@mqpathid", model.mqpathid), //生产者最后心跳时间 new ProcedureParameter("@lastheartbeat", model.lastheartbeat), //生产者创建时间 new ProcedureParameter("@createtime", model.createtime) }; int rev = PubConn.ExecuteSql(@"insert into tb_producter(tempid,productername,ip,mqpathid,lastheartbeat,createtime) values(@tempid,@productername,@ip,@mqpathid,@lastheartbeat,@createtime)" , Par); return(rev == 1); }
public virtual bool Edit(DbConn PubConn, tb_producter_model model) { List <ProcedureParameter> Par = new List <ProcedureParameter>() { //生产者临时id(消费者启动后唯一,Guid转long) new ProcedureParameter("@tempid", model.tempid), //生产者名称 new ProcedureParameter("@productername", model.productername), //ip地址 new ProcedureParameter("@ip", model.ip), //队列id new ProcedureParameter("@mqpathid", model.mqpathid), //生产者最后心跳时间 new ProcedureParameter("@lastheartbeat", model.lastheartbeat), //生产者创建时间 new ProcedureParameter("@createtime", model.createtime) }; Par.Add(new ProcedureParameter("@id", model.id)); int rev = PubConn.ExecuteSql("update tb_producter set tempid=@tempid,productername=@productername,ip=@ip,mqpathid=@mqpathid,lastheartbeat=@lastheartbeat,createtime=@createtime where id=@id", Par); return(rev == 1); }