public InvokeResult <AuthenticateRet> SignOut(string applicationIdFrom, string applicationIdTo, string tag)
        {
            InvokeResult <AuthenticateRet> result = new InvokeResult <AuthenticateRet>()
            {
                Success = true, ret = new AuthenticateRet()
            };

            try
            {
                CertManager.LogoffUser(
                    new LogoffCallbackDelegate(delegate(LogoffCallbackEventArgs args)
                {
                    var redirectToLogin = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <Redirect>(new Redirect {
                        ApplicationIdFrom = applicationIdFrom, ApplicationIdTo = applicationIdTo, Tag = tag
                    }).FirstOrDefault();
                    if (redirectToLogin != null)
                    {
                        result.ret.RedirectUrl = redirectToLogin.Url;
                    }
                }));
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public InvokeResult <AuthenticateRet> SignIn(string applicationIdFrom, string applicationIdTo, string token, string tag)
        {
            InvokeResult <AuthenticateRet> result = new InvokeResult <AuthenticateRet>()
            {
                Success = true, ret = new AuthenticateRet()
            };

            try
            {
                CertManager.LogonUserByToken(applicationIdFrom, applicationIdTo, token,
                                             new LogonSuccessDelegate <User>(delegate(LogonSuccessEventArgs <User> args)
                {
                    base.setSessionValue(NormalSession.USER_ID_KEY, args.Instance.UserId.ToString());
                    base.setSessionValue(NormalSession.USER_CODE_KEY, args.Instance.UserCode);
                    base.setSessionValue(NormalSession.USER_NAME_KEY, args.Instance.UserName);
                    base.setSessionValue(NormalSession.USER_TYPE_KEY, args.Instance.UserType);
                    base.setSessionValue(NormalSession.IP_KEY, args.IpAddress);
                    result.ret.SessionId = NormalSession.SessionId;
                    result.ret.UserName  = NormalSession.UserName;
                    result.ret.Ip        = NormalSession.Ip;
                    //var redirectToIndex = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List<Redirect>(new Redirect { ApplicationIdFrom = applicationIdFrom, ApplicationIdTo = applicationIdTo, Tag = "IndexPage" }).FirstOrDefault();
                    var redirectToIndex = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <Redirect>(new Redirect {
                        ApplicationIdFrom = applicationIdFrom, ApplicationIdTo = applicationIdTo, Tag = tag
                    }).FirstOrDefault();
                    if (redirectToIndex != null)
                    {
                        result.ret.RedirectUrl = redirectToIndex.Url;
                    }
                }),
                                             new LogonFailureDelegate(delegate(LogonFailureEventArgs args)
                {
                    result.Success      = false;
                    result.ErrorMessage = args.ErrorMessage;
                }));
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public InvokeResult <LogoutRet> _Logout(LogoutParam param)
        {
            InvokeResult <LogoutRet> result = new InvokeResult <LogoutRet>()
            {
                Success = true, ret = new LogoutRet {
                }
            };

            CertManager.LogoffUser(
                new LogoffCallbackDelegate(delegate(LogoffCallbackEventArgs args)
            {
                //var redirectToLogin = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List<Redirect>(new Redirect { ApplicationIdFrom = param.ApplicationIdFrom, ApplicationIdTo = param.ApplicationIdTo, Tag = "LoginPage" }).FirstOrDefault();
                var redirectToLogin = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <Redirect>(new Redirect {
                    ApplicationIdFrom = param.ApplicationIdFrom, ApplicationIdTo = param.ApplicationIdTo, Tag = param.Tag
                }).FirstOrDefault();
                if (redirectToLogin != null)
                {
                    result.ret.RedirectUrl = redirectToLogin.Url;
                }
            })
                );
            return(result);
        }