Public class queuemanage
{
///
/// Send the object to the queue
///
/// Queue name, because the queue name should not be changed in an application, it is best to write it in the configuration file.
/// The object to be sent out
Public static void sendqueue (string queuepath, mybase. smsqueue sq)
{
System. messaging. messagequeue mqsend = new system. messaging. messagequeue (queuepath, false );
Ensurequeueexists (queuepath );
Mqsend. Send (SQ );
}
///
/// check the queue. If the queue does not exist, create
// queue name
Private Static void ensurequeueexists (string path)
{< br> If (! Messagequeue. exists (PATH)
{< br> If (! Messagequeue. exists (PATH)
{< br> messagequeue. create (PATH);
messagequeue mqtemp = new messagequeue (PATH);
mqtemp. setpermissions ("everyone", system. messaging. messagequeueaccessrights. fullcontrol);
// you do not know the permissions you should grant to everone, of course, you 'd better control it by yourself
}< BR >}
///
/// Retrieve the object list from the queue
///
/// Queue name
Public static system. Collections. arraylist getmessage (string queuepath)
{
Mybase. smsqueue sq = new mybase. smsqueue ();
System. messaging. messagequeue MQ = new system. messaging. messagequeue (queuepath, false );
MQ. formatter = new xmlmessageformatter (New Type [] {typeof (mybase. smsqueue )});
System. messaging. Message [] arrm = MQ. getallmessages ();
MQ. Close ();
System. Collections. arraylist Al = new system. Collections. arraylist ();
Foreach (system. messaging. Message m in arrm)
{
Sq = (timefound. smsgate. Base. smsqueue) M. Body;
Al. Add (SQ );
}
Return al;
}
}