Example #1
0
        public string CardSend(string _orderid, string _cardno, string _cardpwd, int _typeId, int cardvalue, out string supporderid, out string supperrorcode, out string errmsg)
        {
            errmsg        = string.Empty;
            supporderid   = string.Empty;
            supperrorcode = string.Empty;
            string str     = "-1";
            string SuppKey = base.SuppKey;

            if (!string.IsNullOrEmpty(base.PostCardUrl) && !string.IsNullOrEmpty(SuppKey))
            {
                string url  = base.PostCardUrl + "?";
                string str4 = this.GetCardType(_typeId).ToString();
                string str5 = "0";
                string str6 = string.Format("type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}", new object[] { str4, base.SuppAccount, _cardno, _cardpwd, cardvalue, str5, _orderid, this.notify_url });
                string str7 = Cryptography.MD5(str6 + base.SuppKey);
                try
                {
                    StringBuilder builder = new StringBuilder(str6);
                    builder.AppendFormat("&sign={0}", str7);
                    string retcode = WebClientHelper.GetString(url, builder.ToString(), "GET", Encoding.GetEncoding("GB2312"), 0x2710);
                    supperrorcode = retcode.Replace("opstate=", "");
                    errmsg        = this.GetLBMsgInfo(retcode, string.Empty);
                    if (retcode == "opstate=1")
                    {
                        str = "0";
                    }
                }
                catch (Exception exception)
                {
                    ExceptionHandler.HandleException(exception);
                }
            }
            return(str);
        }
Example #2
0
        /// <summary>
        /// https://paygate.baofoo.com/Check/OrderQuery.aspx
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public string OrderQuery(string orderid)
        {
            try
            {
                string queryUrl = "https://paygate.baofoo.com/Check/OrderQuery.aspx";

                string strMerchantID = this.SuppAccount;
                string strTransID    = orderid;

                string strMd5Sign = Md5Encrypt(strMerchantID + strTransID + SuppKey);

                string postData = string.Format("MerchantID={0}&TransID={1}&Md5Sign={2}", strMerchantID, strTransID,
                                                strMd5Sign);

                string responseText = WebClientHelper.GetString(queryUrl
                                                                , postData
                                                                , "POST"
                                                                , Encoding.GetEncoding("utf-8")
                                                                , 10000);

                return(responseText);
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }

            return(string.Empty);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateInfo"></param>
        public static void NotifyCheckStatus(Object stateInfo)
        {
            OrderNotify notify    = (OrderNotify)stateInfo;
            string      notifyUrl = GetCallBackUrl(notify.orderInfo);

            if (string.IsNullOrEmpty(notifyUrl))
            {
                notify.tmr.Dispose();
                notify.tmr = null;
            }
            else
            {
                string callback = WebClientHelper.GetString(notifyUrl, string.Empty, "GET", System.Text.Encoding.GetEncoding("GB2312"));
                if (callback.ToLower() == "ok" || notify.orderInfo.notifycount == 10)
                {
                    notify.tmr.Dispose();
                    notify.tmr = null;
                }
                if (notify.orderInfo.notifycount == 0 || callback.ToLower() == "ok")
                {
                    notify.orderInfo.notifycount++;
                    notify.orderInfo.notifystat     = callback.ToLower() == "ok" ? 2 : 4;
                    notify.orderInfo.againNotifyUrl = notifyUrl;
                    notify.orderInfo.notifycontext  = callback;

                    OrderBankFactory.NotifyResult(notify.orderInfo);
                }

                (notify.tmr).Change(TimeSpan.FromSeconds(10 * notify.orderInfo.notifycount), TimeSpan.FromSeconds(10 * notify.orderInfo.notifycount));
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderamt"></param>
        /// <returns></returns>
        public QueryResponse Query(string orderid, int orderamt)
        {
            string commitUrl = "http://it.51esales.net/gateway/orderquery.asp";

            string customerid = SuppAccount;
            string sdcustomno = orderid;
            string ordermoney = decimal.ToInt32(orderamt).ToString(CultureInfo.InvariantCulture);

            string plain = string.Format("customerid={0}&sdcustomno={1}&mark={2}&key={3}", customerid, sdcustomno, "",
                                         SuppKey);

            string sign = Cryptography.MD5(plain, "GB2312").ToUpper();

            var postData = new StringBuilder();

            postData.AppendFormat("&customerid={0}", SuppAccount);
            postData.AppendFormat("&sdcustomno={0}", sdcustomno);
            postData.AppendFormat("&ordermoney={0}", ordermoney);
            postData.AppendFormat("&sign={0}", sign);

            var response = new QueryResponse(orderid);

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

            if (!string.IsNullOrEmpty(retXml))
            {
                response = GetQueryResponse(orderid, retXml);
            }
            return(response);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public string Query(string orderid)
        {
            string agentID   = SuppAccount;
            string billID    = orderid;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&time_stamp={2}|||{3}"
                                         , agentID
                                         , billID
                                         , timeStamp
                                         , SuppKey);

            string sign = Md5Sign(plain).ToLower();
            string responeText;

            try
            {
                string postUrl = string.Format("http://service.800j.com/consign/HuisuRecycleCardQuery.aspx?agent_id={0}&bill_id={1}&time_stamp={2}&sign={3}"
                                               , agentID
                                               , billID
                                               , timeStamp
                                               , sign);

                responeText = WebClientHelper.GetString(postUrl, null, "GET", Encoding.GetEncoding("gbk"));
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                responeText = ex.Message;
            }
            return(responeText);
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        string SendToSupp()
        {
            string msg = string.Empty;

            try
            {
                ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(TypeId);
                if (chanelTypeInfo == null)
                {
                    msg = "找不到通道,请联系商务或系统管理员处理。";
                }
                else
                {
                    int card_type = 0;

                    if (int.TryParse(chanelTypeInfo.code, out card_type))
                    {
                        string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";

                        string postData =
                            string.Format(
                                "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                card_type, UserId, CardNo, CardPwd, FaceValue, 0, DateTime.Now.Ticks.ToString(), callBackurl);

                        string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey);

                        postData += "&sign=" + sign + "&attach=cardsell";

                        string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx";

                        string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                    System.Text.Encoding.GetEncoding("GB2312"), 10000);

                        if (callback == "opstate=0")
                        {
                            msg = "true";
                        }
                        else
                        {
                            msg = callback;
                        }
                    }
                    else
                    {
                        msg = "系统故障";
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            return(msg);
        }
Example #7
0
        public void GetSessionToken(Action <string, Exception> action, string token, string newCurrentWorkListUser)
        {
            var url = string.Format(PMSClientConfig.BaseApiAddress + "/token");

            if (!string.IsNullOrWhiteSpace(newCurrentWorkListUser))
            {
                url = url + "?CurrentWorkListUserName="******"SilverLight", "1" }, { "Authorization", "SAML " + token }
            });
        }
Example #8
0
        public CardSynchCallBack CardSendV25(string _orderid, string _cardno, string _cardpwd, int _typeId, int cardvalue, out string supporderid, out string errmsg)
        {
            var callBack = new CardSynchCallBack();

            errmsg      = string.Empty;
            supporderid = string.Empty;
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("userid={0}", base.SuppAccount);
            builder.AppendFormat("&orderno={0}", _orderid);
            builder.AppendFormat("&typeid={0}", this.GetPaycardno(_typeId));
            builder.AppendFormat("&cardno={0}", _cardno);
            builder.AppendFormat("&encpwd={0}", 0);
            builder.AppendFormat("&cardpwd={0}", _cardpwd);
            builder.AppendFormat("&cardpwdenc={0}", string.Empty);
            builder.AppendFormat("&money={0}", cardvalue);
            builder.AppendFormat("&url={0}", this.notify_url);
            string str2 = Cryptography.MD5(builder.ToString() + string.Format("&keyvalue={0}", base.SuppKey)).ToLower();

            builder.AppendFormat("&sign={0}", str2);
            builder.AppendFormat("&ext={0}", string.Empty);
            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312");
            string responseText = WebClientHelper.GetString(base.PostCardUrl + "?" + builder.ToString(), null, "GET", Encoding.GetEncoding("utf-8"), 0x2710);

            string[] strArray = responseText.Split(new char[] { '&' });
            //if (strArray.Length >= 2)
            //{
            //    if (strArray[0] == "returncode=1")
            //    {
            //        return "0";
            //    }
            //    errmsg = strArray[1].Replace("message=", "");
            //    string[] strArray2 = errmsg.Split(new char[] { ',' });
            //    errmsg = strArray2[0];
            //}
            //return "-1";
            SynsSummitLogger(strArray.ToString());
            if (strArray.Length >= 2)
            {
                if (strArray[0] == "returncode=1")
                {
                    callBack.Success          = 1;
                    callBack.SuppTransNo      = "";
                    callBack.SuppCallBackText = responseText;
                    callBack.SuppErrorCode    = "0";
                    callBack.SuppErrorMsg     = strArray[1];
                    callBack.SummitStatus     = 1;
                }
            }
            return(callBack);
        }
Example #9
0
        /// <summary>
        /// 发送手机短信
        /// </summary>
        /// <param name="mobile">手机号码</param>
        /// <param name="content">内容</param>
        /// <param name="ext"></param>
        /// <returns></returns>
        public static bool Send(string mobile, string content, string ext)
        {
            //string sn = viviapi.SysConfig.RuntimeSetting.SMSSN;
            //string pwd = viviapi.SysConfig.RuntimeSetting.SMSKEY;
            string sn            = SMSTempSettings.SMS_SN;
            string pwd           = SMSTempSettings.SMS_KEY;
            string sms_website   = SMSTempSettings.SMS_WebSite;
            string encodecontent = HttpUtility.UrlEncode(content, Encoding.GetEncoding("gb2312"));
            string postData      = string.Format("Uid={0}&Key={1}&smsMob={2}&smsText={3}&ext={4}", sn, pwd, mobile, encodecontent, ext);
            //string postData = string.Format("sn={0}&pwd={1}&mobile={2}&content={3}&ext={4}", sn, pwd, mobile, encodecontent, ext);
            string returnStr = WebClientHelper.GetString(sms_website, postData, "get", Encoding.GetEncoding("gb2312"), 10000);

            //viviLib.Logging.LogHelper.Write(returnStr);
            return(returnStr == "1");
        }
Example #10
0
 public string Query(string orderid)
 {
     try
     {
         StringBuilder builder = new StringBuilder();
         builder.AppendFormat("userid={0}", base.SuppAccount);
         builder.AppendFormat("&orderno={0}", orderid);
         string str3 = Cryptography.MD5(builder.ToString() + string.Format("&keyvalue={0}", base.SuppKey)).ToLower();
         builder.AppendFormat("&sign={0}", str3);
         HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312");
         return(WebClientHelper.GetString("http://tong.yzch.net/query.ashx?" + builder.ToString(), null, "GET", Encoding.GetEncoding("utf-8"), 0x2710));
     }
     catch (Exception exception)
     {
         return(exception.Message);
     }
 }
Example #11
0
        /// <summary>
        /// http://cscapi.kamenwang.com/consignsalecard/api
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public string Query(string orderid)
        {
            string method    = "search";
            string timeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string format    = "xml";
            string userid    = suppAccount;
            string v         = "1.0";

            string sign            = "";
            string customerorderid = orderid;

            string plain = string.Format("customerorderid={0}format={1}method={2}timestamp={3}userid={4}v={5}{6}"
                                         , customerorderid
                                         , format
                                         , method
                                         , timeStamp
                                         , userid
                                         , v
                                         , suppKey
                                         );

            sign = md5sign(plain).ToLower();
            string responeText;

            try
            {
                string postUrl = "http://cscapi.kamenwang.com/consignsalecard/api" + string.Format("?customerorderid={0}&format={1}&method={2}&timestamp={3}&userid={4}&v={5}&sign={7}"
                                                                                                   , customerorderid
                                                                                                   , format
                                                                                                   , method
                                                                                                   , timeStamp
                                                                                                   , userid
                                                                                                   , v
                                                                                                   , sign
                                                                                                   );

                responeText = WebClientHelper.GetString(postUrl, null, "POST", Encoding.UTF8);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                responeText = ex.Message;
            }
            return(responeText);
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="suppid"></param>
        /// <param name="paramlist"></param>
        /// <returns></returns>
        public static bool SendtoSupp(int suppid, params object[] paramlist)
        {
            //string postData = string.Format("sn={0}&pwd={1}&mobile={2}&content={3}&ext={4}", paramlist);
            // string postData = string.Format("sn={0}&pwd={1}&mobile={2}&content={3}&ext={4}", paramlist);
            string postData = string.Format("Uid={0}&Key={1}&smsMob={2}&smsText={3}", paramlist);

            if (suppid == 1)
            {
                string sms_website = SMSTempSettings.SMS_WebSite;
                string returncode  = SMSTempSettings.SMS_SendSuccessCode;
                string returnStr   = WebClientHelper.GetString(sms_website, postData, "get", Encoding.GetEncoding("gb2312"), 10000);
                viviLib.Logging.LogHelper.Write(returnStr);
                return(returnStr == returncode);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
        public string Query(string orderid)
        {
            string queryCardUrl = base.SuppInfo.queryCardUrl;

            if (string.IsNullOrEmpty(queryCardUrl))
            {
                return(string.Empty);
            }
            orderid = orderid.Trim();
            string str4 = Cryptography.MD5(string.Format("orderid={0}&parter={1}{2}", orderid, base.SuppAccount, base.SuppKey));

            queryCardUrl = string.Format("{0}?orderid={1}&parter={2}&sign={3}", new object[] { queryCardUrl, orderid, base.SuppAccount, str4 });
            try
            {
                return(WebClientHelper.GetString(queryCardUrl, null, "GET", Encoding.Default));
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
                return(exception.Message);
            }
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public string Query(string orderid)
        {
            string agentID   = SuppAccount;
            string billID    = orderid;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&time_stamp={2}|||{3}"
                                         , agentID
                                         , billID
                                         , timeStamp
                                         , SuppKey);

            string sign = md5sign(plain).ToLower();
            string callBack;

            try
            {
                string postUrl = string.Format("http://Service.800j.com/Consign/Query.aspx?agent_id={0}&bill_id={1}&time_stamp={2}&sign={3}"
                                               , agentID
                                               , billID
                                               , timeStamp
                                               , sign);

                AsynsRetLogger(postUrl);

                callBack = WebClientHelper.GetString(postUrl, null, "get", System.Text.Encoding.GetEncoding("gbk"));

                AsynsRetLogger(callBack);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                callBack = ex.Message;
            }
            return(callBack);
        }
Example #15
0
        public void ProcessRequest(HttpContext context)
        {
            string result = string.Empty;

            try
            {
                string orderid   = viviLib.Web.WebBase.GetFormString("orderid", "");
                string cardNo    = viviLib.Web.WebBase.GetFormString("cardNo", "");
                string cardPwd   = viviLib.Web.WebBase.GetFormString("cardPwd", "");
                string faceValue = viviLib.Web.WebBase.GetFormString("faceValue", "");
                string typeId    = viviLib.Web.WebBase.GetFormString("typeId", "");
                string userId    = viviLib.Web.WebBase.GetFormString("userId", "");
                string sign      = viviLib.Web.WebBase.GetFormString("sign", "");
                string apikey    = string.Empty;
                int    typeid    = 0;
                int.TryParse(typeId, out typeid);

                int?_manageId  = 0;
                int _faceValue = 0;
                try
                {
                    _faceValue = Convert.ToInt32(decimal.Round(Convert.ToDecimal(faceValue), 0).ToString());
                }
                catch
                {
                }

                int _userid = 0;
                if (
                    string.IsNullOrEmpty(orderid) ||
                    string.IsNullOrEmpty(cardNo) ||
                    string.IsNullOrEmpty(cardPwd) ||
                    string.IsNullOrEmpty(faceValue) ||
                    string.IsNullOrEmpty(typeId) ||
                    string.IsNullOrEmpty(userId) ||
                    string.IsNullOrEmpty(sign))
                {
                    result = "参数不正确";
                }
                else
                {
                    if (!string.IsNullOrEmpty(userId))
                    {
                        if (int.TryParse(userId, out _userid))
                        {
                        }
                    }

                    if (_userid == 0)
                    {
                        result = "用户不存在";
                    }
                    else
                    {
                        UserInfo userInfo = viviapi.BLL.User.Factory.GetCacheUserBaseInfo(_userid);

                        if (userInfo == null || userInfo.Status != 2)
                        {
                            result = "用户不存在";
                        }
                        else
                        {
                            apikey    = userInfo.APIKey;
                            _manageId = userInfo.manageId;
                        }
                    }
                }
                if (string.IsNullOrEmpty(result))
                {
                    string plain = orderid + cardNo + cardPwd + faceValue + typeId + userId + apikey;
                    //viviLib.Logging.LogHelper.Write(plain);
                    string localsign = viviLib.Security.Cryptography.MD5(plain);
                    //viviLib.Logging.LogHelper.Write(localsign);
                    //viviLib.Logging.LogHelper.Write(sign);
                    if (localsign != sign)
                    {
                        result = "签名不正确";
                    }
                }

                if (string.IsNullOrEmpty(result))
                {
                    ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(typeid);
                    if (chanelTypeInfo == null)
                    {
                        result = "找不到通道,请联系商务或系统管理员处理。";
                    }
                    else
                    {
                        #region 提交到网关

                        int card_type = 0;

                        if (int.TryParse(chanelTypeInfo.code, out card_type))
                        {
                            string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";

                            string postData =
                                string.Format(
                                    "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                    card_type, userId, cardNo, cardPwd, faceValue, 0, DateTime.Now.Ticks.ToString(),
                                    callBackurl);

                            sign = viviLib.Security.Cryptography.MD5(postData + apikey);

                            postData += "&sign=" + sign + "&attach=clientCardsell";

                            string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx";

                            string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                        System.Text.Encoding.GetEncoding("GB2312"), 10000);

                            if (callback == "opstate=0")
                            {
                                result = "success";
                            }
                            else
                            {
                                result = "提卡失败";
                            }
                        }
                        else
                        {
                            result = "系统故障";
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                result = "系统故障";
            }


            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
Example #16
0
        /// <summary>
        /// http://cscapi.kamenwang.com/consignsalecard/api
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string stockid = GetCardType(o.CardTypeId);

            if (string.IsNullOrEmpty(stockid))
            {
                callBack.Success = 0;
                callBack.Message = "不支持此类型";

                return(callBack);
            }

            string method    = "supply";
            string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string format    = "xml";
            string userid    = suppAccount;
            string v         = "1.0";
            string sign      = "";


            string parvalue = o.FaceValue.ToString(CultureInfo.InvariantCulture);

            string card            = o.CardNo;
            string pwd             = o.CardPass;
            string customerorderid = o.SysOrderNo.ToLower();
            string from            = "api";
            string notifyurl       = NotifyUrl;


            string plain = string.Format("card={0}customerorderid={1}format={2}from={3}method={4}notifyurl={12}parvalue={5}pwd={6}stockid={7}timestamp={8}userid={9}v={10}{11}"
                                         , card
                                         , customerorderid
                                         , format
                                         , from
                                         , method
                                         , parvalue
                                         , pwd
                                         , stockid
                                         , timestamp
                                         , userid
                                         , v
                                         , suppKey
                                         , notifyurl);

            log("CardSend plain" + plain);

            sign = md5sign(plain).ToLower();

            log("CardSend sign" + sign);

            try
            {
                string postUrl = this.postCardUrl +
                                 string.Format(
                    "?card={0}&customerorderid={1}&format={2}&from={3}&method={4}&notifyurl={12}&parvalue={5}&pwd={6}&stockid={7}&timestamp={8}&userid={9}&v={10}&sign={11}"
                    , card
                    , customerorderid
                    , format
                    , from
                    , method
                    , parvalue
                    , pwd
                    , stockid
                    , timestamp
                    , userid
                    , v
                    , sign
                    , HttpUtility.UrlEncode(notifyurl));

                log("CardSend postUrl" + postUrl);

                string callBackText = WebClientHelper.GetString(postUrl, null, "post", Encoding.UTF8);

                log("CardSend callBackText" + callBackText);

                callBack.Success          = 1;
                callBack.SuppCallBackText = callBackText;

                if (!string.IsNullOrEmpty(callBackText))
                {
                    var xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(callBackText);

                    var xmlNodeList = xmlDocument.SelectSingleNode("Root/Ret");
                    if (xmlNodeList != null)
                    {
                        foreach (XmlNode list in xmlNodeList)
                        {
                            switch (list.Name.ToLower())
                            {
                            case "retcode":
                                callBack.SuppErrorCode = list.InnerText;
                                break;

                            case "retmsg":
                                callBack.SuppErrorMsg = list.InnerText;
                                break;
                            }
                        }
                    }
                    xmlNodeList = xmlDocument.SelectSingleNode("Root/Order");
                    if (xmlNodeList != null)
                    {
                        foreach (XmlNode list in xmlNodeList)
                        {
                            switch (list.Name.ToLower())
                            {
                            case "orderid":
                                callBack.SuppTransNo = list.InnerText;
                                break;
                            }
                        }
                    }

                    if (callBack.SuppErrorCode == "20005")
                    {
                        callBack.SummitStatus = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Example #17
0
        public void GetToken(Action <string, Exception> action, string userName, string password)
        {
            var url = string.Format(baseAddressUsers + "?userName="******"&password=" + password);

            WebClientHelper.GetString(new Uri(url, PMSClientConfig.UriKind), action);
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string opstate  = "-1";
            string puserkey = this.SuppKey;

            if (string.IsNullOrEmpty(this.PostCardUrl) ||
                string.IsNullOrEmpty(puserkey))
            {
                callBack.Success = 0;
                callBack.Message = "未配置网关";

                return(callBack);
            }

            string commitUrl = this.PostCardUrl + "?";
            string cardType  = GetCardType(o.CardTypeId).ToString();
            // string cardType = GetCardType(_typeId).ToString("0000") + cardvalue.ToString();
            string _restrict = "0";

            string plain = string.Format("type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}"
                                         , cardType
                                         , SuppAccount
                                         , o.CardNo
                                         , o.CardPass
                                         , o.FaceValue
                                         , _restrict
                                         , o.SysOrderNo
                                         , notify_url);

            string sign = viviLib.Security.Cryptography.MD5(plain + SuppKey);

            try
            {
                var postData = new StringBuilder(plain);
                postData.AppendFormat("&sign={0}", sign);

                //LogWrite(commitUrl + postData.ToString());
                //LogWrite(postData.ToString());

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

                callBack.SuppCallBackText = retCode;
                callBack.SuppErrorCode    = retCode.Replace("opstate=", "");
                callBack.SuppErrorMsg     = GetMsgInfo(retCode, string.Empty);

                if (retCode == "opstate=1")
                {
                    callBack.SummitStatus = 1;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        string SendToSupp()
        {
            string msg = string.Empty;

            try
            {
                ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(CardInfoID);
                if (chanelTypeInfo == null)
                {
                    msg = "找不到通道,请联系商务或系统管理员处理。";
                }
                else
                {
                    int card_type = 0;

                    if (int.TryParse(chanelTypeInfo.code, out card_type))
                    {
                        string        callBackurl  = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";
                        StringBuilder cardno       = new StringBuilder();
                        StringBuilder cardpwd      = new StringBuilder();
                        int           totalValue   = CardPairsList.Count * Convert.ToInt32(ParValue);
                        int           currentIndex = 1;
                        foreach (KeyValuePair <string, string> pair in CardPairsList)
                        {
                            cardno.Append(pair.Key);
                            cardpwd.Append(pair.Value);
                            if (currentIndex < CardPairsList.Count)
                            {
                                cardno.Append(";");
                                cardpwd.Append(";");
                            }
                            currentIndex++;
                        }
                        string postData =
                            //
                            string.Format(
                                "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                card_type, UserId, cardno.ToString(), cardpwd.ToString(), ParValue, 0, DateTime.Now.Ticks.ToString(), callBackurl);

                        string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey);

                        postData += "&sign=" + sign + "&attach=cardsell" + "&totalvalue=" + totalValue.ToString();

                        string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.aspx";

                        string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                    System.Text.Encoding.GetEncoding("GB2312"), 10000);

                        if (callback == "opstate=1" || callback == "opstate=0")//提交成功,返回状态码true
                        {
                            msg = "true";
                        }
                        else
                        {
                            msg = callback;
                        }
                    }
                    else
                    {
                        msg = "系统故障";
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            return(msg);
        }
Example #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string agentID  = SuppAccount;
            string billID   = o.SysOrderNo;
            string billTime = DateTime.Now.ToString("yyyyMMddHHmmss");
            string cardType = GetCardType(o.CardTypeId);
            string cardData = o.CardNo + "," + o.CardPass + "," + o.FaceValue.ToString(CultureInfo.InvariantCulture);// Encode();

            cardData = card_Encode(cardData);

            string cardAMT  = o.FaceValue.ToString(CultureInfo.InvariantCulture);
            string clientIP = viviLib.Web.ServerVariables.TrueIP;

            string desc      = string.Empty;
            string extParam  = string.Empty;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_amt={5}&notify_url={6}&time_stamp={7}|||{8}"
                                         , agentID
                                         , billID
                                         , billTime
                                         , cardType
                                         , cardData
                                         , cardAMT
                                         , NotifyUrl
                                         , timeStamp
                                         , SuppKey);

            string sign = md5sign(plain).ToLower();

            try
            {
                string postUrl = string.Format("{9}?agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_amt={5}&notify_url={6}&time_stamp={7}&sign={8}"
                                               , agentID
                                               , billID
                                               , billTime
                                               , cardType
                                               , cardData
                                               , cardAMT
                                               , NotifyUrl
                                               , timeStamp
                                               , sign
                                               , PostCardUrl);

                SynsSummitLogger(postUrl);

                string callBackText = WebClientHelper.GetString(postUrl, null, "get", System.Text.Encoding.GetEncoding("gbk"));

                SynsSummitLogger(callBackText);

                callBack.Success          = 1;
                callBack.SuppCallBackText = callBackText;

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] results = callBackText.Split('&');
                    if (results.Length > 2)
                    {
                        string retCode = results[0].Replace("ret_code=", "");

                        callBack.SuppErrorCode = retCode;
                        callBack.SuppErrorMsg  = results[1];

                        if (retCode == "0")
                        {
                            callBack.SummitStatus = 1;
                        }
                        if (retCode == "99")
                        {
                            callBack.SummitStatus = 1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Example #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string puserid   = this.SuppAccount;
            string puserkey  = this.SuppKey;
            string commitUrl = this.PostCardUrl + "?";

            string cardno   = o.CardNo;
            string cardpass = o.CardPass;
            string orderId  = o.SysOrderNo;

            string cardtype  = GetPaycardno(o.CardTypeId);
            string productid = GetCardType(o.CardTypeId, o.FaceValue);

            if (productid == "0")
            {
                productid = cardtype + o.FaceValue.ToString(CultureInfo.InvariantCulture);
            }

            string money = o.FaceValue.ToString(CultureInfo.InvariantCulture);

            string md5Str = MD5(string.Format("userid={0}&orderid={1}&typeid={2}&productid={3}&cardno={4}&cardpwd={5}&money={6}&url={7}&keyvalue={8}",
                                              puserid, orderId, cardtype, productid, cardno, cardpass, money, NotifyUrl, puserkey).ToLower());

            string postData = string.Format("userid={0}&orderid={1}&typeid={2}&productid={3}&cardno={4}&cardpwd={5}&money={6}&url={7}&sign={8}&ext={9}"
                                            , puserid, orderId, cardtype, productid, cardno, cardpass, money, NotifyUrl, md5Str, string.Empty);

            try
            {
                string callBackText = WebClientHelper.GetString(commitUrl.ToLower()
                                                                , postData
                                                                , "GET"
                                                                , Encoding.GetEncoding("GB2312")
                                                                , 5000);

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] strings = callBackText.Split('&');

                    callBack.Success          = 1;
                    callBack.SuppCallBackText = callBackText;

                    string returncode    = strings[0].Replace("returncode=", string.Empty);
                    string returnorderid = strings[1].Replace("returnorderid=", string.Empty);
                    string sign          = strings[2].Replace("sign=", string.Empty);

                    callBack.SuppErrorCode = returncode;
                    callBack.SuppTransNo   = returnorderid;
                    callBack.SuppErrorMsg  = GetMsgInfo(returncode);

                    if (MD5(string.Format("returncode={0}&returnorderid={1}&keyvalue={2}", returncode, returnorderid, puserkey).ToLower()) == sign)
                    {
                        if (!string.IsNullOrEmpty(returncode) && returncode == "1")
                        {
                            callBack.SummitStatus = 1;
                        }
                    }
                    else
                    {
                        callBack.Message = "签名失败";
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                callBack.Success = 0;
                callBack.Message = ex.Message;
            }

            return(callBack);
        }
Example #22
0
        /// <summary>
        /// http://service.800j.com/Consign/HuisuRecycleCardSubmit.aspx
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string postUrl = PostCardUrl;

            if (string.IsNullOrEmpty(postUrl))
            {
                postUrl = "http://service.800j.com/Consign/HuisuRecycleCardSubmit.aspx";
            }

            string agentID  = SuppAccount;
            string billID   = o.SysOrderNo;
            string billTime = DateTime.Now.ToString("yyyyMMddHHmmss");
            string cardType = GetCardType(o.CardTypeId);
            string cardData = o.CardNo + "," + o.CardPass + "," + o.FaceValue.ToString(CultureInfo.InvariantCulture);// Encode();

            cardData = card_Encode(cardData);

            string cardPrice = o.FaceValue.ToString(CultureInfo.InvariantCulture);
            string clientIP  = ServerVariables.TrueIP;

            string desc      = string.Empty;
            string extParam  = string.Empty;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_price={5}&notify_url={6}&time_stamp={7}|||{8}"
                                         , agentID
                                         , billID
                                         , billTime
                                         , cardType
                                         , cardData
                                         , cardPrice
                                         , NotifyUrl
                                         , timeStamp
                                         , SuppKey);

            string sign = Md5Sign(plain).ToLower();

            try
            {
                postUrl = string.Format("{9}?agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_price={5}&notify_url={6}&time_stamp={7}&sign={8}"
                                        , agentID
                                        , billID
                                        , billTime
                                        , cardType
                                        , cardData
                                        , cardPrice
                                        , NotifyUrl
                                        , timeStamp
                                        , sign
                                        , postUrl);

                SynsSummitLogger(postUrl);

                string callBackText = WebClientHelper.GetString(postUrl, null, "get", Encoding.GetEncoding("gbk"));

                SynsSummitLogger(callBackText);

                callBack.SuppCallBackText = callBackText;

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] results = callBackText.Split('&');
                    if (results.Length > 2)
                    {
                        string retCode    = GetValue(results[0]);
                        string billStatus = GetValue(results[4]);

                        callBack.SuppErrorCode = retCode + "|" + billStatus;
                        callBack.SuppErrorMsg  = GetValue(results[7]);
                        callBack.SuppTransNo   = GetValue(results[3]);

                        if (retCode == "0" || retCode == "99")
                        {
                            callBack.Success = 1;

                            if (billStatus == "0" || billStatus == "1")
                            {
                                callBack.SummitStatus = 1;
                            }
                            if (billStatus == "2")
                            {
                                callBack.SummitStatus = 1;
                                callBack.OrderStatus  = 2;
                            }
                            if (billStatus == "-1")
                            {
                                callBack.SummitStatus = 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Example #23
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);
        }