Developer forum

Forum » Integration » Accessing Source XML in Job Finished observer

Accessing Source XML in Job Finished observer

Asim Shahzad
Reply

Hi guys,

I need to send emails to all the users after a successful import from ERP system. I have written a batch for getting the users and after getting the users i was thinking to user "Job Finished Observer" where i can see if the job was successfull or not. if the job is successful i am planning to get the xml source file and read all the records which i got from ERP system and then send emails to them.

Is there any better way to do this ? 

Regards

Asim


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Asim,
your approach is fine, but you can optimize the step of double reading the source xml file with users from the ERP. You can use the TableScript code to read your user xml data once it is processed by the data integration job and cache it to Dynamicweb.Context.Current.Items and then in JobFinished observer you can get the xml user data from the cache.
Regards, Dmitrij

Votes for this answer: 1
 
Asim Shahzad
Reply

Hi Dmitriy,

your suggestion is very good, i will implement it they way you mentioned.

Regards

Asim

 
Asim Shahzad
Reply

Hi, 

As i mentioned above, i need to send emails after a job is completed, now i have a pretty good idea how to achieve that but there is one issue. 

Do we have any better way to identify an activity in "Job Finished Observer"  other than using job.name which any one can change in the admin panel ?

hoping to hear suggestions.

Regards

Asim

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Asim,
there is a Job object passed to the JobFinished notification
public JobFinishedIntegrationArgs(bool jobFailed, string logFile, Job job)
So you can access the job.Source or job.Destination and check their types and source/destination settings to identify your job.
Smth like that:
if (job.Source is XmlProvider && job.Destination is UserProvider){
XmlProvider source = (XmlProvider)job.Source;
if(source.SourceFile == "some file"){

}
}

 
Asim Shahzad
Reply

Hi Dmitriy,

i tried the code you gave but i think its not possible to compare the provide like that or maybe i am missing something.

do you have any idea about it? 

Regards

Asim

 

You must be logged in to post in the forum