示例#1
0
        } // findClients

        public RiskMap projectRiskMap(Guid?orgId, Guid projId)
        {
            using (var rmRepo = new RiskMapRepository(orgId)) {
                var riskMap = projects.Where(s => s.Id == projId).Single().RiskFramework;
                return(rmRepo.RiskMap(riskMap));
            } // using ...
        }     // projectRiskMap
        public static ReportData <Row> build(Guid orgId, Guid projId, DateTime?startDate, DateTime?endDate)
        {
            var repo     = new ReportsRepository();
            var allRisks = new RiskMapRepository(orgId).RisksCurrentAndDeleted();

            var clients = repo.findClients(projId, null).Include(c => c.Address);
            var rows    = new List <Row>();

            foreach (var client in clients)
            {
                if (!Reports.activeBetweenDates(client, startDate, endDate))
                {
                    continue;
                }
                if (client.RiskAssessments == null || client.RiskAssessments.Count == 0)
                {
                    continue;
                }

                var postCode = Reports.firstPartOfPostCode(client);
                foreach (var rad in client.RiskAssessments)
                {
                    var row = findRow(rows, postCode);
                    row.bump();
                    var assessed = rad.Risks().Select(riskId => allRisks.Where(r => r.Id == riskId).Single().Title).ToList();
                    row.assessed(assessed);
                    var resolved = rad.ResolvedRisks().Select(riskId => allRisks.Where(r => r.Id == riskId).Single().Title).ToList();
                    row.resolved(resolved);
                    var managed = rad.ManagedRisks().Select(riskId => allRisks.Where(r => r.Id == riskId).Single().Title).ToList();
                    row.managed(managed);
                } // foreach RiskAssessment
            }     // foreach Client

            rows.Sort((lhs, rhs) => postCodeOrder(lhs.PostCode, rhs.PostCode));

            var reportData = new ReportData <Row>(rows);

            reportData.Put("project", repo.projectName(projId));
            reportData.Put("startDate", Reports.formatDate(startDate));
            reportData.Put("endDate", Reports.formatDate(endDate));
            reportData.Put("csvurl", Reports.csvUrl("opendata", orgId, projId, null, startDate, endDate));
            return(reportData);
        } // build
示例#3
0
        public static ReportData <ThemeRow> build(Guid orgId, Guid projId, Guid?locId, DateTime?startDate, DateTime?endDate)
        {
            ProjectOrganisationRepository poRepo = new ProjectOrganisationRepository();
            RiskMapRepository             rmRepo = new RiskMapRepository(orgId);
            ClientRepository clientRepo          = new ClientRepository();

            ProjectOrganisation po      = poRepo.Get(orgId);
            Project             project = poRepo.FindProject(orgId, projId);
            RiskMap             riskMap = rmRepo.RiskMap(project.RiskFramework);
            IList <ClientData>  clients = clientRepo.ProjectClientData(projId, locId);

            IDictionary <Guid, ResolutionRow> report = new Dictionary <Guid, ResolutionRow>();

            foreach (var risk in riskMap.Risks)
            {
                report.Add(risk.Id, new ResolutionRow(risk));
            }

            HashSet <Guid> clientsSeen = new HashSet <Guid>();

            foreach (var client in clients)
            {
                if (client.RiskAssessments == null || client.RiskAssessments.Count == 0)
                {
                    continue;
                }
                foreach (var rad in client.RiskAssessments)
                {
                    if (Reports.outOfBounds(rad.Timestamp, startDate, endDate))
                    {
                        continue;
                    }
                    foreach (var riskId in rad.Risks())
                    {
                        ResolutionRow row = report[riskId];
                        row.Open(client);
                    }
                    foreach (var riskId in rad.ResolvedRisks())
                    {
                        ResolutionRow row = report[riskId];
                        row.Close(client);
                    }

                    clientsSeen.Add(client.Id);
                } // foreach RiskAssessment
            }     // foreach Client

            IList <ThemeRow> themes = new List <ThemeRow>();

            foreach (var theme in riskMap.AllThemes())
            {
                var catRows = buildCatRows(theme, riskMap, report);
                themes.Add(new ThemeRow(theme, catRows));
            } // foreach

            ReportData <ThemeRow> reportData =
                new ReportData <ThemeRow>(themes);

            reportData.Put("clientCount", clientsSeen.Count.ToString());
            reportData.Put("csvurl", Reports.csvUrl("resolution", orgId, projId, locId, startDate, endDate));

            return(reportData);
        } // resolutionReport
 public IEnumerable<RiskMap> OrganisationRiskMaps(Guid id) {
   var rmRepo = new RiskMapRepository(id);
   return rmRepo.RiskMaps();
 } // OrganisationRiskMaps
 protected RiskMap riskMap(Guid id)
 {
     using (var riskMapRepo = new RiskMapRepository(null))
         return(riskMapRepo.RiskMap(id));
 } // RiskMap
        } // project

        protected Guid riskMapId()
        {
            using (var riskMapRepo = new RiskMapRepository(null))
                return(riskMapRepo.RiskMaps().First().Id);
        }