private async Task UpdateAbonentAsync(ScheduleTaskAbonentModel abonent)
        {
            var entity = await _context.CampaignAbonents.FirstAsync(x => x.Id == abonent.Id);

            entity.Status        = 1;
            entity.CallStartDate = DateTime.Now;
            await _context.SaveChangesAsync();
        }
        private async Task GeneratePlayCallFile(ScheduleTaskAbonentModel abonent)
        {
            var fileName = $"call_{_schedule.CampaignId}_{abonent.Id}_{abonent.UniqueId}.call";
            var tempFile = Path.Combine(_configuration.GetValue <string>("Asterisk:TempDir"), fileName);
            await File.WriteAllTextAsync(tempFile,
                                         $"Channel: SIP/{_trunkName}/{abonent.Phone}" + Environment.NewLine +
                                         "MaxRetries: 3" + Environment.NewLine +
                                         "Application: Playback" + Environment.NewLine +
                                         $"Data: {FileType.Voice.ToFileName(_schedule.CampaignId)}" + Environment.NewLine +
                                         "Archive: Yes");

            File.Move(tempFile, Path.Combine(_configuration.GetValue <string>("Asterisk:CallFilesDir"), fileName));
        }
        private async Task GenerateExtensionCallFile(ScheduleTaskAbonentModel abonent)
        {
            var fileName = $"call_{_schedule.CampaignId}_{abonent.Id}_{abonent.UniqueId}.call";
            var tempFile = Path.Combine(_configuration.GetValue <string>("Asterisk:TempDir"), fileName);
            await File.WriteAllTextAsync(tempFile,
                                         $"Channel: local/{abonent.Phone}@from-internal" + Environment.NewLine +
                                         $"Context: {_schedule.Action}" + Environment.NewLine +
                                         "Extension: s" + Environment.NewLine +
                                         "Priority: 1" + Environment.NewLine +
                                         $"Set: audiofile=ru/{FileType.Voice.ToFileName(_schedule.CampaignId)}" + Environment.NewLine +
                                         $"Set: abonentid={abonent.Id}");

            //"Archive: Yes");

            File.Move(tempFile, Path.Combine(_configuration.GetValue <string>("Asterisk:CallFilesDir"), fileName));
        }