示例#1
0
        public async Task <LoadAndParseResult> LoadAndParseDumpPageAsync(CancellationToken cancellationToken)
        {
            LoadAndParseResult result = new LoadAndParseResult();

            DownloadUtils.DownloadPageResult downloadPageResult = await DownloadUtils.DownloadPageAsync(httpClient, databaseDumpPageUrl, cancellationToken);

            if (downloadPageResult.DownloadResult == DownloadUtils.DownloadResult.CANCELLED)
            {
                result.Status = LoadAndParseStatus.CANCELLED;
                return(result);
            }
            if ((downloadPageResult.DownloadResult == DownloadUtils.DownloadResult.ERROR) || (downloadPageResult.HttpStatusCode != HttpStatusCode.OK))
            {
                result.Status = LoadAndParseStatus.LOAD_FAILED;
                return(result);
            }
            string dumpList;

            try
            {
                dumpList = DownloadUtils.ExecuteTransformation(downloadPageResult.PageContent, databaseDumpPageTransformationName, htmlDecode: false);
            }
            catch (Exception exception)
            {
                Logger.Debug($"Transformation {databaseDumpPageTransformationName} threw an exception.");
                Logger.Exception(exception);
                result.Status = LoadAndParseStatus.PARSE_FAILED;
                return(result);
            }
            try
            {
                result.Dumps = ParseDumps(dumpList);
            }
            catch (Exception exception)
            {
                Logger.Debug($"Dump metadata parser threw an exception.");
                Logger.Exception(exception);
                result.Status = LoadAndParseStatus.PARSE_FAILED;
                return(result);
            }
            result.Status = LoadAndParseStatus.COMPLETED;
            return(result);
        }
示例#2
0
 public Task <DownloadUtils.DownloadResult> DownloadDumpAsync(string dumpUrl, string dumpFilePath, IProgress <object> progressHandler,
                                                              CancellationToken cancellationToken)
 {
     return(DownloadUtils.DownloadFileAsync(httpClient, dumpUrl, dumpFilePath, true, progressHandler, cancellationToken));
 }