Beispiel #1
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted)
        {
            try
            {
                string sid = PortalService.AuthUser(uname, pwd, pwdEncrypted);

                if (!String.IsNullOrEmpty(sid))
                {
                    string url = FormsAuthentication.GetRedirectUrl(uname, true);

                    if (asyncreq)
                    {
                        Response.Write(String.Format("success,{0}", url));
                    }
                    else
                    {
                        Response.Redirect(url);
                    }
                }
                else
                {
                    Response.Write("登陆失败,用户名或密码不正确!");
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }

            Response.End();
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted)
        {
            try
            {
                string sql = "select count(UserId) from SysUser where LoginName='" + uname + "'";
                if (DataHelper.QueryValue <int>(sql) > 0)
                {
                    sql = "select password from SysUser where LoginName='" + uname + "'";
                    if (DataHelper.QueryValue(sql) + "" == "")
                    {
                        Response.Write("请先设置密码再登陆!");
                    }
                    else
                    {
                        string sid = PortalService.AuthUser(uname, pwd, pwdEncrypted);
                        if (!String.IsNullOrEmpty(sid))
                        {
                            string url = FormsAuthentication.GetRedirectUrl(uname, true);
                            if (asyncreq)
                            {
                                Response.Write(String.Format("success,{0}", url));
                            }
                            else
                            {
                                Response.Redirect(url);
                            }
                        }
                        else
                        {
                            Response.Write("登陆失败,用户名或密码不正确!");
                        }
                    }
                }
                else
                {
                    Response.Write("用户名不存在!");
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }

            Response.End();
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted)
        {
            try
            {
                SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault();
                if (userent == null)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true);
                    return;
                }

                string   CorpId = userent.Pk_corp;
                SysGroup group  = SysGroup.TryFind(CorpId);
                Session["CompanyId"] = CorpId;
                if (group != null)
                {
                    Session["CompanyName"] = group.Name;
                }
                else
                {
                    Session["CompanyName"] = "";
                }

                string sid = PortalService.AuthUser(uname, pwd, false);
                if (!String.IsNullOrEmpty(sid))
                {
                    string url = FormsAuthentication.GetRedirectUrl(uname, true);
                    Response.Redirect(url);
                    return;
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true);
                    return;
                }
            }
            catch { }
        }
Beispiel #4
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted, string loginstate)
        {
            try
            {
                string  CorpId  = RequestData.Get <string>("CorpId");
                SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault();
                if (userent == null)
                {
                    PageState.Add("error", "用户名错误!");
                    return;
                }
                if (string.IsNullOrEmpty(userent.Password))
                {
                    PageState.Add("error", "nullpwd");
                    return;
                }

                //判断登陆人有没有在这个公司
                string sql       = @"select count(1) from SysUserGroup where UserId='{0}' and GroupId not in (select RoleId from sysRole) and isnull(outdutydate,'')='' and pk_gw is not null and pk_corp='{1}'";
                int    corpcount = DataHelper.QueryValue <int>(string.Format(sql, userent.UserID, CorpId));
                if (corpcount > 0 || uname == "admin")
                {
                    string sid = PortalService.AuthUser(uname, pwd, false);
                    if (!String.IsNullOrEmpty(sid))
                    {
                        string url       = FormsAuthentication.GetRedirectUrl(uname, true);
                        string returnUrl = RequestData.Get <string>("ReturnUrl");
                        Session["CompanyId"] = CorpId;
                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            url = returnUrl;
                            Session["CompanyId"] = CorpId;
                            //公司
                            SysGroup group = SysGroup.TryFind(CorpId);
                            if (group != null)
                            {
                                Session["CompanyName"] = group.Name;
                            }
                            else
                            {
                                Session["CompanyName"] = "";
                            }
                        }
                        PageState.Add("url", url);
                    }
                    else
                    {
                        PageState.Add("error", "登陆失败,用户名或密码不正确!");
                    }
                    return;
                }
                else
                {
                    //查询该人员有没有
                    DataTable dtrole = DataHelper.QueryDataTable("select CompanyIds from sysrole where roleid in ( select RoleID from SysUserRole where UserId='" + userent.UserID + "')");
                    bool      hasQX  = false;
                    foreach (DataRow row in dtrole.Rows)
                    {
                        if ((row["CompanyIds"] + "").Contains(CorpId))
                        {
                            hasQX = true;
                            break;
                        }
                    }
                    if (hasQX)
                    {
                        string sid = PortalService.AuthUser(uname, pwd, false);
                        if (!String.IsNullOrEmpty(sid))
                        {
                            string url = FormsAuthentication.GetRedirectUrl(uname, true);
                            PageState.Add("url", url);

                            Session["CompanyId"] = CorpId;
                        }
                        else
                        {
                            PageState.Add("error", "登陆失败,用户名或密码不正确!");
                        }
                    }
                    else
                    {
                        PageState.Add("error", "您没有该公司的权限,请重新选择公司!");
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                PageState.Add("error", ex.Message);
            }
        }