コード例 #1
0
        public YnWebRight GetYnWebRight()
        {
            YnWebRight ynWebRight = new YnWebRight();
            //string mi = System.Web.HttpContext.Request["mi"];
            //System.Web.HttpContext.Current.Server.UrlEncode(ynWebAccMenuTree.ynWebModule.parameter);
            string mi = System.Web.HttpContext.Current.Request["mi"];

            YnFrame.Dal.Entities.YnUser ynUser = FormsAuthenticationService.GetInstance().GetTicketUserData();
            //ynUser = YnFrame.Services.YnUserService.GetInstance().Get(ynUser.userId);
            if (ynUser != null && mi != null)
            {
                ynWebRight = GetYnWebRight(ynUser.userId, mi);
            }
            return(ynWebRight);
        }
コード例 #2
0
        public void AccMenu()
        {
            List <YnWebAccMenu> listYnWebAccMenu = null;

            try
            {
                YnUser ynUser = FormsAuthenticationService.GetInstance().GetTicketUserData();
                //ynUser = YnFrame.Services.YnUserService.GetInstance().Get(ynUser.userId);
                if (ynUser != null)
                {
                    listYnWebAccMenu = YnPermission.GetInstance().GetYnWebAccMenuList(ynUser);
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
        }
コード例 #3
0
        /*[AcceptVerbs(HttpVerbs.Post)]*/
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    YnUser ynUser = AscmUserInfoService.GetInstance().TryGet(model.UserName);

                    /*
                     * YnUser ynUser = YnUserService.GetInstance().Get(model.UserName);
                     * if (ynUser == null)
                     * {
                     *  //throw new Exception("用户不存在");
                     *  //判断是否erp用户
                     *  ynUser = YnUserService.GetInstance().Get("erp_"+model.UserName);
                     *  if (ynUser == null)
                     *  {
                     *      //判断是否mes用户
                     *  }
                     * }
                     */
                    if (ynUser == null)
                    {
                        throw new Exception("用户不存在");
                    }
                    if (!string.IsNullOrEmpty(ynUser.extExpandType))
                    {
                        if (ynUser.extExpandType.Trim() == "erp")
                        {
                            //供应商登录显示供应商名称
                            AscmUserInfo ascmUserInfo = (AscmUserInfo)ynUser;
                            AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo);
                            if (ascmUserInfo.ascmSupplier != null)
                            {
                                ascmUserInfo.userName1 = ascmUserInfo.ascmSupplier.name;
                            }

                            if (!MembershipService.ValidateUser(ynUser.userId, model.Password))
                            {
                                if (Request.IsAjaxRequest())
                                {
                                    return(Content("用户密码错误!"));
                                }
                                //ModelState.AddModelError("", "提供的用户名或密码不正确。");
                                throw new Exception("提供的用户名或密码不正确。");
                            }
                        }
                        else if (ynUser.extExpandType.Trim() == "mes")
                        {
                            cn.com.midea.mespda.TransferService  service = new cn.com.midea.mespda.TransferService();
                            cn.com.midea.mespda.OutputWebMessage message = service.UserLogin(model.UserName, model.Password);
                            if (!message.IsSuccess)
                            {
                                throw new Exception(message.ErrorMessage);
                            }
                        }
                    }
                    else
                    {
                        if (!MembershipService.ValidateUser(ynUser.userId, model.Password))
                        {
                            if (Request.IsAjaxRequest())
                            {
                                return(Content("用户密码错误!"));
                            }
                            //ModelState.AddModelError("", "提供的用户名或密码不正确。");
                            throw new Exception("提供的用户名或密码不正确。");
                        }
                    }

                    //HttpCookie cookie = Request.Cookies.Get("userName");
                    //Response.Cookies["userName"].Value = model.UserName;
                    string _userName = HttpUtility.UrlEncode(model.UserName);
                    Response.Cookies["userName"].Value   = _userName;
                    Response.Cookies["userName"].Expires = DateTime.MaxValue;

                    int days     = 0;
                    int iExpires = 0;
                    if (days > 0)
                    {
                        iExpires = 60 * 60 * 24 * days;//保存天数
                    }
                    //YnUser ynUser = YnUserService.GetInstance().Get(model.UserName);
                    FormsAuthenticationService.GetInstance().SignIn(ynUser.userId, 0, ynUser, true);
                    PageInit(null);
                    //this.ynSite.systemUser = true;//是系统用户
                    //this.ynSite.siteAdmin = YnUserService.GetInstance().IsSuperAdministrator(ynUser.userId) || YnUserService.GetInstance().IsAdministrator(ynUser.userId);
                    //this.ynSite.userName = ynUser.userName;//是系统用户
                    if (Request.IsAjaxRequest())
                    {
                        return(JavaScript("document.location.href='';"));
                    }
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        //return RedirectToAction("Index", "Home");
                        return(RedirectToAction("YnFrame", "YnPublic"));
                    }
                }
                catch (Exception ex)
                {
                    //throw ex;
                    ModelState.AddModelError("", ex.Message);
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }