Hi,
You need to create your own custom event generators.
/*********Inside the appadf.xml *******/
<EventClasses>
<EventClass>
<EventClassName>DailyReportEvent</EventClassName>
<Schema>
<Field>
<FieldName>TempEventID</FieldName>
<FieldType>varchar(100)</FieldType>
<FieldTypeMods>not null</FieldTypeMods>
</Field>
</Schema>
</EventClass>
<EventClasses>
....
....
<Providers>
<HostedProvider>
<ProviderName>MyEventProvider</ProviderName>
<ClassName>MyEventProviderPrj.ScheduledEvent</ClassName>
<AssemblyName>c:\MyEventProviderPrj.dll</AssemblyName>
<SystemName>%_NSSystem_%</SystemName>
<Schedule>
<StartTime>00:00:00</StartTime>
<Interval>P0DT00H30M00S</Interval>
</Schedule>
</HostedProvider>
</Providers>
Here goes a sample.
Create a new class library project 'MyEventProviderPrj'.
Add the collowing class.
/************ScheduledEvent.cs*********/
using System;
using System.Collections.Specialized;
using Microsoft.SqlServer.NotificationServices;
using System.IO;
namespace SpiderEvent
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class ScheduledEvent : IScheduledEventProvider
{
NSApplication myApplication;
EventCollector myEventCollector;
string eventProviderName;
StringDictionary arguments;
string logfile= @"C:\temp\eventlog.txt";
StreamWriter st;
public ScheduledEvent()
{
FileStream fs= new FileStream(logfile,FileMode.Append);
st= new StreamWriter(fs);
st.WriteLine("Created"+DateTime.Now.ToString());
}
public void Initialize(
NSApplication application,
string providerName,
StringDictionary args,
StopHandler stopDelegate )
{
this.eventProviderName = providerName;
this.arguments = args;
this.myApplication = application;
st.WriteLine("INititialised"+ DateTime.Now.ToString());
//Create the event collector.
this.myEventCollector = new EventCollector(myApplication,
eventProviderName);
}
public bool Run()
{
bool returnValue = true;
st.WriteLine("Running"+DateTime.Now.ToString());
try
{
Event myEvent = new Event();
myEvent.Initialize(myApplication, "DailyReportEvent");
//Create an event to convey the event log data.
myEvent["TempEventID"]=DateTime.Now.ToString();
myEventCollector.Write(myEvent);
//Commit the event batch.
int eventsSubmitted = myEventCollector.Commit();
myEvent = null;
}
catch (Exception /*e*/)
{
//Provide error handling here.
st.WriteLine("Error in run"+DateTime.Now.ToString());
}
return returnValue;
}
//Implement the IScheduledEventProvider.Terminate method.
public void Terminate()
{
st.WriteLine("terminated"+DateTime.Now.ToString());
st.Close();
myEventCollector.Dispose();
}
}
}
Compile the dll, put it in c:\MyEventProviderPrj.dll.
Now for every 30 mins, your event generator (MyEventProviderPrj.dll) will be
called.
Inside the event generator, we are raising an event named 'DailyReportEvent'.
If you create a event based notification, then it will be invoked.
You can adjust the event generation interval in the schedule interval
element node.
Also please go thru the readme.txt (under C:\Program Files\Microsoft SQL
Server Notification Services\v2.0.3008.0 ) the following section.
4.15 Using Custom Components Built With Version 1.1.4322 of
the .NET Framework
And do the necessary changes.
I hope this helps you.
Regards,
R.Balaji
[quoted text, click to view] "Mohammed Anees via SQLMonster.com" wrote:
> Hi,
>
> could somebody help me,
>
> I would like to fire an event schedule wise automatically to all users who
> subscribe in particular category.
>
> e.g.
>
> An event to fire hourly/daily at particular time to all subscriber
> automatically.
>
> how can it possible in SQL Server 200 notification server, if any body have
> the sample code or example please mail me at mdaneespm AT hotmail DOT com
>
> Thanks
>
> Mohammed Anees
Hi Mohammed -
Notification Services can do that.
The most direct way is with scheduled subscriptions. Essentially, the
application collects event data throughout the day, storing it in a
chronicle table, and periodically the application checks to see if any
scheduled subscriptions meet the matching criteria. The weather sample
that comes with SQLNS demonstrates how to set this up; I'd encourage you
to go through this example and the stocks walkthrough.
In your post, you mentioned possibly scheduling hourly notifications.
Scheduled subscriptions work well for daily, weekly, etc, but it does
not allow for sub-day scheduling. If you need that then you'll have to
do some extra work.
To get hourly notifications, you can:
1) Configure multiple scheduled subscriptions for each subscriber, one
for each hour of the day, or
2) Actually use event-driven subscription instead of scheduled
subscriptions and control the event submission process so that it only
submits hourly.
IMHO, #1 is generally a better option even though it creates 24 times
the number of subscriptions.
HTH...
Joe Webb
SQL Server MVP
~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811 [quoted text, click to view] Mohammed Anees via SQLMonster.com wrote:
> Hi,
>
> could somebody help me,
>
> I would like to fire an event schedule wise automatically to all users who
> subscribe in particular category.
>
> e.g.
>
> An event to fire hourly/daily at particular time to all subscriber
> automatically.
>
> how can it possible in SQL Server 200 notification server, if any body have
> the sample code or example please mail me at mdaneespm AT hotmail DOT com
>
> Thanks
>
Hi Balaji -
Creating custom event providers is a wonderful feature in the SQLNS
framework. It provides us with great flexibility and allows us to go
beyond the FileSystemWatcher and SQLServer event providers that come
with SQLNS. Thanks for posting the code!
Just for clarity, there are a couple of points that I'd like to add to
your post.
First, custom event providers are really useful for collecting events
from sources other than an XML file and a database. You can, for
example, develop a custom event provider to gather information from the
AP NewsWire, a propriety CRM package, or even a properly wired coffee
pot so we'll know when there's a fresh pot. :)
Events can be submitted into the SQLNS app at anytime. We can schedule
their occurence (see Defining the SQL Server Event Provider in BOL for
more details), they can be submitted from a trigger or sproc in another
database, or controlled by their own mechanisms.
There doesn't have to be a correlation between the event coming into the
system and the notification that goes out. For event driven
subscriptions, there is that quasi-link that's controlled by the
matching rule, but it for scheduled subscriptions, the link really
doesn't exist. Scheduled subscriptions are evaluated periodically based
on the the QuantumDuration application execution setting. If any
scheduled subscriptions meet the matching rules, notifications are
produced. The weather sample application that comes with SQLNS
demonstrates how to configure scheduled subscriptions.
As I mentioned in another post, scheduled subscription cannot be
scheduled to occur multiple times within a day. To achieve that
frequency, we can create multiple scheduled subscriptions or do like
you've suggested in your post - create event driven subscriptions and
carefully configure their submission.
Thanks again for the post!
HTH...
Joe Webb
SQL Server MVP
~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811 [quoted text, click to view] Balaji Ramachandran wrote:
> Hi,
>
> You need to create your own custom event generators.
>
> /*********Inside the appadf.xml *******/
> <EventClasses>
> <EventClass>
> <EventClassName>DailyReportEvent</EventClassName>
> <Schema>
> <Field>
> <FieldName>TempEventID</FieldName>
> <FieldType>varchar(100)</FieldType>
> <FieldTypeMods>not null</FieldTypeMods>
> </Field>
> </Schema>
> </EventClass>
> <EventClasses>
> ...
> ...
> <Providers>
> <HostedProvider>
> <ProviderName>MyEventProvider</ProviderName>
> <ClassName>MyEventProviderPrj.ScheduledEvent</ClassName>
> <AssemblyName>c:\MyEventProviderPrj.dll</AssemblyName>
> <SystemName>%_NSSystem_%</SystemName>
> <Schedule>
> <StartTime>00:00:00</StartTime>
> <Interval>P0DT00H30M00S</Interval>
> </Schedule>
> </HostedProvider>
> </Providers>
>
>
>
> Here goes a sample.
> Create a new class library project 'MyEventProviderPrj'.
> Add the collowing class.
>
> /************ScheduledEvent.cs*********/
> using System;
> using System.Collections.Specialized;
> using Microsoft.SqlServer.NotificationServices;
> using System.IO;
>
> namespace SpiderEvent
> {
> /// <summary>
> /// Summary description for Class1.
> /// </summary>
> public class ScheduledEvent : IScheduledEventProvider
> {
> NSApplication myApplication;
> EventCollector myEventCollector;
> string eventProviderName;
> StringDictionary arguments;
> string logfile= @"C:\temp\eventlog.txt";
> StreamWriter st;
>
> public ScheduledEvent()
> {
> FileStream fs= new FileStream(logfile,FileMode.Append);
> st= new StreamWriter(fs);
> st.WriteLine("Created"+DateTime.Now.ToString());
>
> }
> public void Initialize(
> NSApplication application,
> string providerName,
> StringDictionary args,
> StopHandler stopDelegate )
> {
> this.eventProviderName = providerName;
> this.arguments = args;
> this.myApplication = application;
>
>
> st.WriteLine("INititialised"+ DateTime.Now.ToString());
>
> //Create the event collector.
> this.myEventCollector = new EventCollector(myApplication,
> eventProviderName);
>
> }
>
> public bool Run()
> {
> bool returnValue = true;
>
> st.WriteLine("Running"+DateTime.Now.ToString());
>
> try
> {
> Event myEvent = new Event();
> myEvent.Initialize(myApplication, "DailyReportEvent");
>
> //Create an event to convey the event log data.
> myEvent["TempEventID"]=DateTime.Now.ToString();
> myEventCollector.Write(myEvent);
>
> //Commit the event batch.
> int eventsSubmitted = myEventCollector.Commit();
> myEvent = null;
> }
> catch (Exception /*e*/)
> {
> //Provide error handling here.
> st.WriteLine("Error in run"+DateTime.Now.ToString());
> }
> return returnValue;
> }
>
> //Implement the IScheduledEventProvider.Terminate method.
> public void Terminate()
> {
>
> st.WriteLine("terminated"+DateTime.Now.ToString());
> st.Close();
> myEventCollector.Dispose();
> }
> }
> }
>
>
> Compile the dll, put it in c:\MyEventProviderPrj.dll.
>
> Now for every 30 mins, your event generator (MyEventProviderPrj.dll) will be
> called.
> Inside the event generator, we are raising an event named 'DailyReportEvent'.
>
> If you create a event based notification, then it will be invoked.
>
> You can adjust the event generation interval in the schedule interval
> element node.
>
> Also please go thru the readme.txt (under C:\Program Files\Microsoft SQL
> Server Notification Services\v2.0.3008.0 ) the following section.
> 4.15 Using Custom Components Built With Version 1.1.4322 of
> the .NET Framework
> And do the necessary changes.
>
> I hope this helps you.
>
> Regards,
> R.Balaji
>
>
>
>
> "Mohammed Anees via SQLMonster.com" wrote:
>
>
>>Hi,
>>
>>could somebody help me,
>>
>>I would like to fire an event schedule wise automatically to all users who
>>subscribe in particular category.
>>
>>e.g.
>>
>>An event to fire hourly/daily at particular time to all subscriber
>>automatically.
>>
>>how can it possible in SQL Server 200 notification server, if any body have
>>the sample code or example please mail me at mdaneespm AT hotmail DOT com
>>
>>Thanks
>>
>>Mohammed Anees
Don't see what you're looking for? Try a search.