Exemple #1
0
        }         // findUserRole

        private bool organisationIsValid(IdentityUser user)
        {
            using (ProjectOrganisationRepository repo_ = new ProjectOrganisationRepository()) {
                var staff = repo_.FindStaffMember(user.UserName);
                return(!staff.Organisation.IsSuspended);
            } // using ...
        }     // organisationIsValid
Exemple #2
0
        public static ReportData <Row> build(Guid orgId)
        {
            var repo     = new ProjectOrganisationRepository();
            var agencies = repo.FetchReferralAgencies(orgId);

            var rows = new List <Row>();

            foreach (var agency in agencies)
            {
                rows.Add(new Row(agency.Id, agency.Name, agency.ReviewDate));
            }

            rows.Sort(
                delegate(Row lhs, Row rhs) {
                if (!lhs.ReviewDate.HasValue)
                {
                    return(1);
                }
                if (!rhs.ReviewDate.HasValue)
                {
                    return(-1);
                }
                return(lhs.ReviewDate.Value.CompareTo(rhs.ReviewDate.Value));
            }
                );

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

            reportData.Put("agencyCount", rows.Count.ToString());

            return(reportData);
        } // build
Exemple #3
0
        } // loadTemplate

        private void sendReferralReportEmail(Client client, string reportEmail, bool sendToClient)
        {
            var poRepo  = new ProjectOrganisationRepository();
            var project = poRepo.FindProject(client.ProjectId);
            var staff   = poRepo.FindStaffMember(User.Identity.Name);

            var mailMessage = new MimeMailMessage();

            mailMessage.From = new MimeMailAddress(project.Address.Email);
            if (sendToClient)
            {
                mailMessage.To.Add(new MailAddress(client.Address.Email));
            }

            if (staff.Email != null && staff.Email.Length != 0)
            {
                mailMessage.To.Add(new MailAddress(staff.Email));
            }

            mailMessage.Subject    = "Referral Report for " + client.Name;
            mailMessage.Body       = reportEmail;
            mailMessage.IsBodyHtml = true;

            var smtpClient = smtpSender();

            smtpClient.Send(mailMessage, SendCompletedEventHandler);
        }
    } // repo()

    private Guid? organisationId() {
      var poRepo = new ProjectOrganisationRepository();
      var projectOrg = poRepo.GetByStaffMember(User.Identity.Name);

      if (projectOrg != null)
        return projectOrg.Id;
      return null; // Admin 
    } // organisationId
 protected Project project()
 {
     using (var repo = new ProjectOrganisationRepository()) {
         var org = repo.Create(TestHelper.testOrg());
         org.RiskMaps.Add(riskMapId());
         repo.Update(org);
         var proj = TestHelper.newProject("CHUNKS");
         proj.RiskFramework = riskMapId();
         return(repo.AddProject(org.Id, proj).Where(s => s.Name == proj.Name).Single());
     }
 } // project
Exemple #6
0
        } // createReferralReport

        private ReferralReport createReferralReport(Client client)
        {
            var poRepo     = new ProjectOrganisationRepository();
            var projectOrg = poRepo.GetByStaffMember(User.Identity.Name);

            var report = new ReferralReport(staffName(User.Identity.Name));

            var ra = client.CurrentRiskAssessment;

            var who = poRepo.FetchReferralAgencies(projectOrg.Id);

            foreach (var theme in ra.ThemeAssessments)
            {
                foreach (var category in theme.Categories)
                {
                    foreach (var risk in category.Risks)
                    {
                        if (risk.Status == "notAtRisk")
                        {
                            continue;
                        }

                        foreach (var agency in who)
                        {
                            foreach (var riskId in agency.AssociatedRiskIds)
                            {
                                if (riskId == risk.Id)
                                {
                                    report.add(risk.Id, agency);
                                }
                            }
                        }
                    }
                }
            }
            return(report);
        } // createReferralReport
Exemple #7
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
Exemple #8
0
        private String staffName(String userName)
        {
            var porepo = new ProjectOrganisationRepository();

            return(porepo.FindStaffMember(userName).Name);
        }