Exemplo n.º 1
0
        public void Clone_SourceNetlistExists_Clone()
        {
            _netlistRepository.Add(new Netlist(DummyNetlist));
            _moduleRepository.Add(new Module(DummyNetlist, "m1"));
            _moduleRepository.Add(new Module(DummyNetlist, "m2"));
            _instanceRepository.Add(new Instance(DummyNetlist, "m1", "an2", "inst1"));
            _instanceRepository.Add(new Instance(DummyNetlist, "m1", "an2", "inst2"));
            _instanceRepository.Add(new Instance(DummyNetlist, "m2", "an3", "inst3"));

            _target.Clone(DummyNetlist, NewDummyNetlist);

            var netlist = _netlistRepository.Get(NewDummyNetlist);

            Assert.That(netlist, Is.Not.Null);

            var modules = _moduleRepository.GetAll(NewDummyNetlist).ToList();

            Assert.That(modules, Has.Count.EqualTo(2));
            Assert.That(modules, Has.Exactly(1).Matches <Module>(m => m.Name == "m1"));
            Assert.That(modules, Has.Exactly(1).Matches <Module>(m => m.Name == "m2"));

            var instances = _instanceRepository.GetBy(NewDummyNetlist).ToList();

            Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst1"));
            Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst2"));
            Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst3"));
        }
        public IActionResult Get()
        {
            var pagination = Request.Headers["Pagination"];

            if (!string.IsNullOrEmpty(pagination))
            {
                string[] vals = pagination.ToString().Split(',');
                int.TryParse(vals[0], out page);
                int.TryParse(vals[1], out pageSize);
            }

            int currentPage     = page;
            int currentPageSize = pageSize;
            var totalModules    = _moduleRepository.Count();
            var totalPages      = (int)Math.Ceiling((double)totalModules / pageSize);

            IEnumerable <Module> _modules = _moduleRepository
                                            .GetAll()
                                            .OrderBy(m => m.Order)
                                            .Skip((currentPage - 1) * pageSize)
                                            .Take(currentPage)
                                            .ToList();

            IEnumerable <ModuleViewModel> _moduleViewModel = Mapper.Map <IEnumerable <Module>, IEnumerable <ModuleViewModel> >(_modules);

            Response.AddPagination(page, pageSize, totalModules, totalPages);

            return(new OkObjectResult(_moduleRepository));
        }
Exemplo n.º 3
0
        public int GetSortCode1()
        {
            int?sortCode = _moduleRepository.GetAll().Max(t => t.F_SortCode);

            if (!sortCode.HasValue)
            {
                return(sortCode.Value + 1);
            }
            return(100001);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 非树形排列
        /// </summary>
        /// <param name="webid"></param>
        /// <returns></returns>
        public ModuleDTOList GetAllWebModules(Guid webid, bool IsMix = false)
        {
            ModuleDTOList dtolist = new ModuleDTOList();
            var           modules = IsMix ? moduleRepository.GetAll(Specification <Module> .Eval(m => m.Web.ID.Equals(webid))) : moduleRepository.GetAll(Specification <Module> .Eval(m => m.Web.ID.Equals(webid)).And(Specification <Module> .Eval(m => m.ParentModule == null)));

            foreach (var item in modules)
            {
                dtolist.Add(Mapper.Map <Module, ModuleDTO>(item));
            }
            return(dtolist.ToViewModel());
        }
Exemplo n.º 5
0
        public IEnumerable <Module> GetAllModule()
        {
            IEnumerable <Module> modules = cacheProvider.Get("module") as IEnumerable <Module>;


            if (modules == null)
            {
                modules = moduleRepository.GetAll();
                if (modules.Any())
                {
                    cacheProvider.Set("module", modules, 240);
                }
            }
            return(moduleRepository.GetAll());
        }
Exemplo n.º 6
0
        public void Clone(string source, string newSource)
        {
            var netlist = _netlistRepository.Get(source);

            if (netlist == null)
            {
                throw new InvalidOperationException("source netlist does not exists");
            }

            if (source == newSource)
            {
                return;
            }

            _netlistRemover.Remove(newSource);

            netlist.Source = newSource;
            _netlistRepository.Add(netlist);

            foreach (var module in _moduleRepository.GetAll(source))
            {
                module.Netlist = newSource;
                _moduleRepository.Add(module);
            }

            foreach (var instance in _instanceRepository.GetBy(source))
            {
                instance.Netlist = newSource;
                _instanceRepository.Add(instance);
            }
        }
Exemplo n.º 7
0
        public async Task <IActionResult> GetModules(string clubId)
        {
            try
            {
                int id = 0;
                if (!int.TryParse(clubId, out id))
                {
                    return(BadRequest());
                }

                var modules = await _moduleRepository.GetAll(id);

                if (modules != null)
                {
                    var response = new List <ModuleOut>();
                    foreach (var m in modules)
                    {
                        response.Add(_mapper.Map <ModuleOut>(m));
                    }

                    return(Ok(response));
                }

                return(BadRequest("Club have not any modules"));
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
Exemplo n.º 8
0
        public async Task <IEnumerable <ModuleModel> > GetAll()
        {
            var modules = await _moduleRepository.GetAll();

            var applications = await _ssoService.GetAllApplications();

            return(await Task.FromResult(
                       from module in modules
                       join application in applications
                       on module.ApplicationId equals application.ApplicationId into app
                       from application in app.DefaultIfEmpty()
                       select new ModuleModel
            {
                ModuleId = module.ModuleId,
                ApplicationId = module.ApplicationId,
                ApplicationName = application.ApplicationName,
                Code = module.Code,
                Name = module.Name,
                IsActive = module.IsActive,
                ParentModule =
                    ObjectMapper.Mapper.Map <ModuleModel>(module.ParentModule),
                ModuleType =
                    ObjectMapper.Mapper.Map <ModuleTypeModel>(module.ModuleType)
            }));
        }
Exemplo n.º 9
0
        public string Construct(string source)
        {
            var builder = new NetlistFileBuilder();
            var netlist = _netlistRepository.Get(source);
            var modules = _moduleRepository.GetAll(netlist.Source);

            builder.BuildMetaStatements(netlist);

            foreach (var module in modules)
            {
                builder.BuildModuleDeclaration(module);
                builder.BuildNewLine();
                builder.BuildModulePortDeclarations(module);
                builder.BuildSupplyDeclarations(module);

                foreach (var instance in _instanceRepository.GetByHostModule(netlist.Source, module.Name))
                {
                    builder.BuildInstanceDeclaration(instance);
                }

                builder.BuildNewLine();
                builder.BuildEndModule();
                builder.BuildNewLine();
            }

            return(builder.GetResult());
        }
Exemplo n.º 10
0
        //Render danh sach cac mon do an
        public ActionResult Category()
        {
            var result = new List <Module>();

            result = ModuleRepository.GetAll().ToList();
            return(PartialView(result));
        }
Exemplo n.º 11
0
        public FileResult Export(Type type)
        {
            var list = moduleRepository.GetAll().ToList();
            var file = new MF.Dev.ExportHelper.ExportHelper.ExcelExportHelper <Module>("Report", Resources.Resource.Module, list).CreateSheet();

            return(file);
        }
Exemplo n.º 12
0
        public async Task <IActionResult> GetAllModules()
        {
            var modules = await _repo.GetAll();

            var modulesToReturn = _mapper.Map <IEnumerable <ModulesForListDto> >(modules);

            return(Ok(modulesToReturn));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 赋予角色权限
        /// </summary>
        /// <param name="roleid"></param>
        /// <param name="moduleids"></param>
        /// <returns></returns>
        public void AssignRolePermission(Guid roleid, Guid webid, List <Guid> moduleids)
        {
            List <Guid> mids      = moduleids;
            var         role      = roleRepository.Find(Specification <Role> .Eval(r => r.ID.Equals(roleid)));
            var         oldmodule = role.Modules;

            role.Modules = null;
            oldmodule.RemoveAll(m => m.Web.ID.Equals(webid));

            var newmodules = moduleRepository.GetAll(Specification <Module> .Eval(m => (mids.Contains(m.ID)))
                                                     .And(Specification <Module> .Eval(m => m.Web.ID.Equals(webid)))).ToList();

            oldmodule.AddRange(newmodules);
            role.Modules = oldmodule;
            roleRepository.Update(role);
            Context.Commit();
        }
Exemplo n.º 14
0
        public void Remove(string netlist, string bufferName, string inputPort, string outputPort)
        {
            _openOutputModuleRemover.Remove(netlist, bufferName, outputPort);

            Parallel.ForEach(_moduleRepository.GetAll(netlist), module =>
                             RemoveBuffers(module, bufferName, inputPort, outputPort)
                             );
        }
Exemplo n.º 15
0
 public IEnumerable <Module> GetModules(long CompanyId)
 {
     if (CompanyId > 0)
     {
         return(_module_repo.GetList(r => r.CompanyId != null && r.CompanyId == CompanyId, a => a.Features, b => b.RoleModules));
     }
     else
     {
         return(_module_repo.GetAll(a => a.Features, b => b.RoleModules));
     }
 }
        public IEnumerable <ModuleDTO> GetModules()
        {
            var Modules = ModuleRepo.GetAll();
            List <ModuleDTO> ModuleDTOs = new List <ModuleDTO>();

            foreach (var Module in Modules)
            {
                ModuleDTOs.Add(Mapper.Map <ModuleDTO>(Module));
            }


            return(ModuleDTOs);
        }
Exemplo n.º 17
0
        public RoleSelectedModuleModel GetRoleSelectedModuleModel(int id)
        {
            //角色 - 菜单
            var model = new RoleSelectedModuleModel();

            #region 角色
            var role = this.GetById(id);
            model.RoleId   = role.Id;
            model.RoleName = role.Name;
            #endregion

            #region 菜单
            //菜单列表
            model.ModuleDataList = _moduleRepository.GetAll().Where(m => m.IsMenu && !m.IsDeleted && m.Enabled)
                                   .Select(t => new ModuleModel
            {
                ModuleId   = t.Id,
                ParentId   = t.ParentId,
                ModuleName = t.Name,
                Code       = t.Code,
            }).OrderBy(t => t.Code).ToList();

            //选中菜单
            var selectedModule = _roleModulePermissionRepository.GetAll().Where(t => t.RoleId == id && t.IsDeleted == false).Select(t => t.ModuleId).ToList();

            //对比菜单
            foreach (var item in model.ModuleDataList)
            {
                if (selectedModule.Contains(item.ModuleId))
                {
                    //选中此菜单
                    item.Selected = true;
                }
            }
            #endregion

            return(model);
        }
 public List <ModuleDto> GetModules()
 {
     return(_moduleRepository.GetAll().AsQueryable()
            .Select(x => new ModuleDto()
     {
         Id = x.Id,
         Name = x.Name,
         Description = x.Description,
         CourseId = x.CourseId,
         Course = x.Course.Description,
         Credits = x.Credits,
         LessonNumber = x.LessonsNumber
     })
            .ToList());
 }
Exemplo n.º 19
0
        public int GetSortCode()
        {
            int?sortCode = _moduleRepository.GetAll().Max(t => t.F_SortCode);

            if (!sortCode.HasValue)
            {
                return(sortCode.Value + 1);
            }

            var query  = _moduleRepository.GetAll();
            var query8 = _moduleButtonRepository.GetAll();

            var ss = query.Join(query8, t => t.Id, s => s.F_ModuleId, (t, s) => t).ToList();;

            return(100001);
        }
Exemplo n.º 20
0
        public void Remove_NetlistExists_RemoveNetlist()
        {
            _netlistCloner.Clone(ExampleNetlistFilePath, DummyNetlist);

            _target.Remove(DummyNetlist);

            var netlist = _netlistRepository.Get(DummyNetlist);

            Assert.That(netlist, Is.Null);

            var modules = _moduleRepository.GetAll(DummyNetlist);

            Assert.That(modules, Is.Empty);

            var instances = _instanceRepository.GetBy(DummyNetlist);

            Assert.That(instances, Is.Empty);
        }
Exemplo n.º 21
0
        public IEnumerable <Module> getAllModules()
        {
            var modulename = _moduleRepository.GetAll();

            return(modulename);
        }
Exemplo n.º 22
0
 public bool CheckExistCode(string code, long?id = null)
 {
     return(_moduleRepository.GetAll().Where(x => x.Code != null && x.Code.Equals(code) && (id.HasValue ? x.Id != id : true)).Any());
 }
Exemplo n.º 23
0
 public QueryRequestOut <ModuleItem> GetAll(ModuleQueryInput input)
 {
     return(_moduleRepository.GetAll()
            .WhereIf(!input.Keywords.IsNullOrWhiteSpace(), m => m.Name.Contains(input.Keywords))
            .ToOutPut <ModuleItem>(input));
 }
Exemplo n.º 24
0
 public IEnumerable <Module> GetAllModules()
 {
     return(repository.GetAll());
 }
Exemplo n.º 25
0
        public async Task <IActionResult> Get()
        {
            var list = await Task.Run(() => _moduleRepository.GetAll());

            return(Ok(list));
        }
Exemplo n.º 26
0
        public void Should_return_all_modules()
        {
            var actual = _sut.GetAll();

            Assert.AreEqual(2, actual.Count);
        }
Exemplo n.º 27
0
 public IEnumerable <Module> DonneTous()
 {
     return(_moduleRepository.GetAll());
 }
Exemplo n.º 28
0
 public List <Module> GetModules()
 {
     return(repository.GetAll());
 }
Exemplo n.º 29
0
 public List <Module> LoadModules()
 {
     return(_moduleRepository.GetAll().ToList());
 }
Exemplo n.º 30
0
        /// <summary>
        /// Get a list of Programs that required to train a Trainee
        /// </summary>
        /// <param name="missingCompetencies">A array id of competencies are missing from a specific Trainee</param>
        /// <returns>List of Programs</returns>
        protected virtual List <ProgramDTO> FindAllRequiredProgram(int[] missingCompetencies)
        {
            try
            {
                List <ProgramDTO> listProgram = new List <ProgramDTO>();

                #region Get all required module
                List <ModuleDTO> requiredModuleDTOs = new List <ModuleDTO>();
                var modules = _moduleRepository.GetAll();
                foreach (Module module in modules.ToList())
                {
                    if (module.ArrayOfTrainingCompetencies.Intersect(missingCompetencies).Any())
                    {
                        ModuleDTO requiredModuleDTO = new ModuleDTO(
                            module.Id, module.ArrayOfTrainingCompetencies.ToList(), module.AreaOfObjective,
                            module.TypeId, module.Title, module.Objectives, module.TopicsCovered, module.Exercises,
                            module.Theory, module.Pratical, module.Methods, module.ReferencesDoc,
                            module.ExamInclude, module.RoomOrEquipment, module.LearningTransfer, module.ExpirationDate,
                            module.TargetGroup, module.PersonId);

                        requiredModuleDTOs.Add(requiredModuleDTO);
                    }
                }

                #endregion

                #region Get all program in database

                //The list that hold all the Program in database
                List <ProgramDTO> allProgramDTOs = new List <ProgramDTO>();

                var programs = _programRepository.GetAll();

                foreach (Program program in programs.ToList())
                {
                    ProgramDTO programDTO = new ProgramDTO(program.Id, program.ProgramTitle,
                                                           program.ArrayOfIncludedModules.ToList(), program.ArrayOfNeedByPotentialTrainees.ToList()
                                                           );

                    allProgramDTOs.Add(programDTO);
                }

                #endregion

                #region Get the list of Program included required Modules

                //The list that hold all Program included required Modules
                List <ProgramDTO> requiredPrograms = new List <ProgramDTO>();
                foreach (ProgramDTO program in allProgramDTOs)
                {
                    bool require = false;
                    foreach (ModuleDTO module in requiredModuleDTOs)
                    {
                        for (int i = 0; i < program.ModulesIncluded.ToArray().Length; i++)
                        {
                            if (module.ModuleID == program.ModulesIncluded[i])
                            {
                                require = true;
                                break;
                            }
                        }
                        if (require)
                        {
                            break;
                        }
                    }
                    if (require)
                    {
                        requiredPrograms.Add(program);
                    }
                }

                #endregion

                //Remove duplicate Programs in the requiredPrograms list and return it
                listProgram = requiredPrograms.GroupBy(program => program.ProgramID)
                              .Select(program => program.First()).ToList();

                return(listProgram);
            }
            catch
            {
                return(null);
            }
        }