示例#1
0
        /// <summary>
        /// 发送红包
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static string SendTo(RequestModel model)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string json = jss.Serialize(model);

            AESHelper Aes      = new AESHelper();
            string    jsondata = AESHelper.Encode(json);
            string    postData = "par=" + HttpUtility.UrlEncode(jsondata);
            //byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            string url = "http://wxin2.cqnews.net/yxhb_grp/pay_qxbbc_interface.aspx?" + postData;

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

            webRequest.Method = "GET";

            webRequest.ContentType = "application/x-www-form-urlencoded";
            //webRequest.ContentLength = byteArray.Length;

            //using (Stream newStream = webRequest.GetRequestStream())//创建一个Stream,赋值是写入HttpWebRequest对象提供的一个stream里面
            //{
            //    newStream.Write(byteArray, 0, byteArray.Length);
            //    newStream.Close();
            //4. 读取服务器的返回信息
            using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse())
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    string content = reader.ReadToEnd();
                    Logging4net.WriteInfo("content: " + content);
                    return(content);
                }
            }
            //}
        }
示例#2
0
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     try
     {
         var exception = e.ExceptionObject as Exception;
         if (exception != null)
         {
             Logging4net.WriteError(exception, "系统异常");
         }
     }
     catch (Exception ex)
     {
         Logging4net.WriteError(ex, "系统异常");
         MsgBox.Show("系统出现错误,即将退出;" + ex.Message);
     }
 }
示例#3
0
 private void btn_start_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         btn_start.IsEnabled = false;
         initListener();
         btn_start.Content = "启动成功";
     }
     catch (Exception ex)
     {
         MsgBox.Show("启动失败,请检查串口连接是否正常");
         btn_start.IsEnabled = true;
         sp.Dispose();
         sp = null;
         Logging4net.WriteError(ex, "串口监听启动失败");
     }
 }
示例#4
0
        //public ActionResult Login()
        //{
        //    string code = Request.QueryString["code"];
        //    string state = Request.QueryString["state"];
        //    string s = Request.QueryString["s"];
        //    if (!IsLogin)
        //    {
        //        OAuthAccessTokenResult result = OAuthApi.GetAccessToken(tenPayV3Info.AppId, tenPayV3Info.AppSecret, code);
        //        if (result.errcode == Senparc.Weixin.ReturnCode.请求成功)
        //        {
        //            string openid = result.openid;
        //            UserService x_userService = new UserService();
        //            var item = x_userService.Get(a => a.OpenId == openid).FirstOrDefault();
        //            if (item != null)
        //            {
        //                if (item.IsValid == 1)
        //                {
        //                    Authentication.Instance.SetAuth(item, true);
        //                }
        //                else
        //                {
        //                    return Redirect("/");
        //                }
        //            }
        //            else  //获取用户的信息
        //            {
        //                OAuthUserInfo wxUser = OAuthApi.GetUserInfo(result.access_token, code);
        //                if (wxUser != null)
        //                {
        //                    UserInfo uInfo = new UserInfo()
        //                    {
        //                        IsValid = 1,
        //                        CreateTime = DateTime.Now,
        //                        Lastlogintime = DateTime.Now,
        //                        NickName = wxUser.nickname,
        //                        OpenId = wxUser.openid,
        //                        HeadImage = wxUser.headimgurl
        //                    };
        //                    uInfo.ID = Convert.ToInt32(x_userService.Insert(uInfo));
        //                    Authentication.Instance.SetAuth(uInfo, true);
        //                }
        //                else
        //                {
        //                    return Redirect("/");
        //                }
        //            }
        //        }
        //    }
        //    string url = "/";
        //    if (!string.IsNullOrEmpty(s))
        //    {
        //        url = s;
        //    }
        //    return Redirect(url);
        //}

        public ActionResult RecLogin()
        {
            string json = Request.Form["jsondata"];
            string data = AESHelper.Decode(json);

            //Logging4net.WriteInfo(data);
            if (!string.IsNullOrEmpty(data))
            {
                JavaScriptSerializer jss = new JavaScriptSerializer();
                WxUserInfo           wxu = jss.Deserialize <WxUserInfo>(data);

                UserService x_userService = new UserService();
                var         item          = x_userService.Get(a => a.OpenId == wxu.openid).FirstOrDefault();
                if (item != null)
                {
                    Logging4net.WriteInfo("isvalid:" + item.IsValid);
                    if (item.IsValid == 1)
                    {
                        Authentication.Instance.SetAuth(item, true);
                        return(RedirectToAction("index", "home"));
                    }
                }
                else
                {
                    UserInfo uInfo = new UserInfo()
                    {
                        IsValid    = 1,
                        CreateTime = DateTime.Now,
                        //Lastlogintime = DateTime.Now,
                        NickName  = wxu.nickname,
                        OpenId    = wxu.openid,
                        HeadImage = wxu.headimgurl,
                        SubTime   = DateTime.Now.AddYears(-100)
                    };
                    uInfo.ID = Convert.ToInt32(x_userService.Insert(uInfo));
                    Authentication.Instance.SetAuth(uInfo, true);
                    return(RedirectToAction("index", "home"));
                }
            }
            return(RedirectToAction("index", "home"));
        }
示例#5
0
 void TsSendRP(object obj)
 {
     try
     {
         RedPackListInfo item  = obj as RedPackListInfo;
         RequestModel    model = new RequestModel()
         {
             openid      = item.OpenId,
             amount      = item.PackMoney.ToString(),
             clientip    = "127.0.0.1",
             clientport  = "80",
             hdclass     = "17",
             sendtxt     = "解放碑地下环道游戏红包",
             timecontrol = "1"
         };
         string req = SendRedPack.SendTo(model);
         Logging4net.WriteInfo("result: " + req);
         if (!req.Contains("Error") && req.Contains("{\"State\":\"0\"}"))
         {
             this.Update(() => new RedPackListInfo()
             {
                 PaySign = req, PackStatus = 1
             }, a => a.ID == item.ID);
         }
         else
         {
             int i = this.Update(() => new RedPackListInfo()
             {
                 PaySign = req
             }, a => a.ID == item.ID);
         }
     }
     catch (Exception ex)
     {
         Logging4net.WriteError(ex, "红包发送失败");
     }
 }