public void SaveAllPackedAssets() { 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(); ProgressPercentage progress = new ProgressPercentage() { TotalWork = ProviderProductList.Count, CurrentProgress = 0, Message = "Saving assets progress" }; foreach (ProviderProductModel providerProduct in ProviderProductList) { Int32 providerProductId = providerProduct.GetDatabaseRecordId(); var entries = ZipAccess.GetAllZipEntries(AssetBasePath, providerProduct.ArchiveFileName); var assets = ZipEntriesToAssetList(entries, providerProduct); SaveAssetsBulk(assets, providerProductId); progress.CurrentProgress++; SaveAssetProgressReporter?.Invoke(this, 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 void SaveAllUnpackedAssets() { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { List <ProviderProductModel> ProviderProductList = ProviderProductDatabaseCollectionModel.ReadAllProviderProductsFromDatabase(); ProviderProductList = ProviderProductList.Where(x => x.Pack.Length == 0).ToList(); ProgressPercentage progress = new ProgressPercentage() { TotalWork = ProviderProductList.Count, CurrentProgress = 0, Message = "Saving assets progress" }; foreach (ProviderProductModel providerProduct in ProviderProductList) { Int32 providerProductId = providerProduct.GetDatabaseRecordId(); String tempPath = $@"{AssetBasePath}{providerProduct.ArchiveFileName}"; if (Directory.Exists(tempPath)) { DirectoryInfo providerProductDir = new DirectoryInfo(tempPath); var assets = ReadAllAssetsFromDirectory(providerProductDir, providerProduct, tempPath.Length); SaveAssetsBulk(assets, providerProductId); progress.CurrentProgress++; SaveAssetProgressReporter?.Invoke(this, progress); } } } catch (Exception ex) { Log.Trace($"Saving unpacked assets failed ", ex, LogEventType.Error); } }