Exemplo n.º 1
0
        private static void PostLoginProcess(O_Login loginResult)
        {
            // Update PoseToken, Update ExpireTime
            ClientContext.SetCredentialsFrom(loginResult.PoseToken);
            ClientContext.UserNo        = loginResult.UserNo;
            ClientContext.TokenExpireIn = DateTime.UtcNow.AddMilliseconds(loginResult.TokenExpireIn);
            ClientContext.LastLoginTime = loginResult.LastLoginTime.ToLocalTime();

            // Set Membership Information
            var membershipService = ShinyHost.Resolve <MembershipService>();

            membershipService.SetMemberRoleType(loginResult.MemberRoleType);
            membershipService.SetRoleExpireTime(loginResult.RoleExpireTime);
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            WebClient.ExceptionHandler = Program.ExceptionHandler;

            // RSA Key
            string serverPubKey = WebClient.RequestAsync <string>(new WebRequestContext
            {
                SerializeType = SerializeType.MessagePack,
                MethodType    = WebMethodType.GET,
                BaseUrl       = ServiceBaseUrl,
                ServiceUrl    = AuthProxy.ServiceUrl,
                SegmentGroup  = AuthProxy.P_PUBLISH_KEY,
            }, ClientContext.Token).Result;

            CryptoFacade.Instance.RSA_FromXmlString(serverPubKey);
            ClientContext.eSignature   = CryptoFacade.Instance.GetEncryptedSignature();
            ClientContext.eSignatureIV = CryptoFacade.Instance.GetEncryptedSignatureIV();

            // Login
            O_Login login_output = WebClient.RequestAsync <O_Login>(new WebRequestContext()
            {
                SerializeType = SerializeType.MessagePack,
                MethodType    = WebMethodType.POST,
                BaseUrl       = ServiceBaseUrl,
                ServiceUrl    = AuthProxy.ServiceUrl,
                SegmentGroup  = AuthProxy.P_E_LOGIN,
                NeedEncrypt   = true,
                PostData      = new I_Login
                {
                    PlatformId = "test",
                }
            }, ClientContext.Token).Result;

            ClientContext.SetCredentialsFrom(login_output.PoseToken);
            ClientContext.TokenExpireIn = DateTime.UtcNow.AddMilliseconds(login_output.TokenExpireIn);
            ClientContext.LastLoginTime = login_output.LastLoginTime.ToLocalTime();

            // Serializer benchmark
            //Task.Factory.StartNew(() =>
            //{
            //    var serializerBenchmark = new SerializerBenchmark();
            //    serializerBenchmark.StartBenchmark();
            //}, TaskCreationOptions.LongRunning);

            Console.ReadLine();
        }