private void ParseOneFile(string path)
        {
            var dataBytes = LoadDataStream(path);

            var appender = new FieldDataResultsAppender
            {
                UtcOffset = Context.LocationUtcOffset,
                Settings  = Context.Settings,
            };

            var locationInfo = !string.IsNullOrEmpty(Context.LocationIdentifier)
                ? appender.CreateDummyLocationInfoByIdentifier(Context.LocationIdentifier)
                : null;

            appender.ForcedLocationInfo = locationInfo;
            appender.AppendedResults.PluginAssemblyQualifiedTypeName = Plugin.GetType().AssemblyQualifiedName;

            try
            {
                var result = new ZipLoader
                {
                    Plugin       = Plugin,
                    Logger       = Logger,
                    Appender     = appender,
                    LocationInfo = locationInfo
                }
                .ParseFile(dataBytes);

                SaveAppendedResults(path, appender.AppendedResults);

                SummarizeResults(path, result, appender.AppendedResults);
            }
            catch (ExpectedException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Log.Error("Plugin has thrown an error", exception);

                throw new ExpectedException($"Unhandled plugin exception: {exception.Message}");
            }
        }
Esempio n. 2
0
        private void Run()
        {
            using (var stream = LoadDataStream())
            {
                var locationInfo = !string.IsNullOrEmpty(Context.LocationIdentifier)
                    ? FieldDataResultsAppender.CreateDummyLocationInfoByIdentifier(Context.LocationIdentifier)
                    : null;

                var plugin   = LoadPlugin();
                var logger   = CreateLogger();
                var appender = new FieldDataResultsAppender {
                    ForcedLocationInfo = locationInfo
                };

                try
                {
                    appender.AppendedResults.PluginAssemblyQualifiedTypeName = plugin.GetType().AssemblyQualifiedName;

                    var result = string.IsNullOrEmpty(Context.LocationIdentifier)
                        ? plugin.ParseFile(stream, appender, logger)
                        : plugin.ParseFile(stream, locationInfo, appender, logger);


                    SaveAppendedResults(appender.AppendedResults);

                    SummarizeResults(result, appender.AppendedResults);
                }
                catch (ExpectedException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    _log.Error("Plugin has thrown an error", exception);

                    throw new ExpectedException($"Unhandled plugin exception: {exception.Message}");
                }
            }
        }