private AuthorizerInfoModel EntityToModel(DataRow dr) { if (dr != null) { AuthorizerInfoModel model = new AuthorizerInfoModel(); model.ID = dr["id"].ToInt(); model.UserID = dr["user_id"].ToString(); model.AuthorizerAppID = dr["authorizer_appid"].ToString(); model.NickName = dr["nick_name"].ToString(); model.HeadImg = dr["head_img"].ToString(); model.ServiceTypeInfo = dr["service_type_info"].ToInt(); model.VerifyTypeInfo = dr["verify_type_info"].ToInt(); model.UserName = dr["user_name"].ToString(); model.Alias = dr["alias"].ToString(); model.QrcodeUrl = dr["qrcode_url"].ToString(); model.OpenPay = dr["open_pay"].ToInt(); model.OpenShake = dr["open_shake"].ToInt(); model.OpenScan = dr["open_scan"].ToInt(); model.OpenCard = dr["open_card"].ToInt(); model.OpenStore = dr["open_store"].ToInt(); model.IDC = dr["idc"].ToInt(); model.PrincipalName = dr["principal_name"].ToString(); model.CreateTime = dr["create_time"].ToDateTime(); model.UpdateTime = dr["update_time"].ToDateTime(); return(model); } return(null); }
public ActionResult Index(string id) { AuthorizerInfoModel model = authorizerInfoBLL.GetModel(id); if (model != null) { Session["authorizer"] = model; return(View(model)); } return(new HttpStatusCodeResult(404)); }
protected override void OnAppActionExecuting(ActionExecutingContext filterContext) { if (Session != null && Session["authorizer"] != null) { CurrentAuthorizer = Session["authorizer"] as AuthorizerInfoModel; } else { filterContext.Result = new HttpStatusCodeResult(500); } base.OnAppActionExecuting(filterContext); }
private RESTfulModel SaveAuthorizer(string componentAppID, string componentAccessToken, string authorizerAppID, string userID, DateTime authTime) { #region 6、获取授权方的公众号帐号基本信息 string url_6 = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=" + componentAccessToken; LogHelper.Info("6、获取授权方的公众号帐号基本信息 url", url_6); // 二次授权成功 AuthorizerInfoGetReq req_6 = new AuthorizerInfoGetReq() { ComponentAppID = componentAppID, AuthorizerAppID = authorizerAppID }; string requestBody_6 = JsonConvert.SerializeObject(req_6); LogHelper.Info("6、获取授权方的公众号帐号基本信息 requestBody_6", requestBody_6); string responseBody_6 = HttpHelper.Post(url_6, requestBody_6); LogHelper.Info("6、获取授权方的公众号帐号基本信息 responseBody_6", responseBody_6); AuthorizerInfoGetResp resp_6 = JsonConvert.DeserializeObject <AuthorizerInfoGetResp>(responseBody_6); #endregion AuthorizerInfoModel authorizerInfoModel = authorizerInfoDAL.GetModel(authorizerAppID); if (authorizerInfoModel == null) { authorizerInfoDAL.Insert( userID, authorizerAppID, resp_6.AuthorizerInfo.NickName, resp_6.AuthorizerInfo.HeadImg, resp_6.AuthorizerInfo.ServiceTypeInfo.ID, resp_6.AuthorizerInfo.VerifyTypeInfo.ID, resp_6.AuthorizerInfo.UserName, resp_6.AuthorizerInfo.Alias, resp_6.AuthorizerInfo.QrcodeUrl, resp_6.AuthorizerInfo.BusinessInfo.OpenPay, resp_6.AuthorizerInfo.BusinessInfo.OpenShake, resp_6.AuthorizerInfo.BusinessInfo.OpenScan, resp_6.AuthorizerInfo.BusinessInfo.OpenCard, resp_6.AuthorizerInfo.BusinessInfo.OpenStore, resp_6.AuthorizerInfo.IDC, resp_6.AuthorizerInfo.PrincipalName, authTime); return(new RESTfulModel() { Code = (int)CodeEnum.成功, Msg = string.Format(codeMsgDAL.GetByCode((int)CodeEnum.成功), "授权成功") }); } else { if (userID != authorizerInfoModel.UserID) { return(new RESTfulModel() { Code = (int)CodeEnum.失败, Msg = string.Format(codeMsgDAL.GetByCode((int)CodeEnum.失败), "公众帐号已授权绑定,如有帐号争执,请联系客服") }); } authorizerInfoDAL.Update( authorizerAppID, resp_6.AuthorizerInfo.NickName, resp_6.AuthorizerInfo.HeadImg, resp_6.AuthorizerInfo.ServiceTypeInfo.ID, resp_6.AuthorizerInfo.VerifyTypeInfo.ID, resp_6.AuthorizerInfo.Alias, resp_6.AuthorizerInfo.QrcodeUrl, resp_6.AuthorizerInfo.BusinessInfo.OpenPay, resp_6.AuthorizerInfo.BusinessInfo.OpenShake, resp_6.AuthorizerInfo.BusinessInfo.OpenScan, resp_6.AuthorizerInfo.BusinessInfo.OpenCard, resp_6.AuthorizerInfo.BusinessInfo.OpenStore, resp_6.AuthorizerInfo.IDC, resp_6.AuthorizerInfo.PrincipalName, authTime); return(new RESTfulModel() { Code = (int)CodeEnum.成功, Msg = string.Format(codeMsgDAL.GetByCode((int)CodeEnum.成功), "授权成功") }); } }