示例#1
0
        public ActionResult Login(Models.SysIndex.Login vm)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var error = new List <string>();
                if (Code.Common.UserId == 0 || string.IsNullOrEmpty(Code.Common.Program) == false)
                {
                    error = new List <string>();
                    error.AddError(SysUserLogin(vm));
                }

                if (vm.ProgramId == 0 && !Code.Common.IsMobile)
                {
                    return(Code.MvcHelper.Post(error, Url.Action("Login", "SysIndex", new { area = "Sys" })));
                }

                var program = (from p in db.TableRoot <Admin.Entity.tbProgram>()
                               where p.Id == vm.ProgramId
                               orderby p.No
                               select new
                {
                    p.Id,
                    p.IsWide,
                    p.ProgramName,
                    p.Startup
                }).FirstOrDefault();
                if (program != null)
                {
                    Code.Common.ProgramId   = program.Id;
                    Code.Common.IsWide      = program.IsWide;
                    Code.Common.ProgramName = program.ProgramName;

                    if (string.IsNullOrEmpty(program.Startup) == false)
                    {
                        return(Code.MvcHelper.Post(error, Url.Content("~/" + program.Startup)));
                    }
                }
                //Add Harvey,20161201,非单点登录功能页面跳转
                if (!string.IsNullOrEmpty(vm.ReturnUrl))
                {
                    return(Code.MvcHelper.Post(error, vm.ReturnUrl));
                }
                //Add End
                return(Code.MvcHelper.Post(error, Url.Action("Index", "SysIndex", new { area = "Sys" })));
            }
        }
示例#2
0
        public ActionResult Login(string returnUrl = "", int programId = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.SysIndex.Login();
                vm.ProgramList = Areas.Admin.Controllers.ProgramController.InfoList();
                if (string.IsNullOrEmpty(Code.Common.Program))
                {
                    vm.ProgramList = vm.ProgramList.Take(16).ToList();
                }
                else
                {
                    if (vm.ProgramList.Where(d => d.IsDefault).Any())
                    {
                        vm.ProgramId = vm.ProgramList.Where(d => d.IsDefault).FirstOrDefault().Id;
                    }
                    else
                    {
                        if (programId != 0)
                        {
                            vm.ProgramId = programId;
                        }
                        else if (Code.Common.ProgramId != 0)
                        {
                            vm.ProgramId = Code.Common.ProgramId;
                        }
                    }
                    vm.ProgramList.Clear();
                }

                vm.CheckCodeRefer = Code.Common.CreateCheckCode();
                if (Request.Cookies[Code.Common.AppName + "AppTitle"] != null)
                {
                    Request.Cookies.Remove(Code.Common.AppName + "AppTitle");
                }

                var cookies = System.Web.HttpContext.Current.Request.Cookies[Code.Common.AppName + "XkSystem"];
                if (cookies != null && cookies.HasKeys)
                {
                    vm.SchoolName = Code.Common.DESDeCode(cookies[Code.Common.AppName + "SchoolName"]);
                    vm.UserCode   = Code.Common.DESDeCode(cookies[Code.Common.AppName + "UserCode"]);
                    vm.Password   = Code.Common.DESDeCode(cookies[Code.Common.AppName + "Password"]);
                    vm.CheckCode  = vm.CheckCodeRefer;
                    vm.Remember   = true;
                }

                if (HttpContext.Cache["TenantName"] != null)
                {
                    vm.SchoolName = db.TableRoot <Admin.Entity.tbTenant>().FirstOrDefault().TenantName;
                }
                else
                {
                    vm.IsTenant = true;
                }

                var tenantDefault = db.Set <Admin.Entity.tbTenant>().Where(d => d.IsDefault).FirstOrDefault();
                if (tenantDefault != null)
                {
                    vm.Logo = tenantDefault.Logo;
                }

                //Add,Harvey,非单点登录功能页面跳转
                vm.ReturnUrl = returnUrl;
                //Add End

                //Add,Harvey,xxzx,for demo,20161031
                //if (Code.Common.IsMobile) return View("mxxzx_Login", vm);//西乡
                //Add End

                //Add,Harvey,二十,for Java,20161129
                //if (Code.Common.IsMobile) return View("m20_Login", vm);
                //Add End

                if (Code.Common.IsMobile)
                {
                    return(View("m_Login", vm));                     //光高
                }
                if (Code.Common.Program.ToUpper() == "EAS")
                {
                    return(View("Login" + Code.Common.Program, vm));
                }
                else
                {
                    return(View("Login", vm));
                }
            }
        }