コード例 #1
0
        private void CreateModule_btn_Click(object sender, RoutedEventArgs e)
        {
            CreateModule CreateModule = new CreateModule();

            CreateModule.Show();
            Close();
        }
コード例 #2
0
        public void Should_validate_command_and_save_new_module()
        {
            var command = new CreateModule
            {
                SiteId       = Guid.NewGuid(),
                ModuleTypeId = Guid.NewGuid(),
                Id           = Guid.NewGuid(),
                Title        = "Title"
            };

            var repositoryMock = new Mock <IModuleRepository>();

            repositoryMock.Setup(x => x.Create(It.IsAny <Module>()));

            var validatorMock = new Mock <IValidator <CreateModule> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            var createModuleHandler = new CreateModuleHandler(repositoryMock.Object, validatorMock.Object);

            createModuleHandler.Handle(command);

            validatorMock.Verify(x => x.Validate(command));
            repositoryMock.Verify(x => x.Create(It.IsAny <Module>()));
        }
コード例 #3
0
        public async Task ShouldCreateModule()
        {
            var userId = await RunAsDefaultUserAsync();

            var command = new CreateModule
            {
                Title       = "New Module",
                Key         = "new-module",
                Description = "New Module Description",
                Necessity   = Necessity.Other,
                Tags        = new List <string> {
                    "Tag1", "Tag2", "Tag3"
                }
            };

            var createdModule = await SendAsync(command);

            var module = await FindAsync <Module>(createdModule.Id);

            module.Should().NotBeNull();
            module.Title.Should().Be(command.Title);
            module.Description.Should().Be(command.Description);
            module.Necessity.Should().Be(command.Necessity);
            module.CreatedBy.Should().Be(userId);
            module.Created.Should().BeCloseTo(DateTime.Now, TimeSpan.FromMilliseconds(1000));
        }
コード例 #4
0
        public async Task <IActionResult> Post([FromBody] CreateModule command)
        {
            command.ModuleId = Guid.NewGuid();
            await _wordsModuleService.CreateAsync(UserId, command.ModuleId, command.Name, command.Description);

            return(Created($"/wordsmodules/{command.ModuleId}", null));
        }
コード例 #5
0
ファイル: ModuleController.cs プロジェクト: hyrmedia/Weapsy
        public async Task <IActionResult> Post([FromBody] CreateModule model)
        {
            model.SiteId = SiteId;
            await Task.Run(() => _commandSender.Send <CreateModule, Module>(model));

            return(new NoContentResult());
        }
コード例 #6
0
        public void ShouldRequireMinimumFields()
        {
            var command = new CreateModule();

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().ThrowAsync <ValidationException>();
        }
コード例 #7
0
ファイル: moduleFactory.cs プロジェクト: bholcomb/gameEngine
        public static ModuleTree create(LuaObject treeConfig)
        {
            int x = treeConfig.get <int>("size[1]");
            int y = treeConfig.get <int>("size[2]");

            ModuleTree tree  = new ModuleTree(x, y);
            LuaObject  nodes = treeConfig["nodes"];

            for (int i = 1; i <= nodes.count(); i++)
            {
                LuaObject nodeConfig = nodes[i];
                string    type       = nodeConfig.get <String>("type");

                CreateModule creator = null;
                Module.Type  mType;
                Enum.TryParse(type, out mType);
                if (myCreators.TryGetValue(mType, out creator) == true)
                {
                    Module m = creator(tree, nodeConfig);
                }
                else
                {
                    throw new Exception(String.Format("Failed to find creator {0}", type));
                }
            }

            string outputName   = treeConfig.get <String>("output");
            Module outputModule = tree.findModule(outputName);

            tree.output = outputModule;

            return(tree);
        }
コード例 #8
0
        public async Task <bool> CreateModuleAsync(CreateModule createModule)
        {
            var module = await _tenantDataContext.Modules.FirstOrDefaultAsync(x => x.Name == createModule.Module.Name);

            if (module != null)
            {
                Console.WriteLine("There's a module with the name already");
                return(false);
            }

            var project = await _tenantDataContext.Projects.FirstOrDefaultAsync(x => x.Id == createModule.ProjectId);

            if (project == null)
            {
                Console.WriteLine("project does not exist");
                return(false);
            }

            createModule.Module.Project = project;

            await _tenantDataContext.Modules.AddAsync(createModule.Module);

            try
            {
                await _tenantDataContext.SaveChangesAsync();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
コード例 #9
0
        private void miProjectCreate_Click(object sender, EventArgs e)
        {
            Powerpoint = Powerpoint ?? new Microsoft.Office.Interop.PowerPoint.Application();
            ppt        = Powerpoint.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue);


            CreateModule.CreateChart(ppt, _database.data);
        }
コード例 #10
0
 public static Module ToEntity(this CreateModule newRegistry)
 {
     return(new Module()
     {
         Name = newRegistry.Name
         , CreateDate = DateTime.Now
         , State = 1
     });
 }
コード例 #11
0
 public RegisteredModule Create(CreateModule newRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var eModule = newRegistry.ToEntity();
         helpDeskDataContext.Modules.Add(eModule);
         helpDeskDataContext.SaveChanges();
         return(eModule.ToDTO());
     }
 }
コード例 #12
0
 private Module(CreateModule cmd) : base(cmd.Id)
 {
     AddEvent(new ModuleCreated
     {
         SiteId          = cmd.SiteId,
         ModuleTypeId    = cmd.ModuleTypeId,
         AggregateRootId = Id,
         Title           = cmd.Title,
         Status          = ModuleStatus.Active
     });
 }
コード例 #13
0
        public void ShouldRequireDescription()
        {
            var command = new CreateModule
            {
                Title = "Module Title"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().ThrowAsync <ValidationException>()
            .Where(ex => ex.Errors.ContainsKey("Description"))
            .Result.And.Errors["Description"].Should().Contain("Description is required.");
        }
コード例 #14
0
        public void ShouldDisallowLongTitle()
        {
            var command = new CreateModule
            {
                Title       = "This module title is too long and exceeds one hundred characters allowed for module titles by CreateModuleCommandValidator",
                Description = "Learn how to design modern web applications using ASP.NET"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().ThrowAsync <ValidationException>()
            .Where(ex => ex.Errors.ContainsKey("Title"))
            .Result.And.Errors["Title"].Should().Contain("Title must not exceed 100 characters.");
        }
コード例 #15
0
        public void ShouldReturnNotFoundForNonExistingPath()
        {
            var command = new CreateModule
            {
                Title       = "New Title",
                Key         = "module-key",
                Description = "New Description",
                Necessity   = 0
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().ThrowAsync <NotFoundException>();
        }
コード例 #16
0
        public async Task <Module> Create([FromBody] CreateModule model)
        {
            var module = await _metaDbContext.Modules.AddAsync(new Domain.Meta.Module
            {
                Id             = Guid.NewGuid(),
                Name           = model.Name,
                Description    = model.Description,
                ParentModuleId = model.ParentModuleId
            });

            _metaDbContext.SaveChanges();
            return(_mapper.Map <Module>(module.Entity));
        }
コード例 #17
0
 public void Setup()
 {
     _command = new CreateModule
     {
         SiteId       = Guid.NewGuid(),
         ModuleTypeId = Guid.NewGuid(),
         Id           = Guid.NewGuid(),
         Title        = "Title"
     };
     _validatorMock = new Mock <IValidator <CreateModule> >();
     _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());
     _module = Module.CreateNew(_command, _validatorMock.Object);
     _event  = _module.Events.OfType <ModuleCreated>().SingleOrDefault();
 }
コード例 #18
0
        protected void Application_Start()
        {
            //Database.SetInitializer(new DbInitializer());

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            NinjectModule userModule    = new CreateModule();
            NinjectModule serviceModule = new ServiceModule("ConnectionString");
            var           kernel        = new StandardKernel(userModule, serviceModule);

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));

            AutoMapperConfig.MapperRegister();
        }
コード例 #19
0
ファイル: ModuleFactory.cs プロジェクト: rioka/Weapsy
        public static Module Module(Guid siteId, Guid moduleTypeId, Guid id, string title)
        {
            var command = new CreateModule
            {
                SiteId       = siteId,
                ModuleTypeId = moduleTypeId,
                Id           = id,
                Title        = title
            };

            var validatorMock = new Mock <IValidator <CreateModule> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            return(Domain.Modules.Module.CreateNew(command, validatorMock.Object));
        }
コード例 #20
0
        public async Task <ActionResult <bool> > Create([FromBody] CreateModule createModule)
        {
            var tenant = (await _tenantService.GetTenantFromHostAsync());

            if (tenant != null)
            {
                Console.WriteLine($"creating module for {tenant.Id} : {tenant.Name}");
                using (var context = _tenantService.CreateContext(tenant))
                {
                    var moduleService = new ModuleService(context);
                    return(Ok(await moduleService.CreateModuleAsync(createModule)));
                }
            }

            return(BadRequest("Tenant doesn't exist"));
        }
コード例 #21
0
        public async Task Create_ReturnsCreatedAtRoute()
        {
            var createCommand = new CreateModule {
                Order = 0, Title = "Create title", Description = "Create Description"
            };
            var controller = new ModulesController(moqMediator.Object);

            var result = await controller.Create(createCommand);

            var content = GetObjectResultContent <Module>(result.Result);

            Assert.IsInstanceOf(typeof(CreatedAtRouteResult), result.Result);
            Assert.AreEqual("GetModule", ((CreatedAtRouteResult)result.Result).RouteName);
            Assert.IsNotNull(content);
            Assert.AreEqual(1, content.Id);
        }
コード例 #22
0
        public void Should_have_validation_error_when_module_type_id_is_empty()
        {
            var command = new CreateModule
            {
                SiteId       = Guid.NewGuid(),
                ModuleTypeId = Guid.Empty,
                Id           = Guid.NewGuid(),
                Title        = "Title"
            };

            var moduleRulesMock = new Mock <IModuleRules>();
            var moduleTypeRules = new Mock <IModuleTypeRules>();
            var siteRulesMock   = new Mock <ISiteRules>();

            var validator = new CreateModuleValidator(moduleRulesMock.Object, moduleTypeRules.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.ModuleTypeId, command);
        }
コード例 #23
0
        private void mi_CreateM_Click(object sender, RoutedEventArgs e)
        {
            CreateModule moduleWin = new CreateModule();

            moduleWin.Left = App.Current.MainWindow.Left + 50;
            moduleWin.Top  = App.Current.MainWindow.Top + 50;
            moduleWin.ShowDialog();

            if (!moduleWin.IsCancel)
            {
                var cls  = steps.CreateModule(moduleWin.ModuleName);
                var code = CodeHelper.GetCode(cls, p => p.GenerateCodeFromType).ToString();

                ScriptWin win = new ScriptWin(code);
                win.Left = App.Current.MainWindow.Left + 50;
                win.Top  = App.Current.MainWindow.Top + 50;
                win.ShowDialog();
            }
        }
コード例 #24
0
        public void Should_have_validation_error_when_site_does_not_exist()
        {
            var command = new CreateModule
            {
                SiteId       = Guid.NewGuid(),
                ModuleTypeId = Guid.NewGuid(),
                Id           = Guid.NewGuid(),
                Title        = "Title"
            };

            var moduleRulesMock = new Mock <IModuleRules>();
            var moduleTypeRules = new Mock <IModuleTypeRules>();
            var siteRulesMock   = new Mock <ISiteRules>();

            siteRulesMock.Setup(x => x.DoesSiteExist(command.SiteId)).Returns(false);

            var validator = new CreateModuleValidator(moduleRulesMock.Object, moduleTypeRules.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.SiteId, command);
        }
コード例 #25
0
ファイル: PageController.cs プロジェクト: zzekikaya/Weapsy
        public IActionResult AddModule([FromBody] AddModuleModel model)
        {
            var defaultViewRoleIds = new List <Guid> {
                Administrator.Id
            };
            var defaultEditRoleIds = new List <Guid> {
                Administrator.Id
            };

            model.SetPageModulePermissions(defaultViewRoleIds, defaultEditRoleIds);
            model.SiteId = SiteId;

            var moduleId = Guid.NewGuid();

            var createModule = new CreateModule
            {
                SiteId       = model.SiteId,
                ModuleTypeId = model.ModuleTypeId,
                Id           = moduleId,
                Title        = model.Title
            };

            _dispatcher.SendAndPublish <CreateModule, Module>(createModule);

            var addPageModule = new AddPageModule
            {
                SiteId                = model.SiteId,
                PageId                = model.PageId,
                ModuleId              = moduleId,
                PageModuleId          = Guid.NewGuid(),
                Title                 = model.Title,
                Zone                  = model.Zone,
                SortOrder             = model.SortOrder,
                PageModulePermissions = model.PageModulePermissions
            };

            _dispatcher.SendAndPublish <AddPageModule, Page>(addPageModule);

            return(new NoContentResult());
        }
コード例 #26
0
        public void Should_throw_validation_exception_when_validation_fails()
        {
            var command = new CreateModule
            {
                SiteId       = Guid.NewGuid(),
                ModuleTypeId = Guid.NewGuid(),
                Id           = Guid.NewGuid(),
                Title        = "Title"
            };

            var repositoryMock = new Mock <IModuleRepository>();

            var validatorMock = new Mock <IValidator <CreateModule> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult(new List <ValidationFailure> {
                new ValidationFailure("Id", "Id Error")
            }));

            var createModuleHandler = new CreateModuleHandler(repositoryMock.Object, validatorMock.Object);

            Assert.Throws <Exception>(() => createModuleHandler.Handle(command));
        }
コード例 #27
0
        // POST: api/Module  create module

        public async Task <HandleResult> Post([FromBody] CreateModuleDto dto)
        {
            var command = new CreateModule(
                ObjectId.GenerateNewStringId(),
                dto.AppSystemId,
                ObjectId.GenerateNewStringId(),
                dto.Name,
                dto.ModuleType,
                dto.VerifyType,
                dto.IsVisible,
                dto.ParentModule,
                dto.LinkUrl,
                dto.Sort,
                dto.Describe,
                dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("创建成功", command.Code));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
コード例 #28
0
        public async Task<ActionResult> Index()
        {
            serviceId = "AC";
            serviceSort = 10000;
            if (serviceDao.Entities.Where(m => m.Id == serviceId).Count() > 0)
            {
                return Content("数据库中已经存在数据库,不需要重新生成。");
            }
            //部门
            CreateDepartment();

            var service = new CreateService(serviceId, "统一授权中心", 1, "http://int.zhongyi-itl.com/");
            await this.commandService.Execute(service);

            var user = new CreateUser("sysadmin", "系统管理员", "Sysadmin", "*****@*****.**", "15817439909", "系统管理员");
            await this.commandService.Execute(user);

            var role = new CreateRole("系统管理员", 0);
            await this.commandService.Execute(role);
            await this.commandService.Execute(new SetUserRoles(user.AggregateRootId, new string[] { role.AggregateRootId }));


            var menu = new CreateMenu("统一授权中心", (int)MenuType.Web, "", "", serviceSort);
            await this.commandService.Execute(menu);
            var menuRoot = menu.AggregateRootId;

            var module = new CreateModule(serviceId, "System", "系统管理", serviceSort);
            await this.commandService.Execute(module);
            var moduleId = module.AggregateRootId;

            menu = new CreateMenu("系统管理", (int)MenuType.Web, "", "", serviceSort + 10, menuRoot);
            await this.commandService.Execute(menu);
            var menuId = menu.AggregateRootId;

            string moduleId2 = await QuickModule("Sys", "Department", "部门信息", moduleId, menuId, 11);

            var permission = new CreatePermission("DepartmentUser", "设置用户", moduleId2);
            await this.commandService.Execute(permission);

            //角色管理
            module = new CreateModule(serviceId, "Role", "角色管理", serviceSort + 16, moduleId);
            await this.commandService.Execute(module);
            permission = new CreatePermission("ViewRole", "查看", module.AggregateRootId);
            await this.commandService.Execute(permission);
            var viewRolePermissionId = permission.AggregateRootId;
            menu = new CreateMenu("角色管理", (int)MenuType.Web, "Sys/RoleList.aspx", "", serviceSort + 16, menuId, permission.AggregateRootId);
            await this.commandService.Execute(menu);
            permission = new CreatePermission("NewRole", "新增", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ModifyRole", "编辑", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("DeleteRole", "删除", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("PermissionRole", "分配权限", module.AggregateRootId);
            await this.commandService.Execute(permission);
            await this.commandService.Execute(new SetRolePermissions(role.AggregateRootId, new string[] { viewRolePermissionId, permission.AggregateRootId }));

            //用户管理
            moduleId2 = await QuickModule("Sys", "User", "用户管理", moduleId, menuId, 21);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ChangePwdUser", "修改密码", moduleId2);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("RoleUser", "分配角色", moduleId2);
            await this.commandService.Execute(permission);
            await QuickModule("Sys", "Service", "服务管理", moduleId, menuId, 26);
            await QuickModule("Sys", "Module", "模块管理", moduleId, menuId, 31);
            await QuickModule("Sys", "Menu", "菜单管理", moduleId, menuId, 36);
            await QuickModule("Sys", "Authority", "权限管理", moduleId, menuId, 41);

            CreateRole();
            return Content("");
        }
コード例 #29
0
        private async void QuickFileModule(string moduleCode, string moduleName, string moduleParentId, string menuParentId, int sort)
        {
            var module = new CreateModule(serviceId, moduleCode, moduleName, serviceSort + sort, moduleParentId);
            await this.commandService.Execute(module);

            var permission = new CreatePermission("Use" + moduleCode, "使用", module.AggregateRootId);
            await this.commandService.Execute(permission);

            var menu = new CreateMenu(moduleName, (int)MenuType.Web, "HardDisk/" + moduleCode + "aspx", "", serviceSort + sort, menuParentId, permission.AggregateRootId);
            await this.commandService.Execute(menu);

            permission = new CreatePermission("Upload" + moduleCode, "上传文件", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ModifyFile" + moduleCode, "编辑文件名", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("DeleteFile" + moduleCode, "删除文件", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("MoveFile" + moduleCode, "移动文件", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("NewFolder" + moduleCode, "新建文件夹", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ModifyFolder" + moduleCode, "编辑文件夹", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("DeleteFolder" + moduleCode, "删除文件夹", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("MoveFolder" + moduleCode, "移动文件夹", module.AggregateRootId);
            await this.commandService.Execute(permission);
        }
コード例 #30
0
        //private async void QuickModuleGroup(string moduleCode, string moduleName, string moduleParentId, string menuParentId, int sort, out string moduleId, out string menuId)
        //{
        //    var module = new CreateModule(serviceId, moduleCode, moduleName, serviceSort + sort, moduleParentId);
        //    await this.commandService.Execute(module);
        //    moduleId = module.AggregateRootId;

        //    var menu = new CreateMenu(moduleName, (int)MenuType.Web, "", "", serviceSort + sort, menuParentId);
        //    await this.commandService.Execute(menu);
        //    menuId = menu.AggregateRootId;
        //}

        private async Task<string> QuickModule(string folder, string moduleCode, string moduleName, string moduleParentId, string menuParentId, int sort, bool canExport = false)
        {
            var module = new CreateModule(serviceId, moduleCode, moduleName, serviceSort + sort, moduleParentId);
            var result = await this.commandService.Execute(module);
            if (result.Status == CommandStatus.Success)
            {
                var permission = new CreatePermission("View" + moduleCode, "查看", module.AggregateRootId);
                result = await this.commandService.Execute(permission);
                if (result.Status == CommandStatus.Success)
                {
                    var menu = new CreateMenu(moduleName, (int)MenuType.Web, folder + "/" + moduleCode + "List.aspx", "", serviceSort + sort, menuParentId, permission.AggregateRootId);
                    await this.commandService.Execute(menu);
                }
                permission = new CreatePermission("New" + moduleCode, "新增", module.AggregateRootId);
                await this.commandService.Execute(permission);
                permission = new CreatePermission("Modify" + moduleCode, "编辑", module.AggregateRootId);
                await this.commandService.Execute(permission);
                permission = new CreatePermission("Delete" + moduleCode, "删除", module.AggregateRootId);
                await this.commandService.Execute(permission);

                if (canExport)
                {
                    permission = new CreatePermission("Upload" + moduleCode, "上传", module.AggregateRootId);
                    await this.commandService.Execute(permission);
                    permission = new CreatePermission("Download" + moduleCode, "下载", module.AggregateRootId);
                    await this.commandService.Execute(permission);
                }
            }
            return module.AggregateRootId;
        }
コード例 #31
0
        public static Module CreateNew(CreateModule cmd, IValidator <CreateModule> validator)
        {
            validator.ValidateCommand(cmd);

            return(new Module(cmd));
        }
コード例 #32
0
        public async Task <ActionResult <Module> > Create([FromBody] CreateModule command)
        {
            Module model = await Mediator.Send(command);

            return(CreatedAtRoute("GetModule", new { moduleId = model.Id }, model));
        }
コード例 #33
0
ファイル: ModuleController.cs プロジェクト: zzekikaya/Weapsy
 public IActionResult Post([FromBody] CreateModule model)
 {
     throw new NotImplementedException();
 }