예제 #1
0
파일: Coupon.aspx.cs 프로젝트: Thn123/hmj
 protected void Page_Load(object sender, EventArgs e)
 {
     //Session["FromUserName"] = "******";
     //Session["ToUserName"] = "******";
     if (!IsPostBack)
     {
         Base();
         if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null))
         {
             string user  = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString();
             string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString();
             Session["FromUserName"] = user;
             Session["ToUserName"]   = user2;
             try
             {
                 Bind(user);
             }
             catch (Exception ex)
             {
                 WXLOG log = new WXLOG();
                 log.CON  = ex.Message.ToString() + "Coupon";
                 log.TIME = DateTime.Now;
                 mss.SaveLog(log);
             }
         }
         else
         {
             Response.Redirect(AuthCode(Request.Url.AbsoluteUri));
         }
     }
 }
예제 #2
0
파일: Order.aspx.cs 프로젝트: Thn123/hmj
 protected void Page_Load(object sender, EventArgs e)
 {
     //Session["FromUserName"] = "******";
     //Session["ToUserName"] = "******";
     //oQaIMwG_9lanE3f5VtvOSrErmfic
     if (!IsPostBack)
     {
         Base();
         if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null))
         {
             string user  = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString();
             string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString();
             Session["FromUserName"] = user;
             Session["ToUserName"]   = user2;
             try
             {
                 Bind(user);
             }
             catch (Exception ex)
             {
                 WXLOG log = new WXLOG();
                 log.CON  = ex.Message.ToString() + "Order";
                 log.TIME = DateTime.Now;
                 mss.SaveLog(log);
             }
         }
     }
 }
예제 #3
0
파일: WXLogService.cs 프로젝트: Thn123/hmj
 /// <summary>
 /// 保存短信日志对象
 /// </summary>
 /// <param name="l">WXDXLog对象</param>
 /// <returns></returns>
 public int Save(WXLOG l)
 {
     if (l.ID <= 0)
     {
         return((int)WXLogReponsitory.Insert(l));
     }
     else
     {
         return(WXLogReponsitory.Update(l));
     }
 }
예제 #4
0
 public bool WriteTxt(string str)
 {
     try
     {
         ISystemService sbo = new SystemService();
         WXLOG          l   = new WXLOG();
         l.CON  = str;
         l.TIME = DateTime.Now;
         sbo.AddLog(l);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #5
0
 public bool WriteTxt(string str)
 {
     try
     {
         WXLOG l = new WXLOG();
         l.CON  = str;
         l.TIME = DateTime.Now;
         // sbo.AddLog(l);
         WriteLogHandler handler = new WriteLogHandler(sbo.AddLog);
         int             result  = handler.Invoke(l);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #6
0
파일: Member.aspx.cs 프로젝트: Thn123/hmj
 protected void Page_Load(object sender, EventArgs e)
 {
     //Session["FromUserName"] = "******";
     //Session["ToUserName"] = "******";
     if (!IsPostBack)
     {
         Base();
         if (Request.QueryString["s"] == null)
         {
             if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null))
             {
                 string user  = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString();
                 string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString();
                 Session["FromUserName"] = user;
                 Session["ToUserName"]   = user2;
                 try
                 {
                     Bind(user);
                 }
                 catch (Exception ex)
                 {
                     WXLOG log = new WXLOG();
                     log.CON  = ex.Message.ToString() + "Member";
                     log.TIME = DateTime.Now;
                     mss.SaveLog(log);
                 }
             }
             else
             {
                 Response.Redirect(AuthCode(Request.Url.AbsoluteUri));
             }
         }
         else if (Request.QueryString["s"] != null)
         {
             string      html = "<option value='0'>请选择城市</option>";
             List <City> list = mss.GetCityByReg(Request.QueryString["s"]);
             foreach (City c in list)
             {
                 html += "<option value='" + c.CityCode + "'>" + c.CityName + "</option>";
             }
             Response.Write(html);
             Response.End();
         }
     }
 }
예제 #7
0
        const string Token     = "puman";       //与微信平台那边填写的token一致
        protected void Page_Load(object sender, EventArgs e)
        {
            string postStr = "";

            if (Request.HttpMethod.ToLower() == "post")
            {
                Stream s = System.Web.HttpContext.Current.Request.InputStream;
                byte[] b = new byte[s.Length];
                s.Read(b, 0, (int)s.Length);
                postStr = Encoding.UTF8.GetString(b);

                WXLOG log = new WXLOG {
                    CON = postStr + "INDEX2", TIME = DateTime.Now
                };
                mss.SaveLog(log);
            }
            else
            {
            }
        }
 /// <summary>
 /// 记录bug,以便调试
 /// </summary>
 ///
 /// <returns></returns>
 public bool WriteTxt(string str)
 {
     try
     {
         //FileStream fs = new FileStream(@"D:\WeiXin\web\buglog.txt", FileMode.Append);
         //StreamWriter sw = new StreamWriter(fs);
         ////开始写入
         //sw.WriteLine(str);
         ////清空缓冲区
         //sw.Flush();
         ////关闭流
         //sw.Close();
         //fs.Close();
         WXLOG l = new WXLOG();
         l.CON  = str;
         l.TIME = DateTime.Now;
         sbo.AddLog(l);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #9
0
        /// <summary>
        /// 微信支付
        /// </summary>
        /// <param name="order"></param>
        private void WX(Pet_XXL_Order order)
        {
            string appid            = GetAppid(mjuserid);                                             //公众号,固定
            string mch_id           = "1261198501";                                                   //商户号,固定
            string nonce_str        = Guid.NewGuid().ToString("d").Replace("-", "").Substring(0, 25); //随机码
            string body             = order.GoodsName;                                                //商品描述
            string notify_url       = WebUrl + "/wechat/order/Notify.aspx";
            string openid           = order.FromUserName;                                             //微信编号
            string out_trade_no     = order.OrderNo;                                                  //商户订单编号
            string spbill_create_ip = GetLoginIp();                                                   //ip地址
            string total_fee        = Convert.ToInt32(order.TotalPrice * 100).ToString();             //总价,分
            string trade_type       = "JSAPI";                                                        //交易类型
            string key    = "7M8Doa2lesq70RbvjhhpZGjeqcuJDReZ";                                       //商户key
            string attach = order.OrderNo;                                                            //附加数据

            string[] ArrTmp = { "appid=" + appid, "mch_id=" + mch_id, "nonce_str=" + nonce_str, "body=" + body, "notify_url=" + notify_url, "openid=" + openid, "out_trade_no=" + out_trade_no, "spbill_create_ip=" + spbill_create_ip, "total_fee=" + total_fee, "trade_type=" + trade_type, "attach=" + attach };
            Array.Sort(ArrTmp);     //字典排序
            string tmpStr = string.Join("&", ArrTmp);

            tmpStr += "&key=" + key;
            string sign = getMD5(tmpStr).ToUpper();

            string resxml = string.Format(@"<xml><appid>{0}</appid><mch_id>{1}</mch_id><nonce_str>{2}</nonce_str><attach>{3}</attach>
                                            <body>{4}</body>
                                            <notify_url>{5}</notify_url>
                                            <openid>{6}</openid>
                                            <out_trade_no>{7}</out_trade_no>
                                            <spbill_create_ip>{8}</spbill_create_ip>
                                            <total_fee>{9}</total_fee>
                                            <trade_type>{10}</trade_type>
                                            <sign>{11}</sign>
                                            </xml>", appid, mch_id, nonce_str, attach, body, notify_url, openid, out_trade_no, spbill_create_ip, total_fee, trade_type, sign);

            string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
            string jg  = HttpXmlPostRequest(url, resxml, Encoding.UTF8);
            WXLOG  log = new WXLOG {
                CON = resxml + "," + tmpStr + "," + jg + "zhifu", TIME = DateTime.Now
            };

            mss.SaveLog(log);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(jg);
            XmlElement rootElement = doc.DocumentElement;
            string     prepay_id   = rootElement.SelectSingleNode("prepay_id") == null ? "" : rootElement.SelectSingleNode("prepay_id").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "");

            if (prepay_id != "")
            {
                string   timeStamp = ConvertDateTimeInt(DateTime.Now).ToString();
                string   package   = "prepay_id=" + prepay_id;
                string   signType  = "MD5";
                string[] ArrTmp2   = { "appId=" + appid, "nonceStr=" + nonce_str, "timeStamp=" + timeStamp, "package=" + package, "signType=" + signType };
                Array.Sort(ArrTmp2);     //字典排序
                string tmpStr2 = string.Join("&", ArrTmp2);
                tmpStr2 += "&key=" + key;
                string sign2 = getMD5(tmpStr2).ToUpper();
                WXLOG  log2  = new WXLOG {
                    CON = resxml + "," + tmpStr + "," + tmpStr2 + "," + jg + "INDEX", TIME = DateTime.Now
                };
                mss.SaveLog(log2);
                Response.Write("{\"appId\":\"" + appid + "\",\"nonceStr\":\"" + nonce_str + "\",\"timeStamp\":\"" + timeStamp + "\",\"package\":\"" + package + "\",\"signType\":\"" + signType + "\",\"paySign\":\"" + sign2 + "\",\"st\":0}");
                Response.End();
            }
            else
            {
                Response.Write("{\"err_code\":\"" + rootElement.SelectSingleNode("err_code_des").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "") + "\",\"st\":1}");
                Response.End();
            }
        }
예제 #10
0
 public int SaveLog(WXLOG log)
 {
     return((int)_set.Insert(log));
 }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["para"] == null)
                {
                    Response.Write(" <input type='hidden'' value='" + Server.UrlEncode(AbsoluteUri) + "' id='url' />");
                }
            }
            if (Request.QueryString["para"] != null)
            {
                try
                {
                    string appid            = GetAppid(mjuserid);                                             //公众号,固定
                    string mch_id           = "1238277202";                                                   //商户号,固定
                    string nonce_str        = Guid.NewGuid().ToString("d").Replace("-", "").Substring(0, 25); //随机码
                    string body             = "手工半湿粮";                                                        //商品描述
                    string notify_url       = "http://cw.meijiewd.com/wechat/test/index2.aspx";
                    string openid           = "o0UMCj6Y9wcOeRVu0hJ0yx2MxCZY";                                 //微信编号
                    string out_trade_no     = "1415659991";                                                   //商户订单编号
                    string spbill_create_ip = GetLoginIp();                                                   //ip地址
                    string total_fee        = "1";                                                            //总价,分
                    string trade_type       = "JSAPI";                                                        //交易类型
                    string key    = "7M8Doa2lesq70RbvjhhpZGjeqcuJDReZ";                                       //商户key
                    string attach = "支付测试";                                                                   //附加数据

                    string[] ArrTmp = { "appid=" + appid, "mch_id=" + mch_id, "nonce_str=" + nonce_str, "body=" + body, "notify_url=" + notify_url, "openid=" + openid, "out_trade_no=" + out_trade_no, "spbill_create_ip=" + spbill_create_ip, "total_fee=" + total_fee, "trade_type=" + trade_type, "attach=" + attach };
                    Array.Sort(ArrTmp);     //字典排序
                    string tmpStr = string.Join("&", ArrTmp);
                    tmpStr += "&key=" + key;
                    string sign = getMD5(tmpStr).ToUpper();

                    string resxml = string.Format(@"<xml><appid>{0}</appid><mch_id>{1}</mch_id><nonce_str>{2}</nonce_str><attach>{3}</attach>
   <body>{4}</body>
   <notify_url>{5}</notify_url>
   <openid>{6}</openid>
   <out_trade_no>{7}</out_trade_no>
   <spbill_create_ip>{8}</spbill_create_ip>
   <total_fee>{9}</total_fee>
   <trade_type>{10}</trade_type>
   <sign>{11}</sign>
</xml>", appid, mch_id, nonce_str, attach, body, notify_url, openid, out_trade_no, spbill_create_ip, total_fee, trade_type, sign);

                    string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
                    string jg  = HttpXmlPostRequest(url, resxml, Encoding.UTF8);
                    WXLOG  log = new WXLOG {
                        CON = resxml + "," + tmpStr + "," + jg + "INDEX", TIME = DateTime.Now
                    };
                    mss.SaveLog(log);
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(jg);
                    XmlElement rootElement = doc.DocumentElement;
                    string     prepay_id   = rootElement.SelectSingleNode("prepay_id") == null ? "" : rootElement.SelectSingleNode("prepay_id").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "");
                    if (prepay_id != "")
                    {
                        string   timeStamp = ConvertDateTimeInt(DateTime.Now).ToString();
                        string   package   = "prepay_id=" + prepay_id;
                        string   signType  = "MD5";
                        string[] ArrTmp2   = { "appId=" + appid, "nonceStr=" + nonce_str, "timeStamp=" + timeStamp, "package=" + package, "signType=" + signType };
                        Array.Sort(ArrTmp2);     //字典排序
                        string tmpStr2 = string.Join("&", ArrTmp2);
                        tmpStr2 += "&key=" + key;
                        string sign2 = getMD5(tmpStr2).ToUpper();
                        WXLOG  log2  = new WXLOG {
                            CON = resxml + "," + tmpStr + "," + tmpStr2 + "," + jg + "INDEX", TIME = DateTime.Now
                        };
                        mss.SaveLog(log2);
                        Response.Write("{\"appId\":\"" + appid + "\",\"nonceStr\":\"" + nonce_str + "\",\"timeStamp\":\"" + timeStamp + "\",\"package\":\"" + package + "\",\"signType\":\"" + signType + "\",\"paySign\":\"" + sign2 + "\",\"st\":0}");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("{\"err_code\":\"" + rootElement.SelectSingleNode("err_code_des").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "") + "\",\"st\":1}");
                        Response.End();
                    }
                }
                catch (Exception ex)
                {
                    WXLOG log = new WXLOG {
                        CON = ex.Message + "," + ex.StackTrace, TIME = DateTime.Now
                    };
                    mss.SaveLog(log);
                }
            }
        }
예제 #12
0
        public PostMessageResult PostMessageByID(int custInfoId, string message)
        {
            PostMessageResult pmr = new PostMessageResult()
            {
                Success = false
            };
            var cust = cs.GetCustomer(custInfoId);

            if (cust == null)
            {
                pmr.ErrorCode = 0;
                pmr.Message   = "未找到用户";
                return(pmr);
            }
            if (!cust.ORG_ID.HasValue)
            {
                pmr.ErrorCode = 1;
                return(pmr);
            }
            var org = cys.GetCompany(cust.ORG_ID.Value);

            if (org == null)
            {
                pmr.ErrorCode = 2;
                pmr.Message   = "未找到公司";
                return(pmr);
            }
            if (string.IsNullOrEmpty(cust.FROM_USER_NAME) || string.IsNullOrEmpty(org.AppID) || string.IsNullOrEmpty(org.Appsecret))
            {
                pmr.ErrorCode = 3;
                pmr.Message   = "未找到用户OPENID或公司应用ID及密钥";
                return(pmr);
            }
            var access_token = GetAccess(org.AppID, org.Appsecret);

            if (string.IsNullOrEmpty(access_token))
            {
                pmr.ErrorCode = 4;
                pmr.Message   = "获取Token授权失败";
                return(pmr);
            }
            var    postUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + access_token;
            string d       = @"{
    ""touser"":""{0}"",
    ""msgtype"":""text"",
    ""text"":
    {
         ""content"":""{1}""
    }
}";

            d = d.Replace("{0}", cust.FROM_USER_NAME).Replace("{1}", message);

            try
            {
                string resMessage = HttpXmlPostRequest(postUrl, d, Encoding.UTF8);
                WXLOG  l          = new WXLOG();
                l.CON  = d + "," + resMessage;
                l.TIME = DateTime.Now;
                wls.Save(l);

                if (resMessage.Contains("ok"))
                {
                    pmr.Success  = true;
                    pmr.Message  = "已推送";
                    pmr.SendTime = DateTime.Now;
                    return(pmr);
                }
                else
                {
                    pmr.ErrorCode = 5;
                    pmr.Message   = "调用微信发消息接口失败";
                    return(pmr);
                }
            }
            catch (Exception ex)
            {
                pmr.ErrorCode = 6;
                pmr.Message   = ex.ToString();
                return(pmr);
            }
        }
예제 #13
0
 /// <summary>
 /// 添加微信日志
 /// </summary>
 /// <param name="l"></param>
 /// <returns></returns>
 public int AddLog(WXLOG l)
 {
     return((int)base.Insert(l));
 }
예제 #14
0
파일: SystemService.cs 프로젝트: Thn123/hmj
 /// <summary>
 /// 添加微信日志
 /// </summary>
 /// <param name="l"></param>
 /// <returns></returns>
 public int AddLog(WXLOG l)
 {
     return(_set.AddLog(l));
 }