This question is locked. New answers and comments are not allowed.
I'm using the method described here to manage my OpenAccessContext (also implementing a BasePage).
Basically, I want to perform logic whenever certain objects are created. For testing purposes, I tried something extremely simple:
Needless to say, nothing was written to the Event Log.
To give you an example scenario of what I want to do:
I have an object named Invoice. I want an email to be fired to a rep whenever an Invoice is created. The problem is that an Invoice can be created in multiple ways, so I'd really prefer not to add logic to every page that creates an Invoice. Rather, I was hoping, I could utilize the Context Events and just check if the object being created is an Invoice and, if so, do any logic.
If there's a better way to do this or if there simply isn't a way to do this, let me know. Either way, thank you for your time!
--- Andrew
Basically, I want to perform logic whenever certain objects are created. For testing purposes, I tried something extremely simple:
protected
DbDataContext DbContext
{
get
;
private
set
;
}
protected
override
void
OnInit(EventArgs e)
{
this
.DbContext = ContextFactory.GetContext();
this
.DbContext.Events.Added += Events_Added;
base
.OnInit(e);
}
public
void
Events_Added(
object
sender, Telerik.OpenAccess.AddEventArgs e)
{
const
string
SourceName =
"Jarvis"
;
if
(!EventLog.SourceExists(SourceName))
EventLog.CreateEventSource(SourceName,
"Application"
);
EventLog.WriteEntry(SourceName,
"object added!!!"
, EventLogEntryType.SuccessAudit);
}
Needless to say, nothing was written to the Event Log.
To give you an example scenario of what I want to do:
I have an object named Invoice. I want an email to be fired to a rep whenever an Invoice is created. The problem is that an Invoice can be created in multiple ways, so I'd really prefer not to add logic to every page that creates an Invoice. Rather, I was hoping, I could utilize the Context Events and just check if the object being created is an Invoice and, if so, do any logic.
If there's a better way to do this or if there simply isn't a way to do this, let me know. Either way, thank you for your time!
--- Andrew