protected void Page_Load(object sender, EventArgs e) { string uer_code = Request["code"].ToString(); //code作为换取access_token的票据,每次用户授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。 //string uer_state = "oNOvqwo-qNYgd0d7bgV2rrn-s9Nc";// Request["state"].ToString(); string uer_state = Request["state"].ToString(); LogTextHelper.Info("传递进来的未知参数:" + uer_state); OAuthAccessTokenResult accToken = OAuthApi.GetAccessToken(WeixinAppId, WeixinAppSecret, uer_code); Response.Write("<br/>用户针对本公众号的唯一ID11" + accToken.access_token.ToString()); //OAuthUserInfo uerinfo = OAuthApi.GetUserInfo(accToken.access_token.ToString(),uer_state); OAuthUserInfo uerinfo = OAuthApi.GetUserInfo(accToken.access_token.ToString(), uer_code); Response.Write("</br>"); Response.Write("<b>用户的openid</b>:" + uerinfo.openid.ToString()); Response.Write("</br>"); Response.Write("<b>用户昵称</b>:" + uerinfo.nickname.ToString()); Response.Write("</br>"); Response.Write("<b>性别</b>:" + uerinfo.sex.ToString()); Response.Write("</br>"); Response.Write("<b>城市</b>:" + uerinfo.province.ToString()); Response.Write("</br>"); Response.Write("<img src=\"" + uerinfo.headimgurl.ToString() + "\"/ width=100 height=100 alt=\"" + uerinfo.nickname.ToString() + "\">"); Response.Write("</br>"); }
public override void Execute(StateEvent data) { if (changeCount >= changeCountMax) { data.stateMachine.previousState = this; data.stateMachine.ChangeState(nextAnimationState, data); LogTextHelper.Info("this is CAR_OUT Execute next state:--->>IDLE"); } else { changeCount++; } }
/// <summary> /// 对用户登录的操作进行验证 /// </summary> /// <param name="username">用户账号</param> /// <param name="password">用户密码</param> /// <param name="code">验证码</param> /// <returns></returns> public ActionResult CheckUser_Server(string username, string password, string code) { CommonResult result = new CommonResult(); if (string.IsNullOrEmpty(username)) { result.ErrorMsg = "用户名不能为空"; } else { try { string ip = GetClientIp(); string macAddr = ""; var info = new AuthorityClient().Sys_Login_CheckUser(username, password, ip, macAddr); if (!String.IsNullOrEmpty(info.Identity)) { result.IsSuccess = true; #region 取得用户的授权信息,并存储在Session中 Session["FullName"] = info.FullName; Session["UserID"] = info.IntID; Session["Company_ID"] = info.IntComID; Session["Dept_ID "] = info.IntDeptID; Session["UserInfo"] = info; Session["IsSuperAdmin"] = info.IntComID == 1 ? true : false; Session["EndCode"] = info.IntComID; #endregion LogTextHelper.Info(ip + " " + username + "登陆成功");//错误记录 } else { result.ErrorMsg = "用户名输入错误或者您已经被禁用"; LogTextHelper.Info(ip + " " + username + "登陆失败");//错误记录 } } catch (Exception ex) { LogTextHelper.Error(ex);//错误记录 if (ex.Message.Contains("登录失败")) { result.ErrorMsg = "数据库账号或密码错误,请检查数据库是否正常"; } else { result.ErrorMsg = ex.Message; } } } return(ToJsonContent(result)); }
public static void SetMainThreadUICulture(string cultureName) { try { LogTextHelper.Info(string.Format("UICulture = {0}", cultureName)); CultureInfo info = new CultureInfo(cultureName); cultureInfo_0 = info; Thread.CurrentThread.CurrentUICulture = info; } catch (Exception exception) { LogTextHelper.Error(string.Format("Error setting UICulture: {0}", cultureName), exception); } }
/// <summary> /// 设置主线程的UI Culture /// </summary> /// <param name="cultureName"></param> public static void SetMainThreadUICulture(string cultureName) { try { LogTextHelper.Info(string.Format("UICulture = {0}", cultureName)); var culture = new CultureInfo(cultureName); mainCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } catch (Exception ex) { LogTextHelper.Error(string.Format("Error setting UICulture: {0}", cultureName), ex); } }
/// <summary> /// 存取款 /// </summary> /// <param name="custNo">客户编号</param> /// <returns></returns> public ActionResult PayGetMoney_Server(string custNo) { //认证模块 ServiceDbClient dbClient = new ServiceDbClient(); using (OperationContextScope Scope = new OperationContextScope(dbClient.InnerChannel)) { CommonResult result = new CommonResult(); AuthHeader AuthObj = new AuthHeader() { Nonce = new Random().Next(0, 100).ToString(), Timestamp = DateTime.Now }; AuthObj.Signature = TokenHelper.GetSignature(AuthObj.Timestamp, AuthObj.Nonce); OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Auth", "http://tempuri.org", AuthObj)); try { var payMoney = Request["payMoney"] ?? "0"; var sRemark = ""; var iUserID = userid; var sReceiptNo = ""; var flag = dbClient.Account_DepositOperate(endcode, custNo.ToIntOrZero(), payMoney.ToDouble(), sRemark, iUserID, sReceiptNo); if (flag.IsSuccess) { result.IsSuccess = true; result.StrData1 = flag.StrData1; LogTextHelper.Info("缴费成功" + " 操作员:" + userid + " 用户编号" + custNo.ToIntOrZero() + " 缴费金额:" + payMoney.ToDouble()); } else { LogTextHelper.Error("缴费失败" + " 操作员:" + userid + " 用户编号" + custNo.ToIntOrZero() + " 缴费金额:" + payMoney.ToDouble()); result.ErrorMsg = flag.ErrorMsg; result.IsSuccess = false; } } catch (Exception ex) { LogTextHelper.Error("缴费异常错误" + ex); result.IsSuccess = false; result.ErrorMsg = ex.Message; } return(ToJsonContentDate(result)); } }
public override void Exit(StateEvent data) { LogTextHelper.Info("this is CAR_OUT Exit "); }
public override void Enter(StateEvent data) { LogTextHelper.Info("this is CAR_Weighted Enter"); }
public override void Exit(StateEvent data) { LogTextHelper.Info("this is CAR_ReadyWeight Exit "); }
public override void Exit(StateEvent data) { LogTextHelper.Info("this is IDLE Exit next state:"); }
protected void Page_Load(object sender, EventArgs e) { string signature = Request["signature"]; string timestamp = Request["timestamp"]; string nonce = Request["nonce"]; string echostr = Request["echostr"]; if (Request.HttpMethod == "GET") { //get method - 仅在微信后台填写URL验证时触发 if (CheckSignature.Check(signature, timestamp, nonce, Token)) { WriteContent(echostr); //返回随机字符串则表示验证通过 } else { WriteContent("failed:" + signature + "," + CheckSignature.GetSignature(timestamp, nonce, Token) + "。" + "看这里::如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。"); } Response.End(); } else { //post method - 当有用户想公众账号发送消息时触发 if (!CheckSignature.Check(signature, timestamp, nonce, Token)) { WriteContent("参数错误!"); return; } //post method - 当有用户想公众账号发送消息时触发 var postModel = new PostModel() { Signature = Request.QueryString["signature"], Msg_Signature = Request.QueryString["msg_signature"], Timestamp = Request.QueryString["timestamp"], Nonce = Request.QueryString["nonce"], //以下保密信息不会(不应该)在网络上传播,请注意 Token = Token, EncodingAESKey = WeixinEncodingAESKey, // "mNnY5GekpChwqhy2c4NBH90g3hND6GeI4gii2YCvKLY",//根据自己后台的设置保持一致 AppId = WeixinAppId // "wx669ef95216eef885"//根据自己后台的设置保持一致 }; //v4.2.2之后的版本,可以设置每个人上下文消息储存的最大数量,防止内存占用过多,如果该参数小于等于0,则不限制 var maxRecordCount = 10; var messageHandler = new CustomMessageHandler(Request.InputStream, postModel, maxRecordCount); try { //自定义MessageHandler,对微信请求的详细判断操作都在这里面。 //使用完整的应用凭证获取Token //Senparc.Weixin.MP.Containers.AccessTokenContainer.TryGetAccessToken(postModel.AppId, WeixinAppSecret); string access_token = Senparc.Weixin.MP.Containers.AccessTokenContainer.TryGetAccessToken(WeixinAppId, WeixinAppSecret); //string access_token = Senparc.Weixin.MP.Containers.AccessTokenContainer.GetAccessToken(WeixinAppId); //LogTextHelper.Info("access_token是:" + access_token); LogTextHelper.Info("\r\n\r\n第一步:用户名是(weixin):" + messageHandler.RequestMessage.FromUserName); //保存这次来访的accekn FileName = System.Web.HttpContext.Current.Server.MapPath("~/"); dac = new DataAccess.Class1(FileName); dac.set_accken(messageHandler.RequestMessage.FromUserName.Trim()); ////测试时可开启此记录,帮助跟踪数据,使用前请确保App_Data文件夹存在,且有读写权限。 //messageHandler.RequestDocument.Save( // Server.MapPath("~/App_Data/" + DateTime.Now.Ticks + "_Request_" + // messageHandler.RequestMessage.FromUserName + ".txt")); //执行微信处理过程 messageHandler.Execute(); //测试时可开启,帮助跟踪数据 //messageHandler.ResponseDocument.Save( // Server.MapPath("~/App_Data/" + DateTime.Now.Ticks + "_Response_" + // messageHandler.ResponseMessage.ToUserName + ".txt")); //WriteContent(messageHandler.ResponseDocument.ToString()); return; } catch (Exception ex) { using (TextWriter tw = new StreamWriter(Server.MapPath("~/App_Data/Error_" + DateTime.Now.Ticks + ".txt"))) { tw.WriteLine(ex.Message); tw.WriteLine(ex.InnerException.Message); if (messageHandler.ResponseDocument != null) { tw.WriteLine(messageHandler.ResponseDocument.ToString()); } tw.Flush(); tw.Close(); } } finally { Response.End(); } } }