コード例 #1
0
ファイル: User.asmx.cs プロジェクト: tunkobarrios/mixerp2
        private string Login(string catalog, int officeId, string userName, string password, string culture,
                             bool rememberMe, string challenge, HttpContext context)
        {
            try
            {
                long globalLoginId = Data.Office.User.SignIn(catalog, officeId, userName, password, culture, rememberMe,
                                                             challenge, context);

                Log.Information("{UserName} signed in to office : #{OfficeId} from {IP}.", userName, officeId,
                                context.Request.ServerVariables["REMOTE_ADDR"]);

                if (globalLoginId > 0)
                {
                    MixERPWebpage.SetAuthenticationTicket(HttpContext.Current.Response, globalLoginId, rememberMe);

                    AppUsers.SetCurrentLogin(globalLoginId);
                    return("OK");
                }

                this.LogInvalidSignIn();
                return(Warnings.UserIdOrPasswordIncorrect);
            }
            catch (MixERPException ex)
            {
                Log.Warning("{UserName} could not sign in to office : #{OfficeId} from {IP}.", userName, officeId,
                            context.Request.ServerVariables["REMOTE_ADDR"]);

                this.LogInvalidSignIn();
                return(ex.Message);
            }
        }
コード例 #2
0
        private string Login(int officeId, string userName, string password, string culture, bool rememberMe, string challenge, HttpContext context)
        {
            try
            {
                long signInId = Data.Office.User.SignIn(officeId, userName, password, culture, rememberMe, challenge, context);

                Log.Information("{UserName} signed in to office : #{OfficeId}.", userName, officeId);

                if (signInId > 0)
                {
                    MixERPWebpage.SetSession(this.Context.Session, signInId);
                    MixERPWebpage.SetAuthenticationTicket(this.Context.Response, signInId, rememberMe);

                    return("OK");
                }

                this.LogInvalidSignIn();
                return(Warnings.UserIdOrPasswordIncorrect);
            }
            catch (MixERPException ex)
            {
                Log.Warning("{UserName} could not sign in to office : #{OfficeId}.", userName, officeId);

                this.LogInvalidSignIn();
                return(ex.Message);
            }
        }
コード例 #3
0
ファイル: SignIn.aspx.cs プロジェクト: magogoba/mixerp
        private static bool Login(int officeId, string userName, string password, string culture, bool rememberMe, Page page)
        {
            bool results = Data.Office.User.SignIn(officeId, userName, password, culture, rememberMe, page);

            if (results)
            {
                MixERPWebpage.SetSession(page, userName);
                MixERPWebpage.SetAuthenticationTicket(page, userName, rememberMe);
            }

            return(results);
        }
コード例 #4
0
        public static bool SetSession(Page page, string user)
        {
            if (page != null)
            {
                try
                {
                    SignInView signInView = GetLastSignInView(user);
                    long       logOnId    = signInView.LogOnId;

                    if (logOnId.Equals(0))
                    {
                        MixERPWebpage.RequestLogOnPage();
                        return(false);
                    }

                    page.Session["LogOnId"]            = signInView.LogOnId;
                    page.Session["UserId"]             = signInView.UserId;
                    page.Session["Culture"]            = signInView.Culture;
                    page.Session["UserName"]           = user;
                    page.Session["FullUserName"]       = signInView.FullName;
                    page.Session["Role"]               = signInView.Role;
                    page.Session["IsSystem"]           = signInView.IsSystem;
                    page.Session["IsAdmin"]            = signInView.IsAdmin;
                    page.Session["OfficeCode"]         = signInView.OfficeCode;
                    page.Session["OfficeId"]           = signInView.OfficeId;
                    page.Session["NickName"]           = signInView.Nickname;
                    page.Session["OfficeName"]         = signInView.OfficeName;
                    page.Session["RegistrationDate"]   = signInView.RegistrationDate;
                    page.Session["RegistrationNumber"] = signInView.RegistrationNumber;
                    page.Session["PanNumber"]          = signInView.PanNumber;
                    page.Session["AddressLine1"]       = signInView.AddressLine1;
                    page.Session["AddressLine2"]       = signInView.AddressLine2;
                    page.Session["Street"]             = signInView.Street;
                    page.Session["City"]               = signInView.City;
                    page.Session["State"]              = signInView.State;
                    page.Session["Country"]            = signInView.Country;
                    page.Session["ZipCode"]            = signInView.ZipCode;
                    page.Session["Phone"]              = signInView.Phone;
                    page.Session["Fax"]   = signInView.Fax;
                    page.Session["Email"] = signInView.Email;
                    page.Session["Url"]   = signInView.Url;

                    return(true);
                }
                catch (DbException)
                {
                    //Swallow the exception
                }
            }

            return(false);
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.CheckDbConnectivity();
            PageUtility.CheckInvalidAttempts(this.Page);

            try
            {
                this.BindBranchDropDownList();
            }
            catch
            {
                //Could not bind the branch office dropdownlist.
                //The target database does not contain mixerp schema.
                //Swallow the exception
                //and redirect to application offline page.
                this.RedirectToOfflinePage();
                return;
            }


            if (!this.IsPostBack)
            {
                if (this.User.Identity.IsAuthenticated)
                {
                    long signInId = Conversion.TryCastLong(this.User.Identity.Name);

                    if (signInId > 0)
                    {
                        string sessionUser = Conversion.TryCastString(this.Page.Session["UserName"]);

                        if (string.IsNullOrWhiteSpace(sessionUser))
                        {
                            if (MixERPWebpage.SetSession(this.Page.Session, signInId))
                            {
                                this.RedirectToDashboard();
                            }
                        }
                        else
                        {
                            this.RedirectToDashboard();
                        }
                    }
                }
            }
        }