Ejemplo n.º 1
0
 private static string GetReportFileName(IOrganisation organisation, EmployerReport report)
 {
     if (report is ResumeSearchActivityReport)
     {
         return("Resume search activity - " + organisation.FullName + ".pdf");
     }
     return("Job board activity - " + organisation.FullName + ".pdf");
 }
Ejemplo n.º 2
0
        public void AddNoActivityReport(EmployerReport report)
        {
            if (report == null)
            {
                throw new ArgumentNullException("report");
            }

            _noActivity.Add(report.Name);
        }
Ejemplo n.º 3
0
        private static string GetResultMessage(EmployerReport report, IOrganisation organisation, string result)
        {
            if (report is CandidateCareReport)
            {
                return(string.IsNullOrEmpty(result)
                    ? string.Format("{0} has not referred any members during this reporting period.", HttpUtility.HtmlEncode(organisation.FullName))
                    : string.Format("{0} has referred {1} member{2} during this reporting period.", HttpUtility.HtmlEncode(organisation.FullName), result, result == "1" ? "" : "s"));
            }

            return(null);
        }
Ejemplo n.º 4
0
 private static string GetTemplateFileName(EmployerReport report, bool includeCredits)
 {
     if (report is JobBoardActivityReport)
     {
         return(includeCredits ? "JobBoardActivity.xls" : "JobBoardActivityNoCredits.xls");
     }
     if (report is ResumeSearchActivityReport)
     {
         return(includeCredits ? "ResumeSearchActivity.xls" : "ResumeSearchActivityNoCredits.xls");
     }
     return(null);
 }
Ejemplo n.º 5
0
        private static void UpdateReport(EmployerReport report, CheckBoxValue includeChildOrganisations, CheckBoxValue includeDisabledUsers, string promoCode, CheckBoxValue sendToAccountManager, CheckBoxValue sendToClient)
        {
            if (report is ResumeSearchActivityReport)
            {
                UpdateReport((ResumeSearchActivityReport)report, includeDisabledUsers);
            }
            if (report is CandidateCareReport)
            {
                UpdateReport((CandidateCareReport)report, promoCode);
            }

            UpdateReport(report, includeChildOrganisations, sendToAccountManager, sendToClient);
        }
Ejemplo n.º 6
0
 private static void UpdateReport(EmployerReport report, CheckBoxValue includeChildOrganisations, CheckBoxValue sendToAccountManager, CheckBoxValue sendToClient)
 {
     if (includeChildOrganisations != null)
     {
         report.IncludeChildOrganisations = includeChildOrganisations.IsChecked;
     }
     if (sendToAccountManager != null)
     {
         report.SendToAccountManager = sendToAccountManager.IsChecked;
     }
     if (sendToClient != null)
     {
         report.SendToClient = sendToClient.IsChecked;
     }
 }
Ejemplo n.º 7
0
        ReportRunOutcome IExecuteEmployerReportsCommand.RunReport(EmployerReport report, bool includeCredits, IOrganisation organisation, IAdministrator accountManager, DateRange dateRange, Stream xlsOutput, Stream pdfOutput, StringBuilder stringOutput)
        {
            if (organisation == null)
            {
                throw new ArgumentNullException("organisation");
            }
            if (report.ReportAsFile && xlsOutput == null && pdfOutput == null)
            {
                throw new ArgumentException("At least one output stream must be supplied.");
            }

            using (var templateStream = GetTemplateStream(report, includeCredits))
            {
                XlsFile excelFile = null;
                if (templateStream != null)
                {
                    excelFile = new XlsFile(true);
                    excelFile.Open(templateStream);
                    FixHyperlink(excelFile, 1, "mailto:%3c%23AccountManagerEmail%3e", "mailto:" + HttpUtility.UrlEncode(accountManager.EmailAddress.Address));
                }

                var outcome = Run(report, includeCredits, organisation, accountManager, dateRange, excelFile, stringOutput);

                if (excelFile != null && (outcome == ReportRunOutcome.FileResult || report.ReportFileEvenIfNoResults))
                {
                    if (xlsOutput != null)
                    {
                        excelFile.Save(xlsOutput);
                    }

                    if (pdfOutput != null)
                    {
                        using (var export = new FlexCelPdfExport(excelFile, false))
                        {
                            export.Properties.Author = "LinkMe.com.au";
                            export.Export(pdfOutput);
                        }
                    }
                }

                return(outcome);
            }
        }
Ejemplo n.º 8
0
        private void TestResults(IUser administrator, IOrganisation organisation, EmployerReport report, string extension, string contentType, HtmlButtonTester button)
        {
            // Create a result.

            var startDate = DateTime.Now.AddDays(-30).Date;
            var endDate   = DateTime.Now.AddDays(10).Date;

            LogIn(administrator);
            var url = GetReportUrl(organisation, report.GetType().Name);

            Get(url);

            _startDateTextBox.Text = startDate.ToString("dd/MM/yyyy");
            _endDateTextBox.Text   = endDate.ToString("dd/MM/yyyy");
            button.Click();

            // Not sure how to check the contents but look for the appropriate headers etc to at least make sure a report was generated.

            Assert.AreEqual(contentType, Browser.ResponseHeaders["Content-Type"]);
            Assert.AreEqual("attachment; filename=\"" + organisation.FullName.Replace(Organisation.FullNameSeparator, '-') + " - " + report.Name + extension + "\"", Browser.ResponseHeaders["Content-Disposition"]);
        }
Ejemplo n.º 9
0
        private ReportRunOutcome Run(EmployerReport report, bool includeCredits, IOrganisation organisation, IAdministrator accountManager, DateRange dateRange, XlsFile excelFile, StringBuilder stringOutput)
        {
            ReportRunner runner = null;

            if (report is JobBoardActivityReport)
            {
                runner = new JobBoardActivityReportRunner(_creditReportsQuery, _jobAdReportsQuery, _recruitersQuery, _organisationsQuery, (JobBoardActivityReport)report, includeCredits, organisation, accountManager, dateRange);
            }
            if (report is ResumeSearchActivityReport)
            {
                runner = new ResumeSearchActivityReportRunner(_creditReportsQuery, (ResumeSearchActivityReport)report, includeCredits, organisation, accountManager, dateRange);
            }
            if (report is CandidateCareReport)
            {
                runner = new CandidateCareReportRunner((CandidateCareReport)report, organisation, accountManager, dateRange);
            }

            return(runner != null
                ? runner.Run(_connectionFactory, excelFile, stringOutput)
                : ReportRunOutcome.NoResults);
        }
Ejemplo n.º 10
0
 private static string GetFilename(EmployerReport report, IOrganisation organisation, string extension)
 {
     return(FileSystem.GetValidFileName(report.Name + " - " + organisation.FullName + extension));
 }
Ejemplo n.º 11
0
        private IEnumerable <TemplateEmail> RunReport(EmployerReport report, VerifiedOrganisation organisation, DateTime startDate, DateTime endDate, IAdministrator accountManager)
        {
            // First work out who we need to send it to

            var contactDetails = report.SendToClient
                ? _organisationsQuery.GetEffectiveContactDetails(organisation.Id)
                : null;

            var accountManagerEmail = report.SendToAccountManager && accountManager.IsEnabled
                ? new AccountManagerReportEmail((ICommunicationUser)accountManager, report, organisation, startDate, endDate)
                : null;

            if (contactDetails == null && accountManagerEmail == null)
            {
                return(new TemplateEmail[0]); // No-one to send the report to.
            }
            // Run the report and attach it to the email(s).

            string fileName = GetFilename(report, organisation, ".pdf");

            var pdfStream = new MemoryStream();
            var sb        = new StringBuilder();
            var outcome   = _executeEmployerReportsCommand.RunReport(report, true, organisation, accountManager, new DateRange(startDate, endDate), null, pdfStream, sb);

            if (outcome == ReportRunOutcome.InvalidParameters)
            {
                return(new TemplateEmail[0]);
            }

            if (accountManagerEmail != null)
            {
                switch (outcome)
                {
                case ReportRunOutcome.TextResultOnly:
                    accountManagerEmail.AddCustomHtml(GetResultsHtml(report, organisation, sb.ToString()));
                    break;

                case ReportRunOutcome.NoResults:
                    accountManagerEmail.AddNoActivityReport(report);
                    break;
                }
            }

            var allEmails = new List <TemplateEmail>();

            if (accountManagerEmail != null)
            {
                allEmails.Add(accountManagerEmail);
            }

            if (contactDetails != null && (report.ReportAsFile || sb.Length != 0))
            {
                if (!string.IsNullOrEmpty(contactDetails.EmailAddress))
                {
                    allEmails.Add(CreateEmail(
                                      new Employer
                    {
                        EmailAddress = new EmailAddress {
                            Address = contactDetails.EmailAddress
                        },
                        FirstName = contactDetails.FirstName,
                        LastName  = contactDetails.LastName,
                        IsEnabled = true
                    },
                                      (ICommunicationUser)accountManager,
                                      report,
                                      organisation,
                                      startDate,
                                      endDate,
                                      outcome,
                                      sb.ToString(),
                                      _memberCount));
                }

                if (!string.IsNullOrEmpty(contactDetails.SecondaryEmailAddresses))
                {
                    var secondaryEmailAddresses = TextUtil.SplitEmailAddresses(contactDetails.SecondaryEmailAddresses);
                    if (secondaryEmailAddresses != null)
                    {
                        foreach (var secondaryEmailAddress in secondaryEmailAddresses)
                        {
                            allEmails.Add(CreateEmail(
                                              new Employer
                            {
                                EmailAddress = new EmailAddress {
                                    Address = secondaryEmailAddress
                                },
                                IsEnabled = true
                            },
                                              (ICommunicationUser)accountManager,
                                              report,
                                              organisation,
                                              startDate,
                                              endDate,
                                              outcome,
                                              sb.ToString(),
                                              _memberCount));
                        }
                    }
                }
            }

            if (outcome == ReportRunOutcome.FileResult || report.ReportFileEvenIfNoResults)
            {
                foreach (var email in allEmails)
                {
                    if (email != null)
                    {
                        // The same Stream can't be used for multiple attachments, so clone it.
                        var attachmentStream = new MemoryStream(pdfStream.ToArray());
                        email.AddAttachments(new[] { new ContentAttachment(attachmentStream, fileName, MediaType.Pdf) });
                    }
                }
            }

            return(allEmails);
        }
Ejemplo n.º 12
0
 void IEmployerReportsCommand.UpdateReport(EmployerReport report)
 {
     _reportsCommand.UpdateReport(report);
 }
Ejemplo n.º 13
0
 private void TestPdfResults(Administrator administrator, IOrganisation organisation, EmployerReport report)
 {
     TestResults(administrator, organisation, report, ".pdf", "application/pdf", _downloadPdfButton);
 }
Ejemplo n.º 14
0
 private void TestXlsResults(Administrator administrator, IOrganisation organisation, EmployerReport report)
 {
     TestResults(administrator, organisation, report, ".xls", "application/vnd.ms-excel", _downloadButton);
 }
        public async Task <EmployerReportEntity> GetEmployerReportList(string groupNum, DateTime periodBegin, DateTime periodEnd)
        {
            try
            {
                using (var connection = dbConnection.Database.Connection)
                {
                    if (connection != null && connection.State != ConnectionState.Open)
                    {
                        await connection.OpenAsync();
                    }

                    DbCommand command = connection.CreateCommand();
                    command.CommandText = Constants.EXEC + ConfigurationManager.AppSettings["PrsSchema"] + Constants.DOT + ConfigurationManager.AppSettings["GetEmployerReport"] +
                                          Constants.SPACE + Constants.Group_NUM + Constants.COMMA + Constants.PERIOD_BEGIN + Constants.COMMA + Constants.PERIOD_END;

                    command.Parameters.AddRange(new[]
                    {
                        new SqlParameter {
                            ParameterName = Constants.Group_NUM, Value = groupNum
                        },
                        new SqlParameter {
                            ParameterName = Constants.PERIOD_BEGIN, Value = periodBegin
                        },
                        new SqlParameter {
                            ParameterName = Constants.PERIOD_END, Value = periodEnd
                        }
                    });

                    command.CommandTimeout = 0;

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        if (reader.HasRows)
                        {
                            EmployerReport employerReport = new EmployerReport
                            {
                                TitlePage                   = await GetGroupReportAsync <TitlePage>(dbConnection, reader),
                                FinancialSummary            = await GetGroupReportAsync <FinancialSummary>(dbConnection, reader),
                                PhmpEligibility             = await GetGroupReportAsync <PhmpEligibility>(dbConnection, reader),
                                ParticipantContacts         = await GetGroupReportAsync <ParticipantContacts>(dbConnection, reader),
                                RealTimeTelemed             = await GetGroupReportAsync <RealTimeTelemed>(dbConnection, reader),
                                DnaTesting                  = await GetGroupReportAsync <DnaTesting>(dbConnection, reader),
                                RealTimeChoices             = await GetGroupReportAsync <RealTimeChoices>(dbConnection, reader),
                                RealTimeWellness            = await GetGroupReportAsync <RealTimeWellness>(dbConnection, reader),
                                RecentScreeningEventSummary = await GetGroupReportAsync <RecentScreeningEventSummary>(dbConnection, reader),
                                ChronicConditions           = await GetGroupReportAsync <ChronicConditions>(dbConnection, reader),
                                HealthRiskAssessment        = await GetGroupReportAsync <HealthRiskAssessment>(dbConnection, reader),
                                HealthScreenings            = await GetGroupReportAsync <HealthScreenings>(dbConnection, reader),
                                IndemnityBenefit            = await GetGroupReportAsync <IndemnityBenefit>(dbConnection, reader)
                            };

                            connection.Close();
                            EmployerReportEntity groupEntitiesList = EntityMapper <EmployerReport, EmployerReportEntity> .MapEntity(employerReport);

                            return(groupEntitiesList);
                        }
                        return(null);
                    }
                }
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 16
0
 public ReportStatus(EmployerReport report, bool isActivity)
 {
     Report     = report;
     IsActivity = isActivity;
 }
Ejemplo n.º 17
0
 private static Stream GetTemplateStream(EmployerReport report, bool includeCredits)
 {
     return(report.ReportAsFile
         ? Assembly.GetExecutingAssembly().GetManifestResourceStream("LinkMe.Apps.Agents.Reports.Employers." + GetTemplateFileName(report, includeCredits))
         : null);
 }