You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
740 lines
26 KiB
740 lines
26 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Runtime.Serialization;
|
|
using System.Xml.Serialization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using SiaSun.LMS.Common;
|
|
using SiaSun.LMS.Model;
|
|
using System.Reflection;
|
|
using Apache.NMS;
|
|
using Apache.NMS.ActiveMQ;
|
|
using System.Threading;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace SiaSun.LMS.LED
|
|
{
|
|
public partial class Main : Form
|
|
{
|
|
#region 自定义变量
|
|
|
|
Dictionary<int, object> dic = new Dictionary<int, object>();
|
|
|
|
//public static SiaSun.LMS.Common.ActiveMsg _ActiveMsg = new SiaSun.LMS.Common.ActiveMsg();
|
|
|
|
SiaSun.LMS.LED.BX_5M_Base mBX_5M = null;
|
|
|
|
public static Main mainWin;
|
|
|
|
#endregion
|
|
|
|
#region 消息队列变量
|
|
|
|
//public IConnectionFactory factory = null;
|
|
|
|
//public IConnection connection = null;
|
|
|
|
//public ISession session = null;
|
|
|
|
//public IMessageConsumer consumer = null;
|
|
|
|
#endregion
|
|
|
|
#region 构造函数
|
|
|
|
public Main()
|
|
{
|
|
InitializeComponent();
|
|
mainWin = this;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 系统函数
|
|
|
|
//加载窗体
|
|
private void Main_Load(object sender, EventArgs e)
|
|
{
|
|
//忽略线程间调用错误
|
|
Control.CheckForIllegalCrossThreadCalls = false;
|
|
|
|
Get_BX_5M_Models();
|
|
|
|
Initialize();
|
|
|
|
//显示托盘
|
|
this.notifyIcon1.Visible = true;
|
|
|
|
this.btnStop.Enabled = false;
|
|
|
|
//默认启动
|
|
this.btnStart_Click(null, EventArgs.Empty);
|
|
|
|
//后台运行:属性中FormWindowState=Maximized
|
|
this.btnBackRun_Click(null, EventArgs.Empty);
|
|
}
|
|
|
|
//启动发送大屏
|
|
private void btnStart_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//设置状态
|
|
btnStart.Enabled = false;
|
|
btnStop.Enabled = true;
|
|
|
|
//开启监听消息
|
|
//this.Listener_Init("Client1", "LedSend", "testing listener 1");
|
|
|
|
//开启发送消息
|
|
LEDApply.RunWorkerAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
//停止发送大屏
|
|
private void btnStop_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("确定停止LED监视任务!","系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
btnStop.Enabled = false;
|
|
btnStart.Enabled = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
//后台监控
|
|
private void LEDApply_DoWork(object sender, DoWorkEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
while (btnStop.Enabled)
|
|
{
|
|
//检查是否最大值
|
|
if (rchMessage.Lines.Length >= rchMessage.MaxLength)
|
|
rchMessage.Clear();
|
|
|
|
this.LEDSendMsg();
|
|
|
|
//延迟显示
|
|
System.Threading.Thread.Sleep(2000);
|
|
|
|
//释放内存
|
|
System.Diagnostics.Process.GetCurrentProcess().MinWorkingSet = new IntPtr(20);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
btnStart.Enabled = true;
|
|
btnStop.Enabled = false;
|
|
lblMessage.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
//后台运行
|
|
private void btnBackRun_Click(object sender, EventArgs e)
|
|
{
|
|
if (!this.Visible)
|
|
return;
|
|
|
|
this.WindowState = FormWindowState.Minimized;
|
|
|
|
this.Hide();
|
|
|
|
this.notifyIcon1.ShowBalloonTip(3, "提示", "程序隐藏在后台运行", ToolTipIcon.Info);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 显示或隐藏窗体
|
|
|
|
//显示
|
|
private void menuItemShow_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.Visible)
|
|
return;
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
this.WindowState = FormWindowState.Maximized;
|
|
this.Visible = true;
|
|
}
|
|
|
|
//双击显示
|
|
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
menuItemShow_Click(null, EventArgs.Empty);
|
|
}
|
|
|
|
//退出
|
|
private void menuItemExit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//停止监视
|
|
btnStop_Click(null, EventArgs.Empty);
|
|
|
|
//释放资源
|
|
this.LEDApply.Dispose();
|
|
|
|
//释放LED资源
|
|
Uninitialize();
|
|
|
|
//释放资源
|
|
this.notifyIcon1.Visible = false;
|
|
this.notifyIcon1.Dispose();
|
|
|
|
//断开消息连接
|
|
//this.connection.Stop();
|
|
//this.connection.Close();
|
|
|
|
//退出
|
|
Application.ExitThread();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 自定义方法
|
|
|
|
/// <summary>
|
|
/// 根据LED_MAIN配置,动态创建BX_5M实例
|
|
/// </summary>
|
|
private void Get_BX_5M_Models()
|
|
{
|
|
try
|
|
{
|
|
Type t = typeof(SiaSun.LMS.LED.BX_5M_Base);
|
|
Assembly complierAssembly = t.Assembly;
|
|
|
|
IList<SiaSun.LMS.Model.LED_MAIN> lsLED_MAIN = Program._I_LEDService.LED_MAIN_GetList();
|
|
foreach (SiaSun.LMS.Model.LED_MAIN mLED_MAIN in lsLED_MAIN)
|
|
{
|
|
if (string.IsNullOrEmpty(mLED_MAIN.LED_MAIN_PARA1))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
object complierInstance = complierAssembly.CreateInstance(mLED_MAIN.LED_MAIN_PARA1, true);
|
|
|
|
dic.Add(mLED_MAIN.LED_ID, complierInstance);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Fatal(string.Format("Get_BX_5M_Models: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化所有屏幕DLL资源
|
|
/// </summary>
|
|
private void Initialize()
|
|
{
|
|
try
|
|
{
|
|
foreach (var item in dic)
|
|
{
|
|
mBX_5M = item.Value as SiaSun.LMS.LED.BX_5M_Base;
|
|
mBX_5M.InitializeLED();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Fatal(string.Format("Initialize: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 释放所有屏幕DLL资源
|
|
/// </summary>
|
|
private void Uninitialize()
|
|
{
|
|
try
|
|
{
|
|
foreach (var item in dic)
|
|
{
|
|
mBX_5M = item.Value as SiaSun.LMS.LED.BX_5M_Base;
|
|
mBX_5M.UninitializeLED();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Fatal(string.Format("Uninitialize: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 遍历LED_MAIN,发送消息
|
|
/// </summary>
|
|
private void LEDSendMsg()
|
|
{
|
|
string sResult = string.Empty;
|
|
try
|
|
{
|
|
//取得自动处理标识为“1”自动处理,发送状态为“0”未发送的记录
|
|
//已发送的屏幕,间隔超出的,发送默认值
|
|
IList<SiaSun.LMS.Model.LED_MAIN> lsLED_MAIN = Program._I_LEDService.LED_MAIN_GetList();
|
|
|
|
foreach (SiaSun.LMS.Model.LED_MAIN mLED_MAIN in lsLED_MAIN)
|
|
{
|
|
bool bSend = false;
|
|
|
|
if (mLED_MAIN.AUTO_FLAG.Equals("1") && mLED_MAIN.LED_STATUS.Equals("0"))
|
|
{
|
|
//bSend = true;
|
|
this.LED_SEND(mLED_MAIN);
|
|
}
|
|
else
|
|
{
|
|
DateTime dt = DateTime.Parse(string.IsNullOrEmpty(mLED_MAIN.LED_MAIN_PARA2) ? SiaSun.LMS.Common.StringUtil.GetDateTime() : mLED_MAIN.LED_MAIN_PARA2);
|
|
|
|
//超过时间间隔
|
|
if (!string.IsNullOrEmpty(mLED_MAIN.LED_MAIN_PARA3))
|
|
{
|
|
if (dt.AddMinutes(Convert.ToInt32(mLED_MAIN.LED_MAIN_PARA3)) < DateTime.Now)
|
|
{
|
|
//bSend = true;
|
|
this.LED_SEND_Default(mLED_MAIN);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bSend)
|
|
{
|
|
//停用消息队列
|
|
//string sMsg = SiaSun.LMS.Common.Xml.Serializer<LED_MAIN>(mLED_MAIN);
|
|
|
|
//bResult = _ActiveMsg.SendMsg(
|
|
// "LedSend"
|
|
// , sMsg
|
|
// , out sResult);
|
|
|
|
//if (bResult)
|
|
//{
|
|
// //已发送
|
|
// mLED_MAIN.LED_STATUS = "1";
|
|
|
|
// //发送时间
|
|
// mLED_MAIN.LED_MAIN_PARA2 = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
// Program._I_LEDService.LED_MAIN_Update(mLED_MAIN);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Error(string.Format("LEDSendMsg catch Exception: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送指定屏幕
|
|
/// </summary>
|
|
/// <param name="mBX_5M"></param>
|
|
/// <param name="?"></param>
|
|
public void LED_SEND(Model.LED_MAIN mLED_MAIN)
|
|
{
|
|
int AREA_NO =-1;
|
|
|
|
int RETURN_ERROR = 0;
|
|
|
|
string RETURN_ERROR_MESSAGE = string.Empty;
|
|
|
|
string APP_PATH = AppDomain.CurrentDomain.BaseDirectory.ToString().Trim();
|
|
|
|
try
|
|
{
|
|
//mBX_5M = dic[mLED_MAIN.LED_ID] as SiaSun.LMS.LED.BX_5M_Base;
|
|
|
|
//检查是否最大值
|
|
if (rchMessage.Lines.Length >= rchMessage.MaxLength)
|
|
rchMessage.Clear();
|
|
|
|
//初始化图文区序号
|
|
AREA_NO = -1;
|
|
|
|
#region 添加屏幕
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreen(mLED_MAIN.CONTROL_TYPE,
|
|
mLED_MAIN.SCREEN_WIDTH,
|
|
mLED_MAIN.SCREEN_HEIGHT,
|
|
mLED_MAIN.LED_IP);
|
|
if (!mBX_5M.GetErrorMessage("AddScreen", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreen Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 添加节目
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgram();
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgram", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgram Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
//取得指定LED_ID且按LINE_NO从小到大排序的LED_LIST记录
|
|
IList<SiaSun.LMS.Model.LED_LIST> lsLED_LIST = Program._I_LEDService.LED_LIST_GetList_LED_ID(mLED_MAIN.LED_ID);
|
|
|
|
foreach (SiaSun.LMS.Model.LED_LIST mLED_LIST in lsLED_LIST)
|
|
{
|
|
//BX-5M屏幕不支持发送内容为空
|
|
if (string.IsNullOrEmpty(mLED_LIST.LINE_TEXT) || mLED_LIST.LINE_TEXT == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//图文区序号从0开始
|
|
AREA_NO++;
|
|
|
|
string PATH = APP_PATH + mLED_LIST.FILE_NAME;
|
|
|
|
#region 添加图文区
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgramBmpTextArea(mLED_LIST.AREA_X,
|
|
mLED_LIST.AREA_Y,
|
|
mLED_LIST.AREA_WIDTH,
|
|
mLED_LIST.AREA_HEIGHT);
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgramBmpTextArea", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgramBmpTextArea Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
//生成或重写对应文件
|
|
System.IO.File.WriteAllText(PATH, mLED_LIST.LINE_TEXT);
|
|
|
|
//160,32的屏幕,10号字体,每行最多显示10字
|
|
if (mLED_LIST.LINE_TEXT.Length < 10 && mLED_LIST.FONT_SIZE == 10)
|
|
{
|
|
mLED_LIST.SHOW_STUNT = 1;//静止
|
|
}
|
|
|
|
#region 添加文件到图文区
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgramAreaBmpTextFile(AREA_NO,
|
|
PATH,
|
|
mLED_LIST.FONT_SIZE,
|
|
mLED_LIST.SHOW_STUNT,
|
|
mLED_LIST.RUN_SPEED,
|
|
mLED_LIST.SHOW_TIME);
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgramAreaBmpTextFile", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgramAreaBmpTextFile Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
//添加图文区成功,则发送屏幕
|
|
if (AREA_NO > -1)
|
|
{
|
|
#region 发送数据
|
|
|
|
RETURN_ERROR = mBX_5M.SendScreenInfo();
|
|
if (!mBX_5M.GetErrorMessage("SendScreenInfo", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("SendScreenInfo Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除本次屏幕,否则下次添加不成功
|
|
|
|
RETURN_ERROR = mBX_5M.DeleteScreen();
|
|
if (!mBX_5M.GetErrorMessage("DeleteScreen", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("DeleteScreen Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
//记录发送时间
|
|
mLED_MAIN.LED_STATUS = "1";
|
|
mLED_MAIN.LED_MAIN_PARA2 = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
Program._I_LEDService.LED_MAIN_Update(mLED_MAIN);
|
|
|
|
//清空发送内容
|
|
string strUpdate = string.Format(@"UPDATE LED_LIST SET LINE_TEXT='{1}' WHERE LED_ID={0}", mLED_MAIN.LED_ID,string.Empty);
|
|
Program._I_BaseService.ExecuteNonQuery_ReturnVoid(strUpdate);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Error(string.Format("LED_SEND catch Exception: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送指定屏幕-默认文本
|
|
/// </summary>
|
|
/// <param name="mBX_5M"></param>
|
|
/// <param name="?"></param>
|
|
public void LED_SEND_Default(Model.LED_MAIN mLED_MAIN)
|
|
{
|
|
int AREA_NO = -1;
|
|
|
|
int RETURN_ERROR = 0;
|
|
|
|
string RETURN_ERROR_MESSAGE = string.Empty;
|
|
|
|
string APP_PATH = AppDomain.CurrentDomain.BaseDirectory.ToString().Trim();
|
|
|
|
try
|
|
{
|
|
mBX_5M = dic[mLED_MAIN.LED_ID] as SiaSun.LMS.LED.BX_5M_Base;
|
|
|
|
//检查是否最大值
|
|
if (rchMessage.Lines.Length >= rchMessage.MaxLength)
|
|
rchMessage.Clear();
|
|
|
|
//初始化图文区序号
|
|
AREA_NO = -1;
|
|
|
|
#region 添加屏幕
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreen(mLED_MAIN.CONTROL_TYPE,
|
|
mLED_MAIN.SCREEN_WIDTH,
|
|
mLED_MAIN.SCREEN_HEIGHT,
|
|
mLED_MAIN.LED_IP);
|
|
if (!mBX_5M.GetErrorMessage("AddScreen", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreen Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 添加节目
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgram();
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgram", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgram Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
//取得指定LED_ID且按LINE_NO从小到大排序的LED_LIST记录
|
|
IList<SiaSun.LMS.Model.LED_LIST> lsLED_LIST = Program._I_LEDService.LED_LIST_GetList_LED_ID(mLED_MAIN.LED_ID);
|
|
|
|
if (lsLED_LIST.Count > 0)
|
|
{
|
|
//图文区序号从0开始
|
|
AREA_NO++;
|
|
|
|
string PATH = APP_PATH + lsLED_LIST[0].FILE_NAME;
|
|
|
|
#region 添加图文区
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgramBmpTextArea(0,
|
|
0,
|
|
mLED_MAIN.SCREEN_WIDTH,
|
|
mLED_MAIN.SCREEN_HEIGHT);
|
|
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgramBmpTextArea", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgramBmpTextArea Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
//根据默认文本,生成或重写对应文件
|
|
System.IO.File.WriteAllText(PATH, mLED_MAIN.LED_MAIN_PARA4);
|
|
|
|
//160,32的屏幕,10号字体,每行最多显示10字
|
|
if (mLED_MAIN.LED_MAIN_PARA4.Length < 10)
|
|
{
|
|
lsLED_LIST[0].SHOW_STUNT = 1;//静止
|
|
}
|
|
|
|
#region 添加文件到图文区
|
|
|
|
RETURN_ERROR = mBX_5M.AddScreenProgramAreaBmpTextFile(AREA_NO,
|
|
PATH,
|
|
lsLED_LIST[0].FONT_SIZE,
|
|
lsLED_LIST[0].SHOW_STUNT,
|
|
lsLED_LIST[0].RUN_SPEED,
|
|
lsLED_LIST[0].SHOW_TIME);
|
|
|
|
if (!mBX_5M.GetErrorMessage("AddScreenProgramAreaBmpTextFile", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("AddScreenProgramAreaBmpTextFile Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
//添加任何图文区成功,则发送
|
|
if (AREA_NO > -1)
|
|
{
|
|
#region 发送数据
|
|
|
|
RETURN_ERROR = mBX_5M.SendScreenInfo();
|
|
if (!mBX_5M.GetErrorMessage("SendScreenInfo", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("SendScreenInfo Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除本次屏幕,否则下次添加不成功
|
|
|
|
RETURN_ERROR = mBX_5M.DeleteScreen();
|
|
if (!mBX_5M.GetErrorMessage("DeleteScreen", RETURN_ERROR, out RETURN_ERROR_MESSAGE))
|
|
{
|
|
rchMessage.Text += SiaSun.LMS.Common.StringUtil.GetCurDateTimeString() + string.Format("DeleteScreen Error: {0}\r\n", RETURN_ERROR_MESSAGE);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
//记录发送时间
|
|
mLED_MAIN.LED_STATUS = "1";
|
|
mLED_MAIN.LED_MAIN_PARA2 = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
Program._I_LEDService.LED_MAIN_Update(mLED_MAIN);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Program._log.Error(string.Format("LED_SEND catch Exception: {0}", ex.Message));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 消息监听-停用
|
|
|
|
/*消息队列发送屏幕,不支持多个屏幕并发,
|
|
* 并发时,只能发送单个屏幕,其他屏幕会返回错误
|
|
* 且发送成功的内容可能与并发的屏幕内容混淆*/
|
|
|
|
|
|
/// <summary>
|
|
/// 创建消息主题消费者,开始监听
|
|
/// </summary>
|
|
/// <param name="ClientId"></param>
|
|
/// <param name="Topic"></param>
|
|
/// <param name="name"></param>
|
|
//public void Listener_Init(string ClientId, string Topic, string name)
|
|
//{
|
|
// try
|
|
// {
|
|
// this.factory = new ConnectionFactory(SiaSun.LMS.Common.StringUtil.GetConfig("ActiveMQUrl"));
|
|
|
|
// this.connection = this.factory.CreateConnection();
|
|
// this.connection.ClientId = ClientId;
|
|
// this.connection.Start();
|
|
// this.session = this.connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
|
|
|
|
// this.consumer = session.CreateDurableConsumer(new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic(Topic)
|
|
// , name
|
|
// , null
|
|
// , false);
|
|
|
|
// this.consumer.Listener += new MessageListener(this.Listener);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Program._log.Error(string.Format("Listener_Init catch Exception: {0}", ex.Message));
|
|
// }
|
|
//}
|
|
|
|
//监听,开启线程
|
|
//public void Listener(IMessage message)
|
|
//{
|
|
// string sResult = string.Empty;
|
|
|
|
// try
|
|
// {
|
|
// ParameterizedThreadStart ParStart = new ParameterizedThreadStart(this.LedSendThread);
|
|
// Thread myThread = new Thread(ParStart);
|
|
// myThread.Start(message as object);
|
|
// }
|
|
// catch (System.Exception ex)
|
|
// {
|
|
// Program._log.Error(string.Format("Listener catch Exception: {0}", ex.Message));
|
|
// }
|
|
//}
|
|
|
|
//发送屏幕
|
|
//public void LedSendThread(object obj)
|
|
//{
|
|
// string sResult = string.Empty;
|
|
|
|
// ITextMessage txtMsg = null;
|
|
|
|
// try
|
|
// {
|
|
// txtMsg = obj as ITextMessage;
|
|
|
|
// SiaSun.LMS.Model.LED_MAIN mLED_MAIN = SiaSun.LMS.Common.Xml.DeSerializer<LED_MAIN>(txtMsg.Text);
|
|
|
|
// string strLedText = string.Format(@"SELECT * FROM LED_LIST WHERE LED_ID={0} AND LINE_TEXT IS NOT NULL AND LINE_TEXT!='{1}'", mLED_MAIN.LED_ID,string.Empty);
|
|
|
|
// DataTable dt=Program._I_BaseService.GetList(strLedText);
|
|
|
|
// if (dt.Rows.Count == 0)
|
|
// {
|
|
// this.LED_SEND_Default(mLED_MAIN);
|
|
// }
|
|
// else
|
|
// {
|
|
// this.LED_SEND(mLED_MAIN);
|
|
// }
|
|
// }
|
|
// catch (System.Exception ex)
|
|
// {
|
|
// Program._log.Error(string.Format("LedSendThread catch Exception: {0}", ex.Message));
|
|
// }
|
|
// finally
|
|
// {
|
|
// txtMsg.Acknowledge();
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 数据清理
|
|
|
|
private void miDataClear_Click(object sender, EventArgs e)
|
|
{
|
|
ToolStripMenuItem item = sender as ToolStripMenuItem;
|
|
if (item != null)
|
|
{
|
|
switch (item.Name)
|
|
{
|
|
//数据清理
|
|
case "miDataClear":
|
|
TABLE_CLEAR frmClear = new TABLE_CLEAR();
|
|
frmClear.Show(this);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|