Beispiel #1
0
        public ApplicationFormViewModel CreateFormViewModelFor(Application application)
        {
            ApplicationFormViewModel viewModel = new ApplicationFormViewModel();

            application.SetHostIdsFromHost();
            viewModel.Application = application;
            LoadViewModel(viewModel);
            if (application.SupportTeamId != null)
            {
                viewModel.SupportTeam = _supportTeamManagementService.Get(application.SupportTeamId.Value);
                if (viewModel.SupportTeam != null && viewModel.SupportTeam.SupervisorId.HasValue)
                {
                    viewModel.SupportTeamSupervisor = _personManagementService.Get(viewModel.SupportTeam.SupervisorId.Value);
                }
                if (viewModel.SupportTeamSupervisor != null && viewModel.SupportTeamSupervisor.SupervisorId.HasValue)
                {
                    viewModel.SupportTeamAdmin = _personManagementService.Get(viewModel.SupportTeamSupervisor.SupervisorId.Value);
                }
            }
            if (application.SubjectMatterExpertId != null)
            {
                viewModel.SubjectMatterExpert = _personManagementService.Get(application.SubjectMatterExpertId.Value);
            }
            return(viewModel);
        }
        public void CanGetPerson()
        {
            // Establish Context
            Person personToExpect =
                PersonInstanceFactory.CreateValidTransientPerson();

            _personRepository.Expect(r => r.Get(1))
            .Return(personToExpect);

            // Act
            Person personRetrieved =
                _personManagementService.Get(1);

            // Assert
            personRetrieved.ShouldNotBeNull();
            personRetrieved.ShouldEqual(personToExpect);
        }
Beispiel #3
0
        public ActionResult Show(int id)
        {
            Person person = _personManagementService.Get(id);

            return(View(person));
        }
Beispiel #4
0
        public void RunAudit(DateTime weekEndingDate)
        {
            string body;
            string subject;
            var    email           = new Email();
            var    emailExceptions = new List <string>();
            IList <TimeEntryAuditDto> auditList =
                _timeEntryAuditManagementService.GetIncompleteWeeklyTimeForAllUsers(weekEndingDate);

            Logger.Info("Found {0} users ");
            var sb = new StringBuilder();

            sb.Append(
                string.Format("Found {0} users in GetIncompleteWeeklyTimeForAllUsers({1}) for the following users: ",
                              auditList.Count, weekEndingDate.ToShortDateString()));
            sb.Append(Environment.NewLine);
            foreach (var dto in auditList)
            {
                sb.Append(string.Format("{0}, ", dto.UserId));
            }
            sb.Remove(sb.Length - 2, 2);
            Logger.Info(sb.ToString());

            IList <string> emailSummaryList = new List <string>();

            foreach (var dto in auditList)
            {
                //Console.WriteLine(string.Format("User: {0}, Hours worked: {1}", dto.UserId, dto.Hours));
                if (dto.UserId.HasValue)
                {
                    var ccAddress    = "";
                    var user         = _personManagementService.Get(dto.UserId.Value);
                    var emailAddress = string.Format("{0}@TucsonAz.gov", user.NovellId);
                    if (user.SupervisorId.HasValue)
                    {
                        var mgr = _personManagementService.Get(user.SupervisorId.Value);
                        if (mgr != null)
                        {
                            ccAddress = string.Format("{0}@TucsonAz.gov", mgr.NovellId);
                            //Console.WriteLine(ccAddress + " for user " + emailAddress);
                        }
                    }

                    subject = string.Format("WRMS time entry for week ending {0}", weekEndingDate.ToShortDateString());
                    body    =
                        string.Format(
                            "The WRMS system is showing {0} hour{1} of time entered for the week ending {2}.  Time should be entered into WRMS on a daily basis so that it is sure to be in by Tuesday morning.  Please enter your time and let your manager know when it is done.",
                            dto.Hours, (float.Parse(dto.Hours) == 1 ? "" : "s"), weekEndingDate.ToShortDateString());
                    //Console.WriteLine(body);
                    //Console.WriteLine();
                    var logMsg = string.Format("Sending notification to {0}", emailAddress);
                    if (!string.IsNullOrEmpty(ccAddress))
                    {
                        logMsg += string.Format(" and copying {0}", ccAddress);
                    }
                    Logger.Info(logMsg);
                    try
                    {
#if (DEBUG)
                        //email.SendNotification(subject, body, "*****@*****.**"); // FOR TESTING PURPOSES
                        Console.WriteLine(body);
                        Console.WriteLine();
#else
                        email.SendNotification(subject, body, emailAddress, ccAddress);
#endif
                        emailSummaryList.Add(string.Format("{0} (hours: {1})", user.FullName, dto.Hours));
                        _timeEntryAuditManagementService.SaveIncompleteTimeEntry(dto);
                    }
                    catch (Exception)
                    {
                        var msg = String.Format("Failed on emailAddress:{0}, ccAddress:{1};", emailAddress, ccAddress);
                        Logger.Error(msg);
                        Console.WriteLine(msg);
                        emailExceptions.Add(string.Format("{0} (Novell ID: {1})", user.FullName, user.NovellId));
                    }
                }
            }

            subject = string.Format("WRMS Late Notice Summary for week of {0}", weekEndingDate.ToShortDateString());
            if (emailSummaryList.Count == 0 && emailExceptions.Count == 0)
            {
                body = "All staff entered their WRMS hours this week!  (Either that or this app has a bug...)";
            }
            else
            {
                body =
                    emailSummaryList.Aggregate(
                        string.Format("Email notices were sent to the following people for the week of {0}:\n\n",
                                      weekEndingDate.ToShortDateString()),
                        (current, recipient) => current + (recipient + "\n"));
            }
            Logger.Info(body);
#if (DEBUG)
            email.SendNotification(subject, body, "*****@*****.**");
#else
            email.SendSummary(subject, body);
#endif

            if (emailExceptions.Count > 0)
            {
                emailExceptions.ToArray();
                string joined = string.Join("\n", emailExceptions.ToArray());
                body =
                    string.Format(
                        "Email notices not sent to the following people because of an invalid novell user id:\n\n{0}",
                        joined);
                Logger.Error(body);
                Console.WriteLine(body);
#if (DEBUG)
                email.SendNotification("WRMS Audit Email Exception", body, "*****@*****.**");
#else
                email.SendNotification("WRMS Audit Email Exception", body, "*****@*****.**");
#endif
            }
        }