public bool Login(Employee employee)
 {
     bool retVal = false;
     IList<Employee> emps=employeeOper.Get(
         delegate(object sender, ICriteria criteria)
         {
             ICriterion criterion = Restrictions.Eq("Code", employee.Code);
             criteria.Add(criterion);
             criterion = Restrictions.Eq("Pwd", employee.Pwd);
             criteria.Add(criterion);
         }
         );
     if (emps != null && emps.Count > 0)
     {
         retVal = true;
         HttpContext.Current.Session["Employee"] = emps[0];
         emps.Clear();
     }
     else
     {
         throw new Exception("UserNameOrPwdError");//用户名或密码错误
     }
     
     return retVal;
 }
Ejemplo n.º 2
0
        public ActionResult Login(Employee employee)
        {
            bool retVal = false;
            IList<Employee> emps = employeeOper.Get(
                delegate(object sender, ICriteria criteria)
                {
                    ICriterion criterion = Restrictions.Eq("Code", employee.Code);
                    criteria.Add(criterion);
                    criterion = Restrictions.Eq("Pwd", employee.Pwd);
                    criteria.Add(criterion);
                }
                );
            if (emps != null && emps.Count > 0)
            {
                retVal = true;
                Session[SessionConst.Employee] = emps[0];
                emps.Clear();
            }
            else
            {
                throw new  Exceptions.UserNameOrPwdErrorException();//用户名或密码错误
            }

            return Json(retVal);
        }
Ejemplo n.º 3
0
	    public bool checkVersion(ISession session,int ver){
            bool retVal = true;

            switch (ver) {
                case 0:
                    //初始化维修类型
                    //InitWorkType(session);
                    //给员工初始化
                    Employee e = new Employee();
                    e.Code = "999";
                    e.EmpName = "System";
                    e.PwdWeb = "123456";
                    //e.Birthday = DateTime.Now;
                    //e.ComeDate = DateTime.Now;
                    //e.StaffDate = DateTime.Now;
                    //e.LeaveDate = DateTime.Now;
                    //e.OnDuty = DateTime.Now;
                    //e.OffDuty = DateTime.Now;
                    session.Save(e);

                    break;
                default:
                    retVal = false;
                    break;
            }
		    return retVal;
	    }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller is BaseController)
            {
                BaseController bc = (BaseController)filterContext.Controller;
                Employee emp = (Employee)bc.Session["Employee"];

                if (emp != null)
                {
                    bc.MySelf = emp;
                }
                else
                {
                    emp = new Employee();
                    emp.Id = new Guid("31512C37-A7EC-4DF3-9619-EE0662FCE9D1");
                    emp.Name = "123456";
                    emp.Code = "00001";
                    emp.Pwd = "fdsfswe";
                    bc.Session["Employee"] = emp;
                    throw new Exception("Is not login");
                }
                
            }

//            JsonResult jr = new JsonResult();
//            jr.Data = emp;
//            jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
//
//            filterContext.Result = jr;
        }
Ejemplo n.º 5
0
        private void IsExistsCode(ISession session, Employee emp)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Employee));

            ICriterion criterion = null;
            if (emp.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(emp.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Code", emp.Code);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.EmpCodeIsExistsException();//部门Code已经存在
            }
        }
 public IList<EmpModFunc> GetEmpModFuncs(Employee emp)
 {
     IList<EmpModFunc> retVal = empModFuncOper.Get(
         delegate(object sender, ICriteria criteria)
         {
             ICriterion criterion = null;
             criterion = Restrictions.Eq("Emp", emp);
             criteria.Add(criterion);
         }
         );
     return retVal;
 }
Ejemplo n.º 7
0
        private IList<EmpModFunc> GetEmpModFuncs(Employee emp)
        {
            IList<EmpModFunc> retVal = (IList<EmpModFunc>)HttpContext.Current.Session["EmpModFuncs"];

            if (retVal == null)
            {
                retVal = empModFuncOper.Get(
                delegate(object sender, ICriteria criteria)
                {
                    ICriterion criterion = null;
                    criterion=Restrictions.Eq("Emp", emp);
                    criteria.Add(criterion);
                }
                );
                HttpContext.Current.Session["EmpModFuncs"] = retVal;
            }
            return retVal;
        }
Ejemplo n.º 8
0
        private bool IsHavePower(Employee emp, ServiceBase serviceBase, string funcName)
        {
            bool retVal = false;
            string cls = serviceBase.GetType().FullName;

            //获取员工的权限
            IList<EmpModFunc> empModFuncs = GetEmpModFuncs(emp);
            if (empModFuncs != null)
            {
                foreach (EmpModFunc empModFunc in empModFuncs)
                {
                    if (empModFunc.ModFunc.Cls.Equals(cls) && empModFunc.ModFunc.FuncName.Equals(funcName))
                    {
                        retVal = true;
                    }
                }
            }
            return retVal;
        }
Ejemplo n.º 9
0
        public ActionResult Login(Employee employee)
        {
            bool retVal = false;
            //由工号与密码查找员工
            Employee emp = GetEmpForCodeAndPwd(employee.Code, employee.PwdWeb);

            if (emp != null)
            {
                retVal = true;
                //保存到SESSION
                MySelf = emp;
            }
            else
            {
                throw new  Exceptions.UserNameOrPwdErrorException();//用户名或密码错误
            }

            return Json(retVal);
        }
 public bool Update(Employee employee)
 {
     return employeeOper.Update(employee);
 }
 public string Add(Employee employee)
 {
     return employeeOper.Add(employee);
 }
Ejemplo n.º 12
0
 public IList<EmpModFunc> GetEmpModFuncs(Employee emp)
 {
     return GetEmpModFuncs(EmpModFunc.RoleFlagVal.Emp,emp.Id);
 }
 public bool Del(Employee employee)
 {
     return employeeOper.Del(employee);
 }
Ejemplo n.º 14
0
 public ActionResult Add(Employee employee)
 {
     //根据地址码获取地址
     employee.Addr = PojoUtil.GetAddrForCode(HibernateOper, employee.AddrCode);
     LocationUtil.Location loc = LocationUtil.GetLocation(employee.Addr + employee.Location);
     if (loc != null)
     {
         employee.Lat = loc.lat;
         employee.Lng = loc.lng;
     }
     return Json(employeeOper.Add(employee));
 }
Ejemplo n.º 15
0
 public ActionResult Update(Employee employee)
 {
     //根据地址码获取地址
     employee.Addr = PojoUtil.GetAddrForCode(HibernateOper, employee.AddrCode);
     LocationUtil.Location loc = LocationUtil.GetLocation(employee.Addr + employee.Location);
     if (loc != null)
     {
         employee.Lat = loc.lat;
         employee.Lng = loc.lng;
     }
     return Json(employeeOper.Update(employee,
         delegate(object sender, ISession session)
         {
             //判断是否存在部门Code
             IsExistsCode(session, employee);
         }
         ));
 }
Ejemplo n.º 16
0
 public ActionResult Del(Employee employee)
 {
     return Json(employeeOper.Del(employee));
 }
Ejemplo n.º 17
0
        public void Init2()
        {
            try
            {
                //给员工初始化
                Employee e = new Employee();
                e.Code = "999";
                e.Name = "System";
                e.Pwd = "123456";
                e.Birthday = DateTime.Now;
                e.Entry = DateTime.Now;
                TbBaseOper<Employee> employeeOper = new TbBaseOper<Employee>(HibernateFactory.GetInstance(), typeof(Employee));
                employeeOper.Add(e);

                TbBaseOper<EmpModFunc> emfOper = new TbBaseOper<EmpModFunc>(HibernateFactory.GetInstance(), typeof(EmpModFunc));
                IList<ModFunc> funcs = modFuncOper.Get();

                foreach (ModFunc mf in funcs)
                {
                    EmpModFunc emf = new EmpModFunc();
                    emf.Emp = e;
                    emf.ModFunc = mf;
                    emf.FuncNames = "|Add|Update|Del|Get|";
                    emfOper.Add(emf);
                }

                TbBaseOper<EmpMod> emOper = new TbBaseOper<EmpMod>(HibernateFactory.GetInstance(), typeof(EmpMod));
                IList<Mod> mods = modOper.Get();

                foreach (Mod m in mods)
                {
                    EmpMod em = new EmpMod();
                    em.Emp = e;
                    em.Mod = m;
                    emOper.Add(em);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 修改我自己
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public ActionResult UpdateMySelf(Employee employee)
        {
            employee.Id = MySelf.Id;
            employee.Code = MySelf.Code;//自己不修改自己的工号,如果要修改必须要经过Update接口
            employee.IfPrincipal = MySelf.IfPrincipal;
            employee.IfSysUser = MySelf.IfSysUser;
            employee.IfWork = MySelf.IfWork;
            employee.State = MySelf.State;
            employee.PwdWeb = MySelf.PwdWeb;
            employee.Dept = MySelf.Dept;
            employee.Pos = MySelf.Pos;

            return Update(employee);
        }