public void PollforMemberResultMailedReport() { try { if (_accountId < 1) { _logger.Info("No account Ids provided"); return; } if (_memberResultMailedReportDayOfWeek != DateTime.Today.DayOfWeek) { _logger.Info("Report is schedule to run on " + _memberResultMailedReportDayOfWeek); _logger.Info("Today is day of week " + DateTime.Today.DayOfWeek); _logger.Info(string.Format("Set day of week to {0} to run today ", ((int)DateTime.Today.DayOfWeek))); return; } var account = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(_accountId); var shippintOptionId = _corporateAccountRepository.GetAccountShippingOptionIds(account.Id); if (shippintOptionId.IsNullOrEmpty()) { _logger.Info("No shipping has been selected at Account"); return; } try { var directoryPath = _destinationFolderPdfPath + "\\"; directoryPath = string.Format(directoryPath, account.FolderName); CreateDistinationDirectory(directoryPath); var serviceReportSettings = string.Format(_memberResultMailedSettingPath, account.Tag); var customSettings = _customSettingManager.Deserialize(serviceReportSettings); var fromDate = (customSettings.LastTransactionDate != null) ? new DateTime(customSettings.LastTransactionDate.Value.Year, 1, 1) : _cutOfDate; var toDate = DateTime.Now; if (fromDate.Year == toDate.Year) { DeleteIffileExist(directoryPath, toDate.Year); //MemberReportForRiskCustomer(account, fromDate, toDate, directoryPath, shippintOptionId); MemberReportForGapCustomer(account, fromDate, toDate, directoryPath, shippintOptionId); //MemberReportForCustomerNoTags(account, fromDate, toDate, directoryPath, shippintOptionId); } else if (fromDate.Year < DateTime.Today.Year) { toDate = new DateTime(fromDate.Year, 12, 31); while (true) { DeleteIffileExist(directoryPath, toDate.Year); //MemberReportForRiskCustomer(account, fromDate, toDate, directoryPath, shippintOptionId); MemberReportForGapCustomer(account, fromDate, toDate, directoryPath, shippintOptionId); //MemberReportForCustomerNoTags(account, fromDate, toDate, directoryPath, shippintOptionId); fromDate = new DateTime((fromDate.Year + 1), 1, 1); toDate = DateTime.Now; if (fromDate.Year < DateTime.Today.Year) { toDate = new DateTime(fromDate.Year, 12, 31); } if (fromDate.Year > DateTime.Today.Year) { break; } } } customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(serviceReportSettings, customSettings); } catch (Exception ex) { _logger.Error("Some Error occurred for Tag" + account.Tag); _logger.Error("Message: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } } catch (Exception ex) { _logger.Error("Message: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } }