ldj/winform/service/LightService.cs

116 lines
3.2 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DeiNiu.Utils;
namespace DNLightSvr
{
// 注意: 使用“重构”菜单上的“重命名”命令可以同时更改代码和配置文件中的类名“LightService”。
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class LightService : ILightService
{
// static log4net.ILog log = log4net.LogManager.GetLogger("light");
public delegate bool lightLable(ELabel[] lables);
public delegate bool clsOrder(ClearOrder clearOrder);
public clsOrder clearO = null;
public lightLable lightUp = null;
public string lightLabels(ELabel[] labels)
{
if (lightUp != null)
{
if (lightUp(labels))
{
return "success";
}
}
return "failure";
}
public string clearOrder(ClearOrder clearOrder)
{
if (clearO != null)
{
if (clearO(clearOrder))
{
return "success";
}
}
return "failure";
}
public string testPost(ELabel label)
{
string json = getJson(label);
// Console.Write("get the lable: " + json );
return json;// "succeed";
}
public string test()
{
Console.Write("get request");
return "服务响应 success";
}
public string getJson(ELabel label)
{
string json = String.Format("\"labelId\":{0},\"address\":{1},\"count\":{2},\"color\":{3},\"port\":{4},\"orderNo\":{5}"
, label.labelId, label.address, label.count, label.color, label.port, label.orderNo);
// Console.Write("get the lable: " + json);
return "{" + json + "}";
}
static string getMsg(string className, string msg)
{
return string.Format("{0} {1}", className, msg);
}
//--------------------------------------------light by order
public delegate int lightOrder(string orderNo,bool isPickOrder, int partion);
public lightOrder lightOd = null;
public int lightByPickOrder(string orderNo, int partion)
{
if (lightOd != null)
{
return lightOd(orderNo, true, partion);
//success
}
return 0;
}
public int lightBySaleOrder(string orderNo, int partion)
{
if (lightOd != null)
{
return lightOd(orderNo, false, partion);
}
return 0;
}
//---light by plate
public delegate string lightPlate(string plateId,int part);
public lightPlate lightPl = null;
public string lightByPlate(string plateId,int partion)
{
if (lightPl != null)
{
return lightPl(plateId, partion);
}
return "亮灯失败001";
}
}
}