/// <summary> /// 获取OAuth配置信息 /// </summary> public static oauth_config get_config(int site_oauth_id) { //读取接口配置信息 Model.site_oauth model = new BLL.site_oauth().GetModel(site_oauth_id); if (model != null) { Model.siteconfig sysConfig = new BLL.siteconfig().loadConfig(); //系统配置 Model.sites siteModel = new BLL.sites().GetModel(model.site_id); //站点配置 Model.oauth_app appModel = new BLL.oauth_app().GetModel(model.oauth_id); //OAuth应用 //赋值 oauth_config config = new oauth_config(); config.oauth_id = model.id; config.oauth_name = appModel.api_path.Trim(); config.oauth_app_id = model.app_id.Trim(); config.oauth_app_key = model.app_key.Trim(); config.site_path = siteModel.build_path; if (!string.IsNullOrEmpty(siteModel.domain.Trim()) && siteModel.is_default == 0) //如果有自定义域名且不是默认站点 { config.return_uri = "http://" + siteModel.domain + "/api/oauth/return_url.aspx"; } else if (siteModel.is_default == 0) //不是默认站点也没有绑定域名 { config.return_uri = "http://" + HttpContext.Current.Request.Url.Authority.ToLower() + sysConfig.webpath + siteModel.build_path.ToLower() + "/api/oauth/return_url.aspx"; } else //否则使用当前域名 { config.return_uri = "http://" + HttpContext.Current.Request.Url.Authority.ToLower() + sysConfig.webpath + "api/oauth/return_url.aspx"; } return(config); } return(null); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("user_oauth", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.site_oauth bll = new BLL.site_oauth(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除OAuth列表成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("site_oauth_list.aspx", "site_id={0}&keywords={1}", this.site_id.ToString(), this.keywords)); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); ddlSiteId.SelectedValue = this.site_id.ToString(); txtKeywords.Text = this.keywords; BLL.site_oauth bll = new BLL.site_oauth(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("site_oauth_list.aspx", "site_id={0}&keywords={1}&page={2}", this.site_id.ToString(), this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("user_oauth", DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.site_oauth bll = new BLL.site_oauth(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "保存OAuth列表排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("site_oauth_list.aspx", "site_id={0}&keywords={1}", this.site_id.ToString(), this.keywords)); }
private bool DoEdit(int _id) { bool result = false; BLL.site_oauth bll = new BLL.site_oauth(); model.site_id = ConvertTool.ToInt(ddlSiteId.SelectedValue, 0); model.oauth_id = ConvertTool.ToInt(ddlOauthId.SelectedValue, 0); model.sort_id = ConvertTool.ToInt(txtSortId.Text.Trim(), 99); model.title = txtTitle.Text.Trim(); model.app_id = txtAppId.Text.Trim(); model.app_key = txtAppKey.Text.Trim(); if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改站点OAuth列表:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { bool result = false; this.model = new Model.site_oauth(); BLL.site_oauth bll = new BLL.site_oauth(); model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0); model.oauth_id = Utils.StrToInt(ddlOauthId.SelectedValue, 0); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.title = txtTitle.Text.Trim(); model.app_id = txtAppId.Text.Trim(); model.app_key = txtAppKey.Text.Trim(); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加站点OAuth列表:" + model.title); //记录日志 result = true; } return(result); }