示例#1
0
        public void InitServiceTest()
        {
            new Thread(() => {
                while (true)
                {
                    var pid = "0";
                    try
                    {
                        pid = HttpRequestUtil.GetHttpResponse("http://localhost:8081/pid", 3000);
                    }
                    catch (Exception e) { }

                    var p = Convert.ToInt64(pid);
                    if (p > 0)
                    {
                        CmdUtils.RunCmdStandard("taskkill /f /pid " + p);
                        break;
                    }
                    else
                    {
                        Thread.Sleep(3000);
                    }
                }
            }).Start();

            IRpcService rpc = new RpcServiceImpl();

            rpc.ReCreateJMapQuery();
            rpc.InitService();
        }
示例#2
0
        public IActionResult RechargeCallBack(string openId, decimal amount)
        {
            var isOk  = dbService.ReCharge(openId, amount);
            var state = isOk ? BIZSTATUS.SUCCESS : BIZSTATUS.FAILEDTORECHARGE;

            return(Ok(HttpRequestUtil.GetHttpResponse((int)state, state.GetDescription(), "")));
        }
示例#3
0
        public IActionResult GetJSSDKConfig(string url)
        {
            var config     = wxService.GetWxJSSDKConfig(wxContext, url);
            var statusCode = config == null ? BIZSTATUS.DATAEMPTY : BIZSTATUS.SUCCESS;

            return(Ok(HttpRequestUtil.GetHttpResponse((int)statusCode, statusCode.GetDescription(), config)));
        }
示例#4
0
        public IActionResult IsRegister(string openId)
        {
            var res        = dbService.GetUserByOpenId(openId);
            var isRegister = res.Count() <= 0 ? false : true;

            return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), isRegister)));
        }
示例#5
0
        public IActionResult SendVerificationCode(string openId, string phone)
        {
            var code = verificationCodeService.NewCode(codeDict, phone);

            var result = smsService.SentSMS(phone, code.Code);

            return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), result)));
        }
示例#6
0
        public IActionResult Register(string openId, string phone, string validCode)
        {
            var isValidCode = verificationCodeService.ValidateCode(codeDict, phone, Convert.ToInt32(validCode));

            if (!isValidCode)
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.INVALIDCODE, BIZSTATUS.INVALIDCODE.GetDescription(), isValidCode)));
            }

            dbService.Register(phone, openId);
            return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), "")));
        }
示例#7
0
        public HttpResult <WxJSSDKConfig> GetWxJSSDKConfig(string url)
        {
            var config     = WxJSSDKAuthHelper.GetWxJSSDKConfig(WxContext.Context, url);
            var statusCode = HTTP_STATUS_CODE.SUCCESS;
            var msg        = "请求成功";

            if (config == null)
            {
                statusCode = HTTP_STATUS_CODE.DATAEMPTY;
                msg        = "请求成功,但数据为空";
            }
            return(HttpRequestUtil.GetHttpResponse(HTTP_SUCCESS.SUCCESS, statusCode, msg, config));
        }
示例#8
0
        public IActionResult GetWxOpenId(string code, string state)
        {
            var res = wxService.GetAuthToken(wxContext, code);

            if (res != null)
            {
                HttpContext.Session.SetString("OpenId", res.OpenId);
                return(Redirect("/?openId=" + res.OpenId));
            }
            else
            {
                return(Ok(HttpRequestUtil.GetHttpResponse <string>((int)BIZSTATUS.ERROR, BIZSTATUS.ERROR.GetDescription(), "")));
            }
        }
示例#9
0
        public long JMapQueryIsRunning()
        {
            var pid = "0";

            try
            {
                var path = Resources.JMapQueryBaseUrl + Resources.JMapQueryPid;
                pid = HttpRequestUtil.GetHttpResponse(path, 3000);
            }
            catch (Exception e) { }
            long p = long.Parse(pid);

            return(p);
        }
示例#10
0
        public static string DoGet <T>(string url, T obj) where T : BaseRequestDTO
        {
            Trace.TraceInformation("DoGet方法====>请求url={0},请求参数={1}", url, obj.ToString());
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            var sn    = AKSNCaculater.CaculateAKSN(Resources.MyAk, Resources.MySk, url, obj);
            var param = obj.ToString() + "&ak=" + Resources.MyAk + "&sn=" + sn;

            Trace.TraceInformation("DoGet方法====>请求地址={0}", param);
            var result = HttpRequestUtil.GetHttpResponse(Resources.BaiduMapBaseUrl + url + "?" + param, 3000);

            stopwatch.Stop();
            Trace.TraceInformation("DoGet方法====>耗时={0}毫秒,请求地址={1},返回结果={2}", stopwatch.ElapsedMilliseconds.ToString(), param, result);
            return(result);
        }
示例#11
0
        public IActionResult GetWxUserInfo(string openId)
        {
            var userInfo = wxService.GetWxUserInfo(wxContext, openId);

            if (userInfo == null)
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.ERROR, BIZSTATUS.ERROR.GetDescription(), "")));
            }

            if (dbService.IsRegister(openId))
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), userInfo)));
            }
            else
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.NOREGISTER, BIZSTATUS.NOREGISTER.GetDescription(), openId)));
            }
        }
示例#12
0
        public bool JMapQueryHealthCheck()
        {
            var status = "";

            try
            {
                var path = Resources.JMapQueryBaseUrl + Resources.JMapQueryHealthCheck;
                status = HttpRequestUtil.GetHttpResponse(path, 3000);
            }
            catch (Exception e) { }
            if (status == "OK")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#13
0
        public IActionResult BuyFlowPackage(string openId, string iccId, string flowPackageId)
        {
            var cards = dbService.GetFlowCards(openId);

            if (cards == null || cards.Count() <= 0 || cards.SingleOrDefault(n => n.ICCId == iccId) == null)
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.USERHASNOCARD, BIZSTATUS.USERHASNOCARD.GetDescription(), "")));
            }

            if (!dbService.IsExistedFlowPackage(flowPackageId))
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.INVALIDFLOWPACKAGE, BIZSTATUS.INVALIDFLOWPACKAGE.GetDescription(), "")));
            }

            if (dbService.BuyFlowPackage(iccId, flowPackageId))
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), "")));
            }
            return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.ERROR, BIZSTATUS.ERROR.GetDescription(), "")));
        }
示例#14
0
        public IActionResult AddCards(string openId, string iccId)
        {
            if (!iCCIDService.IsValidICCID(iccId))
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.INVALIDICCID, BIZSTATUS.INVALIDICCID.GetDescription(), "")));
            }

            if (dbService.IsExistedFlowCard(iccId))
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.EXISTEDCARD, BIZSTATUS.EXISTEDCARD.GetDescription(), "")));
            }

            var state = BIZSTATUS.SUCCESS;

            if (!dbService.AddFlowCards(openId, iccId))
            {
                state = BIZSTATUS.ERROR;
            }

            return(Ok(HttpRequestUtil.GetHttpResponse((int)state, state.GetDescription(), "")));
        }
示例#15
0
        public IActionResult GetCards(string openId)
        {
            var cards = dbService.GetFlowCards(openId);

            if (cards == null || cards.Count() <= 0)
            {
                return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.NOCARDS, BIZSTATUS.NOCARDS.GetDescription(), "")));
            }
            List <FlowCardModel> flowCardsList = new List <FlowCardModel>();

            foreach (var item in cards)
            {
                FlowCardModel model = new FlowCardModel()
                {
                    OpenId     = item.OpenId,
                    ICCId      = item.ICCId,
                    TotalFlow  = item.TotalFlow,
                    UsagedFlow = item.UsagedFlow
                };

                flowCardsList.Add(model);
            }
            return(Ok(HttpRequestUtil.GetHttpResponse((int)BIZSTATUS.SUCCESS, BIZSTATUS.SUCCESS.GetDescription(), flowCardsList)));
        }
示例#16
0
        public void GetHttpResponseTest()
        {
            var response = HttpRequestUtil.GetHttpResponse("http://api.map.baidu.com/place/v2/search?query=ATM%E6%9C%BA&tag=%E9%93%B6%E8%A1%8C&region=%E5%8C%97%E4%BA%AC&output=json&ak=Y1XohU4UQoppPo2eRjmdm9ed72qPwKp9&sn=b115c7a5e533345798210949f39975e0", 3000);

            var obj = JsonConvert.DeserializeObject <BaseResponseDTO <List <PlaceSearchResponseDTO> > >(response);
        }