Ejemplo n.º 1
0
 private async Task _projectBuilder_OnSucceed(object sender, OnProjectBuildSucceedEventArgs eventArgs)
 {
     await _etlRepository.Success(_project.GetETKTaskId());
 }
Ejemplo n.º 2
0
        public async Task Run()
        {
            InitParameters();

            LastExtract = await _etlRepository.GetLastExtract(_project.GetETLCode());

            _project.SetETLLastExtract(LastExtract);

            var queryParams = new Dictionary <string, object>
            {
                { "LastMaxId", LastExtract.MaxId },
                { "LastQueryTime", LastExtract.QueryTime },
                { "LastMaxModifyTime", LastExtract.MaxModifyTime }
            };

            Total = await SqlMapper.ExecuteScalarAsync <int>(new RequestContext
            {
                RealSql = TotalCmd,
                Request = queryParams
            });

            if (Total == 0)
            {
                _logger.LogInformation("can not find any record.");
                return;
            }

            if (BulkSize == 0)
            {
                BulkSize = Total;
            }

            BuildContext buildContext = null;

            while (Offset < Total)
            {
                _logger.LogInformation($"--------Total:[{Total}] , Offset:[{Offset}]  ---------");
                try
                {
                    var etlTaskId = await _etlRepository.Startup(_project.ConfigPath, _project.GetETLCode());

                    _project.SetETKTaskId(etlTaskId);
                    await Extract();

                    if (String.IsNullOrEmpty(TotalCmd))
                    {
                        Total    = GetCount();
                        BulkSize = Total;
                    }

                    foreach (var buildKV in _project.BuildTasks)
                    {
                        _logger.LogInformation($"-------- BuildTask:{buildKV.Key} Start! ---------");
                        var output = buildKV.Value.Output;
                        buildContext = new BuildContext
                        {
                            PluginManager = _pluginManager,
                            Project       = _project,
                            BuildKey      = buildKV.Key,
                            Build         = buildKV.Value,
                            Output        = output?.Copy()
                        };
                        buildContext.SetExtractData(this);
                        await _pluginManager.Resolve <IBuildTask>(buildKV.Value.Type).Build(buildContext);

                        _logger.LogInformation($"-------- BuildTask:{buildKV.Key} End! ---------");
                    }

                    await _etlRepository.Success(_project.GetETKTaskId());

                    Offset += BulkSize;
                }
                catch (Exception e)
                {
                    await _etlRepository.Fail(_project.GetETKTaskId(), e);

                    throw;
                }
            }
        }