开发者

WPF C# Client/Server announcement system

开发者 https://www.devze.com 2022-12-17 06:46 出处:网络
I\'m currently in the process of creating 开发者_JAVA百科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

I'm currently in the process of creating 开发者_JAVA百科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.


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消