Beispiel #1
0
        public void ExecuteCommand()
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            try
            {
                if (Command != null)
                {
                    Me = (ValidateUserCommand)Command;
                }

                if (ValidateUser())
                {
                    HttpCookie ck = null;
                    ck = FormsAuthenticationMode.CreateFormAuthenticationCookie(LoginName, DateTime.Now.AddMinutes(Me.LogoutTimeout), false, FormsAuthentication.FormsCookieName, FormsAuthentication.FormsCookiePath, profile);

                    Page.Response.Cookies.Add(ck);

                    string strRedirect;
                    strRedirect = Page.Request["ReturnUrl"];
                    if (strRedirect == null)
                    {
                        strRedirect = FormsAuthentication.DefaultUrl;
                    }
                    Page.Response.Redirect(strRedirect, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    Page.DisplayErrorAlert("You have entered an invalid username/password combination. Please try again.");
                }
            }
            catch (Exception ex)
            {
                Page.DisplayErrorAlert(ex);

                log.Error(ex);
            }
        }
Beispiel #2
0
        public void ValidateUser(ValidateUserCommand command)
        {
            var service = NcqrsEnvironment.Get <ICommandService>();

            service.Execute(command);
        }
        public async void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (ValidateUserCommand)Command;
            }
            try
            {
                DataTable          dt            = null;
                DataCommandService dataCommandDB = DataCommandService.GetInstance();
                bool IsAuthenticated             = false;

                //call data command

                //if we get datatable and row=1 store

                List <ScreenDataCommandParameter> parameters = null;
                parameters = Common.GetPopulatedCommandParameters(Me.LoginCommand, IPage);

                DataCommand command = DataCommand.GetDataCommand(Me.LoginCommand);

                switch (command.ReturnType)
                {
                case DataCommandReturnType.DataTable:
                    dt = await dataCommandDB.GetDataForDataCommand(Me.LoginCommand, parameters);

                    break;

                case DataCommandReturnType.Integer:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.Xml:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.None:
                    throw new NotImplementedException();
                    break;
                }

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        DataRow row = dt.Rows[0];
                        Common.DataRowToSettings(row, Me.AfterLoginSettings);
                        IsAuthenticated = true;
                        if (!String.IsNullOrEmpty(Me.AfterLoginRedirectScreen))
                        {
                            Page p = MobilePage.GetPage(Me.AfterLoginRedirectScreen).GetPage();

                            Page.Navigation.PushAsync(p);
                        }
                    }
                }

                if (!IsAuthenticated)
                {
                    IPage.DisplayErrorAlert("You have entered an invalid username/password combination. Please try again.");
                }
            }
            catch (Exception ex)
            {
                IPage.DisplayErrorAlert(ex.Message);
            }
        }