/// <summary> /// 修改主链接 /// </summary> public bool UpdateMainLink(RouterMainLink model) { var dal = new DalRouter(); using (var connection = ProcessConnection.OpenGungnir) { return(dal.UpdateMainLink(connection, model)); } }
/// <summary> /// 修改主链接 /// </summary> public bool UpdateMainLink(SqlConnection connection, RouterMainLink model) { var sql = @"UPDATE Configuration.dbo.RouterMainLink SET Content=@Content , Discription=@Discription , UpdateDateTime=GetDate() , LinkKind=@LinkKind WHERE PKID=@PKID"; return(connection.Execute(sql, model) > 0); }
/// <summary> /// 新建主链接 /// </summary> public bool AddMainLink(SqlConnection connection, RouterMainLink model) { var sql = @"INSERT INTO Configuration.dbo.RouterMainLink ( CreateDateTime , UpdateDateTime , [Content], Discription, LinkKind ) VALUES ( GETDATE() , -- CreateDateTime - datetime GETDATE() , -- UpdateDateTime - datetime @Content, -- Content - varchar(1000) @Discription, -- Discription - varchar(100) @LinkKind -- LinkKind - int )"; return(connection.Execute(sql, model) > 0); }
/// <summary> /// 获取所有参数 /// </summary> public IEnumerable <RouterParameter> GetParameterList(SqlConnection connection, int mId) { var dp = new DynamicParameters(); dp.Add("@MId", mId); RouterMainLink mainLink = connection .Query <RouterMainLink>( "select PKID,CreateDateTime,UpdateDateTime,Content,Discription,LinkKind from [Configuration].[dbo].RouterMainLink where RouterMainLink.PKID=@MId;", dp) .FirstOrDefault(); if (mainLink != null) { dp.Add("@LinkKind", mainLink.LinkKind); return(connection .Query <RouterParameter>( "select PKID,CreateDateTime,UpdateDateTime,Content,Discription,LinkKind from [Configuration].[dbo].RouterParameter where LinkKind=@LinkKind;", dp)); } return(null); }
/// <summary> /// 保存主链接的新增或修改操作 /// </summary> public ActionResult MainLinkSave(RouterMainLink model) { RouterConfigManager manger = new RouterConfigManager(); if (model.PKID == 0) { if (manger.AddMainLink(model)) { LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(model), Author = User.Identity.Name, BeforeValue = "", ChangeDatetime = DateTime.Now, ObjectID = model.PKID.ToString(), ObjectType = "MainLink", Operation = "新增主链接配置" + model.Content }); return(Json(1)); } else { return(Json(0)); } } else { var before = manger.GetMainLink(model.PKID); if (manger.UpdateMainLink(model)) { LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(model), Author = User.Identity.Name, BeforeValue = JsonConvert.SerializeObject(before), ChangeDatetime = DateTime.Now, ObjectID = model.PKID.ToString(), ObjectType = "MainLink", Operation = "编辑主链接配置" + model.Content }); return(Json(1)); } else { return(Json(0)); } } }