public async Task <HttpResponseMessage> Post(CancellationToken cancellationToken, [FromBody] ConversionSettings settings)
        {
            var authorization = this.HttpContext.Request.Headers["Authorization"].ToString();
            HttpResponseMessage returnMessage = new HttpResponseMessage();

            try
            {
                _queue.Aborted = false;


                if (settings.DestinationEngine.ToLower() == "mysql")
                {
                    settings.DestinationEngine = "MySql";
                    settings.DestinationSchema = null;
                }

                if (settings.SourceEngine.ToLower() == "mysql")
                {
                    settings.SourceEngine = "MySql";
                    settings.SourceSchema = null;
                }

                _queue.QueueBackgroundWorkItem(async token =>
                {
                    await Task.Run(() =>
                    {
                        try
                        {
                            WriteLog(authorization, Status.Started, string.Empty, 0);
                            _queue.State = "Running";

                            var conversion = new ConversionController(_queue, settings, _configuration, _logHub, authorization);
                            conversion.Start();

                            _queue.State = "Idle";
                            WriteLog(authorization, Status.Finished, string.Empty, 100);
                        }
                        catch (Exception e)
                        {
                            WriteLog(authorization, Status.Failed, e.Message, 100);
                        }
                    });
                });
            }
            catch (Exception ex)
            {
                WriteLog(authorization, Status.Failed, ex.Message, 100);
            }

            //WriteLog("conversion done");
            return(await Task.FromResult(returnMessage));
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> Post(CancellationToken cancellationToken, [FromBody] ConversionSettings settings)
        {
            HttpResponseMessage returnMessage = new HttpResponseMessage();

            WriteLog("conversion added to ");

            _queue.QueueBackgroundWorkItem(async token =>
            {
                await Task.Run(() =>
                {
                    _queue.State = "Running";

                    var conversion = new ConversionController(_queue, settings, _configuration, _logHub);
                    conversion.Start();

                    _queue.State = "Idle";
                });
            });

            //WriteLog("conversion done");
            return(await Task.FromResult(returnMessage));
        }