コード例 #1
0
        private void GenerateJsonforEventCustomers(Event eventData, ILogger logger)
        {
            int totalrecords;

            logger.Info("Getting event customers......");

            var eventCusomters = _eventCustomerRepository.GetMyBioCheckEventCustomers(1, 400, new MyBioCheckCustomerModelFilter {
                EventId = eventData.Id
            }, out totalrecords);

            if (eventCusomters == null || !eventCusomters.Any())
            {
                logger.Info(string.Format("No event customers found for Event Id {0} EventDate {1}", eventData.Id, eventData.EventDate));
                return;
            }

            logger.Info(string.Format("{0} event customers found.", eventCusomters.Count()));

            var customers = _customerRepository.GetCustomers(eventCusomters.Select(x => x.CustomerId).ToArray());
            var healthAssessmentAnswer = _healthAssessmentRepository.GetCustomerHealthInfoByEventCustomerIds(eventCusomters.Select(ec => ec.Id).ToArray());

            foreach (var ec in eventCusomters)
            {
                try
                {
                    var customer  = customers.Single(c => c.CustomerId == ec.CustomerId);
                    var hafAnswer = healthAssessmentAnswer.Where(c => c.EventCustomerId == ec.Id);

                    logger.Info("Started For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);

                    var bioCheckJsonViewModel = GenerateBioCheckResponseModel(ec, customer, hafAnswer, eventData, logger);

                    if (bioCheckJsonViewModel != null)
                    {
                        bioCheckJsonViewModel.ProfileId = _profileId;
                        logger.Info("Saving Request JSON For eventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        SaveRequestJson(bioCheckJsonViewModel, ec.EventId, ec.CustomerId);

                        logger.Info("Submitting Post Request For eventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        var response = _trailApiService.Post <BioCheckJsonViewModel>(bioCheckJsonViewModel);

                        if (response != null)
                        {
                            logger.Info("Saving response For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                            SaveReports(response, ec.EventId, ec.CustomerId, logger);
                        }
                        else
                        {
                            logger.Info("No Response found for EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        }
                    }
                    logger.Info("Complete For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                }
                catch (Exception exception)
                {
                    logger.Error(string.Format("Error while generating My Bio-Check Assessment Data for customer Id: {0} and EventId {1} Message: {2}, StackTrace {3}", ec.CustomerId, ec.EventId, exception.Message, exception.StackTrace));
                }
            }
        }
コード例 #2
0
        public ListModelBase <KynCustomerModel, KynCustomerModelFilter> GetKynCustomerReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var kynfilter      = filter as KynCustomerModelFilter;
            var eventCustomers = _eventCustomerRepository.GetKynEventCustomers(pageNumber, pageSize, kynfilter, out totalRecords);

            if (eventCustomers.IsNullOrEmpty())
            {
                return(new KynCustomerListModel());
            }
            var eventIds          = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray();
            var eventCustomerIds  = eventCustomers.Select(ec => ec.Id).Distinct().ToArray();
            var healthAssessments = _healthAssessmentRepository.GetCustomerHealthInfoByEventCustomerIds(eventCustomerIds);

            var healthAssessmentsOrgRoleUserIds    = healthAssessments.Where(ha => ha.DataRecorderMetaData != null && ha.DataRecorderMetaData.DataRecorderCreator != null).Select(ha => ha.DataRecorderMetaData.DataRecorderCreator.Id).ToList();
            var healthAssessmentsbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(healthAssessmentsOrgRoleUserIds.ToArray()).ToArray();
            var healthAssessmentModifiedByAgent    = _organizationRoleUserRepository.GetOrganizationRoleUsers(healthAssessmentsOrgRoleUserIds.ToArray()).ToArray();
            var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());

            var events       = _eventRepository.GetEventswithPodbyIds(eventIds);
            var pods         = _podRepository.GetPodsForEvents(eventIds);
            var appointments = _appointmentRepository.GetAppointmentsForEvents(eventIds);
            var showKyn      = kynfilter != null && kynfilter.ShowOnlyKyn;

            var orgRoleUserIds    = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();
            var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);
            var roles             = _roleRepository.GetAll();

            var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();
            var customerIds           = customers.Select(c => c.CustomerId).ToArray();
            var customTags            = _customTagRepository.GetByCustomerIds(customerIds);
            var corporateAccountNames = _corporateAccountRepository.GetEventIdCorporateAccountNamePair(eventIds);
            var hospitalPartnerNames  = _hospitalPartnerRepository.GetEventIdHospitalPartnerNamePair(eventIds);

            return(_kynCustomerReportingFactory.Create(eventCustomers, events, customers, appointments, pods, showKyn, registeredbyAgent, roles, registeredbyAgentNameIdPair, customTags, corporateAccountNames, hospitalPartnerNames,
                                                       healthAssessments, healthAssessmentsbyAgentNameIdPair, healthAssessmentModifiedByAgent));
        }
コード例 #3
0
        public void GenerateJsonforEventCustomers(Event eventData, ILogger logger)
        {
            int totalrecords;

            logger.Info("Getting event customers......");

            var eventCusomters = _eventCustomerRepository.GetMyBioCheckEventCustomers(1, 400, new MyBioCheckCustomerModelFilter {
                EventId = eventData.Id
            }, out totalrecords);

            if (eventCusomters == null || !eventCusomters.Any())
            {
                logger.Info(string.Format("No event customers found for Event Id {0} EventDate {1}", eventData.Id, eventData.EventDate));
                return;
            }

            logger.Info(string.Format("{0} event customers found.", eventCusomters.Count()));

            var eventCustomerIds = eventCusomters.Select(x => x.Id).ToArray();
            var customerIds      = eventCusomters.Select(x => x.CustomerId).ToArray();

            var          customers = _customerRepository.GetCustomers(customerIds);
            var          healthAssessmentAnswer = _healthAssessmentRepository.GetCustomerHealthInfoByEventCustomerIds(eventCustomerIds);
            var          account      = _corporateAccountRepository.GetbyEventId(eventData.Id);
            Organization organization = null;

            if (account != null)
            {
                organization = _organizationRepository.GetOrganizationbyId(account.Id);
                account.Name = organization.Name;
            }


            DirectoryOperationsHelper.CreateDirectoryIfNotExist(_bioCheckAssessmentFailedListPath);

            var fileName = Path.Combine(_bioCheckAssessmentFailedListPath, string.Format("failedCustomerRecord_{0}.xml", DateTime.Now.Ticks));

            var failedCustomerList = new BioCheckAssessmentFailedList {
                EventCustomers = new List <BioCheckAssessmentFailed>()
            };

            var eventCustomerResultTrales = _eventCustomerResultTraleRepository.GetByEventCustomerResultIds(eventCustomerIds);
            var customerTrales            = _customerTraleRepository.GetByCustomerIds(customerIds);

            eventCustomerResultTrales = eventCustomerResultTrales.IsNullOrEmpty() ? new List <EventCustomerResultTrale>() : eventCustomerResultTrales.ToList();
            customerTrales            = customerTrales.IsNullOrEmpty() ? new List <CustomerTrale>() : customerTrales;

            foreach (var ec in eventCusomters)
            {
                try
                {
                    var customer  = customers.Single(c => c.CustomerId == ec.CustomerId);
                    var hafAnswer = healthAssessmentAnswer.Where(c => c.EventCustomerId == ec.Id);

                    logger.Info("Started For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);

                    var bioCheckJsonViewModel = GenerateBioCheckResponseModel(ec, customer, hafAnswer, eventData, logger, eventCustomerResultTrales, customerTrales, account);

                    if (bioCheckJsonViewModel != null)
                    {
                        bioCheckJsonViewModel.ProfileId = _profileId;
                        logger.Info("Saving Request JSON For eventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        SaveRequestJson(bioCheckJsonViewModel, ec.EventId, ec.CustomerId);

                        logger.Info("Submitting Post Request For eventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        var response        = _trailApiService.Post <BioCheckJsonViewModel>(bioCheckJsonViewModel);
                        var isNewResultFlow = eventData.EventDate >= _settings.ResultFlowChangeDate;

                        if (response != null)
                        {
                            logger.Info("Saving response For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                            SaveReports(response, ec.EventId, ec.CustomerId, logger, isNewResultFlow);
                        }
                        else
                        {
                            logger.Info("No Response found for EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                        }
                    }
                    logger.Info("Complete For EventId: " + ec.EventId + " customerId: " + ec.CustomerId);
                }
                catch (Exception exception)
                {
                    failedCustomerList.EventCustomers.Add(new BioCheckAssessmentFailed {
                        CustomerId = ec.CustomerId, EventId = ec.EventId
                    });
                    logger.Error(string.Format("Error while generating My Bio-Check Assessment Data for customer Id: {0} and EventId {1} Message: {2}, StackTrace {3}", ec.CustomerId, ec.EventId, exception.Message, exception.StackTrace));
                }
            }

            if (!failedCustomerList.EventCustomers.IsNullOrEmpty())
            {
                _bioCheckAssessmentFailedListXmlSerializer.SerializeandSave(fileName, failedCustomerList);
            }
        }