Exemplo n.º 1
0
        //得到查询xml签名
        private static string GetQueryOrderPostSign(WXQueryOrderPost postParams)
        {
            //拼接排序list
            Dictionary <string, string> packageParams = new Dictionary <string, string>();

            packageParams.Add("appid", postParams.appid);
            packageParams.Add("mch_id", postParams.mch_id);
            packageParams.Add("nonce_str", postParams.nonce_str);
            packageParams.Add("out_trade_no", postParams.out_trade_no);
            StringBuilder sb = new StringBuilder();

            foreach (var packageParam in packageParams)
            {
                sb.Append(packageParam.Key);
                sb.Append('=');
                sb.Append(packageParam.Value);
                sb.Append('&');
            }
            sb.Append("key=");
            sb.Append(PartnerKey);//key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
            //这里又用到了从实例代码复制的MD5 可以去上面copy
            String packageSign = MD5Tool.GetMD5(sb.ToString()).ToUpper();

            return(packageSign);
        }
Exemplo n.º 2
0
        private static string genPackageSign(WXPrePost postParams)
        {
            //拼接排序list
            Dictionary <string, string> packageParams = new Dictionary <string, string>();

            packageParams.Add("appid", postParams.appid);
            packageParams.Add("body", postParams.body);
            packageParams.Add("detail", postParams.detail);
            packageParams.Add("mch_id", postParams.mch_id);
            packageParams.Add("nonce_str", postParams.nonce_str);
            packageParams.Add("notify_url", postParams.notify_url);
            packageParams.Add("out_trade_no", postParams.out_trade_no);
            packageParams.Add("spbill_create_ip", postParams.spbill_create_ip);
            packageParams.Add("total_fee", postParams.total_fee + "");
            packageParams.Add("trade_type", postParams.trade_type);
            StringBuilder sb = new StringBuilder();

            foreach (var packageParam in packageParams)
            {
                sb.Append(packageParam.Key);
                sb.Append('=');
                sb.Append(packageParam.Value);
                sb.Append('&');
            }
            sb.Append("key=");
            sb.Append(PartnerKey);//key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
            //这里又用到了从实例代码复制的MD5 可以去上面copy
            String packageSign = MD5Tool.GetMD5(sb.ToString()).ToUpper();

            return(packageSign);
        }
Exemplo n.º 3
0
        public LoginResult Login(String username, String password)
        {
            RestClient  client  = new RestClient(ServerURL.URL);
            RestRequest request = new RestRequest("/api/account/authentication", Method.POST);

            request.AddHeader("X-Username", username);
            request.AddHeader("X-Password", MD5Tool.GetMD5(MD5Tool.GetMD5(MD5Tool.GetMD5(password) + username) + "1234"));
            var response = client.Execute <LoginResult>(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                foreach (Parameter header in response.Headers)
                {
                    if (header.Name.Equals("X-Auth-Token"))
                    {
                        response.Data.token = header.Value.ToString();
                    }
                }
                return(response.Data);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer clientPeer,
                                              SendParameters sendParameters)
        {
            Dictionary <byte, object> parameters;

            parameters = request.Parameters;
            object jsonObj = null;

            parameters.TryGetValue((byte)ParameterCode.User, out jsonObj);
            MUser user;

            user = JsonMapper.ToObject <MUser>(jsonObj.ToString());
            IList <MUser> userDB;

            userDB = mgr.GetUserByName(user.UserName);
            foreach (MUser mUser in userDB)
            {
                if (mUser.PassWord == MD5Tool.GetMD5(user.PassWord))
                {
                    //username and password is correct, success , login
                    response.ReturnCode  = (short)ReturnCode.Success;
                    clientPeer.LoginUser = mUser;
                }
                else
                {
                    response.ReturnCode   = (short)ReturnCode.Fail;
                    response.DebugMessage = "username or password error !";
                }
            }
        }
Exemplo n.º 5
0
        public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            Dictionary <byte, object> parameters = request.Parameters;
            object jsonObject = null;

            parameters.TryGetValue((byte)ParameterCode.User, out jsonObject);
            User user   = JsonMapper.ToObject <User>(jsonObject.ToString());
            User userDB = manager.GetUserByUsername(user.Username);

            if (userDB != null && userDB.Password == MD5Tool.GetMD5(user.Password))
            {
                //用户名和密码正确 登录成功
                response.ReturnCode = (short)ReturnCode.Success;
                peer.LoginUser      = userDB;
            }
            else
            {
                response.ReturnCode   = (short)ReturnCode.Fail;
                response.DebugMessage = "用户名或密码错误!";
            }
        }