Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="responseText"></param>
        /// <returns></returns>
        public SynchResponse GetSynchResponse(string responseText)
        {
            var response = new SynchResponse();

            try
            {
                responseText = responseText.Replace("<fill version=\"1.0\">", "");
                responseText = responseText.Replace("</fill>", "");

                Stream inStream = new MemoryStream(Encoding.Default.GetBytes(responseText));
                var    document = new XmlDocument();
                document.Load(inStream);

                var selectSingleNode = document.SelectSingleNode("items");
                if (selectSingleNode != null)
                {
                    XmlNodeList childNodes = selectSingleNode.ChildNodes;
                    if (childNodes.Count != 0)
                    {
                        foreach (XmlNode node2 in childNodes)
                        {
                            if (node2.Attributes == null)
                            {
                                continue;
                            }

                            string avalue = node2.Attributes["value"].InnerText;
                            switch (node2.Attributes["name"].InnerText)
                            {
                            case "state":
                                response.State = avalue;
                                break;

                            case "errcode":
                                response.Errcode = avalue;
                                break;

                            case "errmsg":
                                response.Errmsg = avalue;
                                break;

                            case "mark":
                                response.Mark = avalue;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
            return(response);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string commitUrl = this.PostCardUrl + "?";

            if (string.IsNullOrEmpty(PostCardUrl))
            {
                commitUrl = "http://it.51esales.net/gateway/zfgateway.asp?";
            }
            string cardno = GetCardNo(o.CardTypeId);
            string faceno = cardno + o.FaceValue.ToString("000");

            if (o.FaceValue >= 1000)
            {
                faceno = cardno + "000";
            }

            string remarks = string.Empty;
            string mark    = string.Empty;

            string md5Str = "customerid=" + SuppAccount + "&sdcustomno=" + o.SysOrderNo + "&noticeurl=" + NotifyUrl + "&mark=" + mark + "&key=" + SuppKey;
            string sign   = Cryptography.MD5(md5Str, "GB2312").ToUpper();

            try
            {
                var postData = new StringBuilder();
                postData.AppendFormat("&customerid={0}", SuppAccount);
                postData.AppendFormat("&sdcustomno={0}", o.SysOrderNo);
                postData.AppendFormat("&ordermoney={0}", o.FaceValue);
                postData.AppendFormat("&cardno={0}", cardno);
                postData.AppendFormat("&faceno={0}", faceno);
                postData.AppendFormat("&cardnum={0}", o.CardNo);
                postData.AppendFormat("&cardpass={0}", o.CardPass);
                postData.AppendFormat("&noticeurl={0}", NotifyUrl);
                postData.AppendFormat("&remarks={0}", remarks);
                postData.AppendFormat("&mark={0}", mark);
                postData.AppendFormat("&remoteip={0}", ServerVariables.TrueIP);
                postData.AppendFormat("&sign={0}", sign);

                callBack.Success = 0;

                SynsSummitLogger(commitUrl);

                SynsSummitLogger("postData:" + postData.ToString());

                string retXml = WebClientHelper.GetString(commitUrl, postData.ToString(), "GET", Encoding.GetEncoding("GB2312"), 10000);

                SynsSummitLogger(retXml);

                var response = new SynchResponse();
                if (!string.IsNullOrEmpty(retXml))
                {
                    response = GetSynchResponse(retXml);
                }

                if (!string.IsNullOrEmpty(response.State))
                {
                    callBack.Success          = 1;
                    callBack.SuppTransNo      = "";
                    callBack.SuppCallBackText = retXml;
                    callBack.SuppErrorCode    = response.Errcode;
                    callBack.SuppErrorMsg     = response.Errmsg;

                    if (response.State == "1")
                    {
                        callBack.SummitStatus = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                callBack.Success = 0;
                ExceptionHandler.HandleException(ex);
            }
            return(callBack);
        }