This commit is contained in:
@ -36,53 +36,50 @@ namespace Epost.BLL
|
||||
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("");
|
||||
|
||||
DataTable dt = addrBLL.getControlList();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
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 + "已连接!");
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("连接失败" + ipaddress);
|
||||
resultModel.result = "-1";
|
||||
resultModel.msg = "连接失败" + ipaddress;
|
||||
return resultModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Any())
|
||||
{
|
||||
resultModel = SendALL_Init(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return resultModel;
|
||||
|
||||
}
|
||||
@ -96,6 +93,72 @@ namespace Epost.BLL
|
||||
}
|
||||
return resultModel;
|
||||
}
|
||||
//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;
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 设备检测 查询所有标签
|
||||
@ -513,35 +576,32 @@ namespace Epost.BLL
|
||||
#region 清除所有任务并熄灭通道灯
|
||||
public void CloseALL_M()
|
||||
{
|
||||
//DataTable dt = addrBLL.getControlList();
|
||||
|
||||
//if (dt != null && dt.Rows.Count > 0)
|
||||
//{
|
||||
// foreach (DataRow item in dt.Rows)
|
||||
// {
|
||||
|
||||
// LabelParamModel model = new LabelParamModel();
|
||||
// model.ControlIP = item["ControlIP"].ToString();
|
||||
// FORMATE_JOB_DATA(model);
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
List<LightcontrolModel> conlist = cachedal.GetControlList();
|
||||
if (conlist.Any() && conlist.Count > 0)
|
||||
DataTable dt = addrBLL.getControlList();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
Ledonoff_dengdai("0","");
|
||||
Thread.Sleep(500);
|
||||
foreach (LightcontrolModel con in conlist)
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
bool b = con.maincontrol.DisConnect(con.controlip, con.port);
|
||||
LogHelper.WriteLogInfo(b + "断开连接" + con.controlip + "==" + con.port);
|
||||
|
||||
LabelParamModel model = new LabelParamModel();
|
||||
model.ControlIP = item["ControlIP"].ToString();
|
||||
FORMATE_JOB_DATA(model);
|
||||
LED_OFF_CLEAR(item["ControlIP"].ToString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
cachedal.ClearControlList();
|
||||
|
||||
|
||||
|
||||
//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();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
Reference in New Issue
Block a user