public IEnumerable <EventCustomerBarrier> GetForBarrierInboundReport(BarrierInboundFilter filter, int pageNumber, int pageSize, out int totalRecords) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var account = filter.AccountId > 0 ? (from a in linqMetaData.Account where a.AccountId == filter.AccountId select a).SingleOrDefault() : null; var query = (from ecb in linqMetaData.EventCustomerBarrier join ec in linqMetaData.EventCustomers on ecb.EventCustomerId equals ec.EventCustomerId join e in linqMetaData.Events on ec.EventId equals e.EventId join cp in linqMetaData.CustomerProfile on ec.CustomerId equals cp.CustomerId where (filter.StartDate == null || e.EventDate >= filter.StartDate) && (filter.EndDate == null || e.EventDate <= filter.EndDate) && (account == null || cp.Tag == account.Tag) select new { ecb, ec.CustomerId }); if (!filter.CustomTags.IsNullOrEmpty()) { var customTagCustomersIds = (from ct in linqMetaData.CustomerTag where ct.IsActive && filter.CustomTags.Contains(ct.Tag) select ct.CustomerId); query = (from q in query where customTagCustomersIds.Contains(q.CustomerId) select q); } var entities = (from q in query select q.ecb); totalRecords = entities.Count(); var result = entities.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToArray(); return(Mapper.Map <IEnumerable <EventCustomerBarrierEntity>, IEnumerable <EventCustomerBarrier> >(result)); } }
private void GenerateBarrierInboundReport(BarrierInboundFilter filter) { var dataGen = new ExportableDataGenerator <BarrierInboundViewModel, BarrierInboundFilter>(_barrierInboundReportService.GetBarrierInboundReportList, _logger); var model = dataGen.GetData(filter); var account = _corporateAccountRepository.GetById(filter.AccountId); if (model != null && !model.Collection.IsNullOrEmpty()) { var folder = string.Format(_settings.FloridaBlueInboundReportPath, account.FolderName, DateTime.Now.ToString("yyyy-MM-dd")); if (!Directory.Exists(folder)) { DirectoryOperationsHelper.CreateDirectory(folder); } var fileName = _pipeDelimitedReportHelper.GetReportName(ReportType.BarrierInbound); if (model.Collection != null && model.Collection.Any()) { _pipeDelimitedReportHelper.Write(model.Collection, folder, fileName + ".txt"); if (_sendReportToSftp) { try { _logger.Info("Sending file to SFTP."); var destinationPath = _destinationSftpPath + "\\" + account.FolderName + "\\Download\\Reports"; SendFilesToSftp(Path.Combine(folder, fileName), destinationPath, fileName); _logger.Info("File sent to SFTP."); } catch (Exception ex) { _logger.Info("Error sending file to SFTP."); _logger.Error("Message : " + ex.Message); _logger.Error("Stack Trace : " + ex.StackTrace); } } } } else { _logger.Info("No record found for " + account.Tag); } }
public void PollForBarrierInboundReport() { try { if (DateTime.Today.DayOfWeek != _dayOfWeek) { _logger.Info(string.Format("Today is {0}. Job is set to run on {1}.", DateTime.Today.DayOfWeek, _dayOfWeek)); return; } var accountIds = _settings.FloridaBlueAccountId.Split(','); if (accountIds.IsNullOrEmpty()) { _logger.Info("No accounts found for Response Vendor Report."); return; } _logger.Info("Starting Barrier Inbound Report generation."); var customSettingFilePath = string.Format(_customSettingFile, ReportType.BarrierInbound); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOffDate; foreach (var accountId in accountIds) { _logger.Info("Generating Barrier Inbound Report for Account ID : " + accountId); var filter = new BarrierInboundFilter { StartDate = exportFromTime, EndDate = exportToTime, AccountId = Convert.ToInt32(accountId), CustomTags = _settings.FloridaBlueMedicareCustomTags }; if (filter.AccountId == _settings.FloridaBlueCommercialId) { filter.CustomTags = _settings.FloridaBlueCommercialCustomTags; } else if (filter.AccountId == _settings.FloridaBlueMammoId) { filter.CustomTags = _settings.FloridaBlueMammoCustomTags; } else if (filter.AccountId == _settings.FloridaBlueGapsId) { filter.CustomTags = _settings.FloridaBlueGapsCustomTags; } GenerateBarrierInboundReport(filter); customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); } _logger.Info("Completed Barrier Inbound Report generation."); } catch (Exception ex) { _logger.Error("Some error occured while generating Barrier Inbound Report"); _logger.Error("Exception: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } }