/// <summary> /// A dummy function for the durable commit callback. /// </summary> /// <param name="instance"> /// The instance. /// </param> /// <param name="commitIdSeen"> /// The commit identifier. /// </param> /// <param name="grbit"> /// A group of option bits. /// </param> /// <returns>An error code, equal to success.</returns> private JET_err NullDurableCommitCallback( IntPtr instance, ref NATIVE_COMMIT_ID commitIdSeen, uint grbit) { return(JET_err.Success); }
/// <summary> /// Commits the changes made to the state of the database during the current save point /// and migrates them to the previous save point. If the outermost save point is committed /// then the changes made during that save point will be committed to the state of the /// database and the session will exit the transaction. /// </summary> /// <param name="sesid">The session to commit the transaction for.</param> /// <param name="grbit">Commit options.</param> /// <param name="durableCommit">Duration to commit lazy transaction.</param> /// <param name="commitId">Commit-id associated with this commit record.</param> /// <returns>An error if the call fails.</returns> public int JetCommitTransaction2(JET_SESID sesid, CommitTransactionGrbit grbit, TimeSpan durableCommit, out JET_COMMIT_ID commitId) { TraceFunctionCall("JetCommitTransaction2"); this.CheckSupportsWindows8Features("JetCommitTransaction2"); int err; uint cmsecDurableCommit = (uint)durableCommit.TotalMilliseconds; NATIVE_COMMIT_ID nativeCommitId = new NATIVE_COMMIT_ID(); unsafe { err = Err(NativeMethods.JetCommitTransaction2(sesid.Value, unchecked((uint)grbit), cmsecDurableCommit, ref nativeCommitId)); } commitId = new JET_COMMIT_ID(nativeCommitId); return err; }
/// <summary> /// Commits the changes made to the state of the database during the current save point /// and migrates them to the previous save point. If the outermost save point is committed /// then the changes made during that save point will be committed to the state of the /// database and the session will exit the transaction. /// </summary> /// <param name="sesid">The session to commit the transaction for.</param> /// <param name="grbit">Commit options.</param> /// <param name="durableCommit">Duration to commit lazy transaction.</param> /// <param name="commitId">Commit-id associated with this commit record.</param> /// <returns>An error if the call fails.</returns> public int JetCommitTransaction2(JET_SESID sesid, CommitTransactionGrbit grbit, TimeSpan durableCommit, out JET_COMMIT_ID commitId) { TraceFunctionCall(); this.CheckSupportsWindows8Features("JetCommitTransaction2"); int err; uint cmsecDurableCommit = (uint)durableCommit.TotalMilliseconds; NATIVE_COMMIT_ID nativeCommitId = new NATIVE_COMMIT_ID(); unsafe { err = Err(NativeMethods.JetCommitTransaction2(sesid.Value, unchecked ((uint)grbit), cmsecDurableCommit, ref nativeCommitId)); } commitId = new JET_COMMIT_ID(nativeCommitId); return(err); }
public void Setup() { var sigX = new NATIVE_SIGNATURE() { ulRandom = 1, logtimeCreate = Any.Logtime, szComputerName = "Komputer", }; this.managedOriginal = new JET_COMMIT_ID(new NATIVE_COMMIT_ID() { signLog = sigX, commitId = 123, }); this.native = this.managedOriginal.GetNativeCommitId(); this.managed = new JET_COMMIT_ID(this.native); }
/// <summary> /// The proxy callback function to call the user-defined managed delegate. /// </summary> /// <param name="instance"> /// The instance. /// </param> /// <param name="commitIdSeen"> /// The commit-id flushed. /// </param> /// <param name="grbit"> /// Reserved currently. /// </param> /// <returns> /// An error code. /// </returns> private JET_err NativeDurableCommitCallback( IntPtr instance, ref NATIVE_COMMIT_ID commitIdSeen, uint grbit) { RuntimeHelpers.PrepareConstrainedRegions(); try { JET_INSTANCE jetInstance = new JET_INSTANCE() { Value = instance }; if (this.instance != jetInstance) { // We assume it's only called on one instance at a time. The only thing // we really care about is serialization of the byte array. // // It would be nice to throw an error, but we're going back to real // code, which doesn't deal with managed exceptions well. return JET_err.CallbackFailed; } JET_COMMIT_ID commitId = new JET_COMMIT_ID(commitIdSeen); return this.wrappedCallback(jetInstance, commitId, (DurableCommitCallbackGrbit)grbit); } catch (Exception ex) { Trace.WriteLineIf( TraceSwitch.TraceWarning, string.Format(CultureInfo.InvariantCulture, "Caught Exception {0}", ex)); JetApi.ReportUnhandledException(ex, "Unhandled exception during NativeDurableCommitCallback"); // This should never be executed, but the compiler doesn't know it. return JET_err.CallbackFailed; } }
public static extern int JetCommitTransaction2( IntPtr sesid, uint grbit, uint cmsecDurableCommit, ref NATIVE_COMMIT_ID pCommitId);