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


C# Database.OpenExecuteView方法代码示例

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


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

示例1: Run

 public override void Run(List<string> args)
 {
     // args[0]=v, args[1]=filename.msi
     if (args.Count < 2)
         throw new OptionException("You must specify an msi filename.", "v");
     var msiFileName = args[1];
     using (var msidb = new Database(msiFileName, OpenDatabase.ReadOnly))
     {
         const string tableName = "Property";
         var query = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM `{0}`", tableName);
         using (var view = new ViewWrapper(msidb.OpenExecuteView(query)))
         {
             foreach (var row in view.Records)
             {
                 var property = (string)row[view.ColumnIndex("Property")];
                 var value = row[view.ColumnIndex("Value")];
                 if (string.Equals("ProductVersion", property, StringComparison.InvariantCultureIgnoreCase))
                 {
                     Console.WriteLine(value);
                     return;
                 }
             }
             Console.WriteLine("Version not found!");
         }
     }
 }
开发者ID:radiesel,项目名称:lessmsi,代码行数:26,代码来源:ShowVersionCommand.cs

示例2: GetRowsFromTable

        public static TableRow[] GetRowsFromTable(Database msidb, string tableName)
        {
            if (!msidb.TableExists(tableName))
            {
                Trace.WriteLine(string.Format("Table name does {0} not exist Found.", tableName));
                return new TableRow[0];
            }

            string query = string.Concat("SELECT * FROM `", tableName, "`");
            using (var view = new ViewWrapper(msidb.OpenExecuteView(query)))
            {
                var /*<TableRow>*/ rows = new ArrayList(view.Records.Count);

                ColumnInfo[] columns = view.Columns;
                foreach (object[] values in view.Records)
                {
                    HybridDictionary valueCollection = new HybridDictionary(values.Length);
                    for (int cIndex = 0; cIndex < columns.Length; cIndex++)
                    {
                        valueCollection[columns[cIndex].Name] = values[cIndex];
                    }
                    rows.Add(new TableRow(valueCollection));
                }
                return (TableRow[]) rows.ToArray(typeof(TableRow));
            }
        }
开发者ID:dbremner,项目名称:lessmsi,代码行数:26,代码来源:TableWrapper.cs

示例3: Run

        public override void Run(List<string> args)
        {
            /* examples:
             *	lessmsi l -t Component c:\theinstall.msi
             *	lessmsi l -t Property c:\theinstall.msi
            */
            args = args.Skip(1).ToList();
            var tableName = "";
            var options = new OptionSet {
                { "t=", "Specifies the table to list.", t => tableName = t }
            };
            var extra = options.Parse(args);
            if (extra.Count < 1)
                throw new OptionException("You must specify the msi file to list from.", "l");
            if (string.IsNullOrEmpty(tableName))
                throw new OptionException("You must specify the table name to list.", "t");

            var csv = new StringBuilder();
            Debug.Print("Opening msi file '{0}'.", extra[0]);
            using (var msidb = new Database(extra[0], OpenDatabase.ReadOnly))
            {
                Debug.Print("Opening table '{0}'.", tableName);
                var query = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM `{0}`", tableName);
                using (var view = new ViewWrapper(msidb.OpenExecuteView(query)))
                {
                    for (var index = 0; index < view.Columns.Length; index++)
                    {
                        var col = view.Columns[index];
                        if (index > 0)
                            csv.Append(',');
                        csv.Append(col.Name);
                    }
                    csv.AppendLine();
                    foreach (var row in view.Records)
                    {
                        for (var colIndex = 0; colIndex < row.Length; colIndex++)
                        {
                            if (colIndex > 0)
                                csv.Append(',');
                            var val = Convert.ToString(row[colIndex], CultureInfo.InvariantCulture);
                            var newLine = Environment.NewLine;
                            string[] requireEscapeChars = { ",", newLine };
                            Array.ForEach(requireEscapeChars, s => {
                                if (val.Contains(s))
                                    val = "\"" + val + "\"";
                            });
                            csv.Append(val);
                        }
                        csv.AppendLine();
                    }
                }
            }
            Console.Write(csv.ToString());
        }
开发者ID:radiesel,项目名称:lessmsi,代码行数:54,代码来源:ListTableCommand.cs

示例4: ExtractCabFromPackage

        /// <summary>
        /// Write the Cab to disk.
        /// </summary>
        /// <param name="filePath">Specifies the path to the file to contain the stream.</param>
        /// <param name="cabName">Specifies the name of the file in the stream.</param>
        public static void ExtractCabFromPackage(string filePath, string cabName, Database inputDatabase)
        {
            using (View view = inputDatabase.OpenExecuteView(String.Concat("SELECT * FROM `_Streams` WHERE `Name` = '", cabName, "'")))
            {
                Record record;
                if (view.Fetch(out record))
                {
                    FileStream cabFilestream = null;
                    BinaryWriter writer = null;
                    try
                    {
                        cabFilestream = new FileStream(filePath, FileMode.Create);

                        // Create the writer for data.
                        writer = new BinaryWriter(cabFilestream);

                        var buf = new byte[1024*1024];
                        int count;
                        do
                        {
                            const int MsiInterop_Storages_Data = 2; //From wiX:Index to column name Data into Record for row in Msi Table Storages
                            count = record.GetStream(MsiInterop_Storages_Data, buf, buf.Length);
                            if (count > 0)
                                writer.Write(buf, 0, count);
                        } while (count > 0);
                    }
                    finally
                    {
                        if (writer != null)
                        {
                            writer.Close();
                        }

                        if (cabFilestream != null)
                        {
                            cabFilestream.Close();
                        }
                    }
                }
            }
        }
开发者ID:radiesel,项目名称:lessmsi,代码行数:46,代码来源:Wixtracts.cs

示例5: ProcessUncompressedFiles

        /// <summary>
        /// Process uncompressed files.
        /// </summary>
        /// <param name="tempDatabaseFile">The temporary database file.</param>
        /// <param name="fileRows">The collection of files to copy into the image.</param>
        /// <param name="fileTransfers">Array of files to be transfered.</param>
        /// <param name="mediaRows">The indexed media rows.</param>
        /// <param name="layoutDirectory">The directory in which the image should be layed out.</param>
        /// <param name="compressed">Flag if source image should be compressed.</param>
        /// <param name="longNamesInImage">Flag if long names should be used.</param>
        private void ProcessUncompressedFiles(string tempDatabaseFile, FileRowCollection fileRows, ArrayList fileTransfers, MediaRowCollection mediaRows, string layoutDirectory, bool compressed, bool longNamesInImage)
        {
            if (0 == fileRows.Count || this.core.EncounteredError)
            {
                return;
            }

            Hashtable directories = new Hashtable();
            using (Database db = new Database(tempDatabaseFile, OpenDatabase.ReadOnly))
            {
                using (View directoryView = db.OpenExecuteView("SELECT `Directory`, `Directory_Parent`, `DefaultDir` FROM `Directory`"))
                {
                    while (true)
                    {
                        using (Record directoryRecord = directoryView.Fetch())
                        {
                            if (null == directoryRecord)
                            {
                                break;
                            }

                            string sourceName = Installer.GetName(directoryRecord.GetString(3), true, longNamesInImage);

                            directories.Add(directoryRecord.GetString(1), new ResolvedDirectory(directoryRecord.GetString(2), sourceName));
                        }
                    }
                }

                using (View fileView = db.OpenView("SELECT `Directory_`, `FileName` FROM `Component`, `File` WHERE `Component`.`Component`=`File`.`Component_` AND `File`.`File`=?"))
                {
                    using (Record fileQueryRecord = new Record(1))
                    {
                        // for each file in the array of uncompressed files
                        foreach (FileRow fileRow in fileRows)
                        {
                            string relativeFileLayoutPath = null;

                            string mediaLayoutDirectory = this.FileManager.ResolveMedia(mediaRows[fileRow.DiskId], layoutDirectory);

                            // setup up the query record and find the appropriate file in the
                            // previously executed file view
                            fileQueryRecord[1] = fileRow.File;
                            fileView.Execute(fileQueryRecord);

                            using (Record fileRecord = fileView.Fetch())
                            {
                                if (null == fileRecord)
                                {
                                    throw new WixException(WixErrors.FileIdentifierNotFound(fileRow.SourceLineNumbers, fileRow.File));
                                }

                                relativeFileLayoutPath = Binder.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], compressed, longNamesInImage);
                            }

                            // finally put together the base media layout path and the relative file layout path
                            string fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath);
                            FileTransfer transfer;
                            if (FileTransfer.TryCreate(fileRow.Source, fileLayoutPath, false, "File", fileRow.SourceLineNumbers, out transfer))
                            {
                                fileTransfers.Add(transfer);
                            }
                        }
                    }
                }
            }
        }
开发者ID:zooba,项目名称:wix3,代码行数:76,代码来源:Binder.cs

示例6: ProcessMergeModules

        /// <summary>
        /// Retrieve files and their information from merge modules.
        /// </summary>
        /// <param name="output">Internal representation of the msi database to operate upon.</param>
        /// <param name="fileRows">The indexed file rows.</param>
        private void ProcessMergeModules(Output output, FileRowCollection fileRows)
        {
            Table wixMergeTable = output.Tables["WixMerge"];
            if (null != wixMergeTable)
            {
                IMsmMerge2 merge = NativeMethods.GetMsmMerge();

                // Get the output's minimum installer version
                int outputInstallerVersion = int.MinValue;
                Table summaryInformationTable = output.Tables["_SummaryInformation"];
                if (null != summaryInformationTable)
                {
                    foreach (Row row in summaryInformationTable.Rows)
                    {
                        if (14 == (int)row[0])
                        {
                            outputInstallerVersion = Convert.ToInt32(row[1], CultureInfo.InvariantCulture);
                            break;
                        }
                    }
                }

                foreach (Row row in wixMergeTable.Rows)
                {
                    bool containsFiles = false;
                    WixMergeRow wixMergeRow = (WixMergeRow)row;

                    try
                    {
                        // read the module's File table to get its FileMediaInformation entries and gather any other information needed from the module.
                        using (Database db = new Database(wixMergeRow.SourceFile, OpenDatabase.ReadOnly))
                        {
                            if (db.TableExists("File") && db.TableExists("Component"))
                            {
                                Hashtable uniqueModuleFileIdentifiers = System.Collections.Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable();

                                using (View view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`"))
                                {
                                    // add each file row from the merge module into the file row collection (check for errors along the way)
                                    while (true)
                                    {
                                        using (Record record = view.Fetch())
                                        {
                                            if (null == record)
                                            {
                                                break;
                                            }

                                            // NOTE: this is very tricky - the merge module file rows are not added to the
                                            // file table because they should not be created via idt import.  Instead, these
                                            // rows are created by merging in the actual modules
                                            FileRow fileRow = new FileRow(null, this.core.TableDefinitions["File"]);
                                            fileRow.File = record[1];
                                            fileRow.Compressed = wixMergeRow.FileCompression;
                                            fileRow.Directory = record[2];
                                            fileRow.DiskId = wixMergeRow.DiskId;
                                            fileRow.FromModule = true;
                                            fileRow.PatchGroup = -1;
                                            fileRow.Source = String.Concat(this.TempFilesLocation, Path.DirectorySeparatorChar, "MergeId.", wixMergeRow.Number.ToString(CultureInfo.InvariantCulture.NumberFormat), Path.DirectorySeparatorChar, record[1]);

                                            FileRow collidingFileRow = fileRows[fileRow.File];
                                            FileRow collidingModuleFileRow = (FileRow)uniqueModuleFileIdentifiers[fileRow.File];

                                            if (null == collidingFileRow && null == collidingModuleFileRow)
                                            {
                                                fileRows.Add(fileRow);

                                                // keep track of file identifiers in this merge module
                                                uniqueModuleFileIdentifiers.Add(fileRow.File, fileRow);
                                            }
                                            else // collision(s) detected
                                            {
                                                // case-sensitive collision with another merge module or a user-authored file identifier
                                                if (null != collidingFileRow)
                                                {
                                                    this.core.OnMessage(WixErrors.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, collidingFileRow.File));
                                                }

                                                // case-insensitive collision with another file identifier in the same merge module
                                                if (null != collidingModuleFileRow)
                                                {
                                                    this.core.OnMessage(WixErrors.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, fileRow.File, collidingModuleFileRow.File));
                                                }
                                            }

                                            containsFiles = true;
                                        }
                                    }
                                }
                            }

                            // Get the summary information to detect the Schema
                            using (SummaryInformation summaryInformation = new SummaryInformation(db))
                            {
                                string moduleInstallerVersionString = summaryInformation.GetProperty(14);
//.........这里部分代码省略.........
开发者ID:zooba,项目名称:wix3,代码行数:101,代码来源:Binder.cs

示例7: MergeModules


//.........这里部分代码省略.........
            }
            finally
            {
                if (databaseOpen)
                {
                    merge.CloseDatabase(commit);
                }

                if (logOpen)
                {
                    merge.CloseLog();
                }
            }

            // stop processing if an error previously occurred
            if (this.core.EncounteredError)
            {
                return;
            }

            using (Database db = new Database(tempDatabaseFile, OpenDatabase.Direct))
            {
                Table suppressActionTable = output.Tables["WixSuppressAction"];

                // suppress individual actions
                if (null != suppressActionTable)
                {
                    foreach (Row row in suppressActionTable.Rows)
                    {
                        if (db.TableExists((string)row[0]))
                        {
                            string query = String.Format(CultureInfo.InvariantCulture, "SELECT * FROM {0} WHERE `Action` = '{1}'", row[0].ToString(), (string)row[1]);

                            using (View view = db.OpenExecuteView(query))
                            {
                                using (Record record = view.Fetch())
                                {
                                    if (null != record)
                                    {
                                        this.core.OnMessage(WixWarnings.SuppressMergedAction((string)row[1], row[0].ToString()));
                                        view.Modify(ModifyView.Delete, record);
                                    }
                                }
                            }
                        }
                    }
                }

                // query for merge module actions in suppressed sequences and drop them
                foreach (string tableName in suppressedTableNames)
                {
                    if (!db.TableExists(tableName))
                    {
                        continue;
                    }

                    using (View view = db.OpenExecuteView(String.Concat("SELECT `Action` FROM ", tableName)))
                    {
                        while (true)
                        {
                            using (Record resultRecord = view.Fetch())
                            {
                                if (null == resultRecord)
                                {
                                    break;
                                }
开发者ID:zooba,项目名称:wix3,代码行数:67,代码来源:Binder.cs

示例8: InscribeDatabase

        /// <summary>
        /// Updates database with signatures from external cabinets.
        /// </summary>
        /// <param name="databaseFile">Path to MSI database.</param>
        /// <param name="outputFile">Ouput for updated MSI database.</param>
        /// <param name="tidy">Clean up files.</param>
        /// <returns>True if database is updated.</returns>
        public bool InscribeDatabase(string databaseFile, string outputFile, bool tidy)
        {
            // Keeps track of whether we've encountered at least one signed cab or not - we'll throw a warning if no signed cabs were encountered
            bool foundUnsignedExternals = false;
            bool shouldCommit = false;

            FileAttributes attributes = File.GetAttributes(databaseFile);
            if (FileAttributes.ReadOnly == (attributes & FileAttributes.ReadOnly))
            {
                this.OnMessage(WixErrors.ReadOnlyOutputFile(databaseFile));
                return shouldCommit;
            }

            using (Database database = new Database(databaseFile, OpenDatabase.Transact))
            {
                // Just use the English codepage, because the tables we're importing only have binary streams / MSI identifiers / other non-localizable content
                int codepage = 1252;

                // list of certificates for this database (hash/identifier)
                Dictionary<string, string> certificates = new Dictionary<string, string>();

                // Reset the in-memory tables for this new database
                Table digitalSignatureTable = new Table(null, this.tableDefinitions["MsiDigitalSignature"]);
                Table digitalCertificateTable = new Table(null, this.tableDefinitions["MsiDigitalCertificate"]);

                // If any digital signature records exist that are not of the media type, preserve them
                if (database.TableExists("MsiDigitalSignature"))
                {
                    using (View digitalSignatureView = database.OpenExecuteView("SELECT `Table`, `SignObject`, `DigitalCertificate_`, `Hash` FROM `MsiDigitalSignature` WHERE `Table` <> 'Media'"))
                    {
                        while (true)
                        {
                            using (Record digitalSignatureRecord = digitalSignatureView.Fetch())
                            {
                                if (null == digitalSignatureRecord)
                                {
                                    break;
                                }

                                Row digitalSignatureRow = null;
                                digitalSignatureRow = digitalSignatureTable.CreateRow(null);

                                string table = digitalSignatureRecord.GetString(0);
                                string signObject = digitalSignatureRecord.GetString(1);

                                digitalSignatureRow[0] = table;
                                digitalSignatureRow[1] = signObject;
                                digitalSignatureRow[2] = digitalSignatureRecord.GetString(2);

                                if (false == digitalSignatureRecord.IsNull(3))
                                {
                                    // Export to a file, because the MSI API's require us to provide a file path on disk
                                    string hashPath = Path.Combine(this.TempFilesLocation, "MsiDigitalSignature");
                                    string hashFileName = string.Concat(table,".", signObject, ".bin");

                                    Directory.CreateDirectory(hashPath);
                                    hashPath = Path.Combine(hashPath, hashFileName);

                                    using (FileStream fs = File.Create(hashPath))
                                    {
                                        int bytesRead;
                                        byte[] buffer = new byte[1024 * 4];

                                        while (0 != (bytesRead = digitalSignatureRecord.GetStream(3, buffer, buffer.Length)))
                                        {
                                            fs.Write(buffer, 0, bytesRead);
                                        }
                                    }

                                    digitalSignatureRow[3] = hashFileName;
                                }
                            }
                        }
                    }
                }

                // If any digital certificates exist, extract and preserve them
                if (database.TableExists("MsiDigitalCertificate"))
                {
                    using (View digitalCertificateView = database.OpenExecuteView("SELECT * FROM `MsiDigitalCertificate`"))
                    {
                        while (true)
                        {
                            using (Record digitalCertificateRecord = digitalCertificateView.Fetch())
                            {
                                if (null == digitalCertificateRecord)
                                {
                                    break;
                                }

                                string certificateId = digitalCertificateRecord.GetString(1); // get the identifier of the certificate

                                // Export to a file, because the MSI API's require us to provide a file path on disk
//.........这里部分代码省略.........
开发者ID:zooba,项目名称:wix3,代码行数:101,代码来源:inscriber.cs

示例9: LoadTables


//.........这里部分代码省略.........
                "MIME",
                "MoveFile",
                "MsiAssembly",
                "MsiAssemblyName",
                "MsiDigitalCertificate",
                "MsiDigitalSignature",
                "MsiEmbeddedChainer",
                "MsiEmbeddedUI",
                "MsiFileHash",
                "MsiLockPermissionsEx Table",
                "MsiPackageCertificate",
                "MsiPatchCertificate",
                "MsiPatchHeaders",
                "MsiPatchMetadata",
                "MsiPatchOldAssemblyName",
                "MsiPatchOldAssemblyFile",
                "MsiPatchSequence",
                "MsiServiceConfig",
                "MsiServiceConfigFailureActions",
                "MsiSFCBypass",
                "ODBCAttribute",
                "ODBCDataSource",
                "ODBCDriver",
                "ODBCSourceAttribute",
                "ODBCTranslator",
                "Patch",
                "PatchPackage",
                "ProgId",
                "Property",
                "PublishComponent",
                "RadioButton",
                "Registry",
                "RegLocator",
                "RemoveFile",
                "RemoveIniFile",
                "RemoveRegistry",
                "ReserveCost",
                "SelfReg",
                "ServiceControl",
                "ServiceInstall",
                "SFPCatalog",
                "Shortcut",
                "Signature",
                "TextStyle",
                "TypeLib",
                "UIText",
                "Verb",
                "_Validation",
                "_Columns",
                "_Streams",
                "_Storages",
                "_Tables",
                "_TransformView Table",
                "Upgrade"
                #endregion
            };

            var systemTables = new string[]
            {
                "_Validation",
                "_Columns",
                "_Streams",
                "_Storages",
                "_Tables",
                "_TransformView Table"
            };

            IEnumerable<string> msiTableNames = allTableNames;

            using (var msidb = new Database(View.SelectedMsiFile.FullName, OpenDatabase.ReadOnly))
            {
                using (new DisposableCursor(View))
                {
                    try
                    {
                        Status("Loading list of tables...");
                        var query = "SELECT * FROM `_Tables`";
                        using (var msiTable = new ViewWrapper(msidb.OpenExecuteView(query)))
                        {
                            var tableNames = from record in msiTable.Records
                                select record[0] as string;
                            //NOTE: system tables are not usually in the _Tables table.
                            var tempList = tableNames.ToList();
                            tempList.AddRange(systemTables);
                            msiTableNames = tempList.ToArray();
                        }

                        Status("");
                    }
                    catch (Exception e)
                    {
                        Status(e.Message);
                    }

                    View.cboTable.Items.Clear();
                    View.cboTable.Items.AddRange(msiTableNames.ToArray());
                    View.cboTable.SelectedIndex = 0;
                }
            }
        }
开发者ID:radiesel,项目名称:lessmsi,代码行数:101,代码来源:MainFormPresenter.cs

示例10: Main

        static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                string [] argSplit = arg.Split(new char[] {':'}, 2);

                if (argSplit.Length != 2) Usage();

                argSplit[0] = argSplit[0].Substring(1).ToLower();

                if (argSplit[0] == "msi")
                {
                    installer = argSplit[1];
                }
                else if (argSplit[0] == "out")
                {
                    outDir = argSplit[1];
                }
                else
                {
                    Usage();
                }
            }

            if (installer == null) Usage();

            Database db = new Database(installer, OpenDatabase.ReadOnly);
            View view = db.OpenExecuteView("SELECT FileName FROM File");

            Record record;
            while (view.Fetch(out record))
            {
                string file = record[1];

                //parse file by |??

                string[] fileParts = file.Split('|');
                string name;

                if (fileParts.Length == 2)
                {
                    name = fileParts[1].ToLower();
                }
                else if (fileParts.Length == 1)
                {
                    name = fileParts[0].ToLower();
                }
                else
                {
                    continue;
                }

                string ext = Path.GetExtension(name);
                if (ext == ".dll" || ext == ".exe")
                {
                    if (!binFiles.Contains(name))
                    {
                        binFiles.Add(name);
                        Console.WriteLine(name);
                    }
                }
            }

            if (outDir == null) Environment.Exit(0);

            if (!Directory.Exists(outDir))
            {
                Directory.CreateDirectory(outDir);   
            }

            if (!Directory.Exists(outDir + "\\client"))
            {
                Directory.CreateDirectory(outDir + "\\client");
            }

            if (!Directory.Exists(outDir + "\\server"))
            {
                Directory.CreateDirectory(outDir + "\\server");
            }

            string clientDir = Environment.GetEnvironmentVariable("BUILD_TREE_CLIENT") + "\\dll";
            string serverDir = Environment.GetEnvironmentVariable("BUILD_TREE_SERVER") + "\\dll";

            if (!Directory.Exists(clientDir))
            {
                Console.WriteLine("Could not find {0}.  Did you set the environment", clientDir);
                Environment.Exit(2);
            }

            if (!Directory.Exists(serverDir))
            {
                Console.WriteLine("Could not find {0}.  Did you set the environment", serverDir);
                Environment.Exit(2);
            }

            foreach (string binFile in binFiles)
            {
                bool copyClient = false;
                if (File.Exists(clientDir + "\\" + binFile))
                {
//.........这里部分代码省略.........
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:101,代码来源:Program.cs

示例11: ImportStreams

        /// <summary>
        /// Adds all the streams to the final output.
        /// </summary>
        /// <param name="databasePath">Path to database.</param>
        /// <param name="output">Output object that points at final output.</param>
        private void ImportStreams(string databasePath, Output output)
        {
            using (Database db = new Database(databasePath, OpenDatabase.Direct))
            {
                View streamsView = null;
                View binaryView = null;
                View iconView = null;
                View certificateView = null;

                try
                {
                    streamsView = db.OpenExecuteView("SELECT `Name`, `Data` FROM `_Streams`");
                    if (db.TableExists("Binary"))
                    {
                        binaryView = db.OpenExecuteView("SELECT `Name`, `Data` FROM `Binary`");
                    }
                    if (db.TableExists("Icon"))
                    {
                        iconView = db.OpenExecuteView("SELECT `Name`, `Data` FROM `Icon`");
                    }
                    if (db.TableExists("MsiDigitalCertificate"))
                    {
                        certificateView = db.OpenExecuteView("SELECT `DigitalCertificate`, `CertData` FROM `MsiDigitalCertificate`");
                    }

                    foreach (ImportStream importStream in output.ImportStreams)
                    {
                        string src;
                        using (Record record = new Record(2))
                        {
                            try
                            {
                                switch (importStream.Type)
                                {
                                    case ImportStreamType.Cabinet:
                                        this.OnMessage(WixVerboses.ImportCabinetStream(importStream.StreamName, importStream.Path));

                                        record[1] = importStream.StreamName;
                                        record.SetStream(2, importStream.Path);
                                        streamsView.Modify(ModifyView.Assign, record);
                                        break;

                                    case ImportStreamType.DigitalCertificate:
                                        src = this.extension.FileResolutionHandler(importStream.Path, FileResolutionType.DigitalCertificate);
                                        this.OnMessage(WixVerboses.ImportDigitalCertificateStream(null, VerboseLevel.Trace, src));

                                        record[1] = importStream.StreamName;
                                        record.SetStream(2, importStream.Path);
                                        certificateView.Modify(ModifyView.Assign, record);
                                        break;

                                    case ImportStreamType.Binary:
                                        src = this.extension.FileResolutionHandler(importStream.Path, FileResolutionType.Binary);
                                        this.OnMessage(WixVerboses.ImportBinaryStream(null, VerboseLevel.Trace, src));

                                        if (OutputType.Module == output.Type)
                                        {
                                            record[1] = String.Concat(importStream.StreamName, ".", output.ModularizationGuid);
                                        }
                                        else
                                        {
                                            record[1] = importStream.StreamName;
                                        }
                                        if (55 < record[1].Length)
                                        {
                                            throw new WixInvalidAttributeException(null, "Binary", "Id", String.Format("Identifier cannot be longer than 55 characters.  Binary identifier: {0}", record[1]));
                                        }
                                        record.SetStream(2, src);
                                        binaryView.Modify(ModifyView.Assign, record);
                                        break;

                                    case ImportStreamType.Icon:
                                        src = this.extension.FileResolutionHandler(importStream.Path, FileResolutionType.Icon);
                                        this.OnMessage(WixVerboses.ImportIconStream(null, VerboseLevel.Verbose, src));

                                        if (OutputType.Module == output.Type)
                                        {
                                            int start = importStream.StreamName.LastIndexOf(".");
                                            if (-1 == start)
                                            {
                                                record[1] = String.Concat(importStream.StreamName, ".", output.ModularizationGuid);
                                            }
                                            else
                                            {
                                                record[1] = String.Concat(importStream.StreamName.Substring(0, start), ".", output.ModularizationGuid, importStream.StreamName.Substring(start));
                                            }
                                        }
                                        else
                                        {
                                            record[1] = importStream.StreamName;
                                        }
                                        if (55 < record[1].Length)
                                        {
                                            throw new WixInvalidAttributeException(null, "Icon", "Id", String.Format("Identifier cannot be longer than 55 characters.  Icon identifier: {0}", record[1]));
                                        }
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:Binder.cs

示例12: CreateUncompressedImage

        /// <summary>
        /// Lays out the binaries for the uncompressed portion of a source image.
        /// </summary>
        /// <param name="databasePath">Path to database.</param>
        /// <param name="output">Output being created.</param>
        /// <param name="files">Array of files to copy into image.</param>
        /// <param name="packageCompressed">Flag if package is compressed.</param>
        /// <param name="fileTransfers">Array of files to be transfered.</param>
        private void CreateUncompressedImage(string databasePath, Output output, ArrayList files, bool packageCompressed, ArrayList fileTransfers)
        {
            if (0 == files.Count || this.foundError)
            {
                return;
            }

            bool longNamesInImage = output.LongFileNames;
            Hashtable directories = new Hashtable();
            using (Database db = new Database(databasePath, OpenDatabase.ReadOnly))
            {
                using (View directoryView = db.OpenExecuteView("SELECT `Directory`, `Directory_Parent`, `DefaultDir` FROM `Directory`"))
                {
                    Record directoryRecord;

                    while (directoryView.Fetch(out directoryRecord))
                    {
                        string sourceName = GetSourceName(directoryRecord.GetString(3), longNamesInImage);

                        directories.Add(directoryRecord.GetString(1), new ResolvedDirectory(directoryRecord.GetString(2), sourceName));
                    }
                }

                using (View fileView = db.OpenView("SELECT `Directory_`, `FileName` FROM `Component`, `File` WHERE `Component`.`Component`=`File`.`Component_` AND `File`.`File`=?"))
                {
                    // if an output path was specified for our image, use that as our default base,
                    // otherwise use the directory where the output is being placed
                    string defaultBaseOuputPath = null != this.imagebaseOutputPath ? this.imagebaseOutputPath : Path.GetDirectoryName(output.Path);

                    using (Record fileQueryRecord = new Record(1))
                    {
                        // for each file in the array of uncompressed files
                        foreach (FileMediaInformation fmi in files)
                        {
                            string currentSourcePath = null;
                            string relativeSourcePath = null;

                            // determine what the base of the file should be.  If there was
                            // no src specified in the Media element (the default) then just
                            // use the default output path (usually the same directory as the
                            // output file).  If there was a build directory specified then
                            // check if it is a absolute path, and if not add the default
                            // output path to the root
                            MediaRow mediaRow = output.MediaRows[fmi.Media];
                            string baseRelativeSourcePath = mediaRow.Layout;
                            if (null == baseRelativeSourcePath)
                            {
                                baseRelativeSourcePath = defaultBaseOuputPath;
                            }
                            else if (!Path.IsPathRooted(baseRelativeSourcePath))
                            {
                                baseRelativeSourcePath = Path.Combine(defaultBaseOuputPath, baseRelativeSourcePath);
                            }

                            // setup up the query record and find the appropriate file in the
                            // previously executed file view
                            fileQueryRecord[1] = fmi.File;
                            fileView.Execute(fileQueryRecord);

                            Record fileRecord;
                            if (!fileView.Fetch(out fileRecord))
                            {
                                throw new WixFileMediaInformationKeyNotFoundException(fmi.File);
                            }

                            string fileName = GetSourceName(fileRecord[2], longNamesInImage);

                            if (packageCompressed)
                            {
                                // use just the file name of the file since all uncompressed files must appear
                                // in the root of the image in a compressed package
                                relativeSourcePath = fileName;
                            }
                            else
                            {
                                // get the relative path of where we want the source to be as specified
                                // in the Directory table
                                string directoryPath = GetDirectoryPath(directories, fileRecord[1], longNamesInImage);
                                relativeSourcePath = Path.Combine(directoryPath, fileName);
                            }

                            // if the relative source path was not resolved above then we have to bail
                            if (null == relativeSourcePath)
                            {
                                throw new WixFileMediaInformationKeyNotFoundException(fmi.File);
                            }

                            // strip off "SourceDir" if it's still on there
                            if (relativeSourcePath.StartsWith("SourceDir\\"))
                            {
                                relativeSourcePath = relativeSourcePath.Substring(10);
                            }
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:Binder.cs

示例13: UpdateFileInformation

        /// <summary>
        /// Update several msi tables with data contained in files references in the File table.
        /// </summary>
        /// <remarks>
        /// For versioned files, update the file version and language in the File table.  For
        /// unversioned files, add a row to the MsiFileHash table for the file.  For assembly
        /// files, add a row to the MsiAssembly table and add AssemblyName information by adding
        /// MsiAssemblyName rows.
        /// </remarks>
        /// <param name="output">Internal representation of the msi database to operate upon.</param>
        private void UpdateFileInformation(Output output)
        {
            OutputTable mergeTable = output.OutputTables["Merge"];
            if (null != mergeTable)
            {
                foreach (OutputRow outputRow in mergeTable.OutputRows)
                {
                    MergeRow mergeRow = (MergeRow)outputRow.Row;
                    string moduleFile = null;
                    try
                    {
                        moduleFile = this.extension.FileResolutionHandler(mergeRow.SourceFile, FileResolutionType.Module);
                    }
                    catch (WixFileNotFoundException wfnfe)
                    {
                        this.OnMessage(WixErrors.BinderExtensionMissingFile(null, ErrorLevel.Normal, wfnfe.Message));
                        continue;
                    }

                    output.Modules.Add(mergeRow);
                    try
                    {
                        // read the module's File table to get its FileMediaInformation entries
                        using (Database db = new Database(moduleFile, OpenDatabase.ReadOnly))
                        {
                            mergeRow.HasFiles = false;

                            if (db.TableExists("File") && db.TableExists("Component"))
                            {
                                Hashtable uniqueModuleFileIdentifiers = System.Collections.Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable();

                                using (View view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`"))
                                {
                                    Record record;
                                    while (view.Fetch(out record))
                                    {
                                        FileMediaInformation fileMediaInformation = new FileMediaInformation(record[1], record[2], mergeRow.DiskId, String.Concat(this.tempFiles.BasePath, Path.DirectorySeparatorChar, "MergeId.", mergeRow.Id.GetHashCode().ToString("X4", CultureInfo.InvariantCulture.NumberFormat), Path.DirectorySeparatorChar, record[1]), mergeRow.Number, mergeRow.FileCompression, moduleFile, -1);
                                        FileMediaInformation otherFileMediaInformation = output.FileMediaInformationCollection[fileMediaInformation.FileId];
                                        string collidingModuleFileIdentifier = (string)uniqueModuleFileIdentifiers[fileMediaInformation.FileId];

                                        if (null == otherFileMediaInformation && null == collidingModuleFileIdentifier)
                                        {
                                            output.FileMediaInformationCollection.Add(fileMediaInformation);

                                            // keep track of file identifiers in this merge module
                                            uniqueModuleFileIdentifiers.Add(fileMediaInformation.FileId, fileMediaInformation.FileId);
                                        }
                                        else // collision(s) detected
                                        {
                                            // case-sensitive collision with another merge module or a user-authored file identifier
                                            if (null != otherFileMediaInformation)
                                            {
                                                this.OnMessage(WixErrors.DuplicateModuleFileIdentifier(mergeRow.SourceLineNumbers, mergeRow.Id, fileMediaInformation.FileId));
                                            }

                                            // case-insensitive collision with another file identifier in the same merge module
                                            if (null != collidingModuleFileIdentifier)
                                            {
                                                this.OnMessage(WixErrors.DuplicateModuleCaseInsensitiveFileIdentifier(mergeRow.SourceLineNumbers, mergeRow.Id, fileMediaInformation.FileId, collidingModuleFileIdentifier));
                                            }
                                        }

                                        mergeRow.HasFiles = true;
                                    }
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException fnfe)
                    {
                        throw new WixFileNotFoundException(null, moduleFile, fnfe);
                    }
                    catch (IOException ioe)
                    {
                        throw new WixMergeModuleOpenException(mergeRow.SourceLineNumbers, mergeRow.Id, moduleFile, ioe);
                    }
                }
            }

            // calculate sequence numbers and media disk id layout for all file media information objects
            if (OutputType.Module == output.Type)
            {
                int lastSequence = 0;
                foreach (FileMediaInformation fmi in output.FileMediaInformationCollection)
                {
                    fmi.Modularize(output.ModularizationGuid);
                    fmi.Sequence = ++lastSequence;
                }
            }
            else
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:Binder.cs

示例14: MergeModules


//.........这里部分代码省略.........
            }

            // create a Hashtable of all the suppressed sequence types
            Hashtable suppressedTableNames = new Hashtable();
            if (output.SuppressAdminSequence)
            {
                suppressedTableNames[Action.SequenceTypeToString(SequenceType.adminExecute)] = null;
                suppressedTableNames[Action.SequenceTypeToString(SequenceType.adminUI)] = null;
            }
            if (output.SuppressAdvertiseSequence)
            {
                suppressedTableNames[Action.SequenceTypeToString(SequenceType.advertiseExecute)] = null;
            }
            if (output.SuppressUISequence)
            {
                suppressedTableNames[Action.SequenceTypeToString(SequenceType.adminUI)] = null;
                suppressedTableNames[Action.SequenceTypeToString(SequenceType.installUI)] = null;
            }

            using (Database db = new Database(databasePath, OpenDatabase.Direct))
            {
                OutputTable suppressActionOutputTable = output.OutputTables["SuppressAction"];

                // suppress individual actions
                if (null != suppressActionOutputTable)
                {
                    foreach (OutputRow outputRow in suppressActionOutputTable.OutputRows)
                    {
                        if (db.TableExists((string)outputRow.Row[0]))
                        {
                            Row row = outputRow.Row;
                            string query = String.Format("SELECT * FROM {0} WHERE `Action` = '{1}'", row[0].ToString(), (string)row[1]);

                            using (View view = db.OpenExecuteView(query))
                            {
                                Record record;

                                if (view.Fetch(out record))
                                {
                                    this.OnMessage(WixWarnings.SuppressMergedAction((string)row[1], row[0].ToString()));
                                    view.Modify(ModifyView.Delete, record);
                                    record.Close();
                                }
                            }
                        }
                    }
                }

                // query for merge module actions in suppressed sequences and drop them
                foreach (string tableName in suppressedTableNames.Keys)
                {
                    if (!db.TableExists(tableName))
                    {
                        continue;
                    }

                    using (View view = db.OpenExecuteView(String.Concat("SELECT `Action` FROM ", tableName)))
                    {
                        Record resultRecord;
                        while (view.Fetch(out resultRecord))
                        {
                            this.OnMessage(WixWarnings.SuppressMergedAction(resultRecord.GetString(1), tableName));
                            resultRecord.Close();
                        }
                    }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:66,代码来源:Binder.cs

示例15: GenerateDatabase


//.........这里部分代码省略.........
                        {
                            try
                            {
                                db.ImportTable(output.Codepage, this.core, importTable, baseDirectory, keepAddedColumns);
                            }
                            catch (WixInvalidIdtException)
                            {
                                // If ValidateRows finds anything it doesn't like, it throws
                                importTable.ValidateRows();

                                // Otherwise we rethrow the InvalidIdt
                                throw;
                            }
                        }

                        // insert the rows via SQL query if this table contains object fields
                        if (hasBinaryColumn)
                        {
                            StringBuilder query = new StringBuilder("SELECT ");

                            // build the query for the view
                            bool firstColumn = true;
                            foreach (ColumnDefinition columnDefinition in table.Definition.Columns)
                            {
                                if (!firstColumn)
                                {
                                    query.Append(",");
                                }
                                query.AppendFormat(" `{0}`", columnDefinition.Name);
                                firstColumn = false;
                            }
                            query.AppendFormat(" FROM `{0}`", table.Name);

                            using (View tableView = db.OpenExecuteView(query.ToString()))
                            {
                                // import each row containing a stream
                                foreach (Row row in table.Rows)
                                {
                                    using (Record record = new Record(table.Definition.Columns.Count))
                                    {
                                        StringBuilder streamName = new StringBuilder();
                                        bool needStream = false;

                                        // the _Streams table doesn't prepend the table name (or a period)
                                        if ("_Streams" != table.Name)
                                        {
                                            streamName.Append(table.Name);
                                        }

                                        for (int i = 0; i < table.Definition.Columns.Count; i++)
                                        {
                                            ColumnDefinition columnDefinition = table.Definition.Columns[i];

                                            switch (columnDefinition.Type)
                                            {
                                                case ColumnType.Localized:
                                                case ColumnType.Preserved:
                                                case ColumnType.String:
                                                    if (columnDefinition.IsPrimaryKey)
                                                    {
                                                        if (0 < streamName.Length)
                                                        {
                                                            streamName.Append(".");
                                                        }
                                                        streamName.Append((string)row[i]);
                                                    }
开发者ID:zooba,项目名称:wix3,代码行数:67,代码来源:Binder.cs


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