예제 #1
0
        public static void UpdateAuthority(AuthorityModel before, AuthorityModel after)
        {
            using (var connection = new SQLiteConnection(connectionString_))
            {
                connection.Open();
                using (var command = new SQLiteCommand(connection))
                {
                    var sql = @"UPDATE authority
                                SET program_name = :after_program_name,
                                    pc_user = :after_pc_user,
                                    control_flg1 = :after_control_flg1,
                                    control_flg2 = :after_control_flg2
                                WHERE program_name = :before_program_name
                                    and pc_user = :before_pc_user";
                    command.CommandText = sql;
                    command.Parameters.Add(new SQLiteParameter(":after_program_name", after.ProgramName));
                    command.Parameters.Add(new SQLiteParameter(":after_pc_user", after.PCUser));
                    command.Parameters.Add(new SQLiteParameter(":after_control_flg1", after.ControlFlg1));
                    command.Parameters.Add(new SQLiteParameter(":after_control_flg2", after.ControlFlg2));
                    command.Parameters.Add(new SQLiteParameter(":before_program_name", before.ProgramName));
                    command.Parameters.Add(new SQLiteParameter(":before_pc_user", before.PCUser));

                    command.ExecuteNonQuery();
                }
            }
        }
예제 #2
0
        void Awake()
        {
            cachedAuthModel = (AuthorityModel)NetLibrarySettings.Single.defaultAuthority;

            ni = GetComponent <NetworkIdentity>();
            CollectCallbackInterfaces();
        }
예제 #3
0
        public async Task UpdateAsync(AuthorityModel model)
        {
            var entity = await _authorityRepository.GetByIdAsync(model.AuthorityId);

            entity.AuthorityName = model.AuthorityName;

            await _authorityRepository.UpdateAsync(entity);
        }
예제 #4
0
 protected string CreateAuthority(AuthorityModel model)
 {
     if (CheckExist(model))
     {
         return "新增的权限标识已经存在";
     }
     return _dalAuthority.CreateAuthority(model.ToHashTable());
 }
예제 #5
0
 protected string CreateAuthority(AuthorityModel model)
 {
     if (CheckExist(model))
     {
         return("新增的权限标识已经存在");
     }
     return(_dalAuthority.CreateAuthority(model.ToHashTable()));
 }
예제 #6
0
        public async Task AddAsync(AuthorityModel model)
        {
            var authority = new MasterAuthority
            {
                AuthorityName = model.AuthorityName
            };

            await _authorityRepository.AddAsync(authority);
        }
예제 #7
0
        public async Task CreateRoleAsync(string role)
        {
            var authority = new AuthorityModel
            {
                AuthorityName = role
            };

            await _authorityService.AddAsync(authority);
        }
예제 #8
0
 protected bool CheckExist(AuthorityModel model)
 {
     var authList = _dalAuthority.GetAuthorityList();
     return
         authList.Rows.Cast<DataRow>()
             .Any(
                 dr =>
                     dr["AuthorityCode"].ToString()
                         .Equals(model.AuthorityCode, StringComparison.CurrentCultureIgnoreCase));
 }
예제 #9
0
        protected bool CheckExist(AuthorityModel model)
        {
            var authList = _dalAuthority.GetAuthorityList();

            return
                (authList.Rows.Cast <DataRow>()
                 .Any(
                     dr =>
                     dr["AuthorityCode"].ToString()
                     .Equals(model.AuthorityCode, StringComparison.CurrentCultureIgnoreCase)));
        }
예제 #10
0
 public IEnumerable<AuthorityModel> GetAuthorityList(AuthorityModel filterModel)
 {
     var dtAuthoritys = _dalAuthority.GetAuthorityList(filterModel.ToHashTable());
     return dtAuthoritys.AsEnumerable().Select(dr => new AuthorityModel
     {
         Description = dr["Description"].ToString(),
         Id = Convert.ToInt32(dr["Id"]),
         Name = dr["Name"].ToString(),
         AuthorityCode = dr["AuthorityCode"].ToString(),
         AuthorityType = dr["AuthorityType"].ToString()
     });
 }
예제 #11
0
        public IEnumerable <AuthorityModel> GetAuthorityList(AuthorityModel filterModel)
        {
            var dtAuthoritys = _dalAuthority.GetAuthorityList(filterModel.ToHashTable());

            return(dtAuthoritys.AsEnumerable().Select(dr => new AuthorityModel
            {
                Description = dr["Description"].ToString(),
                Id = Convert.ToInt32(dr["Id"]),
                Name = dr["Name"].ToString(),
                AuthorityCode = dr["AuthorityCode"].ToString(),
                AuthorityType = dr["AuthorityType"].ToString()
            }));
        }
예제 #12
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var result = base.AuthorizeCore(httpContext);

            //如果验证成功,表示已经登录
            if (result)
            {
                //从数据库查询获取 权限放入session 中
                AuthorityModel authority = new AuthorityModel();
                httpContext.Session[Config.ConfigParam.Authority_All_Session] = authority;
            }
            return(result);
        }
예제 #13
0
        void Awake()
        {
            pv = GetComponent <PhotonView>();
            //nst = GetComponent<NetworkSyncTransform>();

            //XDebug.LogError("You appear to have an 'NetworkSyncTransform' on instantiated object '" + name + "', but that object has NOT been network spawned. " +
            //	"Only use NST on objects you intend to spawn normally from the server using PhotonNetwork.Instantiate(). " +
            //	"(Projectiles for example probably don't need to be networked objects).", (nst.destroyUnspawned && pv.viewID == 0), true);

            authorityModel = (AuthorityModel)NetLibrarySettings.Single.defaultAuthority;

            CollectCallbackInterfaces();
        }
예제 #14
0
        public async Task <JsonResult> OpenOrStopAccountAuthority(AuthorityModel model)
        {
            ResponseViewModel responseResult = new ResponseViewModel();

            try
            {
                responseResult = await _aspNetUsersService.OpenOrStopAuthority(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(responseResult, JsonRequestBehavior.DenyGet));
        }
        /// <summary>
        /// 保存权限数据
        /// </summary>
        /// <param name="authoritydata"></param>
        /// <returns></returns>
        public JsonResult SaveAuthorityData(AuthorityModel authoritydata)
        {
            var authority = this._authorityService.GetList(t => t.Name == authoritydata.Name && t.Status == 1).ToList();

            if (authority.Count > 0)
            {
                return(Json(ResultStatus.Fail));
            }
            var authority1 = new AuthorityModel();

            authority1            = authoritydata;
            authority1.BuildTime  = DateTime.Now.ToString();
            authority1.UpdateTime = DateTime.Now.ToString();
            this._authorityService.Add(authority1);
            return(Json(ResultStatus.Success));
        }
예제 #16
0
        internal static void DeleteAuthority(AuthorityModel authority)
        {
            using (var connection = new SQLiteConnection(connectionString_))
            {
                connection.Open();
                using (var command = new SQLiteCommand(connection))
                {
                    var sql = @"DELETE FROM authority
                                WHERE program_name = :program_name
                                    and pc_user = :pc_user";
                    command.CommandText = sql;
                    command.Parameters.Add(new SQLiteParameter(":program_name", authority.ProgramName));
                    command.Parameters.Add(new SQLiteParameter(":pc_user", authority.PCUser));

                    command.ExecuteNonQuery();
                }
            }
        }
예제 #17
0
        internal static void InsertAuthority(AuthorityModel authority)
        {
            using (var connection = new SQLiteConnection(connectionString_))
            {
                connection.Open();
                using (var command = new SQLiteCommand(connection))
                {
                    var sql = @"INSERT INTO authority(program_name, pc_user, control_flg1, control_flg2)
                                VALUES (:program_name, :pc_user, :control_flg1, :control_flg2)";
                    command.CommandText = sql;
                    command.Parameters.Add(new SQLiteParameter(":program_name", authority.ProgramName));
                    command.Parameters.Add(new SQLiteParameter(":pc_user", authority.PCUser));
                    command.Parameters.Add(new SQLiteParameter(":control_flg1", authority.ControlFlg1));
                    command.Parameters.Add(new SQLiteParameter(":control_flg2", authority.ControlFlg2));

                    command.ExecuteNonQuery();
                }
            }
        }
        /// <summary>
        /// 更新权限数据
        /// </summary>
        /// <param name="authoritydata"></param>
        /// <returns></returns>
        public JsonResult UpdateAuthorityData(AuthorityModel authoritydata)
        {
            var authority = this._authorityService.GetList(s => s.Name == authoritydata.Name).FirstOrDefault();

            if (authority == null)
            {
                return(Json(ResultStatus.Fail));
            }
            authority.Description = authoritydata.Description;
            authority.Type        = authoritydata.Type;
            authority.UpdateTime  = DateTime.Now.ToString();
            var res = this._authorityService.Update(authority);

            if (res > 0)
            {
                return(Json(ResultStatus.Success));
            }
            return(Json(ResultStatus.Fail));
        }
예제 #19
0
        /// <summary>
        /// 生成权限模型列表
        /// </summary>
        /// <param name="operations"></param>
        /// <returns></returns>
        private List <AuthorityModel> GetAuthorityModels(List <InterfaceOperation> operations)
        {
            var list           = new List <AuthorityModel>();
            var interfaceNames = operations.Select(x => x.ParentName).ToList();
            var interfaces     = _context.InterfaceOperations.Where(x => interfaceNames.Contains(x.Name)).ToList();
            var groups         = interfaces.Select(x => x.GroupName).Distinct().ToList();

            foreach (var g in groups)
            {
                var model = new AuthorityModel();
                model.GroupName = g;
                var groupInterfaces = interfaces.Where(x => x.GroupName == g).ToList();
                foreach (var dexinterface in groupInterfaces)
                {
                    var interfaceOperations = operations.Where(x => x.ParentName == dexinterface.Name).ToList();
                    var modelInterface      = new InterfaceModel();
                    modelInterface.InterfaceName        = dexinterface.Name;
                    modelInterface.InterfaceDescription = dexinterface.Description;
                    foreach (var op in interfaceOperations)
                    {
                        modelInterface.Operations.Add(new OperationModel()
                        {
                            Id          = op.Id,
                            Name        = op.Name,
                            Description = op.Description
                        });
                    }

                    model.Interfaces.Add(modelInterface);
                }

                list.Add(model);
            }

            return(list);
        }
예제 #20
0
        // POST api/authority
        public string Post([FromBody] AuthorityModel model)
        {
            var result = _bllAuthority.SaveAuthority(model);

            return(result);
        }
예제 #21
0
 public void DeleteAuthority(AuthorityModel authority)
 {
     DBAccess.DeleteAuthority(authority);
 }
예제 #22
0
 public void InsertAuthority(AuthorityModel authority)
 {
     DBAccess.InsertAuthority(authority);
 }
예제 #23
0
 public void UpdateAuthority(AuthorityModel before, AuthorityModel after)
 {
     DBAccess.UpdateAuthority(before, after);
 }
예제 #24
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            #region Autofac在MVC中注册
            ContainerBuilder builder = new ContainerBuilder();
            var        service       = Assembly.Load("IService");
            var        service1      = Assembly.Load("Service");
            var        service2      = Assembly.Load("Model");
            Assembly[] assemblyArr   = new Assembly[] { service, service1, service2 };
            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterAssemblyTypes(assemblyArr).AsImplementedInterfaces();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            #endregion

            #region 添加初始数据
            DbContext db = new MyContext();
            if (db.Database.CreateIfNotExists())
            {
                //前台权限
                IAuthorityWebService  authorityService = new AuthorityWebService();
                List <AuthorityModel> authorityList    = new List <AuthorityModel>()
                {
                    new AuthorityModel()
                    {
                        BuildTime = DateTime.Now, Description = "读博客的权限", Name = "读权限", State = 1, Type = 1, UpdateTime = DateTime.Now, RoleModels = new List <RoleModel>()
                    },
                    new AuthorityModel()
                    {
                        BuildTime = DateTime.Now, Description = "写博客的权限", Name = "写权限", State = 1, Type = 1, UpdateTime = DateTime.Now, RoleModels = new List <RoleModel>()
                    }
                };
                authorityService.AddRange(authorityList);
                AuthorityModel authority1 = new AuthorityModel();
                authority1 = authorityService.GetList(s => s.Name == "读权限" && s.State == 1).ToList().FirstOrDefault();


                //前台角色
                IRoleWebService  roleService = new RoleWebService();
                List <RoleModel> roleList    = new List <RoleModel>()
                {
                    new RoleModel()
                    {
                        BuildTime = DateTime.Now, Description = "一般用户", RoleName = "普通用户", State = 1, UpdateTime = DateTime.Now, AuthorityModels = new List <AuthorityModel>(), UserModels = new List <UserModel>()
                    },
                    new RoleModel()
                    {
                        BuildTime = DateTime.Now, Description = "充值的用户拥有更多权限", RoleName = "VIP用户", State = 1, UpdateTime = DateTime.Now, AuthorityModels = new List <AuthorityModel>(), UserModels = new List <UserModel>()
                    }
                };
                roleService.AddRange(roleList);

                var role1 = roleService.GetList(s => s.RoleName == "普通用户" && s.State == 1).ToList().FirstOrDefault();
                var role2 = roleService.GetList(s => s.RoleName == "VIP用户" && s.State == 1).ToList().FirstOrDefault();
                role1.AuthorityModels.Add(authority1);
                role2.AuthorityModels.Add(authority1);
                roleService.Update(role1);
                roleService.Update(role2);

                //用户数据
                IUserWebService  userService = new UserWebService();
                List <UserModel> userList    = new List <UserModel>()
                {
                    new UserModel()
                    {
                        BuildTime = DateTime.Now, Count = 0, EMail = "*****@*****.**", HeadPicUrl = "~/Imgs/HeadPic/headpic-1.jpg", LoginTime = DateTime.Now, Type = 1, Pwd = Common.EncryptionHelper.GetMd5Str("112233"), State = 1, TelNumber = "155555555", Name = "MrChen", UpdateTime = DateTime.Now, Role = role1
                    },
                    new UserModel()
                    {
                        BuildTime = DateTime.Now, Count = 0, EMail = "*****@*****.**", HeadPicUrl = "~/Imgs/HeadPic/headpic-2.jpg", LoginTime = DateTime.Now, Type = 2, Pwd = Common.EncryptionHelper.GetMd5Str("112233"), State = 1, TelNumber = "155555555", Name = "MrSong", UpdateTime = DateTime.Now, Role = role2
                    }
                };
                userService.AddRange(userList);

                UserModel user11 = new UserModel();
                user11 = userService.GetList(s => s.Id == 1).ToList().FirstOrDefault();

                //博客类型
                IBlogTypeWebService blogTypeService = new BlogTypeWebService();
                List <BlogTypes>    typeList        = new List <BlogTypes>()
                {
                    new BlogTypes()
                    {
                        CreateTime = DateTime.Now, State = 1, TypeName = "类型1", UpdateTmie = DateTime.Now, BlogArticles = new List <BlogArticle>()
                    },
                    new BlogTypes()
                    {
                        CreateTime = DateTime.Now, State = 1, TypeName = "类型2", UpdateTmie = DateTime.Now, BlogArticles = new List <BlogArticle>()
                    },
                };
                blogTypeService.AddRange(typeList);

                var       type1  = blogTypeService.GetList(s => s.Id == 1).ToList().FirstOrDefault();
                var       type2  = blogTypeService.GetList(s => s.Id == 2).ToList().FirstOrDefault();
                BlogTypes type11 = new BlogTypes();
                type11 = type1;
                BlogTypes type22 = new BlogTypes();
                type22 = type2;

                //博客文章
                IBlogArticleWebService blogArticleService = new BlogArticleWebService();
                List <BlogArticle>     articleList        = new List <BlogArticle>()
                {
                    new BlogArticle()
                    {
                        Address = "1313", Content = "1211122212", CreateTime = DateTime.Now, State = 1, Title = "测试1", UpdateTime = DateTime.Now, WatchCount = 1, ZanCount = 0, BlogComments = new List <BlogComment>(), Type = type11, Summary = "aaa"
                    },
                    new BlogArticle()
                    {
                        Address = "1312", Content = "1211122212", CreateTime = DateTime.Now, State = 1, Title = "测试2", UpdateTime = DateTime.Now, WatchCount = 1, ZanCount = 0, BlogComments = new List <BlogComment>(), Type = type22, Summary = "bbb"
                    }
                };
                blogArticleService.AddRange(articleList);

                BlogArticle article1 = new BlogArticle();
                article1 = blogArticleService.GetList(s => s.Id == 1).ToList().FirstOrDefault();

                //博客评论
                IBlogCommentWebService blogCommentService = new BlogCommentWebService();
                List <BlogComment>     commentList        = new List <BlogComment>()
                {
                    new BlogComment()
                    {
                        Content = "你好啊", UpdateTime = DateTime.Now, State = 1, CommentId = 0, BlogArticle = article1, User = user11, CreateTime = DateTime.Now
                    },
                    new BlogComment()
                    {
                        Content = "你好啊", UpdateTime = DateTime.Now, State = 1, CommentId = 1, BlogArticle = article1, User = user11, CreateTime = DateTime.Now
                    },
                };
                blogCommentService.AddRange(commentList);



                //管理员数据
                IAdminUserService adminUserService = new AdminUserService();
                List <AdminUser>  adminUserList    = new List <AdminUser>()
                {
                    new AdminUser()
                    {
                        BuildTime = DateTime.Now, Name = "sbk", LoginTime = DateTime.Now, Password = Common.EncryptionHelper.GetMd5Str("abc112233"), State = 1, TelNumber = "18251935175", Type = 1
                    },
                    new AdminUser()
                    {
                        BuildTime = DateTime.Now, Name = "admin", LoginTime = DateTime.Now, Password = Common.EncryptionHelper.GetMd5Str("abc112233"), State = 1, TelNumber = "18251935175", Type = 1
                    }
                };
                adminUserService.AddRange(adminUserList);

                //后台权限数据
                IAdminAuthorityService adminAuthorityService = new AdminAuthorityService();
                List <AdminAuthority>  adminAuthorityList    = new List <AdminAuthority>()
                {
                    new AdminAuthority()
                    {
                        BuildTime = DateTime.Now, Description = "用于读取基本信息的权限", Name = "读权限", State = 1, Type = 1
                    },
                    new AdminAuthority()
                    {
                        BuildTime = DateTime.Now, Description = "用于写入基本信息的权限", Name = "写权限", State = 1, Type = 1
                    }
                };
                adminAuthorityService.AddRange(adminAuthorityList);

                //后台角色数据
                IAdminRoleService adminRoleService = new AdminRoleService();
                List <AdminRole>  adminRoleList    = new List <AdminRole>()
                {
                    new AdminRole()
                    {
                        BuildTime = DateTime.Now, Description = "管理单个项目", RoleName = "S级管理员", State = 1
                    },
                    new AdminRole()
                    {
                        BuildTime = DateTime.Now, Description = "管理单个项目", RoleName = "SS级管理员", State = 1
                    }
                };
                adminRoleService.AddRange(adminRoleList);
            }
            #endregion
            //log4net.Config.XmlConfigurator.Configure();//读取Log4Net配置信息

            //MiniProfilerEF6.Initialize();//注册MiniProfiler,网页性能插件

            log4net.Config.XmlConfigurator.Configure();

            //WaitCallback
            ThreadPool.QueueUserWorkItem((a) =>
            {
                while (true)
                {
                    if (MyExceptionAttribute.ExceptionQueue.Count > 0)
                    {
                        Exception ex = MyExceptionAttribute.ExceptionQueue.Dequeue();//出队
                        //string fileName = DateTime.Now.ToString("yyyy-MM-dd")+".txt";
                        //File.AppendAllText(fileLogPath + fileName, ex.ToString(), System.Text.Encoding.Default);
                        //ILog logger = LogManager.GetLogger("errorMsg");
                        ILog logger = log4net.LogManager.GetLogger("logger");
                        logger.Error(ex.ToString());

                        #region 发送邮件
                        //MailHelper mail = new MailHelper();
                        //mail.MailServer = "smtp.qq.com";
                        //mail.MailboxName = "*****@*****.**";
                        //mail.MailboxPassword = "******";//开启QQ邮箱POP3/SMTP服务时给的授权码
                        ////操作打开QQ邮箱->在账号下方点击"设置"->账户->POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务
                        ////obxxsfowztbideee为2872845261@qq的授权码
                        //mail.MailName = "Error";
                        //try
                        //{
                        //    mail.Send("*****@*****.**", "Error", ex.ToString());
                        //}
                        //catch
                        //{ }
                        #endregion
                    }
                    else
                    {
                        Thread.Sleep(3000);//如果队列中没有数据,则休息为了避免占用CPU的资源.
                    }
                }
            });
        }
예제 #25
0
 protected string ModifyAuthority(AuthorityModel model)
 {
     return _dalAuthority.ModifyAuthority(model.ToHashTable());
 }
예제 #26
0
 protected string ModifyAuthority(AuthorityModel model)
 {
     return(_dalAuthority.ModifyAuthority(model.ToHashTable()));
 }
예제 #27
0
 public string SaveAuthority(AuthorityModel model)
 {
     return(model.Id.HasValue ? ModifyAuthority(model) : CreateAuthority(model));
 }
예제 #28
0
 public string SaveAuthority(AuthorityModel model)
 {
     return model.Id.HasValue ? ModifyAuthority(model) : CreateAuthority(model);
 }
예제 #29
0
        public JsonResult SetAuthority(AuthorityModel authority)
        {
            var rv = _manageService.SaveAuthority(authority);

            return(Json(rv));
        }