Exemplo n.º 1
0
            private EtlStepResult InvokePackageStep(EtlStep step, EtlContext context)
            {
                try
                {
                    var startDateTime = DateTime.Now;
                    _logger.LogEtlMessage(new EtlMessage
                    {
                        EtlPackageId   = context.EtlPackageId,
                        EtlSessionId   = context.EtlSessionId,
                        EtlStepName    = step.Name,
                        LogDateTime    = startDateTime,
                        LogUtcDateTime = startDateTime.ToUniversalTime(),
                        MessageType    = EtlMessageType.StepStart,
                        Text           = string.Format(Properties.Resources.StepStarted, step.Name),
                        StackTrace     = step.GetType().FullName,
                    });

                    var stepResult = step.Invoke(context, _logger);

                    var endDateTime = DateTime.Now;
                    _logger.LogEtlMessage(new EtlMessage
                    {
                        EtlPackageId   = context.EtlPackageId,
                        EtlSessionId   = context.EtlSessionId,
                        EtlStepName    = step.Name,
                        LogDateTime    = endDateTime,
                        LogUtcDateTime = endDateTime.ToUniversalTime(),
                        MessageType    = EtlMessageType.StepEnd,
                        Text           = string.Format(Properties.Resources.StepFinished, step.Name, stepResult.Status),
                    });

                    return(stepResult);
                }
                catch (Exception exc)
                {
                    if (IsCriticalException(exc))
                    {
                        throw;
                    }

                    var errorDateTime = DateTime.Now;
                    _logger.LogEtlMessage
                    (
                        new EtlMessage
                    {
                        EtlPackageId   = context.EtlPackageId,
                        EtlSessionId   = context.EtlSessionId,
                        EtlStepName    = step.Name,
                        LogDateTime    = errorDateTime,
                        LogUtcDateTime = errorDateTime.ToUniversalTime(),
                        MessageType    = EtlMessageType.Error,
                        Text           = exc.Message,
                        StackTrace     = exc.StackTrace,
                    }
                    );

                    return(new EtlStepResult(EtlStatus.Failed, exc.Message));
                }
            }
            private EtlStepResult InvokePackageStep(EtlStep step, EtlContext context)
            {
                try
                {
                    var startDateTime = DateTime.Now;
                    _logger.LogEtlMessage(new EtlMessage
                    {
                        EtlPackageId = context.EtlPackageId,
                        EtlSessionId = context.EtlSessionId,
                        EtlStepName = step.Name,
                        LogDateTime = startDateTime,
                        LogUtcDateTime = startDateTime.ToUniversalTime(),
                        MessageType = EtlMessageType.StepStart,
                        Text = string.Format(Properties.Resources.StepStarted, step.Name),
                        StackTrace = step.GetType().FullName,
                    });

                    var stepResult = step.Invoke(context, _logger);

                    var endDateTime = DateTime.Now;
                    _logger.LogEtlMessage(new EtlMessage
                    {
                        EtlPackageId = context.EtlPackageId,
                        EtlSessionId = context.EtlSessionId,
                        EtlStepName = step.Name,
                        LogDateTime = endDateTime,
                        LogUtcDateTime = endDateTime.ToUniversalTime(),
                        MessageType = EtlMessageType.StepEnd,
                        Text = string.Format(Properties.Resources.StepFinished, step.Name, stepResult.Status),
                    });

                    return stepResult;
                }
                catch (Exception exc)
                {
                    if (IsCriticalException(exc))
                    {
                        throw;
                    }

                    var errorDateTime = DateTime.Now;
                    _logger.LogEtlMessage
                    (
                        new EtlMessage
                        {
                            EtlPackageId = context.EtlPackageId,
                            EtlSessionId = context.EtlSessionId,
                            EtlStepName = step.Name,
                            LogDateTime = errorDateTime,
                            LogUtcDateTime = errorDateTime.ToUniversalTime(),
                            MessageType = EtlMessageType.Error,
                            Text = exc.Message,
                            StackTrace = exc.StackTrace,
                        }
                    );

                    return new EtlStepResult(EtlStatus.Failed, exc.Message);
                }
            }