public override void ExecuteTask() { const string method = "ExecuteTask"; // Run all reports for the last calendar month. var now = DateTime.Now; var startDate = new DateTime(now.Year, now.Month, 1).AddMonths(-1); var endDate = new DateTime(now.Year, now.Month, 1).AddDays(-1); var reportsToRun = (from r in _employerReportsQuery.GetReportsToRun(startDate, endDate) group r by r.ClientId).ToDictionary(r => r, r => r.ToList()); if (reportsToRun.Count == 0) { EventSource.Raise(Event.Information, method, string.Format("There are no customer reports to run for time period from {0} to {1}.", startDate.ToString(Common.Constants.DATE_FORMAT), endDate.ToString(Common.Constants.DATE_FORMAT))); return; } EventSource.Raise(Event.Information, method, string.Format("Running customer reports for {0} organisations for time period from {1} to {2}.", reportsToRun.Count, startDate.ToString(Common.Constants.DATE_FORMAT), endDate.ToString(Common.Constants.DATE_FORMAT))); _memberCount = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now); int emailCount = 0; foreach (var reportToRun in reportsToRun) { emailCount += SendReports(reportToRun.Value, startDate, endDate); } EventSource.Raise(Event.Information, method, string.Format("{0} report emails were sent.", emailCount)); }
public void TestGetMembers() { _memberAccountsCommand.CreateTestMember(1); _memberAccountsCommand.CreateTestMember(2); _memberAccountsCommand.CreateTestMember(3); Assert.AreEqual(3, _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now)); }
public void TestNewEmployerWelcomeEmailLinks() { var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0)); // Create the email. var candidates = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now); _emailsCommand.TrySend(new NewEmployerWelcomeEmail(employer, employer.GetLoginId(), employer.GetPassword(), candidates)); // Check the email. var email = _emailServer.AssertEmailSent(); var links = email.GetHtmlView().GetLinks(); Assert.AreEqual(3, links.Count); var definition = typeof(NewEmployerWelcomeEmail).Name; AssertLink(definition, employer, _changePasswordUrl, links[0]); AssertLink(definition, new ReadOnlyApplicationUrl("~/employers/resources"), links[1]); AssertLink(definition, _contactUsUrl, links[2]); // Check the tracking pixel. var link = email.GetHtmlView().GetImageLinks().Last(); AssertTrackingLink(link); }
public ActionResult ChangePassword(Guid id, EmployerLoginModel employerLogin, [Bind(Include = "SendPasswordEmail")] CheckBoxValue sendPasswordEmail) { var employer = _employersQuery.GetEmployer(id); if (employer == null) { return(NotFound("employer", "id", id)); } var credentials = _loginCredentialsQuery.GetCredentials(employer.Id); if (credentials == null) { return(NotFound("employer", "id", id)); } try { // Validate. employerLogin.SendPasswordEmail = sendPasswordEmail.IsChecked; employerLogin.Validate(); // Update. credentials.PasswordHash = LoginCredentials.HashToString(employerLogin.Password); credentials.MustChangePassword = true; _loginCredentialsCommand.UpdateCredentials(employer.Id, credentials, User.Id().Value); string message; if (employerLogin.SendPasswordEmail) { var members = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now); _emailsCommand.TrySend(new NewEmployerWelcomeEmail(employer, credentials.LoginId, employerLogin.Password, members)); message = "The password has been reset and an email has been sent."; } else { message = "The password has been reset."; } return(RedirectToRouteWithConfirmation(EmployersRoutes.Edit, new { id }, message)); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } employerLogin.LoginId = credentials.LoginId; return(View("Edit", new UserModel <IEmployer, EmployerLoginModel> { User = _employersQuery.GetEmployer(id), UserLogin = employerLogin })); }
private FeaturedStatistics GetFeaturedStatistics() { var today = DateTime.Today; var dateRange = new DateRange(today.AddDays(-7), today); return(new FeaturedStatistics { CreatedJobAds = _jobAdReportsQuery.GetCreatedJobAds(dateRange), Members = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now), MemberSearches = _searchReportsQuery.GetAllMemberSearches(dateRange), MemberAccesses = _employerMemberAccessReportsQuery.GetMemberAccesses(dateRange) }); }
private void UpdateFeaturedStatistics(int days) { var today = DateTime.Today; var dateRange = new DateRange(today.AddDays(-1 * days), today); var statistics = new FeaturedStatistics { CreatedJobAds = _jobAdReportsQuery.GetCreatedJobAds(dateRange), Members = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now), MemberSearches = _memberSearchReportsQuery.GetAllMemberSearches(dateRange), MemberAccesses = _employerMemberAccessReportsQuery.GetMemberAccesses(dateRange) }; _featuredCommand.UpdateFeaturedStatistics(statistics); }
private void CreateEmployer(IOrganisation organisation, CreateEmployerModel model) { var employer = new Employer { Organisation = organisation, SubRole = model.SubRole, EmailAddress = new EmailAddress { Address = model.EmailAddress, IsVerified = true }, FirstName = model.FirstName, LastName = model.LastName, JobTitle = model.JobTitle, PhoneNumber = _phoneNumbersQuery.GetPhoneNumber(model.PhoneNumber, ActivityContext.Location.Country), }; if (model.IndustryId != null) { employer.Industries = new List <Industry> { _industriesQuery.GetIndustry(model.IndustryId.Value) } } ; // Create the account, where the password must be changed at next login. var credentials = new LoginCredentials { LoginId = model.LoginId, Password = model.Password, PasswordHash = LoginCredentials.HashToString(model.Password), MustChangePassword = true, }; _employerAccountsCommand.CreateEmployer(employer, credentials); var members = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now); _emailsCommand.TrySend(new NewEmployerWelcomeEmail(employer, model.LoginId, model.Password, members)); }
DailyReport IDailyReportsQuery.GetDailyReport(DayRange day) { var week = new DateTimeRange(day.Start.Value.AddDays(-7), day.End.Value); var month = new DateTimeRange(day.Start.Value.AddMonths(-1), day.End.Value); var web = _channelsQuery.GetChannel("Web"); var api = _channelsQuery.GetChannel("API"); var channels = new[] { web, api }; var userTypes = new[] { UserType.Member, UserType.Employer, UserType.Administrator, UserType.Custodian }; return(new DailyReport { Day = day, OpenJobAds = _jobAdReportsQuery.GetOpenJobAds(), ResumeSearchAlerts = _memberSearchReportsQuery.GetMemberSearchAlerts(), JobSearchAlerts = _jobAdSearchReportsQuery.GetJobAdSearchAlerts(), JobSearches = _jobAdSearchReportsQuery.GetJobAdSearches(day), InternalJobApplications = _jobAdReportsQuery.GetInternalApplications(day), ExternalJobApplications = _jobAdReportsQuery.GetExternalApplications(day), InvitationsSent = _networkingReportsQuery.GetInvitationsSent(day), InvitationsAccepted = _networkingReportsQuery.GetInvitationsAccepted(day), AcceptanceRateLast48Hours = (int)_networkingReportsQuery.Get48HourInvitationAcceptancePercent(), AcceptanceRatePreviousMonth = (int)_networkingReportsQuery.GetMonthlyInvitationAcceptancePercent(), MemberReport = new MemberReport { Total = _accountReportsQuery.GetUsers(UserType.Member, day.End.Value), Enabled = _accountReportsQuery.GetEnabledUsers(UserType.Member, day.End.Value), Active = _accountReportsQuery.GetActiveUsers(UserType.Member, day.End.Value), New = _accountReportsQuery.GetNewUsers(UserType.Member, day), }, ResumeReport = new ResumeReport { Total = _resumeReportsQuery.GetResumes(day.End.Value), Searchable = _resumeReportsQuery.GetSearchableResumes(day.End.Value), New = _resumeReportsQuery.GetNewResumes(day), Uploaded = _resumeReportsQuery.GetUploadedResumes(day), Reloaded = _resumeReportsQuery.GetReloadedResumes(day), Edited = _resumeReportsQuery.GetEditedResumes(day), Updated = _resumeReportsQuery.GetUpdatedResumes(day), }, // Logins. DailyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, day) }).ToDictionary(x => x.UserType, x => x.LogIns), WeeklyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, week) }).ToDictionary(x => x.UserType, x => x.LogIns), MonthlyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, month) }).ToDictionary(x => x.UserType, x => x.LogIns), // Member search reports. MemberSearchReports = (from c in channels select new { c.Name, Report = new MemberSearchReport { TotalSearches = _memberSearchReportsQuery.GetMemberSearches(c, day), FilterSearches = _memberSearchReportsQuery.GetFilterMemberSearches(c, day), SavedSearches = _memberSearchReportsQuery.GetSavedMemberSearches(c, day), AnonymousSearches = _memberSearchReportsQuery.GetAnonymousMemberSearches(c, day), } }).ToDictionary(x => x.Name, x => x.Report), MemberViewingReports = (from c in channels select new { c.Name, Report = _employerMemberAccessReportsQuery.GetEmployerMemberViewingReport(c, day), }).ToDictionary(x => x.Name, x => x.Report), MemberAccessReports = (from c in channels select new { c.Name, Report = _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(c, day), }).ToDictionary(x => x.Name, x => x.Report), // Others. OrderReports = _orderReportsQuery.GetOrderReports(day), CommunciationReports = GetCommunicationReports(day), PromotionCodeReports = _registrationReportsQuery.GetPromotionCodeReports(day).ToDictionary(x => x.Key, x => x.Value), JobAdIntegrationReports = GetJobAdIntegrationReports(day), }); }