public SolutionEx BySolution(string solutionId) { return(GetInternal(() => { var retval = new SolutionEx { Solution = _solutionDatastore.ById(solutionId), TechnicalContact = _technicalContactDatastore.BySolution(solutionId).ToList(), ClaimedCapability = _claimedCapabilityDatastore.BySolution(solutionId).ToList(), ClaimedStandard = _claimedStandardDatastore.BySolution(solutionId).ToList() }; // populate Evidence + Review retval.ClaimedCapabilityEvidence = retval.ClaimedCapability .SelectMany(cc => _claimedCapabilityEvidenceDatastore.ByClaim(cc.Id)) .SelectMany(x => x) .ToList(); retval.ClaimedCapabilityReview = retval.ClaimedCapabilityEvidence .SelectMany(cce => _claimedCapabilityReviewsDatastore.ByEvidence(cce.Id)) .SelectMany(x => x) .ToList(); retval.ClaimedStandardEvidence = retval.ClaimedStandard .SelectMany(cs => _claimedStandardEvidenceDatastore.ByClaim(cs.Id)) .SelectMany(x => x) .ToList(); retval.ClaimedStandardReview = retval.ClaimedStandardEvidence .SelectMany(cse => _claimedStandardReviewsDatastore.ByEvidence(cse.Id)) .SelectMany(x => x) .ToList(); return retval; })); }
public void PrepareForSolution(IClaimsInfoProvider claimsInfoProvider, string solutionId) { GetInternal(() => { if (_env.IsDevelopment() && _isFakeSharePoint) { LogInformation($"PrepareForSolution disabled in 'test' Development environment"); return(0); } LogInformation($"PrepareForSolution: solutionId: {solutionId}"); var soln = _solutionsDatastore.ById(solutionId); if (soln == null) { throw new KeyNotFoundException($"Could not find solution: {solutionId}"); } var org = _organisationsDatastore.ById(soln.OrganisationId); var claimedCapNames = _capabilitiesImplementedDatastore .BySolution(solutionId) .Select(x => CleanupFileName(_capabilitiesDatastore.ById(x.CapabilityId).Name)); var claimedNameStds = _standardsApplicableDatastore .BySolution(solutionId) .Select(x => CleanupFileName(_standardsDatastore.ById(x.StandardId).Name)); var capsTask = Task.Factory.StartNew(() => CreateClaimSubFolders(CreateClientContext(), SharePoint_OrganisationsRelativeUrl, CleanupFileName(org.Name), CleanupFileName(soln.Name), CleanupFileName(soln.Version), CleanupFileName(claimsInfoProvider.GetCapabilityFolderName()), claimedCapNames)); var stdsTask = Task.Factory.StartNew(() => CreateClaimSubFolders(CreateClientContext(), SharePoint_OrganisationsRelativeUrl, CleanupFileName(org.Name), CleanupFileName(soln.Name), CleanupFileName(soln.Version), CleanupFileName(claimsInfoProvider.GetStandardsFolderName()), claimedNameStds)); Task.WaitAll(capsTask, stdsTask); return(0); }); }
public IEnumerable <SolutionEx> ByCapabilities(IEnumerable <string> capIds) { var capIdsQuoted = capIds.Select(x => $"'{x}'"); var capsSet = string.Join(",", capIdsQuoted); _logger.LogInformation($"{capsSet}"); return(GetInternal(() => { // get all Frameworks var allFrameworks = _frameworkDatastore.GetAll(); // get all Solutions via frameworks var allSolns = allFrameworks .SelectMany(fw => _solutionDatastore.ByFramework(fw.Id)); // get all unique Solutions with at least all specified Capability var allSolnsCapsIds = allSolns .Where(soln => _claimedCapabilityDatastore .BySolution(soln.Id) .Select(cc => cc.CapabilityId) .Intersect(capIds) .Count() >= capIds.Count()) .Select(soln => soln.Id); var retval = allSolnsCapsIds.Select(solnId => _solutionsExDatastore.BySolution(solnId)); return retval; })); }
public IEnumerable <SearchResult> ByKeyword(string keyword) { _logger.LogInformation($"{keyword}"); return(_policy.Execute(() => { // get all Frameworks var allFrameworks = _frameworkDatastore.GetAll(); // get all Solutions via frameworks var allSolns = allFrameworks .SelectMany(fw => _solutionDatastore.ByFramework(fw.Id)); // get all Capabilities via frameworks var allCapsFrameworks = allFrameworks .SelectMany(fw => _capabilityDatastore.ByFramework(fw.Id)); // get all Capabilities with keyword var allCapsKeywordIds = allCapsFrameworks .Where(cap => cap.Name.ToLowerInvariant().Contains(keyword.ToLowerInvariant()) || cap.Description.ToLowerInvariant().Contains(keyword.ToLowerInvariant())) .Select(cap => cap.Id); // get all unique Solutions with at least one ClaimedCapability with keyword var allSolnsCapsKeyword = allSolns .Where(soln => _claimedCapabilityDatastore .BySolution(soln.Id) .Select(cc => cc.CapabilityId) .Intersect(allCapsKeywordIds) .Any()) .Distinct(); var searchResults = allSolnsCapsKeyword.Select(soln => new SearchResult { SolutionEx = _solutionExDatastore.BySolution(soln.Id), Distance = _claimedCapabilityDatastore.BySolution(soln.Id).Count() - allCapsKeywordIds.Count() }); return searchResults; })); }
public SolutionEx BySolution(string solutionId) { return(GetInternal(() => { var retval = new SolutionEx { Solution = _solutionDatastore.ById(solutionId), TechnicalContact = _technicalContactDatastore.BySolution(solutionId).ToList(), ClaimedCapability = _claimedCapabilityDatastore.BySolution(solutionId).ToList(), ClaimedStandard = _claimedStandardDatastore.BySolution(solutionId).ToList(), Organisation = _organisationsDatastore.ById(_solutionDatastore.ById(solutionId)?.OrganisationId) }; return retval; })); }
public virtual IActionResult ApiCapabilitiesImplementedBySolutionBySolutionIdGet([FromRoute][Required] string solutionId, [FromQuery] int?pageIndex, [FromQuery] int?pageSize) { IEnumerable <CapabilityImplemented> capabilitiesImplemented; int totalPages; try { capabilitiesImplemented = _datastore.BySolution(solutionId); capabilitiesImplemented = _datastore.GetPagingValues(pageIndex, pageSize, capabilitiesImplemented, out totalPages); } catch (Crm.CrmApiException ex) { return(StatusCode((int)ex.HttpStatus, ex.Message)); } return(new ObjectResult(new PaginatedListCapabilitiesImplemented() { Items = capabilitiesImplemented.ToList(), PageSize = pageSize ?? Paging.DefaultPageSize, PageIndex = pageIndex ?? Paging.DefaultIndex, TotalPages = totalPages })); }