コード例 #1
0
ファイル: ZipBundler.cs プロジェクト: jandebonnet/SSRSMigrate
        public void AddItem(string key, string itemFileName, string itemPath, bool isFolder)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("key");
            }

            if (string.IsNullOrEmpty(itemFileName))
            {
                throw new ArgumentException("itemFileName");
            }

            if (string.IsNullOrEmpty(itemPath))
            {
                throw new ArgumentException("itemPath");
            }

            if (!this.mSummary.Entries.ContainsKey(key))
            {
                throw new KeyNotFoundException(key);
            }

            this.mLogger.Debug("AddItem - key = {0}; itemFileName = {1}; itemPath = {2}; isFolder = {3}",
                               key,
                               itemFileName,
                               itemPath,
                               isFolder);

            // Get the path for inside the zip archive
            string zipPath = this.GetZipPath(itemFileName, itemPath, isFolder);

            // If it is a folder, add the folder to the archive, otherwise add file
            if (isFolder)
            {
                this.mZipFileWrapper.AddDirectory(itemFileName, zipPath);
            }
            else
            {
                this.mZipFileWrapper.AddFile(itemFileName, zipPath);
            }

            BundleSummaryEntry entry = this.CreateEntrySummary(itemFileName, zipPath, isFolder);

            this.mSummary.Entries[key].Add(entry);
        }
コード例 #2
0
ファイル: ZipBundler.cs プロジェクト: jandebonnet/SSRSMigrate
        public BundleSummaryEntry CreateEntrySummary(string itemFileName, string zipPath, bool isFolder = false)
        {
            if (string.IsNullOrEmpty(itemFileName))
            {
                throw new ArgumentException("itemFileName");
            }

            if (string.IsNullOrEmpty(zipPath))
            {
                throw new ArgumentException("zipPath");
            }

            this.mLogger.Debug("CreateEntrySummary - itemFileName = {0}; zipPath = {1}; isFolder",
                               itemFileName,
                               zipPath,
                               isFolder);

            string fileName = "";

            // If the item is not a Folder, parse the fileName for the BundleSummaryEntry
            if (!isFolder)
            {
                fileName = itemFileName.Substring(itemFileName.LastIndexOf("\\") + 1);
            }

            BundleSummaryEntry entry = new BundleSummaryEntry()
            {
                CheckSum = this.mCheckSumGenerator.CreateCheckSum(itemFileName),
                FileName = fileName,
                Path     = zipPath
            };

            this.mLogger.Debug("CreateEntrySummary - FileName = {0}; Path = {1}; CheckSum = {2}",
                               entry.FileName,
                               entry.Path,
                               entry.CheckSum);

            return(entry);
        }
コード例 #3
0
ファイル: ZipBundler.cs プロジェクト: jpann/SSRSMigrate
        public BundleSummaryEntry CreateEntrySummary(string itemFileName, string zipPath, bool isFolder = false)
        {
            if (string.IsNullOrEmpty(itemFileName))
                throw new ArgumentException("itemFileName");

            if (string.IsNullOrEmpty(zipPath))
                throw new ArgumentException("zipPath");

            this.mLogger.Debug("CreateEntrySummary - itemFileName = {0}; zipPath = {1}; isFolder",
                itemFileName,
                zipPath,
                isFolder);

            string fileName = "";

            // If the item is not a Folder, parse the fileName for the BundleSummaryEntry
            if (!isFolder)
                fileName = itemFileName.Substring(itemFileName.LastIndexOf("\\") + 1);

            BundleSummaryEntry entry = new BundleSummaryEntry()
            {
                CheckSum = this.mCheckSumGenerator.CreateCheckSum(itemFileName),
                FileName = fileName,
                Path = zipPath
            };

            this.mLogger.Debug("CreateEntrySummary - FileName = {0}; Path = {1}; CheckSum = {2}",
                entry.FileName,
                entry.Path,
                entry.CheckSum);

            return entry;
        }