示例#1
0
        public void init()
        {
            _logger.LogDebug("開始執行訂票流程...");
            var configs = _config.ticketOrders;

            foreach (var config in configs)
            {
                _validation.validOrderIdAndIdCard(config);

                var orderInfo = post_search_order_form(config.IdCard, config.OrderId);

                if (!orderInfo.isTripEditable)
                {
                    _logger.LogDebug($"訂位代號:{config.OrderId} 無法變更行程");
                    return;
                }
                _validation.validConfigDateTime(config, orderInfo);

                if (_validation.haveToDateFunc(config))
                {
                    var result = ModifyTrip(CrawlerModels.ModifyTripType.To, config, orderInfo);
                    _logger.LogDebug($"訂位代號:{config.OrderId} 去程執行結果:{result}");
                }
                if (orderInfo.isRoundTrip && _validation.haveBackDateFunc(config))
                {
                    var result = ModifyTrip(CrawlerModels.ModifyTripType.Back, config, orderInfo);
                    _logger.LogDebug($"訂位代號:{config.OrderId} 回程執行結果:{result}");
                }
            }
            _logger.LogDebug("訂票流程執行成功!");
        }
示例#2
0
        public IEnumerable <string> Get()
        {
            var exception = new Exception();

            _logger.LogTrace("Log trace");
            _logger.LogDebug("Log debug");
            _logger.LogInformation("Log information");
            _logger.LogWarning("Log warning");
            _logger.LogError(exception.HResult, exception, string.Empty);    // this one will not be logged
            _logger.LogCritical(exception.HResult, exception, string.Empty); // this one will not be logged as well

            // you have to specif not empty (might be whitespaced) message when logging exception
            _logger.LogError(exception.HResult, exception, " ");
            _logger.LogCritical(exception.HResult, exception, " ");
//
            // as opposite to the original behavior of NLog
            // NlogLogger.Error(exception);

            return(new string[] { "value1", "value2" });
        }