当前位置: 首页>>代码示例>>C#>>正文


C# Record.SetStream方法代码示例

本文整理汇总了C#中Record.SetStream方法的典型用法代码示例。如果您正苦于以下问题:C# Record.SetStream方法的具体用法?C# Record.SetStream怎么用?C# Record.SetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Record的用法示例。


在下文中一共展示了Record.SetStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetRecordField

 internal static void SetRecordField(Record record, object fieldValue, int index) {
     if (fieldValue == null) {
         record.set_StringData(index+1, "");
     } else if (fieldValue is int) {
         record.set_IntegerData(index+1, (int) fieldValue);
     } else if (fieldValue is string) {
         record.set_StringData(index+1, (string) fieldValue);
     } else if (fieldValue is InstallerStream) {
         record.SetStream(index+1, ((InstallerStream) fieldValue).FilePath);
     } else {
         throw new ApplicationException("Unhandled type: " + fieldValue.GetType());
     }
 }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:13,代码来源:InstallerTable.cs

示例2: ApplyPatch


//.........这里部分代码省略.........
            if(patchCabinets.Count == 0)
            {
                this.LogMessage("Patch cabinet record not found");
                throw new InstallerException("Patch cabinet record not found.");
            }
            string patchCabinet = patchCabinets[0];
            this.LogMessage("Patch cabinet = {0}", patchCabinet);
            if(!patchCabinet.StartsWith("#", StringComparison.Ordinal))
            {
                this.LogMessage("Error: Patch cabinet must be embedded");
                throw new InstallerException("Patch cabinet must be embedded.");
            }
            patchCabinet = patchCabinet.Substring(1);

            string renamePatchCabinet = patchPrefix + patchCabinet;

            const int HIGH_DISKID = 30000; // Must not collide with other patch media DiskIDs
            int renamePatchMediaDiskId = HIGH_DISKID;
            while (this.CountRows("Media", "`DiskId` = " + renamePatchMediaDiskId) > 0) renamePatchMediaDiskId++;

            // Since the patch cab is now embedded in the MSI, it shouldn't have a separate disk prompt/source
            this.LogMessage("Renaming the patch media record");
            int lastSeq = Convert.ToInt32(this.ExecuteScalar("SELECT `LastSequence` FROM `Media` WHERE `DiskId` = {0}", patchMediaDiskId));
            this.Execute("DELETE FROM `Media` WHERE `DiskId` = {0}", patchMediaDiskId);
            this.Execute("INSERT INTO `Media` (`DiskId`, `LastSequence`, `Cabinet`) VALUES ({0}, '{1}', '#{2}')",
                renamePatchMediaDiskId, lastSeq, renamePatchCabinet);
            this.Execute("UPDATE `PatchPackage` SET `Media_` = {0} WHERE `PatchId` = '{1}'", renamePatchMediaDiskId, patchPackage.PatchCode);

            this.LogMessage("Copying patch cabinet: {0}", patchCabinet);
            string patchCabFile = Path.Combine(this.TempDirectory,
                Path.GetFileNameWithoutExtension(patchCabinet) + ".cab");
            using(View streamView = patchPackage.OpenView("SELECT `Name`, `Data` FROM `_Streams` " +
                  "WHERE `Name` = '{0}'", patchCabinet))
            {
                streamView.Execute();
                Record streamRec = streamView.Fetch();
                if(streamRec == null)
                {
                    this.LogMessage("Error: Patch cabinet not found");
                    throw new InstallerException("Patch cabinet not found.");
                }
                using(streamRec)
                {
                    streamRec.GetStream(2, patchCabFile);
                }
            }
            using(Record patchCabRec = new Record(2))
            {
                patchCabRec[1] = patchCabinet;
                patchCabRec.SetStream(2, patchCabFile);
                this.Execute("INSERT INTO `_Streams` (`Name`, `Data`) VALUES (?, ?)", patchCabRec);
            }

            this.LogMessage("Ensuring PatchFiles action exists in InstallExecuteSequence table");
            if (this.Tables.Contains("InstallExecuteSequence"))
            {
                if(this.CountRows("InstallExecuteSequence", "`Action` = 'PatchFiles'") == 0)
                {
                    IList<int> installFilesSeqList = this.ExecuteIntegerQuery("SELECT `Sequence` " +
                        "FROM `InstallExecuteSequence` WHERE `Action` = 'InstallFiles'");
                    short installFilesSeq = (short) (installFilesSeqList.Count != 0 ?
                        installFilesSeqList[0] : 0);
                    this.Execute("INSERT INTO `InstallExecuteSequence` (`Action`, `Sequence`) " +
                        "VALUES ('PatchFiles', {0})", installFilesSeq + 1);
                }
            }

            // Patch-added files need to be marked always-compressed
            this.LogMessage("Adjusting attributes of patch-added files");
            using(View fileView = this.OpenView("SELECT `File`, `Attributes`, `Sequence` " +
                  "FROM `File` ORDER BY `Sequence`"))
            {
                fileView.Execute();
                
                foreach (Record fileRec in fileView) using(fileRec)
                {
                    int fileAttributes = fileRec.GetInteger(2);
                    if ((fileAttributes & (int) Microsoft.Deployment.WindowsInstaller.FileAttributes.PatchAdded) != 0)
                    {
                        fileAttributes = (fileAttributes | (int) Microsoft.Deployment.WindowsInstaller.FileAttributes.Compressed)
                            & ~(int) Microsoft.Deployment.WindowsInstaller.FileAttributes.NonCompressed
                            & ~(int) Microsoft.Deployment.WindowsInstaller.FileAttributes.PatchAdded;
                        fileRec[2] = fileAttributes;
                        fileView.Update(fileRec);
                    }
                }
            }
        }

        this.LogMessage("Applying new summary info from patch package");
        this.SummaryInfo.RevisionNumber = this.Property["PATCHNEWPACKAGECODE"];
        this.SummaryInfo.Subject = this.Property["PATCHNEWSUMMARYSUBJECT"];
        this.SummaryInfo.Comments = this.Property["PATCHNEWSUMMARYCOMMENTS"];
        this.SummaryInfo.Persist();
        this.Property["PATCHNEWPACKAGECODE"    ] = null;
        this.Property["PATCHNEWSUMMARYSUBJECT" ] = null;
        this.Property["PATCHNEWSUMMARYCOMMENTS"] = null;

        this.LogMessage("Patch application finished");
    }
开发者ID:bleissem,项目名称:wix3,代码行数:101,代码来源:InstallPackage.cs

示例3: Consolidate

    /// <summary>
    /// Consolidates a package by combining and re-compressing all files into a single
    /// internal or external cabinet.
    /// </summary>
    /// <param name="mediaCabinet"></param>
    /// <remarks>If an installation package was built from many merge modules, this
    /// method can somewhat decrease package size, complexity, and installation time.
    /// <p>This method will also convert a package with all or mostly uncompressed
    /// files into a package where all files are compressed.</p>
    /// <p>If the package contains any not-yet-applied binary file patches (for
    /// example, a package generated by a call to <see cref="ApplyPatch"/>) then
    /// this method will apply the patches before compressing the updated files.</p>
    /// <p>This method edits the database summary information and the File, Media
    /// and Patch tables as necessary to maintain a valid installation package.</p>
    /// <p>The cabinet compression level used during re-cabbing can be configured with the
    /// <see cref="CompressionLevel"/> property.</p>
    /// </remarks>
    public void Consolidate(string mediaCabinet)
    {
        this.LogMessage("Consolidating package");

        Directory.CreateDirectory(this.TempDirectory);

        this.LogMessage("Extracting/preparing files");
        this.ProcessFilesByMediaDisk(null,
            new ProcessFilesOnOneMediaDiskHandler(this.PrepareOneMediaDiskForConsolidation));

        this.LogMessage("Applying any file patches");
        ApplyFilePatchesForConsolidation();

        this.LogMessage("Clearing PatchPackage, Patch, MsiPatchHeaders tables");
        if (this.Tables.Contains("PatchPackage"))
        {
            this.Execute("DELETE FROM `PatchPackage` WHERE `PatchId` <> ''");
        }
        if (this.Tables.Contains("Patch"))
        {
            this.Execute("DELETE FROM `Patch` WHERE `File_` <> ''");
        }
        if (this.Tables.Contains("MsiPatchHeaders"))
        {
            this.Execute("DELETE FROM `MsiPatchHeaders` WHERE `StreamRef` <> ''");
        }

        this.LogMessage("Resequencing files");
        ArrayList files = new ArrayList();
        using(View fileView = this.OpenView("SELECT `File`, `Attributes`, `Sequence` " +
              "FROM `File` ORDER BY `Sequence`"))
        {
            fileView.Execute();
            
            foreach (Record fileRec in fileView) using(fileRec)
            {
                files.Add(fileRec[1]);
                int fileAttributes = fileRec.GetInteger(2);
                fileAttributes &= ~(int) (Microsoft.Deployment.WindowsInstaller.FileAttributes.Compressed
                    | Microsoft.Deployment.WindowsInstaller.FileAttributes.NonCompressed | Microsoft.Deployment.WindowsInstaller.FileAttributes.PatchAdded);
                fileRec[2] = fileAttributes;
                fileRec[3] = files.Count;
                fileView.Update(fileRec);
            }
        }

        bool internalCab = false;
        if(mediaCabinet.StartsWith("#", StringComparison.Ordinal))
        {
            internalCab = true;
            mediaCabinet = mediaCabinet.Substring(1);
        }

        this.LogMessage("Cabbing files");
        string[] fileKeys = (string[]) files.ToArray(typeof(string));
        string cabPath = Path.Combine(internalCab ? this.TempDirectory
            : this.WorkingDirectory, mediaCabinet);
        this.cabName = mediaCabinet;
        this.cabMsg = "compress {0}\\{1}";
        new CabInfo(cabPath).PackFiles(this.TempDirectory, fileKeys,
            fileKeys, this.CompressionLevel, this.CabinetProgress);

        this.DeleteEmbeddedCabs();

        if(internalCab)
        {
            this.LogMessage("Inserting cab stream into MSI");
            Record cabRec = new Record(1);
            cabRec.SetStream(1, cabPath);
            this.Execute("INSERT INTO `_Streams` (`Name`, `Data`) VALUES ('" + mediaCabinet + "', ?)", cabRec);
        }

        this.LogMessage("Inserting cab media record into MSI");
        this.Execute("DELETE FROM `Media` WHERE `DiskId` <> 0");
        this.Execute("INSERT INTO `Media` (`DiskId`, `LastSequence`, `Cabinet`) " +
            "VALUES (1, " + files.Count + ", '" + (internalCab ? "#" : "") + mediaCabinet + "')");


        this.LogMessage("Setting compressed flag on package summary info");
        this.SummaryInfo.WordCount = this.SummaryInfo.WordCount | 2;
        this.SummaryInfo.Persist();
    }
开发者ID:bleissem,项目名称:wix3,代码行数:99,代码来源:InstallPackage.cs

示例4: UpdateFilesOnOneMediaDisk

    private void UpdateFilesOnOneMediaDisk(string mediaCab,
        InstallPathMap compressedFileMap, InstallPathMap uncompressedFileMap)
    {
        if(compressedFileMap.Count > 0)
        {
            string cabFile = null;
            bool cabFileIsTemp = false;
            if(mediaCab.StartsWith("#", StringComparison.Ordinal))
            {
                cabFileIsTemp = true;
                mediaCab = mediaCab.Substring(1);

                using(View streamView = this.OpenView("SELECT `Name`, `Data` FROM `_Streams` " +
                      "WHERE `Name` = '{0}'", mediaCab))
                {
                    streamView.Execute();
                    Record streamRec = streamView.Fetch();
                    if(streamRec == null)
                    {
                        this.LogMessage("Stream not found: {0}", mediaCab);
                        throw new InstallerException("Stream not found: " + mediaCab);
                    }
                    using(streamRec)
                    {
                        this.LogMessage("extract cab {0}", mediaCab);
                        Directory.CreateDirectory(this.TempDirectory);
                        cabFile = Path.Combine(this.TempDirectory,
                            Path.GetFileNameWithoutExtension(mediaCab) + ".cab");
                        streamRec.GetStream("Data", cabFile);
                    }
                }
            }
            else
            {
                cabFile = Path.Combine(this.SourceDirectory, mediaCab);
            }

            CabInfo cab = new CabInfo(cabFile);
            ArrayList fileKeyList = new ArrayList();
            foreach (CabFileInfo fileInCab in cab.GetFiles())
            {
                string fileKey = fileInCab.Name;
                if(this.Files[fileKey] != null)
                {
                    fileKeyList.Add(fileKey);
                }
            }
            string[] fileKeys = (string[]) fileKeyList.ToArray(typeof(string));

            Directory.CreateDirectory(this.TempDirectory);

            ArrayList remainingFileKeys = new ArrayList(fileKeys);
            foreach(string fileKey in fileKeys)
            {
                InstallPath fileInstallPath = compressedFileMap[fileKey];
                if(fileInstallPath != null)
                {
                    UpdateFileStats(fileKey, fileInstallPath);

                    string filePath = Path.Combine(this.WorkingDirectory, fileInstallPath.SourcePath);
                    this.LogMessage("copy {0} {1}", filePath, fileKey);
                    File.Copy(filePath, Path.Combine(this.TempDirectory, fileKey), true);
                    remainingFileKeys.Remove(fileKey);
                }
            }

            if(remainingFileKeys.Count > 0)
            {
                this.cabName = mediaCab;
                this.cabMsg = "extract {0}\\{1}";
                string[] remainingFileKeysArray = (string[]) remainingFileKeys.ToArray(typeof(string));
                cab.UnpackFiles(remainingFileKeysArray, this.TempDirectory, remainingFileKeysArray,
                    this.CabinetProgress);
            }

            ClearReadOnlyAttribute(this.TempDirectory, fileKeys);

            if(!cabFileIsTemp)
            {
                cab = new CabInfo(Path.Combine(this.WorkingDirectory, mediaCab));
            }
            this.cabName = mediaCab;
            this.cabMsg = "compress {0}\\{1}";
            cab.PackFiles(this.TempDirectory, fileKeys, fileKeys,
                this.CompressionLevel, this.CabinetProgress);

            if(cabFileIsTemp)
            {
                Record streamRec = new Record(1);
                streamRec.SetStream(1, cabFile);
                this.Execute(String.Format(
                    "UPDATE `_Streams` SET `Data` = ? WHERE `Name` = '{0}'", mediaCab),
                    streamRec);
            }
        }

        foreach (KeyValuePair<string, InstallPath> entry in uncompressedFileMap)
        {
            UpdateFileStats((string) entry.Key, (InstallPath) entry.Value);
        }
//.........这里部分代码省略.........
开发者ID:bleissem,项目名称:wix3,代码行数:101,代码来源:InstallPackage.cs


注:本文中的Record.SetStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。