public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!LoginCenter.IsUserLogin() || LoginCenter.CurrentUser.Role == Role.Company) return;

            var onLine = HttpContext.Current.Application[LotterySystem.M_ONLINEUSERCOUNT] as IDictionary<int, Pair<string, Role>>;
            string sessionId = HttpContext.Current.Session.SessionID;
            int userId = onLine.Where(it => it.Value.Key == sessionId).Select(it => it.Key).SingleOrDefault();
            if (!onLine.ContainsKey(userId))
            {
                LoginCenter lotinCentre = new LoginCenter();
                if (filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    filterContext.Result = new JsonResult
                    {
                        Data = new JsonResultModel
                        {
                            IsSuccess = false,
                            Message = Resource.LoginByOtherOne
                        }
                    };
                }
                else
                {
                    var urlHelper = new UrlHelper(filterContext.RequestContext);
                    string actionUrl = urlHelper.Action("Error", "Prompt");
                    string loginUrl = urlHelper.Action(LoginCenter.CurrentUser.Role == Role.Guest ? "Login" : "Agent", "Member");
                    string redirectUrl = string.Format("{0}?Url={1}&Msg={2}", actionUrl, loginUrl, Resource.LoginByOtherOne);
                    filterContext.Result = new RedirectResult(redirectUrl);
                }
                lotinCentre.Logout();
            }
        }
        protected override void OnStart()
        {
            var serviceCollection = new ServiceCollection();
            var container         = ConfigureServices();

            NetCoreProvider.RegisterServiceLocator(container);
            MainPage = new LoginCenter().GetContentPage();
        }
Example #3
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            Contract.serverUrl = ConfigurationManager.AppSettings["serverAddress"];
            var container = ConfigureServices();

            NetCoreProvider.RegisterServiceLocator(container);
            LoginCenter viewCenter = new LoginCenter();
            await viewCenter.ShowDialog();
        }
Example #4
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            this.ConfigureServices();

            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);
            var serviceProvider = serviceCollection.BuildServiceProvider();

            NetCoreProvider.RegisterServiceLocator(serviceProvider);

            LoginCenter viewCenter = new LoginCenter();
            await viewCenter.ShowDialog();
        }