public async Task ImportOrchestration()

in src/ApiForFhirMigrationTool.Function/ImportOrchestrator.cs [53:95]


        public async Task<string> ImportOrchestration(
            [OrchestrationTrigger] TaskOrchestrationContext context, string requestContent)
        {
            ILogger logger = context.CreateReplaySafeLogger(nameof(ImportOrchestration));
            logger.LogInformation("Starting import activities.");
            var statusRespose = new HttpResponseMessage();
            var statusUrl = string.Empty;

            try
            {
                logger.LogInformation("Creating table clients");
                TableClient exportTableClient = _azureTableClientFactory.Create(_options.ExportTableName);
                TableClient chunktableClient = _azureTableClientFactory.Create(_options.ChunkTableName);
                logger.LogInformation("Table clients created successfully.");

                logger.LogInformation(" Query the export table to check for running or started import jobs.");
                Pageable<TableEntity> jobListimportRunning = exportTableClient.Query<TableEntity>(filter: ent => ent.GetString("IsImportRunning") == "Started" || ent.GetString("IsImportRunning") == "Running");
                
                Pageable<TableEntity> jobListimport = exportTableClient.Query<TableEntity>(filter: ent => ent.GetBoolean("IsExportComplete") == true && ent.GetString("ImportRequest") == "Yes" && ent.GetBoolean("IsProcessed") == false && ent.GetBoolean("IsFirst") == true && jobListimportRunning.Count() == 0);
                logger?.LogInformation("Query completed");

                if (jobListimport.Count() > 0)
                {
                    foreach (TableEntity item in jobListimport)
                    {
                        logger?.LogInformation("Calling ProcessImport function");
                        var importResponse = await context.CallActivityAsync<ResponseModel>(nameof(ProcessImport));
                        logger?.LogInformation("ProcessImport function has completed.");

                    }
                }
                else
                {
                    logger?.LogInformation("Currently, an import or export job is already running, so a new import cannot be started.");
                }
            }
            catch
            {
                throw;
            }
            logger?.LogInformation("Completed import activities.");
            return "completed";
        }