private void DailyPatientRecapReport(DailyPatientRecapModelFilter filter, string destinationPath) { var pageNumber = 1; const int pageSize = 100; var list = new List <DailyPatientRecapCustomModel>(); DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationPath); var fileName = string.Format(@"\DailyPatientRecapReport_{0}.csv", filter.EventDateTo.Value.ToString("yyyyMMdd")); if (filter.CorporateAccountId == _settings.ConnecticareAccountId) { fileName = "Comm Daily Patient Recap " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv"; } else if (filter.CorporateAccountId == _settings.ConnecticareMaAccountId) { fileName = "MCR Daily Patient Recap " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv"; } var destinationFileName = Path.Combine(destinationPath, fileName); while (true) { int totalRecords; var model = _dailyPatientRecapReportingService.GetDailyPatientReapCustomModel(pageNumber, pageSize, filter, out totalRecords); if (model == null || model.Collection == null || !model.Collection.Any()) { break; } list.AddRange(model.Collection); _logger.Info(String.Format("\n\nPageNumber:{0} Totalrecords: {1} Current Length: {2}", pageNumber, totalRecords, list.Count)); pageNumber++; if (list.Count >= totalRecords) { break; } } if (list.Any()) { WriteCsvDailyPatientRecap(list, destinationFileName); } }
public ActionResult DailyPatientRecap(DailyPatientRecapModelFilter filter = null, int pageNumber = 1) { int totalRecords = 0; var model = _dailyPatientRecapReporting.GetDailyPatientReapModel(pageNumber, _pageSize, filter, out totalRecords) ?? new DailyPatientRecapListModel(); if (filter == null) { filter = new DailyPatientRecapModelFilter { EventDateFrom = DateTime.Now, EventDateTo = DateTime.Now } } ; filter.EventDateFrom = filter.EventDateFrom.HasValue ? filter.EventDateFrom.Value : DateTime.Now.Date; filter.EventDateTo = filter.EventDateTo.HasValue ? filter.EventDateTo.Value : DateTime.Now.Date; model.Filter = filter; var currentAction = ControllerContext.RouteData.Values["action"].ToString(); Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.EventDateFrom, filter.EventDateTo, filter.CustomerName, filter.CustomerId, filter.IsRetailEvent, filter.IsCorporateEvent, filter.IsPublicEvent, filter.IsPrivateEvent, filter.CorporateAccountId, filter.HospitalPartnerId, filter.Pod, filter.IsHealthPlanEvent, filter.IsGiftCertificateDeleievred }); model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc); return(View(model)); }