//保存restinfo信息 private void SaveRestInfo() { var resInfo = _restInfo; if (resInfo != null) { resInfo.Method = cbMethod.Text; resInfo.EndPoint = txtEndPoint.Text; resInfo.Resource = txtResource.Text; resInfo.ReqHeader = richCurrReqHeader.Text; resInfo.ReqBody = richReqBody.Text; resInfo.MediaType = cbMediaType.Text; var userName = txtUserName.Text; var pwd = txtPassword.Text; var ams = DbContext.DbClient.Queryable <AuthManage>().Where(s => s.Id == resInfo.AuthId); int amId; if (ams.Count() > 0) { var am = ams.First(); am.UserName = userName; am.Password = pwd; am.AuthType = cbAuthType.Text; amId = DbContext.DbClient.Updateable(am).ExecuteCommand(); } else { var am = new AuthManage { AuthType = cbAuthType.Text, UserName = userName, Password = pwd }; amId = DbContext.DbClient.Insertable(am).ExecuteReturnIdentity(); } resInfo.AuthId = amId; DbContext.DbClient.Updateable(resInfo).ExecuteCommand(); } }
public static MvcHtmlString SysAuthButton(this HtmlHelper htmlHelper, string name, AuthManage auth, string code, IDictionary <string, object> htmlAttributes) { string result = string.Empty; if (auth.CheckRight(code)) { StringBuilder sb = new StringBuilder(); string attrs = string.Empty; foreach (var kv in htmlAttributes) { sb.AppendFormat(@"{0}='{1}' ", kv.Key, kv.Value); } result = string.Format(@"<a {0} href='javascript:void(0)' >{1}<span></span></a>", sb.ToString(), name); } return(MvcHtmlString.Create(result)); }