
Visual Basic (Declaration) | |
---|---|
<DefaultExportAttribute(IsDefault=True, ContractName="", ContractType=IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor)> Public Class EntityServerSaveInterceptor |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As EntityServerSaveInterceptor |
C# | |
---|---|
[DefaultExportAttribute(IsDefault=true, ContractName="", ContractType=IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor)] public class EntityServerSaveInterceptor |
C++/CLI | |
---|---|
[DefaultExportAttribute(IsDefault=true, ContractName="", ContractType=IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor)] public ref class EntityServerSaveInterceptor |
C# | ![]() |
---|---|
// Server-side implementation of EntityServerSaveInterceptor public class EntityServerSaveManager : EntityServerSaveInterceptor { // Always require explicit authorization attributes on entities. protected override bool DefaultAuthorization { get { return false; } } // Log errors to any listening loggers. protected override void OnError(Exception e, PersistenceFailure failureType) { TraceFns.WriteLine("Save error: " + e.Message); } // Customized save logic. protected override bool ExecuteSave() { // Pre-save logic. var em = EntityManager; var addedEmps = em.FindEntities(EntityState.Added).OfType<Employee>(); // Mark any added emps with "Added at". addedEmps.ForEach(emp => emp.Notes = "Added at" + DateTime.Now); // Execute the save. var ok = base.ExecuteSave(); // After save logic. if (ok) { // Log any type of saved to an Employee. var emps = EntityManager.FindEntities(EntityState.Added | EntityState.Deleted | EntityState.Modified).OfType<Employee>(); TraceFns.WriteLine("Emps saved: " + emps.Count()); } return ok; } } |
You may intercept and customize save processing at several points during the save lifecycle. The save request is first authorized before any further actions are taken: see DefaultAuthorization, AuthorizeSave and ClientCanSave for information. Next validation can be performed on the entities: see ValidateSave. Finally the save is executed: see ExecuteSave. Save processing can be cancelled at any point in the lifecycle.
At all times during the lifecycle you have access to the Principal for the user issuing the save.
A new instance of your EntityServerSaveInterceptor is created for each save request.
System.Object
IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family