示例#1
0
 public bank_family_user(bool init = false)
 {
     sys_user = new sys_user();
     bank_family = new bank_family();
     if (init)
     {
         this.create_date = DateTime.Now;
         this.modify_date = DateTime.Now;
         this.status = 0;
     }
 }
示例#2
0
 public sys_user_role(bool init = false)
 {
     sys_user = new sys_user();
     sys_role = new sys_role();
     if (init)
     {
         this.create_date = DateTime.Now;
         this.modify_date = DateTime.Now;
         this.status = 0;
     }
 }
示例#3
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public async Task<sys_user> Add_SysUser(sys_user user)
 {
     //BankModel bank = new BankModel();
     sys_user tuser=null;
     await Task.Run(() =>
     {
         tuser=db.sys_users.Add(user);
         db.SaveChanges();
     });
     if (tuser.user_id >= 0)
     {
         return tuser;
     }
     else
     {
         return null;
     }
 }
示例#4
0
        public void InitDb(BankModel context)
        {
            bank_family family = new bank_family(true);
            family.family_name = "董瑞军的家";
            family.family_nick_name = "My Sweet Home";
            family.assets_money = 0;
            family.assets_investment = 0;
            family.assets_real = 0;
            family.assets_total = 0;
            family.assets_debt = 0;
            family.assets_net = 0;
            bank_family tfamily = context.bank_familys.Add(family);

            context.SaveChanges();

            sys_permission permission = new sys_permission(true);
            permission.permission_name = "系统管理员";
            permission.permission_url = "/Home/Index";
            sys_permission tpermission = context.sys_permissions.Add(permission);

            context.SaveChanges();

            sys_role role = new sys_role(true);
            role.role_name = "管理员";
            role.role_desc = "管理员";
            sys_role trole = context.sys_roles.Add(role);

            context.SaveChanges();

            sys_role_permission role_permission = new sys_role_permission(true);
            role_permission.role_id = trole.role_id;
            role_permission.permission_id = tpermission.permission_id;

            role_permission.sys_role = trole;
            role_permission.sys_permission = tpermission;
            sys_role_permission trole_permission = context.sys_role_permissions.Add(role_permission);

            context.SaveChanges();

            sys_user user = new sys_user(true);
            user.email = user.user_name = "*****@*****.**";
            user.password = Utils.MD5Encrypt("dreign");
            user.nick_name = "董瑞军";
            user.birthday = DateTime.Now;
            user.sex = false;
            user.address = "上海市浦东新区";
            user.age = 35;
            user.family_name = "家长";
            user.interest = "电影,音乐,运动";
            user.last_login_ip = "127.0.0.1";
            user.last_login_time = DateTime.Now;
            user.phone = "1861xxxx091";
            user.post = "200126";
            user.qq = "27178846";
            user.remark = "好想给国家多庆祝几天生日啊~";
            user.weixin = "dreign";
            user.user_desc = @"上海交通大学继续教育学院网络教育(原网络教育学院),位于上海市华山路1954号交大徐汇校区。开展专升本\高升专\高升本学历教育,招生专业涵盖艺术\经济管理\船舶\计算机\英语\机电等十余个领域,总机:021-52389900。";
            user.bank_family = tfamily;
            sys_user tuser1 = context.sys_users.Add(user);
            user = new sys_user(true);
            user.email = user.user_name = "*****@*****.**";
            user.password = Utils.MD5Encrypt("dreign");
            user.nick_name = "魏晶晶";
            user.birthday = DateTime.Now;
            user.sex = true;
            user.address = "上海市浦东新区";
            user.age = 30;
            user.family_name = "家长";
            user.interest = "美食,音乐";
            user.last_login_ip = "127.0.0.1";
            user.last_login_time = DateTime.Now;
            user.phone = "1861xxxx091";
            user.post = "200126";
            user.qq = "27178846";
            user.remark = "好好学习天天向上~";
            user.weixin = "dreign";
            user.user_desc = @"东宫白庶子,南寺远禅师。何处遥相见,心无一事时。";
            user.bank_family = tfamily;
            sys_user tuser2 = context.sys_users.Add(user);

            context.SaveChanges();

            sys_user_role user_role = new sys_user_role(true);
            user_role.user_name = tuser1.user_name;
            user_role.role_id = trole.role_id;
            user_role.sys_role = trole;
            user_role.sys_user = tuser1;
            sys_user_role tuser_role1 = context.sys_user_roles.Add(user_role);
            user_role = new sys_user_role(true);
            user_role.user_name = tuser2.user_name;
            user_role.role_id = trole.role_id;
            user_role.sys_role = trole;
            user_role.sys_user = tuser2;
            sys_user_role tuser_role2 = context.sys_user_roles.Add(user_role);

            context.SaveChanges();

            bank_account account = new bank_account(true);
            account.user_id = tuser1.user_id;
            account.user_name = tuser1.user_name;
            account.money = 9500;
            account.freezing = 0;
            bank_account taccount1 = context.bank_accounts.Add(account);
            account = new bank_account(true);
            account.user_id = tuser2.user_id;
            account.user_name = tuser2.user_name;
            account.money = 0;
            account.freezing = 0;
            bank_account taccount2 = context.bank_accounts.Add(account);

            context.SaveChanges();

          
            //bank_family_user family_relation = new bank_family_user(true);
            //family_relation.family_id = tfamily.family_id;
            //family_relation.user_name = tuser1.user_name;
            //family_relation.sys_user = tuser1;
            //family_relation.bank_family = tfamily;
            //bank_family_user tfamily_user1 = context.bank_family_users.Add(family_relation);
            //family_relation = new bank_family_user(true);
            //family_relation.family_id = tfamily.family_id;
            //family_relation.user_name = tuser2.user_name;
            //family_relation.sys_user = tuser2;
            //family_relation.bank_family = tfamily;
            //bank_family_user tfamily_user2 = context.bank_family_users.Add(family_relation);

            context.SaveChanges();

            sys_subject subject = new sys_subject(true);
            subject.subject_id = 1;
            subject.subject_name = "资产";
            subject.subject_level = 1;
            subject.subject_desc = "资产";
            subject.parents_id = 0;
            sys_subject tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 2;
            subject.subject_name = "负债";
            subject.subject_level = 1;
            subject.subject_desc = "负债";
            subject.parents_id = 0;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 3;
            subject.subject_name = "货币资产";
            subject.subject_level = 2;
            subject.subject_desc = "资产";
            subject.parents_id = 1;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 4;
            subject.subject_name = "投资资产";
            subject.subject_level = 2;
            subject.subject_desc = "资产";
            subject.parents_id = 1;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 5;
            subject.subject_name = "实物资产";
            subject.subject_level = 2;
            subject.subject_desc = "资产";
            subject.parents_id = 1;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 6;
            subject.subject_name = "贷款";
            subject.subject_level = 2;
            subject.subject_desc = "负债";
            subject.parents_id = 2;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 7;
            subject.subject_name = "债务";
            subject.subject_level = 2;
            subject.subject_desc = "负债";
            subject.parents_id = 2;
            tsubject = context.sys_subjects.Add(subject);

            subject = new sys_subject(true);
            subject.subject_id = 8;
            subject.subject_name = "日常家用";
            subject.subject_level = 2;
            subject.subject_desc = "负债";
            subject.parents_id = 2;
            tsubject = context.sys_subjects.Add(subject);

            context.SaveChanges();

            List<sys_subject> subjectList = new List<sys_subject>();

            subject = new sys_subject(true) { subject_id = 9, subject_name = "现金与活期存款", subject_level = 3, subject_desc = "货币资产", parents_id = 3 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 10, subject_name = "活期存款", subject_level = 3, subject_desc = "货币资产", parents_id = 3 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 11, subject_name = "工资", subject_level = 3, subject_desc = "货币资产", parents_id = 3 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 12, subject_name = "其他货币资产", subject_level = 3, subject_desc = "货币资产", parents_id = 3 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 13, subject_name = "股票", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 14, subject_name = "债券", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 15, subject_name = "基金", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 16, subject_name = "银行理财", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 17, subject_name = "信托", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 18, subject_name = "互联网金融", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 19, subject_name = "保险", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 20, subject_name = "其他投资资产", subject_level = 3, subject_desc = "投资资产", parents_id = 4 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 21, subject_name = "自住房", subject_level = 3, subject_desc = "实物资产", parents_id = 5 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 22, subject_name = "投资房", subject_level = 3, subject_desc = "实物资产", parents_id = 5 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 23, subject_name = "机动车", subject_level = 3, subject_desc = "实物资产", parents_id = 5 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 24, subject_name = "家具", subject_level = 3, subject_desc = "实物资产", parents_id = 5 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 25, subject_name = "其他实物资产", subject_level = 3, subject_desc = "实物资产", parents_id = 5 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 26, subject_name = "住房贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 27, subject_name = "车辆贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 28, subject_name = "消费贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 29, subject_name = "助学贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 30, subject_name = "信用卡贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 31, subject_name = "其他贷款", subject_level = 3, subject_desc = "贷款", parents_id = 6 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 32, subject_name = "法人债务", subject_level = 3, subject_desc = "债务", parents_id = 7 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 33, subject_name = "个人债务", subject_level = 3, subject_desc = "债务", parents_id = 7 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 34, subject_name = "餐饮", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 35, subject_name = "水电煤", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 36, subject_name = "交通", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 37, subject_name = "通讯", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 38, subject_name = "医疗", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 39, subject_name = "衣服", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 40, subject_name = "社交", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 41, subject_name = "旅游", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 42, subject_name = "教育", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 43, subject_name = "日用品", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);
            subject = new sys_subject(true) { subject_id = 44, subject_name = "其他负债", subject_level = 3, subject_desc = "日常家用", parents_id = 8 }; subjectList.Add(subject);

            context.sys_subjects.AddRange(subjectList);

            context.SaveChanges();

            bank_operate_log operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 11;
            operate_log.sys_subject = tsubject;
            operate_log.money = 5000;
            operate_log.subject_remark = "奖金";
            operate_log.remark = "收入";
            bank_operate_log toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 35;
            operate_log.money = -200;
            operate_log.subject_remark = "水电煤";
            operate_log.remark = "支出";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 37;
            operate_log.money = -100;
            operate_log.subject_remark = "手机费";
            operate_log.remark = "支出";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 36;
            operate_log.money = -200;
            operate_log.subject_remark = "交通费";
            operate_log.remark = "支出";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 11;
            operate_log.money = 10000;
            operate_log.subject_remark = "工资";
            operate_log.remark = "收入";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 42;
            operate_log.money = -4000;
            operate_log.subject_remark = "学费";
            operate_log.remark = "支出";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);

            operate_log = new bank_operate_log(true);
            operate_log.user_id = tuser1.user_id;
            operate_log.user_name = tuser1.user_name;
            operate_log.subject_id = 44;
            operate_log.money = -1000;
            operate_log.subject_remark = "偿还信用卡";
            operate_log.remark = "支出";
            operate_log.sys_subject = tsubject;
            toperate_log1 = context.bank_operate_logs.Add(operate_log);           

            context.SaveChanges();

            sys_log log = new sys_log(true);
            log.user_id = tuser1.user_id;
            log.user_name = tuser1.user_name;
            log.visitor_ip = "127.0.0.1";
            log.local_ip = "127.0.0.1";
            log.result = "OK";
            var tlog = context.sys_logs.Add(log);

            log = new sys_log(true);
            log.user_id = tuser1.user_id;
            log.user_name = tuser1.user_name;
            log.visitor_ip = "127.0.0.1";
            log.local_ip = "127.0.0.1";
            log.result = "OK";

            tlog = context.sys_logs.Add(log);

            context.SaveChanges();

            sys_user_log userlog = new sys_user_log(true);
            userlog.user_id = tuser1.user_id;
            userlog.user_name = tuser1.user_name;
            userlog.login_time = DateTime.Now;
            userlog.action = "Login";
            userlog.action_desc = "登录";
            var tuserlog = context.sys_user_logs.Add(userlog);

            userlog = new sys_user_log(true);
            userlog.user_id = tuser1.user_id;
            userlog.user_name = tuser1.user_name;
            userlog.login_time = DateTime.Now;
            userlog.action = "Login";
            userlog.action_desc = "登录";
            tuserlog = context.sys_user_logs.Add(userlog);

            context.SaveChanges();

        }
示例#5
0
        public static sys_user Clone(sys_user user)
        {
            sys_user olduser = new sys_user();
            if (olduser != null)
            {
                olduser.user_id = user.user_id;
                olduser.user_name = user.user_name;
                olduser.email = user.email;
                olduser.create_date = user.create_date;
                olduser.modify_date = user.modify_date;
                olduser.status = user.status;

                olduser.nick_name = user.nick_name;
                olduser.password = user.password;
                olduser.birthday = user.birthday;
                olduser.sex = user.sex;
                olduser.address = user.address;
                olduser.age = user.age;
                olduser.family_id = user.family_id;
                olduser.family_name = user.family_name;
                olduser.interest = user.interest;
                olduser.last_login_ip = user.last_login_ip;
                olduser.last_login_time = user.last_login_time;
                olduser.phone = user.phone;
                olduser.post = user.post;
                olduser.qq = user.qq;
                olduser.remark = user.remark;
                olduser.weixin = user.weixin;
                olduser.user_desc = user.user_desc;
            }
            return olduser;
        }
示例#6
0
        //protected internal HttpNotFoundResult HttpNotFound();
        //public new HttpNotFoundResult HttpNotFound()
        //{
        //    HttpNotFoundResult result = new HttpNotFoundResult();
        //    return RedirectToAction("Page404", "Home");
        //}
        /// <summary>
        /// 重写基类在Action之前执行的方法
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            #region -----校验用户是否登录进入网站的-----
            base.OnActionExecuting(filterContext);
            CurrentUser = Session[ConfigBusiness.Session_User_Key] as sys_user;

            //检验用户是否已经登录,如果登录则不执行,否则则执行下面的跳转代码
            if (CurrentUser == null)
            {
                RedirectToAction("Index", "Login");
                //Response.Redirect("/Login/Index"); 
            }
            else
            {
                if (string.IsNullOrEmpty(CurrentUser.bank_family.family_name))
                {
                    CurrentUser.bank_family = fservice.FindFamliysByUser(CurrentUser.user_name).FirstOrDefault();
                }
                CacheHelper.SetCache(userCacheKey + User.Identity.Name, CurrentUser);
                ViewData["sys_user"] = CurrentUser;               
            }

            #endregion

            #region some

            //#region ------//留个接口------
            //if (CurrentUserInfo.UName == "admin")
            //{
            //    return;
            //}
            //#endregion

            /*

            #region -------检验用户是否有访问此地址的权利----
            //先将当前的请求,到权限表里面去找对应的数据
            //拿到当前请求的URL地址
            string requestUrl = filterContext.HttpContext.Request.Path;
            //拿到当前请求的类型
            string requestType = filterContext.HttpContext.Request.RequestType.ToLower().Equals("get") ? "HttpGet" : "HttpPost";
            //然后和权限表进行对比,如果取出来则通过请求,否则不通过
            //取出当前权限的数据
            var currentAction = _actioninfoService.LoadEntities(c => c.RequestUrl.Equals(requestUrl, StringComparison.InvariantCultureIgnoreCase) && c.RequestHttpType.Equals(requestType)).FirstOrDefault();
            //如果没有权限对应当前请求的话,直接干掉
            if (currentAction == null)
            {
                EndRequest();
            }
            //想去用户权限表里面查询有没有数据
            //分析第一条线路 UserInfo->R_UserInfo_ActionInfo->ActionInfo
            //拿到当前的用户信息
            var userCurrent = _userInfoService.LoadEntities(u => u.ID == CurrentUserInfo.ID).FirstOrDefault();
            var temp = (from r in userCurrent.R_UserInfo_ActionInfo
                        where r.ActionInfoID == currentAction.ID
                        select r).FirstOrDefault();
            if (temp != null)
            {
                if (temp.HasPermation)
                {
                    return;
                }
                else
                {
                    EndRequest();
                }
            }

            //分析第二条线路 UserInfo->ActionGroup->ActionInfo
            var groups = from n in userCurrent.ActionGroup //拿到当前用户所有的组
                         select n;
            //根据组信息遍历出权限信息  
            bool isPass = (from g in groups
                           from a in g.ActionInfo
                           select a.ID).Contains(currentAction.ID);
            if (isPass)   //11,23,34不包含4
            {
                return;
            }

            //分析第三条线路 分为两个
            //1)UserInfo->R_UserInfo_Role->Role->ActionInfo

            //先拿到用户对应的所有的角色
            var UserRoles = from r in userCurrent.R_UserInfo_Role
                            select r.Role;
            //拿到角色对应的所有权限
            var Rolesaction = (from r in UserRoles
                               from a in r.ActionInfo
                               select a.ID);
            if (Rolesaction.Contains(currentAction.ID))
            {
                return;
            }

            //2)UserInfo->R_UserInfo_Role->Role->ActionGroup->ActionInfo
            //拿到组信息
            var RoleGroupActions = from r in UserRoles
                                   from g in r.ActionGroup
                                   select g;
            //拿到所有的组信息
            var groupActions = from r in RoleGroupActions
                               from g in r.ActionInfo
                               select g.ID;
            if (groupActions.Contains(currentAction.ID))
            {
                return;
            }
            #endregion

    */
            #endregion

        }
示例#7
0
 public sys_user CheckUser()
 {
     var result = new sys_user();
     if (User != null && User.Identity != null && !string.IsNullOrEmpty(User.Identity.Name))
     {
         if (Session[ConfigBusiness.Session_User_Key] != null)
         {
             //result = (sys_user)Newtonsoft.Json.JsonConvert.DeserializeObject<sys_user>(Session["SysUser"].ToString());
             result = (sys_user)Session[ConfigBusiness.Session_User_Key];
         }
     }
     return result;
 }
示例#8
0
 public bank_family_user()
 {
     sys_user = new sys_user();
     bank_family = new bank_family();           
 }
示例#9
0
 public ClaimsIdentity CreateIdentity(sys_user user, string authenticationType)
 {
     ClaimsIdentity _identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);
     _identity.AddClaim(new Claim(ClaimTypes.Name, user.user_name));
     _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.user_id.ToString()));
     _identity.AddClaim(new Claim(ClaimTypes.Surname, user.nick_name));
     _identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity"));
     _identity.AddClaim(new Claim("NickName", user.nick_name));
     return _identity;
 }
示例#10
0
 public sys_user_role()
 {
     sys_user = new sys_user();
     sys_role = new sys_role();
 }
示例#11
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            //ViewBag.Register = "欢迎注册";
            if (ModelState.IsValid)
            {
                if (TempData["VerificationCode"] == null || TempData["VerificationCode"].ToString() != model.VerificationCode.ToUpper())
                {
                    ModelState.AddModelError("VerificationCode", "验证码不正确");
                    return View(model);
                }

                var tuser = await MemberBLL.Instance.Find_SysUser(model.Email);
                if (tuser != null && tuser.user_name == model.Email)
                    ModelState.AddModelError("UserName", "用户名已存在");

                var user = new Famliy.Finance.Models.sys_user
                {
                    user_name = model.Email,
                    email = model.Email,
                    password = Utils.MD5Encrypt(model.Password),
                    nick_name = model.NickName,
                    sex = model.Sex,
                    birthday = model.Birthday
                    //,sys_user_roles = new List<sys_user_role>(),
                    //bank_family = new bank_family()
            };                

                var item = await MemberBLL.Instance.Add_SysUser(user);
                if (item != null)
                {
                    sys_log logInfo = new sys_log();
                    logInfo.user_id = user.user_id;
                    logInfo.user_name = user.user_name;
                    logInfo.interface_name = "Register";
                    logInfo.interface_param = JsonHelper.ToJson(model);
                    logInfo.result = "OK";
                    LogBusiness.Instance.WriteLog(logInfo, GW.Utils.LogMsgLevel.Info);

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    sys_log logInfo = new sys_log();
                    logInfo.user_id = user.user_id;
                    logInfo.user_name = user.user_name;
                    logInfo.interface_name = "Register";
                    logInfo.interface_param = JsonHelper.ToJson(model);
                    logInfo.result = "Error";
                    LogBusiness.Instance.WriteLog(logInfo, GW.Utils.LogMsgLevel.Info);


                    AddErrors(new IdentityResult(new string[] { "注册失败" }));
                }
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }
示例#12
0
 public sys_user_role()
 {
     sys_user = new sys_user();
     sys_role = new sys_role();
 }