public static NowApiResponse <Dictionary <string, BikeResponse> > BikeCheck(string city) { string url = string.Format("http://api.k780.com/?app=pbike.state&city={0}&appkey={1}&sign={2}&format={3}", city, Appkey, Sign, Format); string jsonStr = HttpMethods.HttpGet(url); return(jsonStr.ToObject <NowApiResponse <Dictionary <string, BikeResponse> > >()); }
/// <summary> /// 获取开彩网双色球信息 /// 开彩网API开放平台(免费接口)的开奖结果调用不需要进行任何注册或申请即可直接调用。 /// 开彩网API开放平台(免费接口)的开奖结果发布有2分钟至6分钟的随机延迟。 /// 开彩网API开放平台(免费接口)在调用过程中请注意控制每种彩票访问间隔不小于10秒。 /// </summary> public CrawlSSQInfo KcAPI() { var ssqJson = HttpMethods.HttpGet(CrawlerUrl.ssq); var ssqInfo = JsonHelper.Deserialize <CrawlSSQInfo>(ssqJson); return(ssqInfo); }
public static string GetWeatherbyCityidStr(string cityId) { string _postUrl = string.Format(WeatherBasic, cityId); string _rseult = HttpMethods.HttpGet(_postUrl); return(_rseult); }
public JsonResult GetAuthorityBotton() { //AuthorizeBLL authBLL = new AuthorizeBLL(); //return authBLL.GetOperAuthority(OperatorProvider.Provider.Current(), Request.Cookies["currentmoduleId"].Value, enCode); //20190515 sx 从双控对接按钮和数据权限 try { string userId = OperatorProvider.Provider.Current().UserId; string moduleId = Request.Cookies["currentmoduleId"].Value; string res = HttpMethods.HttpGet(Path.Combine(Config.GetValue("ErchtmsApiUrl"), "BaseData", "getUserPermission") + "?" + string.Format("userId={0}&moduleId={1}", userId, moduleId)); var ret = JsonConvert.DeserializeObject <RetData>(res); return(Json(new { ret.data.operScope, ret.data.dataScope, id1 = userId, id2 = moduleId })); //string operScote = JsonConvert.SerializeObject(ret.data.operScope); //string dataScope = JsonConvert.SerializeObject(ret.data.dataScope ); //return new { operScote= operScote, dataScope= dataScope }; //string s = "{\"operScope\":[{\"encode\":\"add\",\"fullname\":\"新增\",\"faimage\":\"fa fa-plus\",\"actionname\":\"fn$add\"},{\"encode\":\"export\",\"fullname\":\"导出\",\"faimage\":\"fa fa-download\",\"actionname\":\"export\"}]\",\"dataScope\":[{\"authorizetype\":4.0,\"encode\":\"edit\",\"faimage\":\"fa fa-pencil-square-o\",\"actionname\":\"fn$edit\",\"fullname\":\"修改\"},{\"authorizetype\":4.0,\"encode\":\"delete\",\"faimage\":\"fa fa-trash-o\",\"actionname\":\"del\",\"fullname\":\"删除\"},{\"authorizetype\":4.0,\"encode\":\"dafen\",\"faimage\":\"fa fa-calculator\",\"actionname\":\"fn$score\",\"fullname\":\"打分\"},{\"authorizetype\":4.0,\"encode\":\"fabu\",\"faimage\":\"fa fa-rocket\",\"actionname\":\"fn$publish\",\"fullname\":\"发布\"}]}"; //return s; } catch (Exception ex) { return(Json("")); } }
/// <summary> /// 获取IP地址信息 /// </summary> /// <param name="ip"></param> /// <returns></returns> public static string GetLocation(string ip) { string res = ""; try { string url = "http://apis.juhe.cn/ip/ip2addr?ip=" + ip + "&dtype=json&key=b39857e36bee7a305d55cdb113a9d725"; res = HttpMethods.HttpGet(url); var resjson = res.ToObject <objex>(); res = resjson.result.area + " " + resjson.result.location; } catch { res = ""; } if (!string.IsNullOrEmpty(res)) { return(res); } try { string url = "https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=" + ip + "&resource_id=6006&ie=utf8&oe=gbk&format=json"; res = HttpMethods.HttpGet(url, Encoding.GetEncoding("GBK")); var resjson = res.ToObject <obj>(); res = resjson.data[0].location; } catch { res = ""; } return(res); }
public TrafficResult GetTrafficAroundUrl(TrafficAround trafficAround) { Dictionary <string, string> kv = new Dictionary <string, string>(); //kv.Add("ip", "39.91.109.120"); foreach (PropertyInfo pro in typeof(TrafficAround).GetProperties()) { string value = pro.GetValue(trafficAround, null)?.ToString(); string name = pro.Name.ToLower(); if (string.IsNullOrEmpty(value)) { continue; } if (name == "sn") { continue; } kv.Add(name, value); } kv.Add("ak", BaiduMapRoad.AK); var sn = GetSN(trafficAround); string queryparams = kv.GetQueryString(); var url = BaiduMapRoad.Url + "?" + queryparams + "&sn=" + sn; TrafficResult res = HttpMethods.HttpGet <TrafficResult>(url, Encoding.UTF8); return(res); }
public static NowApiResponse <PhoneResponse> PhoneCheck(string phone) { string url = string.Format("http://api.k780.com/?app=phone.get&phone={0}&appkey={1}&sign={2}&format={3}", phone, Appkey, Sign, Format); string jsonStr = HttpMethods.HttpGet(url); var ret = jsonStr.ToObject <NowApiResponse <PhoneResponse> >(); return(ret); }
public static WeatherData GetWeatherbyCityid(string cityId) { string _postUrl = string.Format(WeatherBasic, cityId); string _rseult = HttpMethods.HttpGet(_postUrl); WeatherData _weatherInfo = _rseult.ToObject <WeatherData>(); return(_weatherInfo); }
public static NowApiResponse <PM25Response> PM25Check(string city) { string url = string.Format("http://api.k780.com/?app=weather.pm25&weaid={0}&appkey={1}&sign={2}&format={3}", city, Appkey, Sign, Format); string jsonStr = HttpMethods.HttpGet(url); var ret = jsonStr.ToObject <NowApiResponse <PM25Response> >(); return(ret); }
public static QQUserInfo GetQQUserInfo(string access_token, string openid) { string url = string.Format("https://graph.qq.com/user/get_user_info?access_token={0}&oauth_consumer_key={1}&openid={2}", access_token, appId, openid); string result = HttpMethods.HttpGet(url, Encoding.UTF8); QQUserInfo qqUserInfo = JsonConvert.DeserializeObject <QQUserInfo>(result); return(qqUserInfo); }
public static NowApiResponse <IdCardResponse> IdCardCheck(string idCard) { string url = string.Format("http://api.k780.com/?app=idcard.get&idcard={0}&appkey={1}&sign={2}&format={3}", idCard, Appkey, Sign, Format); string jsonStr = HttpMethods.HttpGet(url); var ret = jsonStr.ToObject <NowApiResponse <IdCardResponse> >(); return(ret); }
public static NowApiResponse <ShortUrlResponse> ShortUrl(string sourceUrl, string fixedUrl = "") { string url = string.Format("http://api.k780.com/?app=shorturl.set&url={0}&fixed={1}&appkey={2}&sign={3}&format={4}", sourceUrl, fixedUrl, Appkey, Sign, Format); string jsonStr = HttpMethods.HttpGet(url); var ret = jsonStr.ToObject <NowApiResponse <ShortUrlResponse> >(); return(ret); }
public static string GetOpenId(string access_token) { string url = string.Format("https://graph.qq.com/oauth2.0/me?access_token={0}", access_token); string result = HttpMethods.HttpGet(url); string client_id = CutString(result, @"client_id"":""", @""","); string openid = CutString(result, @"openid"":""", @"""}"); return(openid); }
public static string GetAccessToken(string code) { string url = string.Format("https://graph.qq.com/oauth2.0/token?grant_type={0}&client_id={1}&client_secret={2}&code={3}&redirect_uri={4}", "authorization_code", appId, appKey, code, redirect_uri); string result = HttpMethods.HttpGet(url); string AccessToken = CutString(result, "access_token=", "&expires_in="); string ExpiresIn = CutString(result, "&expires_in=", "&refresh_token="); string RefreshToken = result.Split(new string[] { "&refresh_token=" }, StringSplitOptions.None)[1]; return(AccessToken); }
/// <summary> /// 通过接口获取数据 /// </summary> /// <returns></returns> protected static string Request(string url) { Hashtable headht = new Hashtable(); headht.Add("X-WAF-UUID", "271e7cdd-14b7-4e1b-a8f0-dfe7a3e870ba"); headht.Add("X-Cache", "MISS"); headht.Add("Vary", "Accept-Encoding"); headht.Add("X-Powered-By", "PHP/5.6.38"); headht.Add("Server", "nginx"); var result = HttpMethods.HttpGet(url); return(result); }
// GET: Test public ActionResult Index() { var str = string.Empty; try { // 创建一个 StreamReader 的实例来读取文件 // using 语句也能关闭 StreamReader //using (StreamReader sr = new StreamReader(Server.MapPath("/Log/2018-03-22.log"),Encoding.GetEncoding("GB2312"))) //{ // string line; // var i = 0; // // 从文件读取并显示行,直到文件的末尾 // while ((line = sr.ReadLine()) != null) // { // //i++; // //if (i > 2) //只读两行文本 // //{ // // break; // //} // str += line+"<br />"; // } //} using (StreamReader sr = new StreamReader(Server.MapPath("/Log/2018-03-22.log"), Encoding.GetEncoding("GB2312"))) { str = sr.ReadToEnd().Replace("\r\n", "<br/>"); //读取文本所有内容 } ViewBag.ClientIP = Net.GetWebClientIp(); ViewBag.LanIP = Net.GetLanIp(); ViewBag.ServerIP = Net.GetWebRemoteIp(); var data = HttpMethods.HttpGet("http://localhost:55216/Com/Disease/GetList"); ViewData["data"] = data; var ComData = HttpMethods.HttpPost("http://localhost:55216/Com/Disease/Del", "DiseaseId=17"); //string[] line = System.IO.File.ReadAllLines(Server.MapPath("/Log/2018-03-22.log"),Encoding.GetEncoding("GB2312")); //str = line[1]; } catch (Exception e) { // 向用户显示出错消息 Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } ViewData["str"] = str; return(View()); }
/// <summary> /// 得到ip定位 /// </summary> /// <param name="ip">不传为当前请求地址</param> /// <param name="coor">设置返回位置信息中,经纬度的坐标类型,分别如下 coor不出现、或为空:百度墨卡托坐标,即百度米制坐标; coor = bd09ll:百度经纬度坐标,在国测局坐标基础之上二次加密而来;coor = gcj02:国测局02坐标,在原始GPS坐标基础上,按照国家测绘行业统一要求,加密后的坐标;注:百度地图的坐标类型为bd09ll,如果结合百度地图使用,请注意坐标选择。</param> /// <returns></returns> public static LocationModel GetLocationByIp(string ip, string coor = "bd09ll") { try { string FormatUrl = Url + "location/ip?ip={0}&ak={1}&coor={2}"; string urlStr = string.Format(FormatUrl, ip, AK, coor); string result = HttpMethods.HttpGet(urlStr); LocationModel model = Json.ToObject <LocationModel>(result); return(model); } catch (Exception) { return(null); } }
public string GetOperAuthority(string enCode) { //AuthorizeBLL authBLL = new AuthorizeBLL(); //return authBLL.GetOperAuthority(OperatorProvider.Provider.Current(), Request.Cookies["currentmoduleId"].Value, enCode); //20190515 sx 从双控对接按钮和数据权限 string userId = OperatorProvider.Provider.Current().UserId; string moduleId = Request.Cookies["currentmoduleId"].Value; string res = HttpMethods.HttpGet(Path.Combine(Config.GetValue("ErchtmsApiUrl"), "BaseData", "getUserPermission") + "?" + string.Format("userId={0}&moduleId={1}", userId, moduleId)); var ret = JsonConvert.DeserializeObject <RetData>(res); if (ret != null && ret.code == 0 && ret.data != null) { //成功 return(ret.data.operScope); } return(""); }
/// <summary> /// 获取双控授权的模块 /// </summary> /// <param name="platform">平台类型 0 windows 1 安卓终端 2手机APP</param> /// <returns></returns> public List <MenuConfigEntity> GetMenuConfigList(int platform) { try { string res = HttpMethods.HttpGet(Path.Combine(Config.GetValue("ErchtmsApiUrl"), "MenuConfig", "GetMenuList") + "?" + string.Format("platform={0}", platform)); MenuRespone dy = JsonConvert.DeserializeObject <MenuRespone>(res); if (dy.Code == 0) { return(dy.Data); } else { return(new List <MenuConfigEntity>()); } } catch (Exception ex) { return(new List <MenuConfigEntity>()); } }
public void GetModel() { string res = HttpMethods.HttpGet("http://localhost:30004/api/test/2/"); }
protected void BtnSubmit_Click(object sender, EventArgs e) { UserName = Request.Form["UserName"].ToString().Trim(); Password = Request.Form["Password"].ToString().Trim(); Password2 = Request.Form["Password2"].ToString().Trim(); try { Result = CustBasicInfo.IsExistUser(UserName); if (Result != 0) { errorHint.InnerHtml = "<script type='text/javascript'>showError('用户名已存在!')</script>"; return; } Result = UserRegistry.UserRegisterWebLowStint(SPID, UserName, Password, out CustID, out ErrMsg); if (Result == 0) { // 重定向到欢迎页面 String IPAddress = Request.UserHostAddress.ToString(); CommonBizRules.WriteTraceIpLog(CustID, UserName, SPID, IPAddress, "client_wap"); String youhuiquan_url = "http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToRegist&wt=json&from=" + Device + "&custId=" + CustID; String jsonmsg = HttpMethods.HttpGet(youhuiquan_url); System.Collections.Generic.Dictionary <string, string> resuzt = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.Dictionary <string, string> >(jsonmsg); //{"returnCode":"00000"} string youhuiquan = ""; resuzt.TryGetValue("returnCode", out youhuiquan); String TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SPInfoManager spInfo = new SPInfoManager(); Object SPData = spInfo.GetSPData(this.Context, "SPData"); String key = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData); String Digest = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key); String temp = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key); String RegistryResponseValue = HttpUtility.UrlEncode(temp); //给用户写cookie UserToken UT = new UserToken(); String RealName = UserName; String NickName = UserName; string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, "", "42", UserName, "1", key, out ErrMsg); string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"]; PageUtility.SetCookie(UserTokenValue, CookieName, this.Page); CreateSPTokenRequest(); StringBuilder URL = new StringBuilder(); URL.Append("LowSintRegisterMSuccess.aspx?SPID="); Response.Redirect(URL.ToString() + SPID + "&SPTokenRequest=" + newSPTokenRequest, true); } else { errorHint.InnerHtml = "<script type='text/javascript'>showError('注册失败:" + ErrMsg + "')</script>"; return; } } catch (Exception exp) { errorHint.InnerHtml = "<script type='text/javascript'>showError('" + exp.ToString() + "!')</script>"; return; } }
public String RegisterInLowstingHttp(String SPID, String UserName, String PassWord, String PassWord2, String Device, String ShareCode, String wt) { StringBuilder ResponseMsg = new StringBuilder(); #region 数据校验 if (CommonUtility.IsEmpty(SPID)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "SPID不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(UserName)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "996"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "996"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "UserName不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(AuthenCode)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AuthenCode不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "998"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "AuthenCode不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } String t_CustID = String.Empty; String msg = String.Empty; int k = PhoneBO.SelSendSMSMassage(t_CustID, UserName, AuthenCode, out msg); if (k != 0) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "验证码不正确!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "998"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "验证码不正确!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } String regMobile = @"^1[345678]\d{9}$"; //String regEmail = @"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$"; //String RegularUserName = @"^[a-zA-Z][a-zA-Z0-9]*([-._]?[a-zA-Z0-9]+)*$"; if (!ValidateUserName(UserName, regMobile)) //if (!ValidateUserName(UserName, RegularUserName)) { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "991"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName只能是手机号码!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "991"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "UserName只能是手机号码!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(PassWord)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "PassWord不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(PassWord2)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord2不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "PassWord2不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (!PassWord.Equals(PassWord2)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1001"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "密码不一致!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1001"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "密码不一致!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } #endregion String appId = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId; String appSecret = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret; String version = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion; String clientType = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType; String clientIp = HttpContext.Current.Request.UserHostAddress; String clientAgent = HttpContext.Current.Request.UserAgent; String sendSms = UDBConstDefinition.DefaultInstance.UnifyPlatformRegisterAccountSendSms; if (String.IsNullOrEmpty(sendSms)) { sendSms = "false"; } //综合平台隐式注册只支持手机,也就是说,用户名模式,放弃注册为天翼账号,仅注册为号百用户 //既有用户名又有手机的,放弃注册天翼账号 String Unify_ErrMsg = String.Empty; String userId = String.Empty; String o_userName = String.Empty; String accessToken = String.Empty; //msg.AppendFormat("注册天翼账号:\r\n"); int Unify_Result = CIP2BizRules.RegisterUnifyPlatformAccount(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, PassWord, sendSms, out userId, out o_userName, out accessToken, out Unify_ErrMsg); //msg.AppendFormat("注册天翼账号,Result:{0},accessToken:{1},userId:{2},usrName:{3},ErrMsg:{4}\r\n", Unify_Result, accessToken, userId, o_userName, Unify_ErrMsg); if (Unify_Result == 0 && !String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(accessToken)) { //Result = UserRegistry.UserRegisterWebLowStintV3(SPID, UserName, PassWord, Device, ShareCode, out CustID, out ErrMsg); UDBMBOSS _UDBMBoss = new UDBMBOSS(); UnifyAccountInfo accountInfo = new UnifyAccountInfo(); Unify_Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, accessToken, clientIp, clientAgent, out accountInfo, out Unify_ErrMsg); String OuterID, Status, CustType, CustLevel, NickName, Email, CertificateCode, CertificateType, Sex, RealName, EnterpriseID, ProvinceID, AreaID, RegistrationSource; if (Unify_Result == 0 && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId))) { String MobileName = String.Empty; String EmailName = String.Empty; if (!String.IsNullOrEmpty(accountInfo.nickName)) { RealName = accountInfo.nickName; } else if (!String.IsNullOrEmpty(accountInfo.userName)) { RealName = accountInfo.userName; } else if (!String.IsNullOrEmpty(accountInfo.mobileName)) { RealName = accountInfo.mobileName; } else if (!String.IsNullOrEmpty(accountInfo.emailName)) { RealName = accountInfo.emailName; } else { RealName = ""; } if (!String.IsNullOrEmpty(accountInfo.mobileName)) { MobileName = accountInfo.mobileName; } if (!String.IsNullOrEmpty(accountInfo.emailName)) { EmailName = accountInfo.emailName; } String EncrytpPassWord = CryptographyUtil.Encrypt(PassWord); String OperType = "2"; // 注册 , if (!String.IsNullOrEmpty(MobileName) || !String.IsNullOrEmpty(EmailName)) { CustID = String.Empty; Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, accountInfo.userId, SPID, OperType, out CustID, out ErrMsg); if (Result == 0 && !String.IsNullOrEmpty(CustID)) { Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName, out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID, out AreaID, out RegistrationSource); CommonBizRules.WriteTraceIpLog(CustID, UserName, SPID, Request.UserHostAddress.ToString(), "client_zc"); String youhuiquan_url = "http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=" + Device + "®isterCustId=" + CustID; String jsonmsg = HttpMethods.HttpGet(youhuiquan_url); System.Collections.Generic.Dictionary <string, string> resuzt = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.Dictionary <string, string> >(jsonmsg); //{"returnCode":"00000"} string youhuiquan = ""; resuzt.TryGetValue("returnCode", out youhuiquan); ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0"); ResponseMsg.AppendFormat("\"CustID\":\"{0}\",", CustID); ResponseMsg.AppendFormat("\"returnCode\":\"{0}\",", youhuiquan); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "注册成功!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<CustID>{0}</CustID>", CustID); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "注册成功!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } } else { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-11"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "MobileName或EmailName为空不能注册天翼账号所以号百注册也失败!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-11"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "MobileName或EmailName为空不能注册天翼账号所以号百注册也失败!!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } //http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=ios®isterCustId=134664179 //"http://116.228.55.13:8113/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=ios®isterCustId= } else { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-10"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "号百账号注册失败!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-10"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "号百账号注册失败!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } } else { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-10"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "天翼账号注册失败!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-10"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "天翼账号注册失败!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } return(ResponseMsg.ToString()); }
public String RegisterInLowstingHttp(String SPID, String UserName, String PassWord, String PassWord2, String Device, String wt) { StringBuilder ResponseMsg = new StringBuilder(); #region 数据校验 if (CommonUtility.IsEmpty(SPID)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "SPID不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(UserName)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "996"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "996"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "UserName不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(AuthenCode)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AuthenCode不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "998"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "AuthenCode不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } String t_CustID = String.Empty; String msg = String.Empty; int k = PhoneBO.SelSendSMSMassage(t_CustID, UserName, AuthenCode, out msg); if (k != 0) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "验证码不正确!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "998"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "验证码不正确!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } String regMobile = @"^1[345678]\d{9}$"; String regEmail = @"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$"; String RegularUserName = @"^[a-zA-Z][a-zA-Z0-9]*([-._]?[a-zA-Z0-9]+)*$"; if (!ValidateUserName(UserName, regMobile)) //if (!ValidateUserName(UserName, RegularUserName)) { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "991"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName只能是手机号码!"); //ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName不合乎规范!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "991"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "UserName只能是手机号码!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(PassWord)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "PassWord不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (CommonUtility.IsEmpty(PassWord2)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord2不能为空!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "PassWord2不能为空!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } if (!PassWord.Equals(PassWord2)) { // 返回错误信息 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1001"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "密码不一致!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1001"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "密码不一致!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } //Result = CustBasicInfo.IsExistUser(UserName); //if (Result != 0) //{ // // 返回错误信息 // ResponseMsg.Length = 0; // if ("json".Equals(wt)) // { // ResponseMsg.Append("{"); // ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1000"); // ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "用户名已经存在!"); // ResponseMsg.Append("}"); // } // else // { // ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // ResponseMsg.Append("<PayPlatRequestParameter>"); // ResponseMsg.Append("<PARAMETERS>"); // ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1000"); // ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "用户名已经存在!"); // ResponseMsg.Append("</PARAMETERS>"); // ResponseMsg.Append("</PayPlatRequestParameter>"); // } // return ResponseMsg.ToString(); //} //验证码校验 //if (!CommonUtility.ValidateValidateCode(HttpUtility.HtmlDecode(checkCode), this.Context)) //{ //hintError提示错误验证码校验未通过 //errorHint.InnerHtml = "验证码校验未通过!"; //return; //} #endregion String appId = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId; String appSecret = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret; String version = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion; String clientType = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType; String clientIp = HttpContext.Current.Request.UserHostAddress; String clientAgent = HttpContext.Current.Request.UserAgent; String sendSms = UDBConstDefinition.DefaultInstance.UnifyPlatformRegisterAccountSendSms; if (String.IsNullOrEmpty(sendSms)) { sendSms = "false"; } //综合平台隐式注册只支持手机,也就是说,用户名模式,放弃注册为天翼账号,仅注册为号百用户 //既有用户名又有手机的,放弃注册天翼账号 String Unify_ErrMsg = String.Empty; String userId = String.Empty; String o_userName = String.Empty; String accessToken = String.Empty; //msg.AppendFormat("注册天翼账号:\r\n"); int Unify_Result = CIP2BizRules.RegisterUnifyPlatformAccount(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, PassWord, sendSms, out userId, out o_userName, out accessToken, out Unify_ErrMsg); //msg.AppendFormat("注册天翼账号,Result:{0},accessToken:{1},userId:{2},usrName:{3},ErrMsg:{4}\r\n", Unify_Result, accessToken, userId, o_userName, Unify_ErrMsg); if (Unify_Result == 0 && !String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(accessToken)) { Result = UserRegistry.UserRegisterWebLowStintV2(SPID, UserName, PassWord, Device, out CustID, out ErrMsg); if (Result == 0) { String IPAddress = Request.UserHostAddress.ToString(); CommonBizRules.WriteTraceIpLog(CustID, UserName, SPID, IPAddress, "client_zc"); String youhuiquan_url = "http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToRegist&wt=json&from=" + Device + "&custId=" + CustID; String jsonmsg = HttpMethods.HttpGet(youhuiquan_url); System.Collections.Generic.Dictionary <string, string> resuzt = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.Dictionary <string, string> >(jsonmsg); //{"returnCode":"00000"} string youhuiquan = ""; resuzt.TryGetValue("returnCode", out youhuiquan); //建立绑定关系 (待完成) //因暂时不支持lognum ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0"); ResponseMsg.AppendFormat("\"CustID\":\"{0}\",", CustID); ResponseMsg.AppendFormat("\"returnCode\":\"{0}\",", youhuiquan); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "注册成功!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<CustID>{0}</CustID>", CustID); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "注册成功!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } else { // 账号注册失败 ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-1"); ResponseMsg.AppendFormat("\"CustID\":\"{0}\",", ""); ResponseMsg.AppendFormat("\"returnCode\":\"{0}\",", ""); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "注册失败!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<CustID>{0}</CustID>", ""); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-1"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "注册失败!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } } else { ResponseMsg.Length = 0; if ("json".Equals(wt)) { ResponseMsg.Append("{"); ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-11"); ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "天翼账号注册失败!"); ResponseMsg.Append("}"); } else { ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ResponseMsg.Append("<PayPlatRequestParameter>"); ResponseMsg.Append("<PARAMETERS>"); ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-11"); ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "天翼账号注册失败!"); ResponseMsg.Append("</PARAMETERS>"); ResponseMsg.Append("</PayPlatRequestParameter>"); } return(ResponseMsg.ToString()); } return(ResponseMsg.ToString()); }
public IHttpActionResult MemberRegister(string username, string userpwd, string yzm, string useryz, string fw) { Regex accountRex = new Regex("^[A-Za-z0-9_][A-Za-z0-9_]*$"); if (!accountRex.IsMatch(username)) { return(Json(new { code = 0, Msg = "用户名包含非法字符" })); } DbHelper helper = new DbHelper("QpAccount"); string sql = string.Format("select * from account where account='{0}'", username); DataSet ds = helper.GetDataTablebySQL(sql); if (ds.Tables[0].Rows.Count > 0) { return(Json(new { code = 0, Msg = "用户名已经存在" })); } string sqlMaxNum = "select MAX(AccountNum) from Account"; DataSet dsMaxNum = helper.GetDataTablebySQL(sqlMaxNum); int num = 100000; if (dsMaxNum.Tables[0].Rows.Count > 0) { num = dsMaxNum.Tables[0].Rows[0][0].ToInt() + 1; } string account = username; string password = userpwd; string accounttype = "11"; string accountsecondtype = "0"; string sex = "2"; string nickname = "新手" + num; string accountnum = num.ToString(); string ipaddress = Net.Ip; string mac = string.Join(" , ", Tz.Core.Net.GetMacByNetworkInterface()); string details = "|||0|0|||||||"; //|密保问题|密保答案|年龄|身高cm|学历|生肖|星座|职业|省|市| //string[] userInfo = details.Split('|'); //string mbwt = userInfo[1]; //string mbda = userInfo[2]; //string age = userInfo[3]; //string sg = userInfo[4]; //string xl = userInfo[5]; //string sx = userInfo[6]; //string xz = userInfo[7]; //string zy = userInfo[8]; //string sheng = userInfo[9]; //string shi = userInfo[10]; string realname = ""; string idntirycard = ""; string telephone = ""; string parentid = ""; string Url = GetUrlStr() + string.Format("function={0}&account={1}&password={2}&accounttype={3}&accountsecondtype={4}&sex={5}&nickname={6}&accountnum={7}&ipaddress={8}&mac={9}&details={10}", "register", account, password, accounttype, accountsecondtype, sex, nickname, accountnum, ipaddress, mac, details); string msg = HttpMethods.HttpGet(Url); return(Json(new { code = 0, Msg = "" })); }
public String getMobileSelfReg(String imsi) { String mobile = String.Empty; StringBuilder requestXml = new StringBuilder(); String responseXml = String.Empty; #region 拼接请求xml字符串 String appKey = System.Configuration.ConfigurationManager.AppSettings["BesttoneOpenApi_appKey"]; // "ED150A183B8DE9A3E040A8C030B452AD"; String appSecret = System.Configuration.ConfigurationManager.AppSettings["BesttoneOpenApi_appSecret"]; //"ED150A183B8EE9A3E040A8C030B452AD"; String apiName = System.Configuration.ConfigurationManager.AppSettings["BesttoneOpenApi_apiName"]; //"mobile"; String apiMethod = System.Configuration.ConfigurationManager.AppSettings["BesttoneOpenApi_apiMethod"]; //"getMobileSelfReg"; if (String.IsNullOrEmpty(appKey)) { appKey = "ED150A183B8DE9A3E040A8C030B452AD"; } if (String.IsNullOrEmpty(appSecret)) { appSecret = "ED150A183B8EE9A3E040A8C030B452AD"; } if (String.IsNullOrEmpty(apiName)) { apiName = "mobile"; } if (String.IsNullOrEmpty(apiMethod)) { apiMethod = "getMobileSelfReg"; } requestXml.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); requestXml.Append("<reqXML version=\"1.0\">"); //添加参数 requestXml.AppendFormat("<appKey>{0}</appKey>", appKey); requestXml.AppendFormat("<apiName>{0}</apiName>", apiName); requestXml.AppendFormat("<apiMethod>{0}</apiMethod>", apiMethod); requestXml.AppendFormat("<timestamp>{0}</timestamp>", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); requestXml.Append("<params>"); requestXml.AppendFormat("<param name=\"imsi\" value='{0}' />", imsi); //手机IMSI号 requestXml.Append("</params>"); requestXml.Append("</reqXML>"); #endregion #region 提交请求 String serverAddress = System.Configuration.ConfigurationManager.AppSettings["BesttoneOpenApiURL"]; // "http://open.118114.cn/"; if (String.IsNullOrEmpty(serverAddress)) { serverAddress = "http://open.118114.cn/"; } String url = serverAddress + "api?reqXml=" + HttpUtility.UrlEncode(requestXml.ToString(), Encoding.UTF8) + "&sign=" + getMD5Str(requestXml.ToString() + appSecret); responseXml = HttpMethods.HttpGet(url); #endregion #region 解析返回报文并取出手机号码 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(responseXml); XmlNode dataNode = xmlDoc.SelectNodes("/data")[0]; mobile = String.Empty; if (dataNode != null) { mobile = dataNode.Attributes["mobile"].Value; } XmlNode errorCodeNode = xmlDoc.SelectNodes("/error/errorCode")[0]; XmlNode errorMessageNode = xmlDoc.SelectNodes("/error/errorMessage")[0]; if (errorCodeNode != null) { mobile = ""; } #endregion return(mobile); }
public bool PostData(ReadRecordViewModel data) { var readTime = data.F_ReadTime == null ? "" : ((DateTime)data.F_ReadTime).ToString("yyyy-MM-dd HH:mm:ss"); return(HttpMethods.HttpGet("http://120.220.0.205:5080/Ammeter/upload/add?number=" + data.F_MeterCode + "&electricity=" + data.F_TotalDosage + "&time=" + readTime) == "true"); }
void DoCallback() { StringBuilder strLog = new StringBuilder(); if (CommonUtility.IsParameterExist("ReturnUrl", this.Page)) { ReturnUrl = Request["ReturnUrl"]; } else { //Logs.logSave("没有ReturnUrl返回"); strLog.AppendFormat("没有ReturnUrl返回\r\n"); } if (CommonUtility.IsParameterExist("code", this.Page)) { code = Request["code"]; } else { //Logs.logSave("没有code返回"); strLog.AppendFormat("没有code返回\r\n"); } if (CommonUtility.IsParameterExist("openid", this.Page)) { openid = Request["openid"]; } else { //Logs.logSave("没有openid返回"); strLog.AppendFormat("没有openid返回\r\n"); } if (CommonUtility.IsParameterExist("openkey", this.Page)) { openkey = Request["openkey"]; } else { //Logs.logSave("没有openkey返回"); strLog.AppendFormat("没有openkey返回\r\n"); } //写日志 //Logs.logSave("返回CODE结果:" + code+",返回的openid:"+openid+",返回的openkey:"+openkey); strLog.AppendFormat("返回CODE结果:" + code + ",返回的openid:" + openid + ",返回的openkey:" + openkey + "\r\n"); //==============通过Authorization Code和基本资料获取Access Token================= send_url = "https://open.t.qq.com/cgi-bin/oauth2/access_token?grant_type=authorization_code&client_id=" + client_id + "&client_secret=" + client_secret + "&code=" + code + "&state=" + state + "&redirect_uri=" + Utils.UrlEncode(redirect_uri); //https://open.t.qq.com/cgi-bin/oauth2/access_token?client_id=APP_KEY&client_secret=APP_SECRET&redirect_uri=http://www.myurl.com/example&grant_type=authorization_code&code=CODE send_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=" + client_id + "&client_secret=" + client_secret + "&code=" + code + "&state=" + state + "&redirect_uri=" + Utils.UrlEncode(redirect_uri); //写日志 //Logs.logSave("第二步,通过Authorization Code获取Access Token,发送URL:" + send_url); strLog.AppendFormat("第二步,通过Authorization Code获取Access Token,发送URL:" + send_url + "\r\n"); //发送并接受返回值 rezult = HttpMethods.HttpGet(send_url); // 返回内容:access_token=7a0fae7d2183c0c54ef18589fffe6475&expires_in=604800&refresh_token=15a0d166120bda818cd0782c0b7a8c1a&name=huoxintang //写日志 //Logs.logSave("取得返回结果:" + rezult); strLog.AppendFormat("取得返回结果:" + rezult + "\r\n"); //如果失败 if (rezult.Contains("error")) { //出错了 //写日志 //Logs.logSave("出错了:" + rezult); strLog.AppendFormat("出错了:" + rezult + "\r\n"); HttpContext.Current.Response.End(); } else { //======================通过Access Token来获取用户的OpenID 这一步不需要 =======graph需要======= string[] parm = rezult.Split('&'); //取得 access_token access_token = parm[0].Split('=')[1]; //取得 过期时间 expires_in = parm[1].Split('=')[1]; //refresh_token = parm[2].Split('=')[1]; 用graph 可能没有refresh_token //拼接url send_url = "https://graph.qq.com/oauth2.0/me?access_token=" + access_token; //发送并接受返回值 rezult = HttpMethods.HttpGet(send_url); //写日志 //Logs.logSave("第三步,发送 access_token:" + send_url); strLog.AppendFormat("第三步,发送 access_token:" + send_url + "\r\n"); //如果失败 if (rezult.Contains("error")) { //出错了 //写日志 //Logs.logSave("出错了:" + rezult); strLog.AppendFormat("出错了:" + rezult + "\r\n"); HttpContext.Current.Response.End(); } //写日志 //Logs.logSave("得到返回结果:" + rezult); strLog.AppendFormat("得到返回结果:" + rezult + "\r\n"); //取得文字出现 int str_start = rezult.IndexOf('(') + 1; int str_last = rezult.LastIndexOf(')') - 1; //取得JSON字符串 rezult = rezult.Substring(str_start, (str_last - str_start)); //反序列化JSON Dictionary <string, string> _dic = JsonConvert.DeserializeObject <Dictionary <string, string> >(rezult); //取值 _dic.TryGetValue("client_id", out new_client_id); _dic.TryGetValue("openid", out openid); //储存获取数据用到的信息 HttpContext.Current.Session["access_token"] = access_token; HttpContext.Current.Session["client_id"] = client_id; HttpContext.Current.Session["openid"] = openid; HttpContext.Current.Session["openkey"] = openkey; // 这里张剑锋还拿到了 Level,NickName,Gender //========继续您的业务逻辑编程========================================== //取到 openId //openId与您系统的user数据进行关联 //一个openid对应一个QQ,一个openid也要对应到您系统的一个账号:QQ--OpenId--User; //这个时候有两种情况: //【1】您让用户绑定系统已有的用户,那么让用户输入用户名密码,找到该用户,然后绑定OpenId //【2】为用户生成一个系统用户,直接绑定OpenId //上面完成之后,设置用户的登录状态,完整绑定和登录 //=============通过Access Token和OpenID来获取用户资料 ==== send_url = "https://open.t.qq.com/api/user/info?access_token=" + access_token + "&oauth_consumer_key=" + client_id + "&openid=" + openid + "&openkey=" + openkey + "&oauth_version=2.a"; //https://open.t.qq.com/api/user/info?access_token=7a0fae7d2183c0c54ef18589fffe6475&oauth_consumer_key=801210600&openid=65FCC7BC2B69619BC13BCF6C16FB06C3&oauth_version=2.a&openkey=05FB5E1C75119B141BAD0444C6EA41CE send_url = "https://graph.qq.com/user/get_user_info?access_token=" + access_token + "&oauth_consumer_key=" + client_id + "&openid=" + openid + "&openkey=" + openkey + "&oauth_version=2.a"; //发送并接受返回值 //Logs.logSave("发送send_url:" + send_url); strLog.AppendFormat("发送send_url:" + send_url + "\r\n"); rezult = HttpMethods.HttpGet(send_url); //写日志 //Logs.logSave("第四步,通过get_user_info方法获取数据:" + send_url); //Logs.logSave("rezult:" + rezult); strLog.AppendFormat("第四步,通过get_user_info方法获取数据:" + send_url + "\r\n"); strLog.AppendFormat("rezult:" + rezult + "\r\n"); //反序列化JSON /** * Dictionary<string, object> _data = JsonConvert.DeserializeObject<Dictionary<string, object>>(rezult); * object jsondata = null; * _data.TryGetValue("data", out jsondata); * string js_data = jsondata.ToString(); * Dictionary<string, object> useinfo_data = JsonConvert.DeserializeObject<Dictionary<string, object>>(js_data); * object nick = null; * object j_openid = null; * object sex = null; * object province_code = null; * object head = null; * object j_name = null; * useinfo_data.TryGetValue("nick", out nick); * useinfo_data.TryGetValue("openid", out j_openid); * useinfo_data.TryGetValue("sex", out sex); * useinfo_data.TryGetValue("province_code", out province_code); * useinfo_data.TryGetValue("head", out head); * useinfo_data.TryGetValue("name", out j_name); * Logs.logSave("====================="); * Logs.logSave("nickname:" + nick.ToString()); * Logs.logSave("openid:"+j_openid.ToString()); * Logs.logSave("sex:"+sex.ToString()); * Logs.logSave("Province_code:" + province_code.ToString()); * Logs.logSave("head:" + head.ToString()); * Logs.logSave("name:" + j_name.ToString()); * //Logs.logSave("jsondata:" + jsondata); * **/ Dictionary <string, string> _dic2 = JsonConvert.DeserializeObject <Dictionary <string, string> >(rezult); string ret = "", msg = "", nickname = "", face = "", sex = "", ret_openid = "", ret_name = ""; //取值 _dic2.TryGetValue("ret", out ret); _dic2.TryGetValue("msg", out msg); //如果失败 if (ret != "0") { //出错了 //写日志 //Logs.logSave("出错了:" + rezult); strLog.AppendFormat("出错了:" + rezult + "\r\n"); //HttpContext.Current.Response.Write(rezult); HttpContext.Current.Response.End(); } _dic2.TryGetValue("nickname", out nickname); _dic2.TryGetValue("head", out face); _dic2.TryGetValue("gender", out sex); _dic2.TryGetValue("openid", out ret_openid); _dic2.TryGetValue("name", out ret_name); //写日志 ///Logs.logSave("得到返回结果:" + rezult); strLog.AppendFormat("得到返回结果:" + rezult + "\r\n"); //string newline = "<br>"; //string str = ""; //str += "openid:" + openid + newline; //str += "昵称:" + nickname + newline; //str += "名称:" + ret_name + newline; //str += "性别:" + sex + newline; //str += "默认头像:" + face + newline; //页面输出结果: //HttpContext.Current.Response.Write("返回结果如下:" + rezult + newline + newline); //HttpContext.Current.Response.Write("经过处理后:" + newline + str); /** * string newline = "<br>"; * string str = ""; * str += "openid:" + j_openid.ToString() + newline; * str += "昵称:" + nick.ToString() + newline; * str += "名称:" + j_name.ToString() + newline; * str += "性别:" + sex.ToString() + newline; * str += "默认头像:" + head.ToString() + newline; * str += "省份:" + province_code.ToString() + newline; **/ //页面输出结果: //HttpContext.Current.Response.Write("返回结果如下:" + rezult + newline + newline); //HttpContext.Current.Response.Write("经过处理后:" + newline + str); string CustID = QueryByOpenID(openid); if (String.IsNullOrEmpty(CustID)) // 已有绑定关系 { //直接单点登录 string AuthenName = ""; string AuthenType = ""; string RealName = ""; string NickName = ""; string UserName = ""; string OutID = ""; string UserAccount = ""; string CustType = ""; string ProvinceID = ""; string _connectionString = WebConfigurationManager.ConnectionStrings["BestToneCenterConStr"].ConnectionString; SqlConnection con = new SqlConnection(_connectionString); SqlCommand cmd = new SqlCommand("select RealName,UserName,NickName,OuterID,CustType,SourceSPID from custinfo where custid=@CustID", con); cmd.Parameters.Add("@CustID", SqlDbType.NVarChar, 16).Value = CustID; using (con) { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { RealName = (string)reader["RealName"]; UserName = (string)reader["UserName"]; NickName = (string)reader["NickName"]; OutID = (string)reader["OuterID"]; CustType = (string)reader["CustType"]; SPID = (string)reader["SourceSPID"]; } } SPInfoManager spInfo = new SPInfoManager(); Object SPData = spInfo.GetSPData(this.Context, "SPData"); string key = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData); string ErrMsg = ""; //生成token并保存 UserToken UT = new UserToken(); string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OutID, CustType, AuthenName, AuthenType, key, out ErrMsg); string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"]; PageUtility.SetCookie(CookieName, UserTokenValue); TokenValidate.IsRedircet = false; TokenValidate.Validate(); //begin this.ssoFunc(); //Response.Redirect(ReturnUrl, true); //end } else // 未有绑定关系 (可能有号百账号-则去绑定,可能没有号百账号,则注册) { string SelectOauthAssertion = System.Configuration.ConfigurationManager.AppSettings["SelectOauthAssertion"]; SelectOauthAssertion = SelectOauthAssertion + "?code=" + openid + "&returnUrl=" + ReturnUrl + "&oauthtype=0"; // 0 代表qq 1代表sina Response.Redirect(SelectOauthAssertion, true); //SelectOauthAssertion 指向地址: http://sso.besttone.cn/SSO/boundingV2.action?code=***&returnUrl=*** //boundingV2.action 会forward到 他自己的一个auth.jsp ,这个jsp会嵌入两个iframe,其中一个iframe的src,指向客户信息平台的AuthBindLogin.aspx,另个iframe指向 客户信息平台的AuthRegister.aspx //同时分别带上SPTokenRequest和code参数,这个SPTokenRequest参数中的ReturnUrl } } log(strLog.ToString()); }
public IHttpActionResult TouristLogin(string verify) { Log.Debug("这个是游客登陆方法"); string upwd = "c8c8e2585e7555ee27396f4645b415ff"; Regex accountRex = new Regex("^[A-Za-z0-9_][A-Za-z0-9_]*$"); int len; len = verify.Length / 2; byte[] inputByteArray = new byte[len]; int x, i; for (x = 0; x < len; x++) { i = Convert.ToInt32(verify.Substring(x * 2, 2), 16); inputByteArray[x] = (byte)i; } byte[] mingwen = YSEncrypt.DecryptData(inputByteArray); string macAddress = Encoding.ASCII.GetString(mingwen); DbHelper helper = new DbHelper("QpAccount"); int rows = 0; string uname = string.Empty; do { uname = BuildAccount(); string sql = string.Format("select * from account where account='{0}'", uname); DataSet ds = helper.GetDataTablebySQL(sql); rows = ds.Tables[0].Rows.Count; } while (rows > 0); string sqlMaxNum = "select MAX(AccountNum) from Account"; DataSet dsMaxNum = helper.GetDataTablebySQL(sqlMaxNum); int num = 100000; if (dsMaxNum.Tables[0].Rows.Count > 0) { num = dsMaxNum.Tables[0].Rows[0][0].ToInt() + 1; } string account = uname; string password = upwd; string accounttype = "11"; string accountsecondtype = "0"; string sex = "2"; string nickname = uname; string accountnum = num.ToString(); string ipaddress = Net.Ip; string mac = Net.GetMacAddress();// string.Join(" , ", Tz.Core.Net.GetMacByNetworkInterface()); string details = "|||0|0|||||||"; //|密保问题|密保答案|年龄|身高cm|学历|生肖|星座|职业|省|市| //string[] userInfo = details.Split('|'); //string mbwt = userInfo[1]; //string mbda = userInfo[2]; //string age = userInfo[3]; //string sg = userInfo[4]; //string xl = userInfo[5]; //string sx = userInfo[6]; //string xz = userInfo[7]; //string zy = userInfo[8]; //string sheng = userInfo[9]; //string shi = userInfo[10]; string realname = ""; string idntirycard = ""; string telephone = ""; string parentid = ""; string Url = GetUrlStr() + string.Format("ysfunction={0}&account={1}&password={2}&accounttype={3}&accountsecondtype={4}&sex={5}&nickname={6}&accountnum={7}&ipaddress={8}&mac={9}&details={10}", "register", account, password, accounttype, accountsecondtype, sex, nickname, accountnum, ipaddress, mac, details); string msg = HttpMethods.HttpGet(Url); Regex rex = new Regex(@"(-\d+|\d+)<"); string result = "0"; string respson = rex.Match(msg).Groups[1].Value; Log.Debug(msg); if (respson != "-1" && respson != "-3" && respson != "-999" && respson != "-404") { result = "0&" + uname + "&" + upwd; } else { result = respson; } return(Json(result)); }
public IHttpActionResult MemberRegister(string username, string userpwd, string verify, string yzm, string useryz, string fw) { Log.Debug("这个是用户注册方法"); Regex accountRex = new Regex("^[A-Za-z0-9_][A-Za-z0-9_]*$"); if (!accountRex.IsMatch(username)) { return(Json(3)); } Log.Debug("返回token:" + fw); string code = Cache.Get(fw)?.ToString(); Log.Debug("服务器保存的验证码:" + code); Log.Debug("用户传递的验证码:" + Md5.md5(yzm.ToLower(), 16)); string yzmMd5 = Md5.md5(yzm.ToLower(), 16); if (code != yzmMd5) { return(Json(2)); } DbHelper helper = new DbHelper("QpAccount"); string sql = string.Format("select * from account where account='{0}'", username); DataSet ds = helper.GetDataTablebySQL(sql); if (ds.Tables[0].Rows.Count > 0) { return(Json(4)); } string sqlMaxNum = "select MAX(AccountNum) from Account"; DataSet dsMaxNum = helper.GetDataTablebySQL(sqlMaxNum); int num = 100000; if (dsMaxNum.Tables[0].Rows.Count > 0) { num = dsMaxNum.Tables[0].Rows[0][0].ToInt() + 1; } int len; len = verify.Length / 2; byte[] inputByteArray = new byte[len]; int x, i; for (x = 0; x < len; x++) { i = Convert.ToInt32(verify.Substring(x * 2, 2), 16); inputByteArray[x] = (byte)i; } byte[] mingwen = YSEncrypt.DecryptData(inputByteArray); string str = Encoding.ASCII.GetString(mingwen); string account = username; string password = userpwd; string accounttype = "11"; string accountsecondtype = "0"; string sex = "2"; string nickname = "新手" + num; string accountnum = num.ToString(); string ipaddress = Net.Ip; string mac = string.Join(" , ", Tz.Core.Net.GetMacByNetworkInterface()); string details = "|||0|0|||||||"; //|密保问题|密保答案|年龄|身高cm|学历|生肖|星座|职业|省|市| //string[] userInfo = details.Split('|'); //string mbwt = userInfo[1]; //string mbda = userInfo[2]; //string age = userInfo[3]; //string sg = userInfo[4]; //string xl = userInfo[5]; //string sx = userInfo[6]; //string xz = userInfo[7]; //string zy = userInfo[8]; //string sheng = userInfo[9]; //string shi = userInfo[10]; string realname = ""; string idntirycard = ""; string telephone = ""; string parentid = ""; string Url = GetUrlStr() + string.Format("ysfunction={0}&account={1}&password={2}&accounttype={3}&accountsecondtype={4}&sex={5}&nickname={6}&accountnum={7}&ipaddress={8}&mac={9}&details={10}", "register", account, password, accounttype, accountsecondtype, sex, nickname, accountnum, ipaddress, mac, details); string msg = HttpMethods.HttpGet(Url); Regex rex = new Regex(@"(-\d+|\d+)<"); int result = 0; string respson = rex.Match(msg).Groups[1].Value; Log.Debug(msg); if (respson != "-1" && respson != "-3" && respson != "-999" && respson != "-404") { result = 0; } else { result = respson.ToInt(); } return(Json(result)); }
protected void register_Click(object sender, EventArgs e) { Response.AddHeader("P3P", "CP=CAO PSA OUR"); UserName = Request.Form["userName"].ToString().Trim(); PassWord = Request.Form["password"].ToString().Trim(); PassWord2 = Request.Form["password2"].ToString().Trim(); checkCode = Request.Form["checkCode"].ToString().Trim(); String IPAddress = Request.UserHostAddress.ToString(); System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(Request.Url.AbsoluteUri); StringBuilder sbLog = new StringBuilder(); sbLog.AppendFormat("userName:{0}\r\n", UserName); sbLog.AppendFormat("password:{0}\r\n", PassWord); sbLog.AppendFormat("password2:{0}\r\n", PassWord2); sbLog.AppendFormat("checkCode:{0}\r\n", checkCode); try { if (!CommonUtility.ValidateValidateCode(HttpUtility.HtmlDecode(checkCode), this.Context)) { //hintError提示错误验证码校验未通过 errorHint.InnerHtml = "验证码校验未通过!"; sbLog.AppendFormat("验证码校验未通过!"); return; } if (!PassWord2.Equals(PassWord)) { errorHint.InnerHtml = "密码不一致!"; return; } Result = CustBasicInfo.IsExistUser(UserName); if (Result != 0) { errorHint.InnerHtml = "用户名已经存在!"; return; } Result = UserRegistry.UserRegisterWebLowStint(SPID, UserName, PassWord, out CustID, out ErrMsg); if (Result == 0) { //记录注册来源ip地址 CommonBizRules.WriteTraceIpLog(CustID, UserName, SPID, IPAddress, "web_zc"); if ("35433334".Equals(SPID)) { String youhuiquan_url = "http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToRegist&wt=json&from=web&custId=" + CustID; String jsonmsg = HttpMethods.HttpGet(youhuiquan_url); System.Collections.Generic.Dictionary <string, string> resuzt = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.Dictionary <string, string> >(jsonmsg); //{"returnCode":"00000"} string youhuiquan = ""; resuzt.TryGetValue("returnCode", out youhuiquan); } // 重定向到欢迎页面 sbLog.AppendFormat("注册成功:{0}\r\n", Result); String TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SPInfoManager spInfo = new SPInfoManager(); Object SPData = spInfo.GetSPData(this.Context, "SPData"); String key = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData); String Digest = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key); String temp = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key); String RegistryResponseValue = HttpUtility.UrlEncode(temp); sbLog.Append("给用户写Cookie\r\n"); //给用户写cookie UserToken UT = new UserToken(); String RealName = UserName; String NickName = UserName; string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, "", "42", UserName, "1", key, out ErrMsg); string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"]; PageUtility.SetCookie(UserTokenValue, CookieName, this.Page); sbLog.Append("创建新的SPTokenRequest\r\n"); CreateSPTokenRequest(); StringBuilder URL = new StringBuilder(); String RegisterInLowstintSuccessURL = ConfigurationManager.AppSettings["RegisterInLowstintSuccessURL"].ToString(); //// 邮箱指向authenv2.aspx if (String.IsNullOrEmpty(RegisterInLowstintSuccessURL)) { RegisterInLowstintSuccessURL = "RegisterSuccessV2.aspx?SPID="; } URL.Append(RegisterInLowstintSuccessURL); //Response.Redirect(URL.ToString() + SPID + "&ReturnUrl=" + ReturnUrl + "&SPTokenRequest=" + newSPTokenRequest, false); //用Redirect 无法从request 的refer 中获得从哪个页面来的 // Server.Transfer //Server.Transfer方法把执行流程从当前的ASPX文件转到同一服务器上的另一个ASPX页面。调用Server.Transfer时,当前的ASPX页面终止执行,执行流程转入另一个ASPX页面,但新的ASPX页面仍使用前一ASPX页面创建的应答流。 //如果用Server.Transfer方法实现页面之间的导航,浏览器中的URL不会改变,因为重定向完全在服务器端进行,浏览器根本不知道服务器已经执行了一次页面变换。 //默认情况下,Server.Transfer方法不会把表单数据或查询字符串从一个页面传递到另一个页面,但只要把该方法的第二个参数设置成True,就可以保留第一个页面的表单数据和查询字符串。 //同时,使用Server.Transfer时应注意一点:目标页面将使用原始页面创建的应答流,这导致ASP.NET的机器验证检查(Machine Authentication Check,MAC)认为新页面的ViewState已被篡改。因此,如果要保留原始页面的表单数据和查询字符串集合,必须把目标页面Page指令的EnableViewStateMac属性设置成False。 sbLog.Append("重定向:"); //Response.Redirect(URL.ToString() + SPID + "&ReturnUrl=" + ReturnUrl + "&SPTokenRequest=" + newSPTokenRequest, true); Server.Transfer(URL.ToString() + SPID + "&ReturnUrl=" + ReturnUrl + "&SPTokenRequest=" + newSPTokenRequest, true); } else { sbLog.AppendFormat("注册失败:{0}\r\n", ErrMsg); errorHint.InnerHtml = "注册失败:" + ErrMsg; return; } } catch (Exception ex) { sbLog.Append(ex.Message); errorHint.InnerHtml = ex.ToString(); return; //重定向到错误页面 } finally { log(sbLog.ToString()); } }