views:

184

answers:

1

I'm currently in the process of creating an announcement system at my place of work. The role of this system will be to replace all users email due to people misusing it and generally abusing the facility. The system will consist of:

Web Portal: Will allow staff to enter any important announcements (this will be restricted via AD).

SQL Server 2k5 DB: Will hold the announcements along with records of staff members and if they've read the announcements etc.

Front End: Created in WPF & C# which is nearly complete, it will display the announcements to the users.

Web Page: Client will contact every so often, which will return an xml file for the client to read.

However my boss has now shifted the goal posts and would like the announcements to appear to the user once they are written to the database, rather than waiting on the client to contact the webpage.

So now I'm a bit unsure as to how to go about this. I have one idea where I would create a small server application to monitor for new announcements then contact the clients to inform them to approach the website for the information they need. But I'm just looking to see if theres a better or more efficient way to do this or if someone else has a more appropriate idea or suggestion.

+1  A: 

Hm an interesting project- One way you could try to satisfy the messaging needs is by using WCF Duplex web services (http://msdn.microsoft.com/en-us/library/ms731064.aspx)

It would look like this - a WCF service is hosted on a central app server, which talks to the DB. All the clients subscribe to this WCF service using a duplex two-way binding. They can then effectively listen for any notification of a new announcement--you'll get a nice callback with args to send them a toast about.

Should be an efficient way to do it.

fyi in duplex bindings you provide two interfaces which get generated on the client, one for the service, and one for a callback class:

public interface ICalculatorDuplex
{
    [OperationContract(IsOneWay = true)]
    void Clear();
    [OperationContract(IsOneWay = true)]
    void AddTo(double n);
    [OperationContract(IsOneWay = true)]
    void SubtractFrom(double n);
    [OperationContract(IsOneWay = true)]
    void MultiplyBy(double n);
    [OperationContract(IsOneWay = true)]
    void DivideBy(double n);
}


public interface ICalculatorDuplexCallback
{
    [OperationContract(IsOneWay = true)]
    void Equals(double result);
    [OperationContract(IsOneWay = true)]
    void Equation(string eqn);
}

So I'm envisioning something like this:

public interface IAnnouncementServiceDuplex
{
    [OperationContract(IsOneWay = true)]
    void Subscribe(int userId);
}
public interface ICalculatorDuplexCallback
{
    [OperationContract(IsOneWay = true)]
    void SendNotification(AnnouncementData data);
}
Bobby
Just wondering, say for example I wanted to send back XML data this way would it be possible?
manemawanna
well, sure- as shown you can define your callback signature however you like (whatever type of args you'd like), so maybe objects would be more appropriate- but if you need to send xml you could do that too (as a string).However, remember these web services (depending on your binding/endpoint configuration) are sending SOAP over the wire, which is an XML format already.
Bobby
Thanks a lot I'll go investigate more, need to find out how I can maintain a connection as the server ideally needs to know who's client is running so it knows who to contact.
manemawanna