コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Common.Utilities.UserValidate(context);
            string res = "修改失败";

            try
            {
                Common.UserModel userInfo = new Common.UserModel();
                userInfo = (Common.UserModel)context.Session["userInfo"];
                string oldPwd = context.Request.Form["oldPwd"];
                string newPwd = context.Request.Form["newPwd"];
                oldPwd = Common.MD5Helper.EncryptString(oldPwd).Substring(0, 20);
                if (oldPwd.ToLower() != userInfo.UserPwd.ToLower())
                {
                    res = "原密码错误";
                }
                else
                {
                    string pwd = Common.MD5Helper.EncryptString(newPwd).Substring(0, 20);
                    if (Common.CommonDB.mySqlNonQuery("update t_users set pwd='" + pwd + "' where username='******'") > 0)
                    {
                        userInfo.UserPwd = pwd;
                        context.Session.Remove("userInfo");
                        context.Session.Add("userInfo", userInfo);
                        res = "OK";
                    }
                }
            }
            finally
            {
                context.Response.Write(res);
                context.Response.End();
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Common.Utilities.UserValidate(context);
            string res = "控制命令发送失败";

            Common.UserModel userInfo = new Common.UserModel();
            try
            {
                userInfo = (Common.UserModel)context.Session["userInfo"];
                if (userInfo != null && userInfo.UserPower < 3)
                {
                    string eqid   = context.Request["eId"];
                    string mode   = context.Request["mode"];
                    string type   = context.Request["type"];
                    string doType = context.Request["doType"];
                    //连接服务器发送命令
                    byte bMode   = byte.Parse(mode);
                    byte bType   = byte.Parse(type);
                    byte bDoType = byte.Parse(doType);
                    SendData(eqid, bMode, bType, bDoType);
                    res = "OK";
                }
                else
                {
                    res = "权限不足";
                }
            }
            finally
            {
                context.Response.Write(res);
                context.Response.End();
            }
        }
コード例 #3
0
ファイル: UserProvider.cs プロジェクト: fenildf/FinanceApp
        /// <summary>
        /// 待修改
        /// 待增加验证匹配ticket与accountName
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="accountName"></param>
        /// <returns></returns>
        public static Common.UserModel GetUserModel(string ticket, string accountName)
        {
            Common.UserModel user = null;

            if (Users.ContainsKey(accountName))
            {
                user = Users[accountName];
                if (user.CookieValue != ticket)
                {
                    return(null);
                }
            }

            RegisterUserModel(ticket, accountName);

            user = Users[accountName];
            return(user);
        }
コード例 #4
0
ファイル: UserProvider.cs プロジェクト: fenildf/FinanceApp
        private static void RegisterUserModel(string ticket, string accountName)
        {
            Common.ResultModel result = null;

            Common.UserModel user = new Common.UserModel();

            //cookie value
            user.CookieValue = ticket;

            //Account
            Model.Account  account    = null;
            DAL.AccountDAL accountDal = new DAL.AccountDAL();
            result = accountDal.Get(Common.DefaultValue.SysUser, accountName);
            if (result.ResultStatus == 0)
            {
                account = result.ReturnValue as Model.Account;
            }
            user.AccountId   = account.AccId;
            user.AccountName = account.AccountName;

            //Employee
            Model.Employee  emp    = null;
            DAL.EmployeeDAL empDal = new DAL.EmployeeDAL();
            result = empDal.Get(Common.DefaultValue.SysUser, account.EmpId);
            if (result.ResultStatus == 0)
            {
                emp = result.ReturnValue as Model.Employee;
            }
            user.EmpId = emp.EmpId;

            ////Department
            //List<Model.Department> depts = new List<Model.Department>();
            //DAL.DepartmentDAL deptDal = new DAL.DepartmentDAL();
            //result = deptDal.Load(Common.DefaultValue.SysUser, emp.EmpId);
            //if (result.ResultStatus == 0)
            //    depts = result.ReturnValue as List<Model.Department>;
            //foreach(Model.Department dept in depts)
            //{
            //    user.DeptIds.Add(dept.DeptId);
            //}

            ////Corporation
            //List<Model.Corporation> corps = new List<Model.Corporation>();
            //DAL.CorporationDAL corpDal = new DAL.CorporationDAL();
            //result = corpDal.Load(Common.DefaultValue.SysUser, emp.EmpId);
            //if (result.ResultStatus == 0)
            //    corps = result.ReturnValue as List<Model.Corporation>;
            //foreach (Model.Corporation corp in corps)
            //{
            //    user.CorpIds.Add(corp.CorpId);
            //}

            ////Bloc
            //Model.Bloc bloc = new Model.Bloc();
            //DAL.BlocDAL blocDal = new DAL.BlocDAL();
            //result = blocDal.Get(Common.DefaultValue.SysUser, emp.BlocId);
            //if (result.ResultStatus == 0)
            //    bloc = result.ReturnValue as Model.Bloc;
            //user.BlocId = bloc.BlocId;

            ////Role
            //List<Model.Role> roles = new List<Model.Role>();
            //DAL.RoleDAL roleDal = new DAL.RoleDAL();
            //result = roleDal.Load(Common.DefaultValue.SysUser, emp.EmpId);
            //if (result.ResultStatus == 0)
            //    roles = result.ReturnValue as List<Model.Role>;
            ////user.Roles = roles;

            ////Menu
            //List<Model.Menu> menus = new List<Model.Menu>();
            //DAL.MenuDAL menuDal = new DAL.MenuDAL();
            //result = menuDal.Load(Common.DefaultValue.SysUser, emp.EmpId);
            //if (result.ResultStatus == 0)
            //    menus = result.ReturnValue as List<Model.Menu>;
            ////user.Menus = menus;

            ////AuthOptionDetailEmpRef
            //List<Model.AuthOptionDetailEmpRef> refs = new List<Model.AuthOptionDetailEmpRef>();
            //DAL.AuthOptionDetailEmpRefDal refDal = new DAL.AuthOptionDetailEmpRefDal();
            //result = refDal.Load(Common.DefaultValue.SysUser, emp.EmpId);
            //if (result.ResultStatus == 0)
            //    refs = result.ReturnValue as List<Model.AuthOptionDetailEmpRef>;
            ////security.Refs = refs;

            lock (Users)
            {
                if (!Users.ContainsKey(accountName))
                {
                    Users.Add(accountName, user);
                }
            }
        }
コード例 #5
0
ファイル: UserProvider.cs プロジェクト: fenildf/FinanceApp
        //internal static Common.UserModel GetUserModel(string accountName)
        //{
        //    if (UserProvider.Users.ContainsKey(accountName))
        //        return UserProvider.Users[accountName];

        //    RegisterUserModel(accountName);

        //    return UserProvider.Users[accountName];
        //}

        private static Common.ResultModel RegisterUserSecurity(string ticket, string accountName)
        {
            Common.ResultModel result = null;

            UserSecurity security = new UserSecurity();

            security.CookieValue = ticket;
            //Account
            Model.Account  account    = null;
            DAL.AccountDAL accountDal = new DAL.AccountDAL();
            security.Account = accountDal.Find(acc => acc.AccountName == "accountName");

            //Employee
            Model.Employee  emp    = null;
            DAL.EmployeeDAL empDal = new DAL.EmployeeDAL();
            security.Emp = empDal.Find(e => e.EmpId == account.EmpId);

            //Department
            Model.Department  dept    = new Model.Department();
            DAL.DepartmentDAL deptDal = new DAL.DepartmentDAL();
            security.Dept = deptDal.Find(d => d.DeptId == emp.DeptId);

            //Corporation
            Model.Corporation  corp    = new Model.Corporation();
            DAL.CorporationDAL corpDal = new DAL.CorporationDAL();
            security.Corp = corpDal.Find(c => c.CorpId == dept.CorpId);

            //Bloc
            Model.Bloc  bloc    = new Model.Bloc();
            DAL.BlocDAL blocDal = new DAL.BlocDAL();
            if (security.Corp != null)
            {
                security.Bloc = blocDal.Find(b => b.BlocId == security.Corp.ParentId);
            }

            //Role
            List <Model.Role> roles = new List <Model.Role>();

            DAL.RoleDAL roleDal = new DAL.RoleDAL();
            result = roleDal.Load(emp.EmpId);
            if (result.ResultStatus == 0)
            {
                roles = result.ReturnValue as List <Model.Role>;
            }
            security.Roles = roles;

            //Menu
            List <Model.Menu> menus = new List <Model.Menu>();

            DAL.MenuDAL menuDal = new DAL.MenuDAL();
            result = menuDal.Load(emp.EmpId);
            if (result.ResultStatus == 0)
            {
                menus = result.ReturnValue as List <Model.Menu>;
            }
            security.Menus = menus;

            Common.UserModel user = security;
            user.AccountId   = security.Account.AccId;
            user.AccountName = security.Account.AccountName;
            user.EmpId       = security.Emp.EmpId;
            user.EmpName     = security.Emp.Name;
            user.CorpId      = security.Corp.CorpId;
            user.DeptId      = security.Dept.DeptId;

            lock (Securities)
            {
                if (!Securities.ContainsKey(accountName))
                {
                    Securities.Add(accountName, security);
                }
            }

            result.ResultStatus = 0;
            return(result);
        }