private void InsertAccountEventZip(long accountId, string tag, AccountEventZipSetting generationSetting)
        {
            var fromDate     = DateTime.Today.AddDays(1);
            var rangeInMiles = _settings.ZipRangeInMiles;

            var events = _eventRepository.GetEventsByAccountIdAndDate(accountId, fromDate, null, true);
            var eventAppointmentStatsModels = _eventAppointmentStatsService.GetStats(events);

            var eventIds = !eventAppointmentStatsModels.IsNullOrEmpty() ? eventAppointmentStatsModels.Where(x => x.FreeSlots > 0 || x.IsDynamicScheduling).Select(x => x.EventId) : null;

            if (eventIds.IsNullOrEmpty())
            {
                _logger.Info("No events found.");
                return;
            }

            _logger.Info("Events found : " + eventIds.Count());

            var zipIds   = new List <long>();
            var hostList = _hostRepository.GetEventHosts(eventIds);

            foreach (var host in hostList)
            {
                var zipcodes = _zipRadiusDistanceRepository.GetBySourceZipIdAndRadius(host.Address.ZipCode.Id, rangeInMiles);

                if (!zipcodes.IsNullOrEmpty())
                {
                    var hostZipIds = zipcodes.Select(x => x.DestinationZipId);
                    zipIds.AddRange(hostZipIds);

                    var recentlyCreatedEvents = events.Where(x => x.HostId == host.Id && x.DataRecorderMetaData.DateCreated > generationSetting.LastGenerationDateTime);

                    _logger.Info("Generating event zip for recently created events. Count : " + recentlyCreatedEvents.Count());

                    foreach (var recentlyCreatedEvent in recentlyCreatedEvents)
                    {
                        if (_healthPlanFillEventCallQueueRepository.IsEventZipAlreadyGenerated(recentlyCreatedEvent.Id))
                        {
                            _logger.Info("Event Zip already generated for EventID : " + recentlyCreatedEvent.Id);
                            continue;
                        }

                        _healthPlanFillEventCallQueueRepository.DeleteEventZipByEventId(recentlyCreatedEvent.Id);
                        foreach (var zipId in hostZipIds)
                        {
                            _healthPlanFillEventCallQueueRepository.SaveEventZips(recentlyCreatedEvent.Id, zipId);
                        }
                    }
                }
            }

            if (generationSetting.LastGeneratedTable == AccountEventZipGenerationType.AccountEventZipSubstitute.ToString())
            {
                _accountEventZipReposiory.Save(accountId, zipIds.Distinct().ToArray());
            }
            else
            {
                _accountEventZipReposiory.SaveSubstitute(accountId, zipIds.Distinct().ToArray());
            }

            //var healthPlanEventZip = new HealthPlanEventZip()
            //{
            //    AccountID = accountId,
            //    AccountTag = tag,
            //    DateCreated = DateTime.Now,
            //    IsQueueGenerated = true
            //};

            //_healthPlanEventZipRepository.Save(healthPlanEventZip);
        }