Ejemplo n.º 1
0
        //
        // GET: /Base/
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            UserBLL       ubll  = new UserBLL();
            WorkUnitBLL   wbll  = new WorkUnitBLL();
            UserManageBLL umbll = new UserManageBLL();
            ShareBLL      sbll  = new ShareBLL();
            BuildTimeBLL  bbll  = new BuildTimeBLL();
            TotalBLL      tbll  = new TotalBLL();

            DT_UserLoginRecord u = filterContext.HttpContext.Session["user"] as DT_UserLoginRecord;

            //没有登录则不能访问
            if (u == null)
            {
                filterContext.Result = new RedirectResult("/Home/Login");
            }
            else
            {
                ViewBag.username = u.Telphone;
                //ViewBag.photo=u
                //是否科级干部
                ViewBag.iscadre = ubll.IsCadre(u.Id);

                //登录id
                ViewBag.id = u.Id;
                //用户角色
                ViewBag.role = Session["roleid"];

                //用户是否有共享
                ViewBag.sharestatus = Session["sharestatus"];

                //全部单位
                List <DT_WorkUnit> allunits = wbll.SelUnitByParent();
                ViewBag.allunits = allunits;

                //全部科室
                List <DT_WorkUnit> alldepts = wbll.SelDeptByParent();
                ViewBag.alldepts = alldepts;

                //照片
                string img = ubll.GetImg(Convert.ToInt32(Session["id"]));
                ViewBag.img = img;

                //全部内部用户
                List <DT_UserLoginRecord> allusers = umbll.SelectUsers();
                ViewBag.allusers = allusers;

                //根据本人登录id查询其单位id
                ViewBag.SelUnitidByUid = ubll.SelUnitidByUid(Convert.ToInt32(Session["id"]));
                //单位id
                ViewBag.unitid = Session["unitid"];

                //年份
                List <DT_Total> years = sbll.Total().GroupBy(a => a.YearTable).Select(b => new DT_Total {
                    YearTable = b.Key
                }).ToList();
                ViewBag.years = years;

                //根据添加时间获取最新的建档时间
                ViewBag.buildtime = bbll.GetLastTime();

                //查询全部基本信息表
                List <DT_UserInfo> userinfolist1 = ubll.SelectUserInfo();
                ViewBag.userinfolist1 = userinfolist1;

                //根据登录id和年份查询出年份
                ViewBag.yeartable = tbll.SelectYear(Convert.ToInt32(Session["id"]));


                //根据登录id查询总表status的状态  这里主要是根据status为“被退回”来判断
                //修改二次修改,点击“保存”时,同时修改status为“未提交”,可再次提交 (注意年份)
                ViewBag.status = ubll.SelStatus(Convert.ToInt32(Session["id"]));
            }
        }
Ejemplo n.º 2
0
        public void ExcLogin()
        {
            UserBLL ubll = new UserBLL();

            string tel = Request["telphone"];
            string pwd = Request["password"];

            Tools t = new Tools();

            pwd = t.GetMd5(pwd);

            DT_UserLoginRecord u = ubll.Login(tel, pwd);

            if (u != null)
            {
                Session["user"]        = u;
                Session["id"]          = u.Id;
                Session["realname"]    = u.RealName;
                Session["roleid"]      = u.RoleId;
                Session["unitid"]      = u.WorkUnitId;
                Session["tel"]         = u.Telphone;
                Session["sharestatus"] = u.ShareStatus;
                Session["count"]       = u.LoginNum;

                //登录IP
                string ip     = Request.UserHostAddress.ToString();
                string remark = "正常登录";

                DT_UserLoginRecord ulr = ubll.QueryOneUser(u.Id);
                ulr.LoginTime = DateTime.Now;                          //登录时间
                ulr.LoginIp   = ip;                                    //登录IP
                ulr.LoginNum  = (u.LoginNum == null?0:u.LoginNum) + 1; //登录次数
                ulr.Remark    = remark;
                ubll.UpdUserLoginRecord(ulr);

                // GetLoginRecord(u.Id,u.LoginNum);

                if (u.Status != null)
                {
                    if (u.Status == true)
                    {
                        if (u.RoleId != null)
                        {
                            if (u.IsCadre != null)
                            {
                                if (u.IsCadre == true)
                                {
                                    if (u.RoleId == 1 || u.RoleId == 2)
                                    {
                                        BuildTimeBLL bbll = new BuildTimeBLL();
                                        //填档开始时间
                                        DateTime?starttime = bbll.GetLastTime().BuildStartTime;
                                        //填档结束时间
                                        DateTime?endtime = bbll.GetLastTime().BuildEndTime;
                                        //这里目前设置的是本地时间
                                        DateTime time = DateTime.Now;
                                        //是科级干部的普通用户或审核用户在填档有效期内时间判断
                                        if (time < starttime)
                                        {
                                            Response.Write("<script type='text/javascript'>alert('很抱歉,填档时间未开始!');location.href='/Home/NoStart';</script>");
                                        }
                                        else if (time > endtime)
                                        {
                                            Response.Write("<script type='text/javascript'>alert('很抱歉,填档时间已结束!');location.href='/Home/HasStop';</script>");
                                        }
                                        else
                                        {
                                            if (u.RoleId == 1)
                                            {
                                                Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/EnterFile/Index';</script>");
                                            }
                                            else if (u.RoleId == 2)
                                            {
                                                Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/Main/Index';</script>");
                                            }
                                        }
                                    }
                                    else if (u.RoleId == 3 || u.RoleId == 4)
                                    {
                                        Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/Main/Index';</script>");
                                    }
                                    else if ((u.RoleId == 1 || u.RoleId == 2 || u.RoleId == 3 || u.RoleId == 4) && u.ShareStatus == "是")
                                    {
                                        ShareBLL sbll = new ShareBLL();
                                        //共享开始时间
                                        DateTime?sharebegintime = sbll.GetLastRecord().ShareBeginTime;
                                        //共享结束时间
                                        DateTime?shareendtime = sbll.GetLastRecord().ShareEndTime;
                                        DateTime?time         = DateTime.Now;
                                        if (time < sharebegintime)
                                        {
                                            Response.Write("<script type='text/javascript'>alert('很抱歉,共享时间未开始!');location.href='/Home/NoStart';</script>");
                                        }
                                        else if (time > shareendtime)
                                        {
                                            Response.Write("<script type='text/javascript'>alert('很抱歉,共享时间已结束!');location.href='/Home/HasStop';</script>");
                                        }
                                        else if (time <= shareendtime && time >= sharebegintime)
                                        {
                                            Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/ForeignShare/Index';</script>");
                                        }
                                    }
                                    else
                                    {
                                        Response.Write("<script type='text/javascript'>alert('你无权登录该系统!');location.href='/Home/Login';</script>");
                                    }
                                }
                            }
                            else
                            {
                                //科级干部为空或者不是科级干部的用户
                                if (u.RoleId == 1)
                                {
                                    Response.Write("<script type='text/javascript'>alert('你无权登录该系统!');location.href='/Home/Login';</script>");
                                }
                                else if (u.RoleId == 2 || u.RoleId == 3 || u.RoleId == 4)
                                {
                                    Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/Main/Index';</script>");
                                }
                                else if (u.RoleId == 0 && u.IsInner == false && u.ShareStatus == "是")
                                {
                                    ShareBLL sbll = new ShareBLL();
                                    //共享开始时间
                                    DateTime?sharebegintime = sbll.GetLastRecord().ShareBeginTime;
                                    //共享结束时间
                                    DateTime?shareendtime = sbll.GetLastRecord().ShareEndTime;
                                    DateTime?time         = DateTime.Now;
                                    if (time < sharebegintime)
                                    {
                                        Response.Write("<script type='text/javascript'>alert('很抱歉,共享时间未开始!');location.href='/Home/NoStart';</script>");
                                    }
                                    else if (time > shareendtime)
                                    {
                                        Response.Write("<script type='text/javascript'>alert('很抱歉,共享时间已结束!');location.href='/Home/HasStop';</script>");
                                    }
                                    else if (time <= shareendtime && time >= sharebegintime)
                                    {
                                        Response.Write("<script type='text/javascript'>alert('登录成功');location.href='/ForeignShare/Index';</script>");
                                    }
                                }
                                else
                                {
                                    Response.Write("<script type='text/javascript'>alert('你无权登录该系统!');location.href='/Home/Login';</script>");
                                }
                            }
                        }
                        else
                        {
                            Response.Write("<script type='text/javascript'>alert('你无权登录该系统!');location.href='/Home/Login';</script>");
                        }
                    }
                    else
                    {
                        //ubll.UpdUserLoginRecord(u.Id, ip, remark2);
                        Response.Write("<script type='text/javascript'>alert('该用户账号已被禁用,请联系高级用户!');;location.href='/Home/Login';</script>");//账号被禁用
                    }
                }
                else
                {
                    Response.Write("<script type='text/javascript'>alert('你无权登录该系统!');location.href='/Home/Login';</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('登录失败!');location.href='/Home/Login';</script>");//登录失败
            }
            Response.End();
        }