/// <summary> /// 提交指定的实体,并在添加、更新实体时,设置实体的跟踪戳。 /// </summary> /// <param name="e">The e.</param> /// <param name="link">The link.</param> protected override void Submit(SubmitArgs e, ISubmitInterceptorLink link) { switch (e.Action) { case SubmitAction.ChildrenOnly: case SubmitAction.Update: var entity = e.Entity; entity.SetUpdatedTime(DateTime.Now); var user = RafyEnvironment.Identity; if (user.IsAuthenticated) { entity.SetUpdatedUser(user.Name); } break; case SubmitAction.Insert: var entity2 = e.Entity; var now = DateTime.Now; entity2.SetUpdatedTime(now); entity2.SetCreatedTime(now); var user2 = RafyEnvironment.Identity; if (user2.IsAuthenticated) { entity2.SetUpdatedUser(user2.Name); entity2.SetCreatedUser(user2.Name); } break; default: //do nothing; break; } link.InvokeNext(this, e); }
/// <summary> /// 提交指定的实体,并在添加、更新实体时,设置实体的跟踪戳。 /// </summary> /// <param name="e">The e.</param> /// <param name="link">The link.</param> protected override void Submit(SubmitArgs e, ISubmitInterceptorLink link) { bool disabled = false; if (StampContext.Disabled) { if (StampContext.ThreadId == Thread.CurrentThread.ManagedThreadId) { //如果是 Disable 的线程,则忽略 disabled = true; } else { //如果不是 Disable 的线程,则需要等待 Disable 的线程结束后,才能继续执行后续的操作。 lock (StampContext.DisabledLock) { } } } if (!disabled) { this.ResetStamp(e); } link.InvokeNext(this, e); }
/// <summary> /// DataProvider 提交拦截器中的最后一个拦截器。 /// </summary> /// <param name="e">The e.</param> /// <param name="locator">The locator.</param> internal protected sealed override void Submit(SubmitArgs e, ISubmitInterceptorLink locator) { this.Submit(e); }
/// <summary> /// 提交指定的实体。 /// 子类在此方法中,使用 locator.InvokeNext(e, this); 来调用被拦截的功能。 /// </summary> /// <param name="e">提交参数,其中封装了需要对实体进行的操作。</param> /// <param name="link">使用此定位器来调用被拦截的实际提交器。</param> internal protected abstract void Submit(SubmitArgs e, ISubmitInterceptorLink link);