Ejemplo n.º 1
0
 //退出切换用户
 protected void lbtnLogout_Click(object sender, EventArgs e)
 {
     Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
     Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(fromUserCode);
     if (model != null)
     {
         System.Web.HttpContext.Current.Session["BPM_User"] = model;
         //Delete
         new SwitchUser().Delete(fromUserCode);
     }
     Response.Redirect("~/Default.aspx");
 }
Ejemplo n.º 2
0
    //取消映射
    protected void lbtnCancelMapping_Click(object sender, EventArgs e)
    {
        Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
        Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(fromUserCode);
        if (model != null)
        {
            System.Web.HttpContext.Current.Session["BPM_User"] = model;

            string CurrentUserCode = HttpContext.Current.User.Identity.Name.ToLower().Replace("founder\\", "");
            ClassMappingUser.UpdateState(CurrentUserCode, 0);
            lbtnMapping.Visible       = true;
            lbtnCancelMapping.Visible = false;
        }

        Response.Redirect("~/Default.aspx");
    }
Ejemplo n.º 3
0
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtUserCode.Text.Trim()))
        {
            //return;
        }

        Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
        Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(fromUserCode);
        if (model != null)
        {
            System.Web.HttpContext.Current.Session["BPM_User"] = model;
            //Delete
            bll.Delete(fromUserCode);
        }
        Response.Redirect("~/Login.aspx");
    }
Ejemplo n.º 4
0
    void DoMapping()
    {
        string currentUserCode = HttpContext.Current.User.Identity.Name.ToLower().Replace("founder\\", "");

        Pkurg.PWorldBPM.Business.Sys.SYS_MappingUser mapping = ClassMappingUser.UpdateState(currentUserCode, 1);
        if (mapping != null)
        {
            string toUserCode = mapping.ToUserCode;
            Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
            Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(toUserCode);
            if (model != null)
            {
                _BPMContext.LoginId = toUserCode;
            }
        }
        Response.Redirect("~/Default.aspx");
    }
Ejemplo n.º 5
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        bool flag = CheckLogin(txtUserCode.Text.Trim(), txtPwd.Text.Trim());

        if (!flag)
        {
            lblMsg.Text = "登录失败,请重新输入!";
            txtPwd.Focus();
        }
        else
        {
            //如果切换的账号和当前一致,不处理
            if (fromUserCode.ToLower() == txtUserCode.Text.Trim().ToLower())
            {
                Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
                Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(fromUserCode);
                if (model != null)
                {
                    System.Web.HttpContext.Current.Session["BPM_User"] = model;
                    //Delete
                    new SwitchUser().Delete(fromUserCode);
                }
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                string toUserCode = txtUserCode.Text.Trim().ToLower();
                Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
                Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(toUserCode);
                if (model != null)
                {
                    _BPMContext.LoginId = toUserCode;
                    //Insert
                    bll.Insert(fromUserCode, toUserCode);
                    //JsHelper.AlertAndRedirect(Page, "切换用户成功!如果要注销,请点击“退出”按钮。", "Default.aspx");
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    lblMsg.Text = "域账号不存在!";
                }
            }
        }
    }
Ejemplo n.º 6
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        string toUserCode = txtUserCode.Text.Trim().ToLower();

        Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
        Pkurg.PWorldBPM.Common.Info.UserInfo       model    = services.GetUserInfo(toUserCode);
        if (model != null)
        {
            _BPMContext.LoginId = toUserCode;
            //Insert
            bll.Insert(fromUserCode, toUserCode);
            lblMsg.Text = "";
            Response.Redirect("~/Login.aspx");
        }
        else
        {
            lblMsg.Text = "登录名不存在!";
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 根据登录名获取用户实体
    /// 有缓存
    /// by yanghechun
    /// </summary>
    /// <returns></returns>
    public UserInfo GetEmployee()
    {
        string local = "";

        //移动端没有用户认证,匿名认证
        if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            //app.ashx,移动端查看的view页面请求都会有这两个参数。
            //PC端获取不到当前用户,因为没有userencode
            if (!string.IsNullOrEmpty(HttpContext.Current.Request["userencode"]) && HttpContext.Current.Request["ref"].ToLower() == "mobile")
            {
                local = DESEncrypt.Decrypt(HttpContext.Current.Request["userencode"]);
            }
            else
            {
                local = "zybpm";
            }
        }
        else
        {
            local = HttpContext.Current.User.Identity.Name.ToLower().Replace("founder\\", "");
        }

        string loginName = local;

        //处理方正世纪的域账号
        if (local.ToLower().StartsWith("hold") && local.ToLower() == "hold\\wangwh")
        {
            loginName = "wangweihong";
        }
        else
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                //切换用户
                string to = new SwitchUser().IsExist(local);
                if (!string.IsNullOrEmpty(to))
                {
                    loginName = to;
                }
                //模拟用户
                to = new LoginUser().IsExist(local);
                if (!string.IsNullOrEmpty(to))
                {
                    loginName = to;
                }
                //映射用户
                if (IsMappingUser(local))
                {
                    Pkurg.PWorldBPM.Business.Sys.MappingUser ClassMappingUser = new Pkurg.PWorldBPM.Business.Sys.MappingUser();
                    to = ClassMappingUser.GetToUserCode(local, 1);
                    if (!string.IsNullOrEmpty(to))
                    {
                        loginName = to;
                    }
                }
            }
        }

        //最终用户
        string key = "cache_user_" + loginName;

        if (Pkurg.PWorldBPM.Common.Cache.DataCache.GetCache(key) == null)
        {
            Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
            UserInfo model = services.GetUserInfo(loginName);
            if (model != null)
            {
                Pkurg.PWorldBPM.Common.Cache.DataCache.SetCache(key, model, DateTime.Now.AddDays(7), TimeSpan.Zero);
            }
            else
            {
                //被模拟的用户不存在,重新切换到当前用户
                bool flag1 = new SwitchUser().DeleteByTo(loginName);
                bool flag2 = new LoginUser().DeleteByTo(loginName);
                if (flag1 & flag2)
                {
                    HttpContext.Current.Response.Redirect("~/Default.aspx");
                }
                else
                {
                    throw new Exception("未找到用户信息");
                }
            }
        }
        return((UserInfo)Pkurg.PWorldBPM.Common.Cache.DataCache.GetCache(key));
    }