Exemplo n.º 1
0
 public static string Test()
 {
     SmartHsServiceProxy.SmartHsServiceClient smartClient = new SmartHsServiceClient();
     using (var scope = new OperationContextScope(smartClient.InnerChannel))
     {
         // 注意namespace必须和ServiceContract中定义的namespace保持一致,默认是:http://smarths-ndtv.com
         var myNamespace = "http://smarths-ndtv.com";
         // 注意Header的名字中不能出现空格,因为要作为Xml节点名。
         var user = MessageHeader.CreateHeader("user", myNamespace, "test");
         var pwd  = MessageHeader.CreateHeader("pwd", myNamespace, "test123");
         OperationContext.Current.OutgoingMessageHeaders.Add(user);
         OperationContext.Current.OutgoingMessageHeaders.Add(pwd);
         var result = smartClient.AddMember(string.Empty);
         return(null);
     }
 }
Exemplo n.º 2
0
        public static string OnRegister(string user, string pwd1, string pwd2, int community, string vcode,
                                        string phone, string mail /**/)
        {
            string message = string.Empty;
            int    code;

            if (
                String.Compare(Convert.ToString(HttpContext.Current.Session["VerifyCode"]), vcode,
                               StringComparison.OrdinalIgnoreCase) != 0)
            {
                message = "验证码不正确";
                code    = 0;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }
            if (user.Length < 6 || user.Length > 20)
            {
                message = "用户名长度不正确";
                code    = 0;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }

            if (pwd1.Length < 6 || pwd1.Length > 24)
            {
                message = "密码1长度不正确";
                code    = 0;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }

            if (pwd2.Length < 6 || pwd2.Length > 24)
            {
                message = "密码2长度不正确";
                code    = 0;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }

            if (String.Compare(pwd1, pwd2, StringComparison.Ordinal) != 0)
            {
                message = "两次密码输入不一致";
                code    = 0;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }

            var    serviceClient = new SmartHsServiceClient();
            member memb          = new member()
            {
                name = user,
                default_community = community,
                mail       = mail,
                phone      = phone,
                member_key = pwd1
            };
            var json = serviceClient.AddMember(JsonConvert.SerializeObject(memb));
            var jObj = JObject.Parse(json);

            if (Convert.ToInt32(jObj["Code"]) == 1)
            {
                message = "注册成功";
                code    = 1;
                return(JsonConvert.SerializeObject(new { Code = code, Message = message }));
            }
            else
            {
                message = Convert.ToString(jObj["Message"]);
                if (string.IsNullOrEmpty(message))
                {
                    message = "注册失败";
                }
                return(JsonConvert.SerializeObject(new { Code = 0, Message = message }));
            }
            //return "";
        }
Exemplo n.º 3
0
        private int OnRegister(out string message)
        {
            var user       = this.txtUser.Text.Trim();
            var pwd1       = this.txtPwd1.Text;
            var pwd2       = this.txtPwd2.Text;
            var mail       = this.txtMail.Text;
            var phone      = this.txtPhone.Text;
            var verifyCode = this.txtVCode.Text;

            message = string.Empty;
            if (String.Compare(Convert.ToString(Session["VerifyCode"]), verifyCode, StringComparison.OrdinalIgnoreCase) != 0)
            {
                message = "验证码不正确";
                return(-1);
            }
            if (user.Length < 6 || user.Length > 20)
            {
                message = "用户名长度不正确";
                return(-1);
            }

            if (pwd1.Length < 6 || pwd1.Length > 24)
            {
                message = "密码1长度不正确";
                return(-1);
            }

            if (pwd2.Length < 6 || pwd2.Length > 24)
            {
                message = "密码2长度不正确";
                return(-1);
            }

            if (String.Compare(pwd1, pwd2, StringComparison.Ordinal) != 0)
            {
                message = "两次密码输入不一致";
                return(-1);
            }

            var    serviceClient = new SmartHsServiceClient();
            member memb          = new member()
            {
                name = user,
                default_community = Convert.ToInt32(Request.Form["lstCommunity"]),
                mail       = mail,
                phone      = phone,
                member_key = pwd1
            };
            var json = serviceClient.AddMember(JsonConvert.SerializeObject(memb));
            var jObj = JObject.Parse(json);

            if (Convert.ToInt32(jObj["Code"]) == 1)
            {
                message = "注册成功";
                return(1);
            }
            else
            {
                message = Convert.ToString(jObj["Message"]);
                if (string.IsNullOrEmpty(message))
                {
                    message = "注册失败";
                }
            }

            return(0);
        }