每周200分,长期专栏,体验并推广ASP向ASP.NET过渡。之三

超级大笨狼 2005-05-29 08:46:53
继续我们的话题。
体验并推广ASP向ASP.NET过渡。
大家发表一下感想,顺便粘点有意思的代码。

微软消息队列
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Timers;
using System.Messaging;
using System.Threading;
using System.Diagnostics;


/// <summary>
/// This Class is used read and write message from MessageQueue
/// </summary>
public class Cls_MessageMG
{
public static void clear_message(string Queue_Path)
{
Queue_Path=@".\Private$\"+Queue_Path;
if (!MessageQueue.Exists(Queue_Path))
{
MessageQueue.Create(Queue_Path);
}
MessageQueue mq=new MessageQueue(Queue_Path);
mq.Purge();
}

public static void send_message(string Queue_Path, string Msg_Content, Msg_Type Msg_Type_Instance)
{
Queue_Path=@".\Private$\"+Queue_Path;
if (!MessageQueue.Exists(Queue_Path))
{
MessageQueue.Create(Queue_Path);
}
MessageQueue mq=new MessageQueue(Queue_Path);
mq.Label=System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:ffff");
switch (Msg_Type_Instance)
{
case Msg_Type.XML:
mq.Formatter=new XmlMessageFormatter();
break;
case Msg_Type.Binary:
mq.Formatter=new BinaryMessageFormatter();
break;
case Msg_Type.ActiveX:
mq.Formatter=new ActiveXMessageFormatter();
break;
}
mq.Send(Msg_Content);
}

public static string receive_message(string Queue_Path)
{
Queue_Path=@".\Private$\"+Queue_Path;
if (!MessageQueue.Exists(Queue_Path))
{
MessageQueue.Create(Queue_Path);
return "";
}

MessageQueue mq= new MessageQueue(Queue_Path);
mq.Label=System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:ffff");
((XmlMessageFormatter)mq.Formatter).TargetTypeNames=new string[]{"System.String,mscorlib"};

try
{
System.Messaging.Message m = mq.Receive();
return (string)m.Body;
}
catch (Exception ex)
{
return (ex.ToString());
}
}

public static string peek_message(string Queue_Path)
{
Queue_Path=@".\Private$\"+Queue_Path;
if (!MessageQueue.Exists(Queue_Path))
{
MessageQueue.Create(Queue_Path);
return "";
}

MessageQueue mq= new MessageQueue(Queue_Path);
mq.Label=System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:ffff");
((XmlMessageFormatter)mq.Formatter).TargetTypeNames=new string[]{"System.String,mscorlib"};

try
{
System.Messaging.Message m = mq.Peek();
return (string)m.Body;
}
catch (Exception ex)
{
return (ex.ToString());
}
}

...全文
499 82 打赏 收藏 转发到动态 举报
写回复
用AI写文章
82 条回复
切换为时间正序
请发表友善的回复…
发表回复
hpj2002 2005-06-15
  • 打赏
  • 举报
回复
hpj2002@163.com
謝謝!
allfirst 2005-06-15
  • 打赏
  • 举报
回复
UP UP 顶~!
Aden 2005-06-15
  • 打赏
  • 举报
回复
学习!
班门弄斧 2005-06-15
  • 打赏
  • 举报
回复
up!
ASP0000 2005-06-15
  • 打赏
  • 举报
回复
学习@!
itzhiren 2005-06-15
  • 打赏
  • 举报
回复
正适合我呢,我也要转.net,多谢哦
zwrtv 2005-06-15
  • 打赏
  • 举报
回复
学习
xiaozx 2005-06-15
  • 打赏
  • 举报
回复
学习!
zy51 2005-06-08
  • 打赏
  • 举报
回复
要慢慢学习了.
onkey1999 2005-06-08
  • 打赏
  • 举报
回复
正在过渡,暂时还不能适应NET的编程方式
wzhiyuan 2005-06-08
  • 打赏
  • 举报
回复
up.
丛林蚂蚁 2005-06-08
  • 打赏
  • 举报
回复
偶也要一个了.
zcj78@126.com
NewJacket 2005-06-08
  • 打赏
  • 举报
回复
JF~~~,
wangyingdong 2005-06-08
  • 打赏
  • 举报
回复
学习
HHH3000 2005-06-08
  • 打赏
  • 举报
回复
希望狼版能把这几个帖子加精或者置顶~~

方便大家阅览~~
xmj123 2005-06-08
  • 打赏
  • 举报
回复
该学的东西还是要学的
zhanghongwen 2005-06-08
  • 打赏
  • 举报
回复
楼主说话不算话.我留了邮箱怎么不发给我呀.
yezhutou 2005-06-08
  • 打赏
  • 举报
回复
mark mark
我正在做这方面的进化工作
你们的之一,之二在什么地方?
eyeapple 2005-06-07
  • 打赏
  • 举报
回复
我正在学习ASP
想接触asp.net
hawk2004 2005-06-07
  • 打赏
  • 举报
回复
UP`
加载更多回复(62)

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧