Files
T-DAS/Epost.BLL/CommandBLL.cs

918 lines
32 KiB
C#
Raw Normal View History

2023-01-13 15:30:20 +08:00
using ComposerSDK;
using Epost.Common;
using Epost.DAL;
using Epost.DAL.Cache;
using Epost.DAL.Enum;
using Epost.Model;
2023-12-05 14:35:20 +08:00
using LightContrl;
2023-01-13 15:30:20 +08:00
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
2023-12-05 14:35:20 +08:00
using System.Threading;
2023-01-13 15:30:20 +08:00
using System.Threading.Tasks;
using static Epost.Common.LogHelper;
namespace Epost.BLL
{
public class CommandBLL
{
CommandDAL dal = new CommandDAL();
XgateCacheDAL xageDAL = new XgateCacheDAL();
AddressstorageBLL addrBLL = new AddressstorageBLL();
public static DataTable Controls = new DataTable();
public static DataTable Labels = new DataTable();
2023-12-05 14:35:20 +08:00
JobDownCacheDAL JobCache = new JobDownCacheDAL();
OrdersDAL orderDal = new OrdersDAL();
2023-01-13 15:30:20 +08:00
ConfigurationOperator txtbll = new ConfigurationOperator();
string IP = ConfigurationManager.AppSettings["WebAPIUrl"];
2023-12-05 14:35:20 +08:00
LightControlCacheDAL cachedal = new LightControlCacheDAL();
MainControl lig = new MainControl();
2023-01-13 15:30:20 +08:00
#region
public ResultModel Initialization_M(bool isback = true)
{
ResultModel resultModel = new ResultModel();
List<LabelParamModel> list = new List<LabelParamModel>();
try
{
2024-01-04 15:30:23 +08:00
DataTable dt = addrBLL.getControlList();
2023-01-13 15:30:20 +08:00
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
2024-01-04 15:30:23 +08:00
LabelParamModel model = new LabelParamModel();
model.ControlIP = item["ControlIP"].ToString();
model.Address = "9999";
model.Command = "FORMAT_JOB_DATA";
model.Parameter = "50";
model.Timeout = "0.5";
list.Add(model);
model = new LabelParamModel();
model.ControlIP = item["ControlIP"].ToString();
model.Address = "9999";
model.Command = "CONNECT";
model.Parameter = IP;
model.Timeout = "0.5";
list.Add(model);
model = new LabelParamModel();
model.ControlIP = item["ControlIP"].ToString();
model.Address = "9999";
model.Parameter = "job";
model.Command = "START_POLLING";
model.Timeout = "0.03";
list.Add(model);
model = new LabelParamModel();
model.ControlIP = item["ControlIP"].ToString();
model.Address = "9999";
model.Parameter = "11111000";
model.Command = "UNLOCK";
model.Timeout = "0.5";
list.Add(model);
2023-01-13 15:30:20 +08:00
2024-01-04 15:30:23 +08:00
}
if (list.Any())
{
resultModel = SendALL_Init(list);
2023-01-13 15:30:20 +08:00
}
}
return resultModel;
}
catch (Exception ex)
{
resultModel.result = "0";
resultModel.msg = "初始化失败!";
LogHelper.WriteLogInfo("初始化异常:" + ex.Message);
}
return resultModel;
}
2024-01-04 15:30:23 +08:00
//public ResultModel Initialization_M(bool isback = true)
//{
// ResultModel resultModel = new ResultModel();
// resultModel.result = "0";
// resultModel.msg = "成功";
// List<LabelParamModel> list = new List<LabelParamModel>();
// try
// {
// DataTable dt = addrBLL.QueryControlList("");
// if (dt != null && dt.Rows.Count > 0)
// {
// foreach (DataRow item in dt.Rows)
// {
// string ipaddress = item["controlip"].ToString().Trim();
// List<LightcontrolModel> conlist = cachedal.GetControlList().FindAll(o => o.controlip == ipaddress);
// if (conlist != null && conlist.Count > 0)
// {
// LogHelper.WriteLogInfo(ipaddress + "已连接!");
// Ledonoff_dengdai("0", "");
// }
// else
// {
// int port = Convert.ToInt32(item["port"].ToString().Trim());
// int timeout = 2000;
// bool bo = lig.Connect(ipaddress, port, timeout);//timeout 毫秒
// if (bo)
// {
// LightcontrolModel model = new LightcontrolModel();
// model.controlip = ipaddress;
// model.maincontrol = lig;
// model.port = port;
// cachedal.UpdateControlList(new List<LightcontrolModel> { model }, EcontrolCommend.Create);
// Ledonoff_dengdai("0", "");
// }
// else
// {
// LogHelper.WriteLogInfo("连接失败" + ipaddress);
// resultModel.result = "-1";
// resultModel.msg = "连接失败" + ipaddress;
// return resultModel;
// }
// }
// }
// }
// return resultModel;
// }
// catch (Exception ex)
// {
// resultModel.result = "0";
// resultModel.msg = "初始化失败!";
// LogHelper.WriteLogInfo("初始化异常:" + ex.Message);
// }
// return resultModel;
//}
2023-01-13 15:30:20 +08:00
#endregion
#region
public ResultModel GetAllLabelList_M()
{
ResultModel model = new ResultModel();
try
{
bool bo = true;
DataTable dt = addrBLL.getControlList();
List<LabelParamModel> list = new List<LabelParamModel>();
if (dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
DataTable lableDt = addrBLL.getLabelList(item["id"].ToString());
if (lableDt != null && lableDt.Rows.Count > 0)
{
foreach (DataRow labelItem in lableDt.Rows)
{
if (labelItem["addresstype"].ToString() == "2")
{
LabelParamModel CNlablemodel = new LabelParamModel();
CNlablemodel.Address = labelItem["address"].ToString();
CNlablemodel.ControlIP = item["ControlIP"].ToString();
CNlablemodel.Command = "DISPLAY_JOB";
CNlablemodel.Uid = labelItem["address"].ToString();
CNlablemodel.Type = "C";
CNlablemodel.Mode = "10";
CNlablemodel.Title = labelItem["address"].ToString();
list.Add(CNlablemodel);
}
else
{
LabelParamModel lablemodel = new LabelParamModel();
lablemodel.Address = labelItem["address"].ToString();
lablemodel.ControlIP = item["ControlIP"].ToString();
lablemodel.Command = "DISPLAY_JOB";
lablemodel.Type = "N";
lablemodel.Quantity = labelItem["address"].ToString();
lablemodel.Uid = labelItem["address"].ToString();
lablemodel.Mode = "10";
list.Add(lablemodel);
}
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
//result= combll.DISPLAY_JOB(model);
}
}
}
DISPLAY_JOBALL(list);
}
if (bo)
{
model.result = "1";
model.msg = "成功!";
}
return model;
}
catch (Exception ex)
{
model.result = "0";
model.msg = ex.Message;
return model;
}
}
#endregion
#region
2023-12-05 14:35:20 +08:00
public string GETDISPLAYJOBPAR_CN(string no, string Lightcolor, string IsTwinkle, string Title, string BigQuantity, string BigUnit, string Quantity, string Unit, string Content, string Rfcode)
2023-01-13 15:30:20 +08:00
{
2023-12-05 14:35:20 +08:00
string parar = no + "00" + Lightcolor + IsTwinkle + "30CQ" + Title + "\n\n" + BigQuantity + "\n" + BigUnit + "\n" + Quantity + "\n" + Unit + "\n" + Content + "\n00\n\n" + Rfcode + "\n"; ;
2023-01-13 15:30:20 +08:00
return parar;
}
#endregion
#region
public string GETDISPLAYJOBPAR(string no, string Lightcolor, string IsTwinkle, string location, string Quantity, string Rfcode)
{
string parar = no + Lightcolor + IsTwinkle + "30NQ" + location + "\n" + Quantity + "\n" + Rfcode + "\n";
return parar;
}
#endregion
#region
public void clearALL_M()
{
bool result = false;
DataTable dt = addrBLL.getControlList();
if (dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
LabelParamModel model = new LabelParamModel();
model.Address = "9999";
model.ControlIP = item["ControlIP"].ToString();
result = FORMATE_JOB_DATA(model);
}
}
}
#endregion
#region M系列
#region
public bool FORMATE_JOB_DATA(LabelParamModel model)
{
return dal.FORMATE_JOB_DATA(model);
}
#endregion
#region
public bool CONNECT(LabelParamModel model)
{
return dal.CONNECT(model);
}
#endregion
#region device/job/scan默认job
public bool START_POLLING(LabelParamModel model)
{
return dal.START_POLLING(model);
}
#endregion
#region
public bool ENTER_CONFIG_MODE(LabelParamModel model)
{
return dal.ENTER_CONFIG_MODE(model);
}
#endregion
#region
public bool SET_ADDRESS(LabelParamModel model)
{
return dal.SET_ADDRESS(model);
}
#endregion
#region
public bool DELETE_ADDRESS(LabelParamModel model)
{
return dal.DELETE_ADDRESS(model);
}
#endregion
#region 退
public bool EXIT_CONFIG_MODE(LabelParamModel model)
{
return dal.EXIT_CONFIG_MODE(model);
}
#endregion
#region ()
2023-12-05 14:35:20 +08:00
public void DISPLAY_JOB_M(LabelParamModel model, bool clear = false, bool islock = false)
2023-01-13 15:30:20 +08:00
{
List<LabelParamModel> list = new List<LabelParamModel>();
if (clear)
{
LabelParamModel clearModel = new LabelParamModel();
clearModel.Address = model.Address;
clearModel.ControlIP = model.ControlIP;
clearModel.Parameter = model.Parameter;
clearModel.Uid = model.Uid;
clearModel.Command = "REMOVE_JOB";
clearModel.Timeout = "0.5";
clearModel.Type = model.Type;
2023-12-05 14:35:20 +08:00
// dal.REMOVE_JOB(clearModel);
2023-01-13 15:30:20 +08:00
list.Add(clearModel);
}
LabelParamModel DisplayModel = new LabelParamModel();
DisplayModel.Address = model.Address;
DisplayModel.ControlIP = model.ControlIP;
2023-12-05 14:35:20 +08:00
DisplayModel.Content = model.Content;
DisplayModel.Title = model.Title;
2023-01-13 15:30:20 +08:00
DisplayModel.Loc = model.Loc;
DisplayModel.Quantity = model.Quantity;
DisplayModel.Uid = model.Uid;
DisplayModel.W_quantity = model.W_quantity;
DisplayModel.Unit = model.Unit;
DisplayModel.W_unit = model.W_unit;
DisplayModel.Command = "DISPLAY_JOB";
DisplayModel.Timeout = "0.5";
DisplayModel.Type = model.Type;
DisplayModel.Mode = model.Mode;
// dal.UNLOCK(lockModel);
list.Add(DisplayModel);
if (islock)
{
LabelParamModel lockModel = new LabelParamModel();
lockModel.Address = model.Address;
lockModel.ControlIP = model.ControlIP;
lockModel.Parameter = "11101000";
lockModel.Command = "LOCK";
lockModel.Timeout = "0.5";
lockModel.Type = model.Type;
// dal.LOCK(lockModel);
list.Add(lockModel);
}
else
{
LabelParamModel lockModel = new LabelParamModel();
lockModel.Address = model.Address;
lockModel.ControlIP = model.ControlIP;
lockModel.Parameter = "00011000";
lockModel.Command = "UNLOCK";
lockModel.Timeout = "0.5";
lockModel.Type = model.Type;
// dal.UNLOCK(lockModel);
list.Add(lockModel);
}
dal.DISPLAY_JOBALL(list);
}
#endregion
#region ()
public void LED_ON_M(LabelParamModel model, bool islock = false)
{
List<LabelParamModel> list = new List<LabelParamModel>();
LabelParamModel clearModel = new LabelParamModel();
clearModel.Address = model.Address;
clearModel.ControlIP = model.ControlIP;
clearModel.Parameter = "";
clearModel.Command = "LED_OFF";
clearModel.Timeout = "0.5";
// dal.REMOVE_JOB(clearModel);
list.Add(clearModel);
LabelParamModel DisplayModel = new LabelParamModel();
DisplayModel.Address = model.Address;
DisplayModel.ControlIP = model.ControlIP;
DisplayModel.Parameter = model.Parameter;
DisplayModel.Command = "LED_ON";
DisplayModel.Timeout = "0.5";
// dal.UNLOCK(lockModel);
list.Add(DisplayModel);
if (islock)
{
LabelParamModel lockModel = new LabelParamModel();
lockModel.Address = model.Address;
lockModel.ControlIP = model.ControlIP;
lockModel.Parameter = "11101000";
lockModel.Command = "LOCK";
lockModel.Timeout = "0.5";
// dal.LOCK(lockModel);
list.Add(lockModel);
}
else
{
LabelParamModel lockModel = new LabelParamModel();
lockModel.Address = model.Address;
lockModel.ControlIP = model.ControlIP;
lockModel.Parameter = "00011000";
lockModel.Command = "UNLOCK";
lockModel.Timeout = "0.5";
// dal.UNLOCK(lockModel);
list.Add(lockModel);
}
dal.DISPLAY_JOBALL(list);
}
#endregion
#region LED_OFF()
public void LED_OFF_M(List<JobModel> list)
{
List<LabelParamModel> sendlist = new List<LabelParamModel>();
foreach (JobModel model in list)
{
LabelParamModel clearModel = new LabelParamModel();
clearModel.Address = model.Address;
clearModel.ControlIP = model.ControlIP;
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
clearModel.Command = "LED_OFF";
2023-12-05 14:35:20 +08:00
clearModel.Timeout = "0.5";
2023-01-13 15:30:20 +08:00
sendlist.Add(clearModel);
}
dal.DISPLAY_JOBALL(sendlist);
}
#endregion
#region LED_OFF()
public void LED_OFF_CLEAR(string ip)
{
LabelParamModel clearModel = new LabelParamModel();
clearModel.Address = "9999";
clearModel.ControlIP = ip;
clearModel.Parameter = "1";
clearModel.Command = "LED_OFF";
clearModel.Timeout = "0.5";
dal.Send(clearModel);
}
#endregion
#region LED_OFF()
public void LED_OFF_CLEAR(List<JobModel> offList)
{
List<LabelParamModel> list = new List<LabelParamModel>();
if (offList.Any())
{
foreach (JobModel item in offList)
{
LabelParamModel clearModel = new LabelParamModel();
clearModel.Address = item.Address;
clearModel.ControlIP = item.ControlIP;
clearModel.Parameter = "1";
clearModel.Command = "LED_OFF";
clearModel.Timeout = "0.5";
list.Add(clearModel);
}
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
}
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
dal.SendALL(list);
}
#endregion
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
#region ()
public bool DISPLAY_JOB(LabelParamModel model)
{
return dal.DISPLAY_JOB(model);
}
#endregion
#region ()
public void DISPLAY_JOBALL(List<LabelParamModel> model)
{
dal.DISPLAY_JOBALL(model);
}
#endregion
#region
public ResultModel SendALL_Init(List<LabelParamModel> model)
{
return dal.SendALL_Init(model);
}
#endregion
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
#region ()
public bool REMOVE_JOB(LabelParamModel model)
{
return dal.REMOVE_JOB(model);
}
#endregion
#region
public bool DISPLAY_LIGHT(LabelParamModel model)
{
return dal.DISPLAY_LIGHT(model);
}
#endregion
#region
public bool LOCK(LabelParamModel model)
{
return dal.LOCK(model);
}
#endregion
#region
public bool UNLOCK(LabelParamModel model)
{
return dal.UNLOCK(model);
}
#endregion
#region 使
public bool SET_SCANDEVICE_ON(LabelParamModel model)
{
return dal.SET_SCANDEVICE_ON(model);
}
#endregion
#region 使
public bool SET_SCANDEVICE_OFF(LabelParamModel model)
{
return dal.SET_SCANDEVICE_OFF(model);
}
#endregion
#region
public bool SET_SCANDEVICE_CLEAR(LabelParamModel model)
{
return dal.SET_SCANDEVICE_CLEAR(model);
}
#endregion
#region
public bool SLEEP(LabelParamModel model)
{
return dal.SLEEP(model);
}
#endregion
#region
public void CloseALL_M()
{
2024-01-04 15:30:23 +08:00
DataTable dt = addrBLL.getControlList();
if (dt != null && dt.Rows.Count > 0)
2023-12-05 14:35:20 +08:00
{
2024-01-04 15:30:23 +08:00
foreach (DataRow item in dt.Rows)
2023-12-05 14:35:20 +08:00
{
2024-01-04 15:30:23 +08:00
LabelParamModel model = new LabelParamModel();
model.ControlIP = item["ControlIP"].ToString();
FORMATE_JOB_DATA(model);
LED_OFF_CLEAR(item["ControlIP"].ToString());
2023-12-05 14:35:20 +08:00
2024-01-04 15:30:23 +08:00
}
2023-12-05 14:35:20 +08:00
2024-01-04 15:30:23 +08:00
}
//List<LightcontrolModel> conlist = cachedal.GetControlList();
//if (conlist.Any() && conlist.Count > 0)
//{
// Ledonoff_dengdai("0","");
// Thread.Sleep(500);
// foreach (LightcontrolModel con in conlist)
// {
// bool b = con.maincontrol.DisConnect(con.controlip, con.port);
// LogHelper.WriteLogInfo(b + "断开连接" + con.controlip + "==" + con.port);
// }
//}
//cachedal.ClearControlList();
2023-12-05 14:35:20 +08:00
}
#endregion
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
#region
public void Ledonoff_dengdai(string lightType, string lightcolor)
{
DataTable dt = addrBLL.QueryControlList(" ");
2023-01-13 15:30:20 +08:00
if (dt != null && dt.Rows.Count > 0)
{
2023-12-05 14:35:20 +08:00
foreach (DataRow rowitem in dt.Rows)
2023-01-13 15:30:20 +08:00
{
2023-12-05 14:35:20 +08:00
string ipaddress = rowitem["controlip"].ToString().Trim();
List<LightcontrolModel> conlist = cachedal.GetControlList().FindAll(o => o.controlip == ipaddress);
if (conlist != null && conlist.Count > 0)
{
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
MainControl control = conlist.FirstOrDefault().maincontrol;
bool bo = false;
string Address = dt.Rows[0]["address"].ToString().Trim();
string resstr = string.Empty;
if (lightType == "0")
{
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
bo = control.LED_OFF(ipaddress, Address, ref resstr);
}
else
{
bo = control.LED_ON(ipaddress, Address, ref resstr, "3", "0", lightcolor);
}
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
}
}
2023-01-13 15:30:20 +08:00
}
2023-12-05 14:35:20 +08:00
}
#endregion
#region /
public void display_dengdai(string location,string color)
{
DataTable dt = addrBLL.QueryControlList("");
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow rowitem in dt.Rows)
{
string ipaddress = rowitem["controlip"].ToString().Trim();
List<LightcontrolModel> conlist = cachedal.GetControlList().FindAll(o => o.controlip == ipaddress);
if (conlist != null && conlist.Count > 0)
{
MainControl control = conlist.FirstOrDefault().maincontrol;
DataTable locdt = addrBLL.QueryAddrList(" and location ='" + location + "' and controlip='" + ipaddress + "'");
if (locdt != null && locdt.Rows.Count > 0)
{
List<LightParagraph> list = new List<LightParagraph>();
string address = locdt.Rows[0]["address"].ToString().Trim();
foreach (DataRow locitem in locdt.Rows)
{
//根据播种墙号、格口号查询播种墙ip及灯带地址
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
LightParagraph show = new LightParagraph();
show.WayNu = Convert.ToInt32(locitem["wayno"].ToString().Trim());
show.LightBeganNu = locitem["beginno"].ToString().Trim();
show.LightEndNu = locitem["endno"].ToString().Trim();
show.LightColor = color; //1:蓝色 2:绿色 3青色 4:红色 5紫色 6黄色 7白色
show.Brightness = "9";//亮度 1-9
list.Add(show);
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
}
string resstr = string.Empty;
bool bo = control.LED_By_Paragraph(ipaddress, address, list, ref resstr);
if (bo)
{
LogHelper.WriteLogInfo("成功" + ipaddress + "list:" + JsonHelper.SerializeObject(list));
}
else
{
LogHelper.WriteLogInfo("失败" + ipaddress + "list:" + JsonHelper.SerializeObject(list), LogHelper.Log_Type.ERROR);
}
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
}
}
else
{
LogHelper.WriteLogInfo("请先连接设备!");
}
}
2023-01-13 15:30:20 +08:00
2023-12-05 14:35:20 +08:00
}
2023-01-13 15:30:20 +08:00
}
#endregion
#region
public void UNLOCK_M(List<JobModel> offList)
{
// DataTable dt = addrBLL.getAddresslist(block,area,type);
if (offList.Any())
{
List<LabelParamModel> list = new List<LabelParamModel>();
foreach (JobModel item in offList)
{
LabelParamModel model = new LabelParamModel();
model.ControlIP = item.ControlIP;
model.Address = item.Address;
model.Command = "UNLOCK";
model.Parameter = "11111000";
list.Add(model);
}
dal.SendALL(list);
}
}
#endregion
#region
public void ClearArea_M(List<JobModel> offList)
{
// DataTable dt = addrBLL.getAddresslist(block,area,type);
2023-12-05 14:35:20 +08:00
if (offList.Any())
2023-01-13 15:30:20 +08:00
{
List<LabelParamModel> list = new List<LabelParamModel>();
foreach (JobModel item in offList)
{
LabelParamModel model = new LabelParamModel();
model.ControlIP = item.ControlIP;
model.Address = item.Address;
model.Command = "REMOVE_JOB";
model.Uid = item.ID;
model.Type = "N";
list.Add(model);
LabelParamModel Unlockmodel = new LabelParamModel();
Unlockmodel.ControlIP = item.ControlIP;
Unlockmodel.Address = item.Address;
Unlockmodel.Command = "UNLOCK";
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
Unlockmodel.Type = "N";
Unlockmodel.Parameter = "11111000";
list.Add(Unlockmodel);
}
dal.SendALL(list);
}
}
#endregion
#region
public void ClearAreaLEDOFF(List<JobModel> offList)
{
// DataTable dt = addrBLL.getAddresslist(block,area,type);
if (offList.Any())
{
List<LabelParamModel> list = new List<LabelParamModel>();
foreach (JobModel item in offList)
{
LabelParamModel model = new LabelParamModel();
model.ControlIP = item.ControlIP;
model.Address = item.Address;
model.Command = "LED_OFF";
model.Parameter = "0";
list.Add(model);
}
dal.SendALL(list);
}
}
#endregion
#region
public void ShowBoxMessage_M(ShowMessageModel_M show)
{
2023-12-05 14:35:20 +08:00
//获取作业区对应的显示标签地址
DataTable showaddrDT = addrBLL.GetBoxAddress(show.Block, show.Area, show.Type);
2023-01-13 15:30:20 +08:00
if (showaddrDT != null && showaddrDT.Rows.Count > 0)
{
foreach (DataRow addritem in showaddrDT.Rows)
{
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
LabelParamModel lablemodel = new LabelParamModel();
lablemodel.Address = addritem["address"].ToString();
lablemodel.ControlIP = addritem["controlip"].ToString();
lablemodel.Command = "DISPLAY_JOB";
2023-12-05 14:35:20 +08:00
lablemodel.Uid = show.Uid;
2023-01-13 15:30:20 +08:00
if (string.IsNullOrEmpty(show.Uid))
{ lablemodel.Uid = addritem["address"].ToString(); }
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
lablemodel.Mode = show.Color + "0";
if (addritem["addresstype"].ToString() == "2")
2023-12-05 14:35:20 +08:00
{
2023-01-13 15:30:20 +08:00
lablemodel.Type = "C";
lablemodel.Loc = show.Location;
lablemodel.Title = show.Title;
lablemodel.Content = show.Contents;
lablemodel.Quantity = show.Qty;
lablemodel.Unit = show.Unit;
lablemodel.W_unit = show.Wholeunit;
lablemodel.W_quantity = show.Wholeqty.ToString();
}
else
2023-12-05 14:35:20 +08:00
{
2023-01-13 15:30:20 +08:00
lablemodel.Type = "N";
2023-12-05 14:35:20 +08:00
lablemodel.Quantity = show.Qty;
2023-01-13 15:30:20 +08:00
lablemodel.Loc = show.Location;
2023-12-05 14:35:20 +08:00
}
2023-01-13 15:30:20 +08:00
DISPLAY_JOB_M(lablemodel, true, show.Islock);
LogHelper.WriteLogInfo("点亮显示标签" + addritem["address"].ToString());
}
}
}
/// <summary>
/// 判断输入的字符串是否只包含数字和英文字母
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsNumAndEnCh(string input)
{
string pattern = @"^[A-Za-z0-9]+$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input);
}
#endregion
#region
public bool DISPLAY_LIGHT_BLOCK(string block, string area, string isoff)
{
DataTable dt = addrBLL.GetBoxAddress(block, area, 4);
List<LabelParamModel> list = new List<LabelParamModel>();
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
LabelParamModel model = new LabelParamModel();
model.Command = "DISPLAY_LIGHT";
model.Timeout = "0.5";
model.Type = "T";
model.Address = item["address"].ToString();
model.ControlIP = item["ControlIP"].ToString();
2023-12-05 14:35:20 +08:00
model.Parameter = ConvertHexHelper.ConvertString(item["addresstype"].ToString(), 10, 16).ToString().PadLeft(2, '0') + isoff;
2023-01-13 15:30:20 +08:00
list.Add(model);
}
}
dal.SendALL(list);
return true;
}
#endregion
#region
public void RemoveBoxMessage_M(ShowMessageModel_M show)
{
//获取作业区对应的显示标签地址
DataTable showaddrDT = addrBLL.GetBoxAddress(show.Block, show.Area, show.Type);
if (showaddrDT != null && showaddrDT.Rows.Count > 0)
{
List<LabelParamModel> list = new List<LabelParamModel>();
foreach (DataRow addritem in showaddrDT.Rows)
{
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
LabelParamModel model = new LabelParamModel();
model.Address = addritem["address"].ToString();
model.ControlIP = addritem["controlip"].ToString();
2023-12-05 14:35:20 +08:00
model.Parameter = show.No;
2023-01-13 15:30:20 +08:00
model.Command = "REMOVE_JOB";
model.Timeout = "0.5";
list.Add(model);
2023-12-05 14:35:20 +08:00
}
2023-01-13 15:30:20 +08:00
if (list != null && list.Count > 0)
{
LogHelper.WriteLogInfo("熄灭点亮的list———————" + list.Count);
dal.DISPLAY_JOBALL(list);
}
}
2023-12-05 14:35:20 +08:00
}
2023-01-13 15:30:20 +08:00
#endregion
#endregion
2023-12-05 14:35:20 +08:00
2023-01-13 15:30:20 +08:00
}
}