예제 #1
0
        public async Task <ActionResult> LogIn(AccountModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Password = "";
                return(View(model));
            }
            if (model.UserName.ToUpper() != "SYSADMIN")
            {
                DateTime?dateOf = _SettingBL.getSettingAsDate(SettingBL.SettingParameters.ExpireDateTime, "SYSTEM");
                if (dateOf != null)
                {
                    DateTime ExpireDate = dateOf ?? DateTime.Now.AddDays(2);
                    if (ExpireDate < DateTime.Now)
                    {
                        ModelState.AddModelError("", "خطای 001 اتفاق افتاده است.با مدیریت تماس بگیرید");
                        model.Password = "";
                        return(View(model));
                    }
                }

                string conn    = _SettingBL.getSettingAsString(SettingBL.SettingParameters.LicenseText, "SYSTEM");
                string gdbConn = _GdbConnection;// System.Configuration.ConfigurationManager.ConnectionStrings["gdbConn"].ConnectionString;
                if (conn != gdbConn)
                {
                    ModelState.AddModelError("", "خطای 002 اتفاق افتاده است.با مدیریت تماس بگیرید");
                    model.Password = "";
                    return(View(model));
                }
            }
            var user = await _UserManager.FindAsync(model.UserName, model.Password);

            _UpdateLogBL.Log(model.UserName.ToUpper(), "", -1, "User Login", "");
            if (user != null)
            {
                var identity = await _UserManager.CreateIdentityAsync(
                    user, DefaultAuthenticationTypes.ApplicationCookie);

                AuthenticationManager.SignIn(new AuthenticationProperties()
                {
                    IsPersistent = model.IsPersistent
                }, identity);

                return(Redirect(GetRedirectUrl(model.ReturnUrl)));
            }

            // user authN failed
            ModelState.AddModelError("", "نام کاربری یا رمز عبور اشتباه است");
            return(View(model));
        }
예제 #2
0
        public ActionResult SYSSetting()
        {
            DateTime?dateOf = _SettingBL.getSettingAsDate(SettingBL.SettingParameters.ExpireDateTime, "SYSTEM");
            var      model  = new SysSettingParam();

            model.MapDefCentroidX = _SettingBL.getSettingAsDouble(DataAccess.Logic.SettingBL.SettingParameters.MapDefCentroidX, User.Identity.Name);
            model.MapDefCentroidY = _SettingBL.getSettingAsDouble(DataAccess.Logic.SettingBL.SettingParameters.MapDefCentroidY, User.Identity.Name);
            model.MapDefultZoom   = _SettingBL.getSettingAsDouble(DataAccess.Logic.SettingBL.SettingParameters.MapDefultZoom, User.Identity.Name);


            PersianCalendar pc       = new PersianCalendar();
            DateTime        thisDate = dateOf ?? DateTime.Now.AddDays(2);

            model.ExpireDate = string.Format("'{0}/{1}/{2}'", pc.GetYear(thisDate), pc.GetMonth(thisDate), pc.GetDayOfMonth(thisDate));
            model.BackupPath = _SettingBL.getSettingAsString(DataAccess.Logic.SettingBL.SettingParameters.BackUpPath, User.Identity.Name);
            return(View(model));
        }