Ejemplo n.º 1
0
        // ---------------------------------------------------------------------------------------------------------


        public bool PopulateSummary(out string pErrorText, AddonPackageSource pSource = null, string pTempFolderPath = null, List <PropModelItem> pPropModelItems = null)
        {
            pErrorText = null;
            if (_initialized)
            {
                return(true);
            }

            if (!PopulateSummaryPreChecks(ref pSource, ref pTempFolderPath, ref pPropModelItems, out pErrorText))
            {
                return(false);
            }

            bool   isOk                    = true;
            string assetDataFile           = null;
            bool   deleteTempAssetDataFile = false;

            try
            {
                if (pSource.SourceType == AddonPackageSourceType.Folder)
                {
                    assetDataFile = Path.Combine(pSource.SourcePath, AddonPackage.AssetDataFilename);
                }
                else
                {
                    assetDataFile = Path.Combine(pTempFolderPath, AddonPackage.AssetDataFilename);
                    pSource.Archiver.ArchivedFilesExtract(pTempFolderPath, new List <string>()
                    {
                        AddonPackage.AssetDataFilename
                    });
                    deleteTempAssetDataFile = true;
                }

                SevenZipArchiver assetDataArchiver = new SevenZipArchiver(assetDataFile);

                foreach (PropModelItem item in pPropModelItems)
                {
                    if (Props == null)
                    {
                        Props = new PropModelSumProps(assetDataArchiver);
                    }

                    if (!Props.AppendPropModelItem(item, out pErrorText))
                    {
                        isOk = false;
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                pErrorText = $"PropModelsSummary.PopulateSummary() EXCEPTION: {exception.Message}";
                isOk       = false;
            }
            finally
            {
                if (deleteTempAssetDataFile)
                {
                    File.Delete(assetDataFile);
                }
            }

            _initialized = isOk;

            return(isOk);
        }