public void GenerateManagementNotifications(string appTempDirectory, int reportingDay)
        {
            logger.Info("Reading system settings");
            string emailClientIP    = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_PROXY_SERVER);
            string ownerEmailID     = ProcessorHelper.GetSettingsValue(ProcessorHelper.CONTRACTOR_REQ_EMAIL_OWNER);
            string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\PODWiseEmployees.html";
            string toEmailID        = null;
            string outlookPwd       = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_OWNERS_PASSWORD);
            string emailSubject     = "RMT Alert - Please Confirm, Employees Under your POD";

            try
            {
                logger.Info("Deleting old files");
                FilesHandler.RemoveAllFilesFromDirectory(appTempDirectory);
            }
            catch (Exception exp)
            {
                logger.Error(exp);
            }

            List <PracticeDto> pods = practiceRepository.GetAll().ToList();

            logger.Info($"There are {pods.Count} PODs");
            foreach (PracticeDto pod in pods)
            {
                logger.Info("Generating CSV file");
                string attachmentFilePath = CreateFileAttachment(appTempDirectory, pod.PracticeID);

                logger.Info("Generating email content");
                string emailContent   = GenerateEmailBody(templateFilePath, pod.PracticeID, pod.PracticeName, pod.ManagerName, reportingDay);
                string managerEmailID = null;
                if (pod.ManagerID.HasValue)
                {
                    managerEmailID = empService.GetByID(pod.ManagerID.Value)?.EmailID;
                }

                if (string.IsNullOrWhiteSpace(managerEmailID))
                {
                    managerEmailID = dmEmailID;
                }
                toEmailID = managerEmailID;

                logger.Info("Sending email with attachment to " + pod.ManagerName);
                EmailHandler emailHandler = new EmailHandler(ownerEmailID, outlookPwd);
                emailHandler.SendEmail(emailClientIP, toEmailID, emailSubject, emailContent, dmEmailID, attachmentFilePath, System.Net.Mail.MailPriority.High);

                WindowsServiceSettingsDto windowsService = new WindowsServiceSettingsDto
                {
                    ExecutionInterval = "Monthly",
                    ServiceID         = (int)WindowsServices.ManagementNotifications,
                    ServiceName       = WindowsServices.ManagementNotifications.ToString(),
                };
                settingRepository.UpdateWindowsServiceStatus(windowsService);
            }
        }
コード例 #2
0
        public void should_Enroll_Device_Site()
        {
            var p1 = Practice.Enroll(Guid.NewGuid(), "1", "Fac1");
            var p2 = Practice.Enroll(Guid.NewGuid(), "2", "Fac2");

            var practices = new List <Practice> {
                p1, p2
            };

            _activationService.EnrollDevicePractice(practices);
            var ids = practices.Select(x => x.Id);
            var pr  = new PracticeRepository(_context);
            var ps  = pr.GetAll().Where(x => ids.Contains(x.Id)).ToList();

            Assert.True(ps.Count == 2);
        }
コード例 #3
0
        public void SetUp()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();
            var connectionString = config["connectionStrings:realConnection"];

            var options = new DbContextOptionsBuilder <LiveHAPIContext>()
                          .UseSqlServer(connectionString)
                          .Options;

            _context = new LiveHAPIContext(options);
            // TestDataCreator.Init(_context);
            var pr = new PracticeRepository(_context);

            _practice = pr.GetAll().First();

            _activationService = new ActivationService(new PracticeRepository(_context), new PracticeActivationRepository(_context), new MasterFacilityRepository(_context));
        }