Wednesday, March 7, 2012

EventData.xml : React differently based on file names & additional data in xslt

Hi,

I am new bee to NS.

Question 1:

I am able to run sample aplications. Now I have question. I would like NS to react differently based on file name in event folder. For example

If file name dropped is EventData.xml then EventRule should be used as follows:

<EventRule>
<RuleName>PMEventRule</RuleName>
<EventClassName>DData</EventClassName>
<Action>
INSERT INTO SA(SubscriberId,
DeviceName, SubscriberLocale, RsId, artist, title )
SELECT s.SubscriberId, s.DeviceName, s.SubscriberLocale,
e.RsId, e.a1, e.t1
FROM DData e, PMS s
WHERE e.RsId = 14

</Action>
</EventRule>

if dropped file name is eventdata1.xml then event rule to eb used is

<EventRule>
<RuleName>PMEventRule</RuleName>
<EventClassName>DData</EventClassName>
<Action>
INSERT INTO SA(SubscriberId,
DeviceName, SubscriberLocale, RsId, artist, title )
SELECT s.SubscriberId, s.DeviceName, s.SubscriberLocale,
e.RsId, e.a1, e.t1
FROM DData e, PMS s
WHERE e.RsId = 15

</Action>
</EventRule>

How do i achive this? One way is getting RSId in my feed but my feed can not contain that info and only way we know is by file name. Any help is appreciated.

Question 2:

Additional data in xslt : based on subscriber demographic info we would like to send addition informative message through xslt which is kept in another Database. How do we insert that in Application.xslt?

Thanks for your help.


1. I believe you need 2 separate FileSystemWatcherProvider 's, and configure them to read data from 2 different directories. Anyway, why don't use use a built-in SQLProvider?.. It's much more "powerful" than the filesystemwatcherprovider.

2. If you have no experience with XSLT, then instead of learning it, I would recommend you should write your own custom formatter in C#. It's not nearly as difficult as it sounds. ...and it gives you enormous opportunities to do whatever you want with your notifications data. There are samples both in Pather's book and in NS BOL.

|||

Hi fafnir

Thanks for the reply. Can you please provide some examples on built-in SQLProvider. I do really appreciate it.

Thanks

|||<HostedProvider>

<ProviderName>RawDataAddedSQLProvider110606</ProviderName>

<ClassName>SQLProvider</ClassName> <!-- Do NOT change this name unless you have written and are using your CUSTOM sql event provider!!! -->

<SystemName>%_NSServer_%</SystemName>

- <Schedule>

<Interval>P0DT00H00M15S</Interval>

</Schedule>

- <Arguments>

- <Argument>

<Name>EventsQuery</Name>

<Value>-- Declare variables used to store the last and current -- run times. DECLARE @.lastRunTime DATETIME DECLARE @.currentRunTime DATETIME -- Select the last run time from the chronicle table. SELECT @.lastRunTime = LastRunTime FROM RawDataSQLProviderRunTime110606 -- Obtain the current run time. SELECT @.currentRunTime = GETDATE() -- Update the chronicle, setting the current run time -- as the last run time. UPDATE RawDataSQLProviderRunTime110606 SET LastRunTime = @.currentRunTime -- Select all the RawData events added between the last run time -- and the current run time. SELECT sd.f_id FROM BLNSDB..view_AlertsRawEvent110606 sd WHERE sd.f_date_ins > @.lastRunTime AND sd.f_date_ins <= @.currentRunTime</Value>

</Argument>

- <Argument>

<Name>EventClassName</Name>

<Value>RawDataAdded110606</Value>

</Argument>

</Arguments>

</HostedProvider>

-

This is a part of my own file for SQL NS 2.0.

Also, BOL have samples that you can modify using your own eventclassname, etc.

|||Hi -

1) If the only difference in the two xml files is RsId, can you include that in the data within the xml document?

2) I've got a simple-talk.com article coming out soon that demonstrates how you can create a custom content formatter that a) retrieves additional information from another database and b) formats that information using an XSLTransform. I'll post here when it's out.

HTH...

Joe|||

Hi Joe,

Thanks for the reply.

1. No RSID can not be part of xml document, that would have been easy. We need to some processing logic based on the file names or folder it contains.

2. I will look forward to your article on XSLT Transformation with additional information.

Thanks

Basu

|||Here's the article I mentioned earlier.

http://www.simple-talk.com/sql/sql-server-2005/creating-a-custom-content-formatter-for-ssns-2005/

HTH...

Joe

No comments:

Post a Comment