public void CreateTransformSummaryInfo( Database referenceDatabase, string transformFile, TransformErrors errors, TransformValidations validations) { if (referenceDatabase == null) { throw new ArgumentNullException("referenceDatabase"); } if (string.IsNullOrWhiteSpace(transformFile)) { throw new ArgumentNullException("transformFile"); } uint ret = NativeMethods.MsiCreateTransformSummaryInfo( (int) this.Handle, (int) referenceDatabase.Handle, transformFile, (int) errors, (int) validations); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } }
internal TableInfo(Database db, string name) { if (db == null) { throw new ArgumentNullException("db"); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } this.name = name; using (View columnsView = db.OpenView("SELECT * FROM `{0}`", name)) { this.columns = new ColumnCollection(columnsView); } this.primaryKeys = new ReadOnlyCollection<string>( TableInfo.GetTablePrimaryKeys(db, name)); }
public bool GenerateTransform(Database referenceDatabase, string transformFile) { if (referenceDatabase == null) { throw new ArgumentNullException("referenceDatabase"); } if (string.IsNullOrWhiteSpace(transformFile)) { throw new ArgumentNullException("transformFile"); } uint ret = NativeMethods.MsiDatabaseGenerateTransform((int) this.Handle, (int) referenceDatabase.Handle, transformFile, 0, 0); if (ret == (uint) NativeMethods.Error.NO_DATA) { return false; } else if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } return true; }
private static IList<string> GetTablePrimaryKeys(Database db, string table) { if (table == "_Tables") { return new string[] { "Name" }; } else if (table == "_Columns") { return new string[] { "Table", "Number" }; } else if (table == "_Storages") { return new string[] { "Name" }; } else if (table == "_Streams") { return new string[] { "Name" }; } else { int hrec; uint ret = RemotableNativeMethods.MsiDatabaseGetPrimaryKeys( (int) db.Handle, table, out hrec); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } using (Record rec = new Record((IntPtr) hrec, true, null)) { string[] keys = new string[rec.FieldCount]; for (int i = 0; i < keys.Length; i++) { keys[i] = rec.GetString(i + 1); } return keys; } } }
public void Merge(Database otherDatabase) { this.Merge(otherDatabase, null); }
public void Merge(Database otherDatabase, string errorTable) { if (otherDatabase == null) { throw new ArgumentNullException("otherDatabase"); } uint ret = NativeMethods.MsiDatabaseMerge((int) this.Handle, (int) otherDatabase.Handle, errorTable); if (ret != 0) { if (ret == (uint) NativeMethods.Error.FUNCTION_FAILED) { throw new MergeException(this, errorTable); } else if (ret == (uint) NativeMethods.Error.DATATYPE_MISMATCH) { throw new MergeException("Schema difference between the two databases."); } else { throw InstallerException.ExceptionFromReturnCode(ret); } } }
/// <summary> /// Closes the session handle. Also closes the active database handle, if it is open. /// After closing a handle, further method calls may throw an <see cref="InvalidHandleException"/>. /// </summary> /// <param name="disposing">If true, the method has been called directly /// or indirectly by a user's code, so managed and unmanaged resources will /// be disposed. If false, only unmanaged resources will be disposed.</param> protected override void Dispose(bool disposing) { try { if (disposing) { if (this.database != null) { this.database.Dispose(); this.database = null; } } } finally { base.Dispose(disposing); } }
public static Session OpenPackage(Database database, bool ignoreMachineState) { if (database == null) { throw new ArgumentNullException("database"); } return Installer.OpenPackage( String.Format(CultureInfo.InvariantCulture, "#{0}", database.Handle), ignoreMachineState); }
internal MergeException(Database db, string conflictsTableName) : base("Merge failed.") { if (conflictsTableName != null) { IList<string> conflictTableList = new List<string>(); IList<int> conflictCountList = new List<int>(); using (View view = db.OpenView("SELECT `Table`, `NumRowMergeConflicts` FROM `" + conflictsTableName + "`")) { view.Execute(); foreach (Record rec in view) using (rec) { conflictTableList.Add(rec.GetString(1)); conflictCountList.Add((int) rec.GetInteger(2)); } } this.conflictTables = conflictTableList; this.conflictCounts = conflictCountList; } }