예제 #1
0
        /// <summary>
        /// 会员注册
        /// </summary>
        /// <param name="config"></param>
        /// <param name="memberrRegister"></param>
        /// <returns></returns>
        public ShuYunResult MemberRegister(SYConfig config, MemberrRegister memberrRegister)
        {
            string actionMethod = "shuyun.loyalty.member.register";//必须为POST方式
            //var result = PostRequestSnd(actionMethod, config, json);
            IClient client = new SYRestClient(config);
            string  memberrRegisterJsonData = Newtonsoft.Json.JsonConvert.SerializeObject(memberrRegister);
            string  result = client.PostRequestSnd(actionMethod, memberrRegisterJsonData);

            return(Newtonsoft.Json.JsonConvert.DeserializeObject <ShuYunResult>(result));
        }
예제 #2
0
        public ResultValue Send(TestMode testMode)
        {
            var result = ResultValue.Current;

            var json         = testMode.Json;
            var config       = testMode.Config;
            var actionMethod = testMode.ApiName;
            var Method       = testMode.Method;
            var isPlatform   = testMode.IsPlatform;

            if (string.IsNullOrEmpty(json))
            {
                result.MsgCode = 2;
                result.Msg     = "json数据不能为空";
                return(result);
            }
            if (config == null || string.IsNullOrEmpty(config.Host))
            {
                result.MsgCode = 2;
                result.Msg     = "Host数据不能为空";
                return(result);
            }
            try
            {
                IClient client = new SYRestClient(config);
                switch (Method)
                {
                case "GET":
                    var pairs = json.ToObject <Dictionary <string, string> >();
                    result.Data = client.GetRequestSnd(actionMethod, pairs);
                    break;

                case "POST":
                    result.Data = client.PostRequestSnd(actionMethod, json, isPlatform);
                    break;

                case "PUT":
                    result.Data = client.PutRequestSnd(actionMethod, json, isPlatform);
                    break;

                default:
                    result.MsgCode = 2;
                    result.Msg     = "json数据不能为空";
                    break;
                }
                result.MsgCode = 1;
                return(result);
            }
            catch (Exception er)
            {
                result.MsgCode = 3;
                result.Msg     = "异常:" + er.Message;
                return(result);
            }
        }