public static void SaveAllPackedAssets(string assetBasePath, bool InGame, bool InArchive) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { // filter this list, to make sure it actually is packed List <ProviderProductModel> ProviderProductList = (ZipAccess.GetPackedProviderProducts(new DirectoryInfo(assetBasePath))).Where(x => x.Pack.Length > 0).ToList(); ProgressPercentageModel progress = new ProgressPercentageModel() { TotalWork = ProviderProductList.Count, CurrentProgress = 0, Message = "Saving assets progress" }; foreach (ProviderProductModel providerProduct in ProviderProductList) { providerProduct.Id = providerProduct.GetDatabaseRecordId(); if (providerProduct.Id <= 0) { Log.Trace($"ProviderProduct {providerProduct} not found in Database. Please file a ticket", LogEventType.Error); throw new InvalidDataException("ProviderProduct not found in Database. Please file a ticket"); } var entries = ZipAccess.GetAllZipEntries(assetBasePath, providerProduct.ArchiveFileName); var assets = ZipEntriesToAssetList(entries, providerProduct); SaveAssetsBulk(assets, providerProduct.Id); UpdateBulkStatus(assets, Converters.LocationToString(InGame, InArchive)); progress.CurrentProgress++; SaveAssetProgressReporter?.Invoke(null, progress); } } catch (Exception ex) { Log.Trace($"Saving packed assets failed", ex, LogEventType.Error); } stopWatch.Stop(); Int64 elapsed = stopWatch.ElapsedMilliseconds / 1000; Log.Trace($"Elapsed time for saving assets {elapsed} seconds"); }
public static void SaveAllUnpackedAssets(string assetBasePath, bool InGame, bool InArchive) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { List <ProviderProductModel> ProviderProductList = ProviderProductCollectionDataAccess.ReadAllProviderProductsFromDatabase(); ProviderProductList = ProviderProductList.Where(x => x.Pack.Length == 0).ToList(); ProgressPercentageModel progress = new ProgressPercentageModel() { TotalWork = ProviderProductList.Count, CurrentProgress = 0, Message = "Saving assets progress" }; foreach (ProviderProductModel providerProduct in ProviderProductList) { providerProduct.Id = providerProduct.GetDatabaseRecordId(); String tempPath = $@"{assetBasePath}{providerProduct.ArchiveFileName}"; if (Directory.Exists(tempPath)) { DirectoryInfo providerProductDir = new DirectoryInfo(tempPath); List <AssetModel> assets = null; assets = ReadAllAssetsFromDirectory(providerProductDir, providerProduct, tempPath.Length, InGame, InArchive); SaveAssetsBulk(assets, providerProduct.Id); UpdateBulkStatus(assets, Converters.LocationToString(InGame, InArchive)); progress.CurrentProgress++; SaveAssetProgressReporter?.Invoke(null, progress); } } } catch (Exception ex) { Log.Trace($"Saving unpacked assets failed ", ex, LogEventType.Error); } }