Beispiel #1
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);
        }
Beispiel #2
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