You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB
C#

10 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Common
{
public static class MsgQueue
{
private static object objLocknotify = new object();
private static Queue<string> msgQueuNotity = new Queue<string>();
public static void AddNotifymsg(string msg)
{
lock (objLocknotify)
{
if (msgQueuNotity.Count > 50)
{
msgQueuNotity.Dequeue();
}
msgQueuNotity.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + msg);
}
}
public static string GetMsg(string type)
{
string result = string.Empty;
for (int i = 0; i < msgQueuNotity.Count; i++)
{
result += msgQueuNotity.Dequeue() + "@";
}
return result;
}
///// <summary>
///// 停止下发门架
///// </summary>
//public static void UpdStopMJ()
//{
// lock (objLockXfMJ)
// {
// if (msgQueueXiafaMJ.Count > 50)
// {
// msgQueueXiafaMJ.Dequeue();
// }
// msgQueueXiafaMJ.Enqueue("stop");
// }
//}
public static void StopNotity()
{
lock (msgQueuNotity)
{
if (msgQueuNotity.Count > 50)
{
msgQueuNotity.Dequeue();
}
msgQueuNotity.Enqueue("stop");
}
}
}
}