diff --git a/AutoWeightServer/App.config b/AutoWeightServer/App.config
index e0b37ec..1a2c075 100644
--- a/AutoWeightServer/App.config
+++ b/AutoWeightServer/App.config
@@ -40,7 +40,7 @@
-
+
diff --git a/AutoWeightServer/AutoWeightServer.csproj b/AutoWeightServer/AutoWeightServer.csproj
index 143a2f4..3bc4860 100644
--- a/AutoWeightServer/AutoWeightServer.csproj
+++ b/AutoWeightServer/AutoWeightServer.csproj
@@ -57,7 +57,7 @@
false
- title.ico
+ Resources\title.ico
LocalIntranet
@@ -195,7 +195,10 @@
+
+
+
@@ -328,16 +331,16 @@
Designer
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
@@ -351,7 +354,7 @@
Settings.settings
True
-
+
Always
@@ -433,11 +436,11 @@
-
+
PreserveNewest
+
-
diff --git a/AutoWeightServer/Center/DeviceCenter.cs b/AutoWeightServer/Center/DeviceCenter.cs
index e0aac3f..5346785 100644
--- a/AutoWeightServer/Center/DeviceCenter.cs
+++ b/AutoWeightServer/Center/DeviceCenter.cs
@@ -1,6 +1,7 @@
using EC.AutoWeightServer.IfManager.FingerPrint;
using EC.AutoWeightServer.IfManager.LedZK;
using EC.AutoWeightServer.IfManager.Light;
+using EC.AutoWeightServer.IfManager.Pos;
using EC.AutoWeightServer.IfManager.Scales;
using EC.AutoWeightServer.IfManager.YkPos;
using EC.AutoWeightServer.Model.Config;
@@ -10,7 +11,6 @@ using EC.Entity.Transport;
using EC.Utils;
using System;
using System.Collections.Generic;
-using System.IO;
using System.Text;
namespace EC.AutoWeightServer.Center
@@ -32,7 +32,7 @@ namespace EC.AutoWeightServer.Center
///
/// 灯光控制
///
- internal ILightManager LightManager { get; set; }
+ internal LightManager LightManager { get; set; }
///
/// 指纹识别
@@ -44,6 +44,8 @@ namespace EC.AutoWeightServer.Center
///
internal LedZKManager LedZKManager { get; set; }
+ internal PosManager PosManager { get; set; }
+
public DeviceCenter()
{
}
@@ -66,7 +68,8 @@ namespace EC.AutoWeightServer.Center
OpenLightServer();
OpenLedServer();
OpenFingerPrintServer();
- OpenYkPosServer();
+ //OpenYkPosServer();
+ OpenPosServer();
}
public void CloseDevices()
@@ -74,9 +77,10 @@ namespace EC.AutoWeightServer.Center
//CloseCameraServer();
//CloseWeightServer();
//CloseLightServer();
+ //CloseLedServer();
//CloseFingerPrintServer();
//CloseYkPosServer();
- //CloseLedServer();
+ //OpenPosServer();
}
public void CheckDevicesConnect()
@@ -98,13 +102,24 @@ namespace EC.AutoWeightServer.Center
msgList.Add("指纹接口未连接");
if (LedZKManager == null || !LedZKManager.IsConnected())
msgList.Add("Led屏未连接");
- if (!YkPosManager.IsConnected())
+ //if (!YkPosManager.IsConnected())
+ //{
+ // msgList.Add("打印接口未连接");
+ //}
+ //else
+ //{
+ // if (YkPosManager.IsPaperExhaust())
+ // msgList.Add("打印接口纸尽");
+ // //if (YkPosManager.IsPaperWillExhaust())
+ // // msgList.Add("打印接口纸将尽");
+ //}
+ if (!PosManager.IsConnected())
{
msgList.Add("打印接口未连接");
}
else
{
- if (YkPosManager.IsPaperExhaust())
+ if (PosManager.IsPaperExhaust())
msgList.Add("打印接口纸尽");
//if (YkPosManager.IsPaperWillExhaust())
// msgList.Add("打印接口纸将尽");
@@ -308,6 +323,8 @@ namespace EC.AutoWeightServer.Center
///
public void PrintBill(TransportBillEntity billEntity)
{
+ if (billEntity == null)
+ return;
if (!YkPosManager.IsConnected() || YkPosManager.IsPaperExhaust())
{
var msg = "打印接口纸尽,请联系管理人员";
@@ -315,11 +332,9 @@ namespace EC.AutoWeightServer.Center
_mainServer?.ShowRecvMessage(msg);
return;
}
- if (billEntity == null)
- return;
YkPosManager.InitPrinter();
- var bmpPath = Path.Combine(CommonUtil.GetWorkDirectory(), Path.Combine("Img", "logo.bmp"));
+ var bmpPath = EnvUtil.CombinePath(EnvUtil.GetWorkDirectory(), "data", "image", "logo.bmp");
YkPosManager.SetAlign(1);//居中
YkPosManager.PrintRasterBmp(new StringBuilder(bmpPath));//打印图片
@@ -379,5 +394,97 @@ namespace EC.AutoWeightServer.Center
}
#endregion YkPosManager
+
+ #region PosManager
+
+ public void OpenPosServer()
+ {
+ PosManager = new PosManager();
+ PosManager.OpenDevice(PosSDK.POS_PT_USB);
+ }
+
+ public void ClosePosServer()
+ {
+ PosManager?.CloseDevice();
+ PosManager = null;
+ }
+
+ public void PrintBIll(TransportBillEntity billEntity)
+ {
+ if (PosManager == null || billEntity == null)
+ return;
+ if (!PosManager.IsConnected() || PosManager.IsPaperExhaust())
+ {
+ var msg = "打印接口纸尽,请联系管理人员";
+ _mainServer?.SetScrollLabelText(msg);
+ _mainServer?.ShowRecvMessage(msg);
+ return;
+ }
+
+ // 初始化
+ PosManager.InitPrinter();
+
+ // 打印票头
+ string bmpPath2 = EnvUtil.CombinePath(EnvUtil.GetWorkDirectory(), "data", "image", "logom.bmp");
+ if (!EnvUtil.ExistFile(bmpPath2))
+ {
+ string bmpPath1 = EnvUtil.CombinePath(EnvUtil.GetWorkDirectory(), "data", "image", "logo.bmp");
+ PosManager.Color24_GrayBW(bmpPath1, bmpPath2);
+ }
+ PosManager.PrintBmp(bmpPath2);
+
+ // 缓冲区
+ byte[] cmd = new byte[] { 0x1c, 0x26 };
+ PosManager.PrintData(cmd, 2);
+
+ // 打印公司
+ PosManager.SetAlign(1);
+ PosManager.PrintStr(0, 1, 0, 0, 0, $"{_mainServer.LocalAttrCenter.Company.F_FullName}\r\n");
+ // 打印分隔符
+ PosManager.PrintStr(0, 0, 0, 0, 0, "================================\r\n");
+
+ // 打印运单信息
+ PosManager.SetAlign(0);//居左
+ var content = new StringBuilder();
+ content.Append($"场地:\t{billEntity.SiteName}\n");
+ content.Append($"运单号:\t{billEntity.SerialNumber}\n");
+ content.Append($"供应商:\t{billEntity.SupplierName}\n");
+ content.Append($"运输车:\t{billEntity.LicensePlate}\n");
+ content.Append($"挂车:\t{billEntity.TrailerPlate}\n");
+ content.Append($"运输员:\t{billEntity.DriverName}\n");
+ content.Append($"押运员:\t{billEntity.Driver2Name}\n");
+ content.Append($"料号:\t{billEntity.MaterialNo}\n");
+ PosManager.PrintStr(0, 0, 0, 0, 0, content.ToString());
+ // 打印分隔符
+ PosManager.SetAlign(1);
+ PosManager.PrintStr(0, 0, 0, 0, 0, "--------------------------------\r\n");
+
+ // 打印进出场信息
+ PosManager.SetAlign(0);
+ content = new StringBuilder();
+ content.Append($"运单重量:\t{billEntity.BillWeight}吨\n");
+ content.Append($"入场重量:\t{billEntity.InWeight}吨\n");
+ content.Append($"出场重量:\t{billEntity.OutWeight}吨\n");
+ content.Append($"实际重量:\t{billEntity.NetWeight}吨\n");
+ content.Append($"达标率:\t{billEntity.StandardRate}%\n");
+ content.Append($"入场时间:\t{billEntity.InStartTime:yyyy/MM/dd HH:mm:ss}\n");
+ content.Append($"出场时间:\t{billEntity.OutFinishTime:yyyy/MM/dd HH:mm:ss}\n");
+ //content.Append($"运单状态:\t{BillStateExt.GetBillStateDesc(billEntity.State)}\n");
+ PosManager.PrintStr(0, 0, 0, 0, 0, content.ToString());
+ //打印分隔符
+ PosManager.SetAlign(1);
+ PosManager.PrintStr(0, 0, 0, 0, 0, "================================\r\n");
+
+ //打印票尾
+ PosManager.SetAlign(2);
+ //PosManager.PrintStr(0, 0, 0, 0, 0,$"管理员:{user?.F_RealName}\n");
+ PosManager.PrintStr(0, 0, 0, 0, 0, $"出票时间:{DateTime.Now:yyyy/MM/dd HH:mm:ss}\r\n");
+ PosManager.InitPrinter();
+
+ //切纸
+ PosManager.CutPaper(1, 3);
+ }
+
+ #endregion PosManager
}
}
\ No newline at end of file
diff --git a/AutoWeightServer/IfManager/Light/ILightManager.cs b/AutoWeightServer/IfManager/Light/ILightManager.cs
index b035e96..87fcb51 100644
--- a/AutoWeightServer/IfManager/Light/ILightManager.cs
+++ b/AutoWeightServer/IfManager/Light/ILightManager.cs
@@ -27,6 +27,5 @@
public bool LockLightOff(int index);
#endregion Control Lights
-
}
}
\ No newline at end of file
diff --git a/AutoWeightServer/IfManager/Light/LightManager.cs b/AutoWeightServer/IfManager/Light/LightManager.cs
index 87b244d..3aec0a6 100644
--- a/AutoWeightServer/IfManager/Light/LightManager.cs
+++ b/AutoWeightServer/IfManager/Light/LightManager.cs
@@ -22,7 +22,7 @@ namespace EC.AutoWeightServer.IfManager.Light
_baudRate = baudRate;
_fileName = fileName;
- ReadLightCodeJson();
+ _readCodeFlag = ReadLightCodeJson();
}
#region Start & Stop Server
@@ -58,6 +58,8 @@ namespace EC.AutoWeightServer.IfManager.Light
#region Control Lights Code
+ private bool _readCodeFlag;
+
///
/// 控制所有灯编码,1 为开启所有灯,2 为关闭所有灯
///
@@ -95,6 +97,11 @@ namespace EC.AutoWeightServer.IfManager.Light
return true;
}
+ public bool IsReadCodeSuccess()
+ {
+ return _readCodeFlag;
+ }
+
#endregion Control Lights Code
#region Control Lights
diff --git a/AutoWeightServer/IfManager/Pos/PosManager.cs b/AutoWeightServer/IfManager/Pos/PosManager.cs
new file mode 100644
index 0000000..8d6b49d
--- /dev/null
+++ b/AutoWeightServer/IfManager/Pos/PosManager.cs
@@ -0,0 +1,206 @@
+namespace EC.AutoWeightServer.IfManager.Pos
+{
+ public class PosManager
+ {
+ private int _portType { get; set; }//0 COM,1 LPT ,2 USB 3 ETH
+ private int _printer { get; set; }
+ private int _bitmapType { get; set; }
+ private int _paperType { get; set; } = 1; //0 88m 1 58m 2 76m
+
+ private int _result { get; set; }
+
+ public PosManager()
+ {
+ }
+
+ ///
+ /// 打开设备
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool OpenDevice(int portType, bool bFile = false, string path = "")
+ {
+ string lpName;
+ _portType = portType;
+ switch (portType)
+ {
+ case PosSDK.POS_PT_COM:
+ lpName = "COM1:9600,N,8,1";
+ break;
+
+ case PosSDK.POS_PT_LPT:
+ lpName = "LPT1";
+ break;
+
+ case PosSDK.POS_PT_USB:
+ lpName = "SP-USB1";
+ break;
+
+ case PosSDK.POS_PT_NET:
+ lpName = "192.168.1.114";
+ break;
+
+ default:
+ lpName = "SP-USB1";
+ portType = PosSDK.POS_PT_USB;
+ break;
+ }
+ _printer = PosSDK.POS_Port_OpenA(lpName, portType, bFile, path);
+ SetResult(_printer);
+ return _printer >= 0;
+ }
+
+ ///
+ /// 关闭设备
+ ///
+ ///
+ public bool CloseDevice()
+ {
+ int ret = PosSDK.POS_Port_Close(_printer);
+ SetResult(ret);
+ _printer = PosSDK.POS_ES_INVALIDPARA;
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 设备是否连接
+ ///
+ ///
+ public bool IsConnected()
+ {
+ return _printer >= 0;
+ }
+
+ public int GetResult()
+ {
+ return _result;
+ }
+
+ private void SetResult(int ret)
+ {
+ _result = ret;
+ }
+
+ ///
+ /// 初始化打印机
+ ///
+ ///
+ public bool InitPrinter()
+ {
+ int ret = PosSDK.POS_Control_ReSet(_printer);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 选择字符对齐(居左/居中/居右)方式
+ ///
+ /// 0:左对齐,1:居中,2:右对齐
+ ///
+ public bool SetAlign(int alignType)
+ {
+ int ret = PosSDK.POS_Control_AlignType(_printer, alignType);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 设置打印左边距和打印区域
+ ///
+ /// 设置左边距,默认值为 0
+ /// 设置打印区域,默认值为 0
+ ///
+ public bool SetLeftMargin(int iLeft, int iWidth)
+ {
+ int ret = PosSDK.POS_Control_SetPrintPosition(_printer, iLeft, iWidth);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 缓冲数据
+ ///
+ ///
+ ///
+ ///
+ public bool PrintData(byte[] strBuff, int ilen)
+ {
+ int ret = PosSDK.POS_Output_PrintData(_printer, strBuff, ilen);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 打印本地单色位图
+ ///
+ /// 本地单色位图存储路径
+ ///
+ public bool PrintBmp(string bmpPath)
+ {
+ int ret = PosSDK.POS_Output_PrintBmpDirectA(_printer, bmpPath);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 打印格式化后的字符串
+ ///
+ /// 0:选择标准 ASCII 字体A(12×24),1:选择压缩 ASCII 字体B(9×17)
+ /// 0:取消加粗模式,1:选择加粗模式
+ /// 0:取消倍宽模式,1:选择倍宽模式
+ /// 0:取消倍高模式,1:选择倍高模式
+ /// 0:取消下划线模式,1:选择下划线模式
+ /// 以空字符结尾的字符串
+ ///
+ public bool PrintStr(int iFont, int iThick, int iWidth, int iHeight, int iUnderLine, string lpstring)
+ {
+ int ret = PosSDK.POS_Output_PrintFontStringA(_printer, iFont, iThick, iWidth, iHeight, iUnderLine, lpstring);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 打印缓冲区内容,进纸由参数 iLines 设置的行数并切纸
+ ///
+ /// 0:全切,1:半切
+ /// 进纸行数
+ ///
+ public bool CutPaper(int type = 0, int len = 1)
+ {
+ int ret = PosSDK.POS_Control_CutPaper(_printer, type, len);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ public bool Color24_GrayBW(string path1, string path2)
+ {
+ int ret = PosSDK.Color24_GrayBW(path1, path2);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_SUCCESS;
+ }
+
+ ///
+ /// 是否纸尽
+ ///
+ ///
+ public bool IsPaperExhaust()
+ {
+ int ret = PosSDK.POS_Status_RTQueryTypeStatus(_printer, 4);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_PAPEROUT;
+ }
+
+ ///
+ /// 是否将纸尽
+ ///
+ ///
+ public bool IsPaperWillExhaust()
+ {
+ int ret = PosSDK.POS_Status_RTQueryTypeStatus(_printer, 4);
+ SetResult(ret);
+ return ret == PosSDK.POS_ES_PAPERENDING;
+ }
+ }
+}
\ No newline at end of file
diff --git a/AutoWeightServer/IfManager/Pos/PosSDK.cs b/AutoWeightServer/IfManager/Pos/PosSDK.cs
new file mode 100644
index 0000000..ad03f3f
--- /dev/null
+++ b/AutoWeightServer/IfManager/Pos/PosSDK.cs
@@ -0,0 +1,274 @@
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace EC.AutoWeightServer.IfManager.Pos
+{
+ public class PosSDK
+ {
+ #region Custom
+
+ public struct PosParam
+ {
+ private string lpName;
+ private string portType;
+ private bool bFile;
+ private string path;
+ }
+
+ #endregion Custom
+
+ #region Const
+
+ // pritner connect way
+ public const int POS_PT_COM = 1000;
+
+ public const int POS_PT_LPT = 1001;
+ public const int POS_PT_USB = 1002;
+ public const int POS_PT_NET = 1003;
+
+ // printer state
+ public const int POS_PS_NORMAL = 3001;
+
+ public const int POS_PS_PAPEROUT = 3002;
+ public const int POS_PS_HEAT = 3003;
+ public const int POS_PS_DOOROPEN = 3004;
+ public const int POS_PS_BUFFEROUT = 3005;
+ public const int POS_PS_CUT = 3006;
+ public const int POS_PS_DRAWERHIGH = 3007;
+
+ public const int POS_ES_PAPERENDING = 6; //纸将尽
+ public const int POS_ES_DRAWERHIGH = 5; //钱箱高电平
+ public const int POS_ES_CUT = 4; //切刀未复位
+ public const int POS_ES_DOOROPEN = 3; //纸仓门开
+ public const int POS_ES_HEAT = 2; //机头过热
+ public const int POS_ES_PAPEROUT = 1; //打印机缺纸
+ public const int POS_ES_SUCCESS = 0; //成功/发送成功/状态正常/打印完成
+ public const int POS_ES_INVALIDPARA = -1; //参数错误
+ public const int POS_ES_WRITEFAIL = -2; //写失败
+ public const int POS_ES_READFAIL = -3; //读失败
+ public const int POS_ES_NONMONOCHROMEBITMAP = -4; //非单色位图
+ public const int POS_ES_OVERTIME = -5; //超时/写超时/读超时/打印未完成
+ public const int POS_ES_FILEOPENERROR = -6; //文件/图片打开失败
+ public const int POS_ES_OTHERERRORS = -100; //其他原因导致的错误
+
+ // barcode type
+ public const int POS_BT_UPCA = 4001;
+
+ public const int POS_BT_UPCE = 4002;
+ public const int POS_BT_JAN13 = 4003;
+ public const int POS_BT_JAN8 = 4004;
+ public const int POS_BT_CODE39 = 4005;
+ public const int POS_BT_ITF = 4006;
+ public const int POS_BT_CODABAR = 4007;
+ public const int POS_BT_CODE93 = 4073;
+ public const int POS_BT_CODE128 = 4074;
+
+ // 2D barcode type
+ public const int POS_BT_PDF417 = 4100;
+
+ public const int POS_BT_DATAMATRIX = 4101;
+ public const int POS_BT_QRCODE = 4102;
+
+ // HRI type
+ public const int POS_HT_NONE = 4011;
+
+ public const int POS_HT_UP = 4012;
+ public const int POS_HT_DOWN = 4013;
+ public const int POS_HT_BOTH = 4014;
+
+ //TSPL
+ public const int TSPL_PRINTER_STATUS_OUTPAPER = 1;//打印机缺纸
+
+ public const int TSPL_PRINTER_STATUS_WORK = 2; //打印中
+ public const int TSPL_PRINTER_STATUS_ENCLOSURENOCLOSE = 3; //机壳未关
+ public const int TSPL_PRINTER_STATUS_ERROR = 4; //打印机内部错误
+
+ public const int TSPL_PARAM_LESS_EQUAL_ZERO = -2; //参数小于等于0
+ public const int TSPL_PARAM_GREAT_RANGE = -3; //参数大于指定范围
+ public const int TSPL_SUCCESS = 0;
+ public const int TSPL_IDERROR = -1;
+
+ #endregion Const
+
+ #region Method
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Port_OpenA")]
+ public static extern int POS_Port_OpenA(string lpName, int iPort, bool bFile, string path);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintstringA")]
+ public static extern int POS_Output_PrintstringA(int printID, string strBuff);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintData")]
+ public static extern int POS_Output_PrintData(int printID, byte[] strBuff, int ilen);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Port_Close")]
+ public static extern int POS_Port_Close(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_CutPaper")]
+ public static extern int POS_Control_CutPaper(int printID, int type, int len);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_CashDraw")]
+ public static extern int POS_Control_CashDraw(int printID, int iNum, int time1, int time2);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_QueryStatus")]
+ public static extern int POS_Status_QueryStatus(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_RTQueryStatus")]
+ public static extern int POS_Status_RTQueryStatus(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_RTQueryTypeStatus")]
+ public static extern int POS_Status_RTQueryTypeStatus(int printID, int n);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_DownloadBmpToFlashA")]
+ public static extern int POS_Output_DownloadBmpToFlashA(int printID, string strPath);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_DownloadBmpToFlashNumA")]
+ public static extern int POS_Control_DownloadBmpToFlashNumA(int printID, string strPath, int num);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintBmpDirectA")]
+ public static extern int POS_Output_PrintBmpDirectA(int printID, string strPath);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintFontStringA")]
+ public static extern int POS_Output_PrintFontStringA(int printID, int iFont, int iThick, int iWidth, int iHeight, int iUnderLine, string lpString);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Input_PrinterId")]
+ public static extern int POS_Input_PrinterId(int printID, StringBuilder Buff);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_BlackMark")]
+ public static extern int POS_Control_BlackMark(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetPrintPosition")]
+ public static extern int POS_Control_SetPrintPosition(int printID, int iLeft, int iWidth);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_QueryTaskStatus")]
+ public static extern int POS_Status_QueryTaskStatus(int printID, int second);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintFlashBmp")]
+ public static extern int POS_Output_PrintFlashBmp(int printID, int n);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintOneDimensionalBarcodeA")]
+ public static extern int POS_Output_PrintOneDimensionalBarcodeA(int printID, int iType, int iWidth, int iHeight, int hri, string lpstring);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintTwoDimensionalBarcodeA")]
+ public static extern int POS_Output_PrintTwoDimensionalBarcodeA(int printID, int iType, int parameter1, int parameter2, int parameter3, string lpstring);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_DownloadRamBmpA")]
+ public static extern int POS_Output_DownloadRamBmpA(int printID, string lpFilePath);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintRamBmp")]
+ public static extern int POS_Output_PrintRamBmp(int printID, int n);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_PrintTestpage")]
+ public static extern int POS_Control_PrintTestpage(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "Color24_GrayBW")]
+ public static extern int Color24_GrayBW(string szSourceFile, string szTargetFile);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetRotaryPrint")]
+ public static extern int POS_Control_SetRotaryPrint(int printID, int n);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_OppositeColor")]
+ public static extern int POS_Control_OppositeColor(int printID, bool bOppsite);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_AlignType")]
+ public static extern int POS_Control_SetRotaryPrint(int printID, bool iAlignType);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_SendLocalFileA")]
+ public static extern int POS_Output_SendLocalFileA(int printID, string lpFilePath);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_ReSet")]
+ public static extern int POS_Control_ReSet(int printID);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetPrintFontC")]
+ public static extern int POS_Control_SetPrintFontC(int printID, bool iDoubleWidth, bool iDoubleHeight, bool iUnderLine);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetInvertedPrint")]
+ public static extern int POS_Control_SetInvertedPrint(int printID, int n);
+
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_AlignType")]
+ public static extern int POS_Control_AlignType(int printID, int iAlignType);
+
+ //--------------ztongli.20170123--------------
+ //设置页宽页高
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PageSetupTSPL")]
+ public static extern int PageSetupTSPL(int printID, int PageWidth, int PageHeight);
+
+ //画线
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawLineTSPL")]
+ public static extern int DrawLineTSPL(int printID, int StartX, int StartY, int LineWidth, int LineHeight);
+
+ //TL51打印
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PrintTSPL")]
+ public static extern int PrintTSPL(int printID, int Set, int Copy);
+
+ //画矩形
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawBorderTSPL")]
+ public static extern int DrawBorderTSPL(int printID, int LineWidth, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y);
+
+ //文字
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawTextTSPL")]
+ public static extern int DrawTextTSPL(int printID, int start_x, int start_y, bool isSimplifiedChinese, int xMultiplication, int yMultiplication, int rotate, string content);
+
+ //一维条码
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawBarCodeTSPL")]
+ public static extern int DrawBarCodeTSPL(int printID, int start_x, int start_y, string type, int height, bool isReadable, int rotate, int narrowWidth, int wideWidth, string content);
+
+ ////清空缓冲区
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "ClearBuffTSPL")]
+ public static extern int ClearBuffTSPL(int printID);
+
+ //二维条码
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "Draw2DBarCodeTSPL")]
+ public static extern int Draw2DBarCodeTSPL(int printID, int start_x, int start_y, string Max, string content);
+
+ //下载位图
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DownLoadBitMapTSPL")]
+ public static extern int DownLoadBitMapTSPL(int printID, bool isMoveFlash, string PathName);
+
+ //将图片刷到缓冲区
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PutBitMapTSPL")]
+ public static extern int PutBitMapTSPL(int printID, int start_x, int start_y, string fileName);
+
+ //得到打印机状态
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "GetPrinterStatusTSPL")]
+ public static extern int GetPrinterStatusTSPL(int printID);
+
+ //控制蜂鸣器发出一声响
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DriveBeepTSPL")]
+ public static extern int DriveBeepTSPL(int printID);
+
+ //设置国际字符集
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetCharsetNameTSPL")]
+ public static extern int SetCharsetNameTSPL(int printID, string CharsetName);
+
+ //控制进纸或退纸距离
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetPaperbackOrPaperFeedTSPL")]
+ public static extern int SetPaperbackOrPaperFeedTSPL(int printID, bool isFeedBack, int mDot);
+
+ //指定的区域反相打印命令
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "ReverseAreaTSPL")]
+ public static extern int ReverseAreaTSPL(int printID, int start_x, int start_y, int width, int height);
+
+ //选择字符代码页
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SelectCodePageTSPL")]
+ public static extern int SelectCodePageTSPL(int printID, int value);
+
+ //设置标签间垂直间距
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetGAPTSPL")]
+ public static extern int SetGAPTSPL(int printID, double value);
+
+ //定义标签的参考坐标原点命令
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetLabelReferenceTSPL")]
+ public static extern int SetLabelReferenceTSPL(int printID, int x, int y);
+
+ //TL21打印
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PrintTSPL21")]
+ public static extern int PrintTSPL21(int printID, int Set);
+
+ //用于确认机型是TL21便于内部区别指令以及相关条件
+ [DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetIs21")]
+ public static extern int SetIs21();
+
+ #endregion Method
+ }
+}
\ No newline at end of file
diff --git a/AutoWeightServer/IfManager/Scales/Scales.cs b/AutoWeightServer/IfManager/Scales/Scales.cs
index 204b01f..bad7e2d 100644
--- a/AutoWeightServer/IfManager/Scales/Scales.cs
+++ b/AutoWeightServer/IfManager/Scales/Scales.cs
@@ -19,6 +19,7 @@ namespace EC.AutoWeightServer.IfManager.Scales
{
this.ComName = comName;
this.BaudRate = baudRate;
+ this.ReceivedBytesThreshold = 32;
}
public Scales(string comName, int baudRate, int receivedBytesThreshold)
diff --git a/AutoWeightServer/IfManager/Scales/ScalesHuiZhou.cs b/AutoWeightServer/IfManager/Scales/ScalesHuiZhou.cs
new file mode 100644
index 0000000..f51ad9b
--- /dev/null
+++ b/AutoWeightServer/IfManager/Scales/ScalesHuiZhou.cs
@@ -0,0 +1,45 @@
+using EC.AutoWeightServer.Model.Config;
+using EC.AutoWeightServer.Model.EventArgsEx;
+using EC.Utils;
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace EC.AutoWeightServer.IfManager.Scales
+{
+ public class ScalesHuiZhou : Scales
+ {
+ public ScalesHuiZhou(string comName, int baudRate, int receivedBytesThreshold) : base(comName, baudRate, receivedBytesThreshold)
+ {
+ }
+
+ public override event EventHandler OnRecData;
+
+ public event EventHandler OnRecTransmit = null;
+
+ public override void RecData(object sender, byte[] buf)
+ {
+ OnRecTransmit?.Invoke(sender, buf);
+
+ string tempBuf = Encoding.UTF8.GetString(buf);
+ string[] splitBufArray = tempBuf.Split('\r');
+ foreach (var item in splitBufArray)
+ {
+ if (item.Length != 16) { continue; }
+ tempBuf = item;
+ MatchCollection mc = Regex.Matches(tempBuf, @"(\d+)");
+ if (mc.Count != 3) { continue; }
+ string weightArg = mc[1].Value;
+ decimal weight = CommonUtil.WeightStrToDec(weightArg) / 1000;
+ string unit = "t";
+
+ var scaleArgs = new ScaleEventArgs(weight, unit);
+ OnRecData?.Invoke(sender, scaleArgs);
+ break;
+ }
+
+ if (ServerConfig.WTDiscardInBufferFlag > 0)
+ _port.DiscardInBuffer();
+ }
+ }
+}
\ No newline at end of file
diff --git a/AutoWeightServer/IfManager/Scales/ScalesManager.cs b/AutoWeightServer/IfManager/Scales/ScalesManager.cs
index ca171f5..046501e 100644
--- a/AutoWeightServer/IfManager/Scales/ScalesManager.cs
+++ b/AutoWeightServer/IfManager/Scales/ScalesManager.cs
@@ -1,7 +1,7 @@
-using EC.AutoWeightServer.Model.EventArgsEx;
+using EC.AutoWeightServer.Model.Config;
+using EC.AutoWeightServer.Model.EventArgsEx;
using EC.Utils.SerialPortHelper;
using System;
-using EC.AutoWeightServer.Model.Config;
namespace EC.AutoWeightServer.IfManager.Scales
{
@@ -11,7 +11,7 @@ namespace EC.AutoWeightServer.IfManager.Scales
private string _comName;
private int _baudRate;
private int _receivedBytesThreshold;
- private ECSerialPort _transmitPort;
+ private ECSerialPort _transmitPort;
public ScalesManager()
{
@@ -34,13 +34,12 @@ namespace EC.AutoWeightServer.IfManager.Scales
public bool StartServer()
{
- //Scales = new ScalesDefault(_comName, _baudRate);
- Scales = new ScalesZhuHai(_comName, _baudRate, _receivedBytesThreshold);
+ Scales = new ScalesHuiZhou(_comName, _baudRate, _receivedBytesThreshold);
Scales.OnRecData += RecData;
if (ServerConfig.WtTransmitFlag > 0)
{
_transmitPort = SerialPortManager.CreateSerialPort(ServerConfig.WtTransmitCom, _baudRate);
- ((ScalesZhuHai)Scales).OnRecTransmit += RecTransmit;
+ ((ScalesHuiZhou)Scales).OnRecTransmit += RecTransmit;
}
Scales.StartServer();
return true;
diff --git a/AutoWeightServer/IfManager/Scales/ScalesZhuHai.cs b/AutoWeightServer/IfManager/Scales/ScalesZhuHai.cs
index 525832e..9f17143 100644
--- a/AutoWeightServer/IfManager/Scales/ScalesZhuHai.cs
+++ b/AutoWeightServer/IfManager/Scales/ScalesZhuHai.cs
@@ -1,31 +1,19 @@
-using EC.AutoWeightServer.Model.EventArgsEx;
+using EC.AutoWeightServer.Model.Config;
+using EC.AutoWeightServer.Model.EventArgsEx;
using EC.Utils;
using System;
using System.Text;
-using EC.AutoWeightServer.Model.Config;
namespace EC.AutoWeightServer.IfManager.Scales
{
public class ScalesZhuHai : Scales
{
- public ScalesZhuHai()
+ public ScalesZhuHai(string comName, int baudRate, int receivedBytesThreshold) : base(comName, baudRate, receivedBytesThreshold)
{
}
- public ScalesZhuHai(string comName, int baudRate)
- {
- this.ComName = comName;
- this.BaudRate = baudRate;
- }
-
- public ScalesZhuHai(string comName, int baudRate, int receivedBytesThreshold)
- {
- this.ComName = comName;
- this.BaudRate = baudRate;
- this.ReceivedBytesThreshold = receivedBytesThreshold;
- }
-
public override event EventHandler OnRecData;
+
public event EventHandler OnRecTransmit = null;
public override void RecData(object sender, byte[] buf)
diff --git a/AutoWeightServer/Img/logo.bmp b/AutoWeightServer/Img/logo.bmp
deleted file mode 100644
index 975d6a3..0000000
Binary files a/AutoWeightServer/Img/logo.bmp and /dev/null differ
diff --git a/AutoWeightServer/Model/Config/BaseConfig.cs b/AutoWeightServer/Model/Config/BaseConfig.cs
index 6f657ee..d607afa 100644
--- a/AutoWeightServer/Model/Config/BaseConfig.cs
+++ b/AutoWeightServer/Model/Config/BaseConfig.cs
@@ -1,4 +1,5 @@
-using System.Configuration;
+using EC.Utils;
+using System.Configuration;
namespace EC.AutoWeightServer.Model.Config
{
@@ -51,7 +52,9 @@ namespace EC.AutoWeightServer.Model.Config
#region Voice.config
- private static readonly Configuration VoiceConfig = GetConfiguration("Voice.config");
+ private static readonly string VoiceConfigPath = EnvUtil.CombinePath(EnvUtil.GetWorkDirectory(), "data", "voice.config");
+
+ private static readonly Configuration VoiceConfig = GetConfiguration(VoiceConfigPath);
public static string GetVoiceConfig(string key)
{
diff --git a/AutoWeightServer/Model/Config/ServerConfig.cs b/AutoWeightServer/Model/Config/ServerConfig.cs
index e2ae57f..2c16965 100644
--- a/AutoWeightServer/Model/Config/ServerConfig.cs
+++ b/AutoWeightServer/Model/Config/ServerConfig.cs
@@ -15,7 +15,6 @@ namespace EC.AutoWeightServer.Model.Config
/// 相机
///
public static string CameraAddress1 { get; } = GetAppConfig("CAMERA_ADDRESS1");
-
public static string CameraAddress2 { get; } = GetAppConfig("CAMERA_ADDRESS2");
public static string CameraAddress3 { get; } = GetAppConfig("CAMERA_ADDRESS3");
public static string CameraAddress4 { get; } = GetAppConfig("CAMERA_ADDRESS4");
@@ -45,7 +44,7 @@ namespace EC.AutoWeightServer.Model.Config
public static string LightRelayCom { get; } = GetAppConfig("Light_Relay_COM");
public static int LightRelayBaudRate { get; } = FormatCom.ToInt(GetAppConfig("Light_Relay_BaudRate"));
- public static string LightCodeName { get; } = Path.Combine(CommonUtil.GetWorkDirectory(), "conf", GetAppConfig("Light_Code_Name"));
+ public static string LightCodeName { get; } = Path.Combine(EnvUtil.GetWorkDirectory(), "data", "light", GetAppConfig("Light_Code_Name"));
public static int LightInterval { get; } = FormatCom.ToInt(GetAppConfig("Light_Interval"));
public static int LightBlink { get; } = FormatCom.ToInt(GetAppConfig("Light_Blink"));
diff --git a/AutoWeightServer/Program.cs b/AutoWeightServer/Program.cs
index 9596ac4..9f88dab 100644
--- a/AutoWeightServer/Program.cs
+++ b/AutoWeightServer/Program.cs
@@ -1,9 +1,8 @@
using EC.AutoWeightServer.UI;
+using EC.Utils;
using EC.Utils.Storage;
using System;
using System.Data.SqlClient;
-using System.IO;
-using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
@@ -20,7 +19,8 @@ namespace EC.AutoWeightServer
[STAThread]
private static void Main()
{
- Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+ EnvUtil.InitWorkDirectory();
+ EnvUtil.AddDllPath(EnvUtil.CombinePath(EnvUtil.GetWorkDirectory(), "dll"));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
diff --git a/AutoWeightServer/Properties/Resources.resx b/AutoWeightServer/Properties/Resources.resx
index 5609ad6..cc83cdf 100644
--- a/AutoWeightServer/Properties/Resources.resx
+++ b/AutoWeightServer/Properties/Resources.resx
@@ -303,7 +303,7 @@
..\Resources\指纹.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\title.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\Resources\title.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
..\Resources\重置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/AutoWeightServer/title.ico b/AutoWeightServer/Resources/title.ico
similarity index 100%
rename from AutoWeightServer/title.ico
rename to AutoWeightServer/Resources/title.ico
diff --git a/AutoWeightServer/UI/FrmMainServer.cs b/AutoWeightServer/UI/FrmMainServer.cs
index 3aa2140..2aeee55 100644
--- a/AutoWeightServer/UI/FrmMainServer.cs
+++ b/AutoWeightServer/UI/FrmMainServer.cs
@@ -994,7 +994,7 @@ namespace EC.AutoWeightServer.UI
private void CheckPhotoSaveCycle()
{
var now = DateTime.Now;
- var workPath = CommonUtil.GetWorkDirectory();
+ var workPath = EnvUtil.GetWorkDirectory();
var capDir = new DirectoryInfo(Path.Combine(workPath, "cap"));
if (!capDir.Exists)
return;
diff --git a/AutoWeightServer/Img/Thumbs.db b/AutoWeightServer/data/image/Thumbs.db
similarity index 100%
rename from AutoWeightServer/Img/Thumbs.db
rename to AutoWeightServer/data/image/Thumbs.db
diff --git a/AutoWeightServer/data/image/logo.bmp b/AutoWeightServer/data/image/logo.bmp
new file mode 100644
index 0000000..b0300d2
Binary files /dev/null and b/AutoWeightServer/data/image/logo.bmp differ
diff --git a/AutoWeightServer/conf/lightCode.json b/AutoWeightServer/data/light/lightCode.json
similarity index 100%
rename from AutoWeightServer/conf/lightCode.json
rename to AutoWeightServer/data/light/lightCode.json
diff --git a/AutoWeightServer/conf/lightCode2.json b/AutoWeightServer/data/light/lightCode2.json
similarity index 100%
rename from AutoWeightServer/conf/lightCode2.json
rename to AutoWeightServer/data/light/lightCode2.json
diff --git a/AutoWeightServer/conf/lightCode3.json b/AutoWeightServer/data/light/lightCode3.json
similarity index 100%
rename from AutoWeightServer/conf/lightCode3.json
rename to AutoWeightServer/data/light/lightCode3.json
diff --git a/AutoWeightServer/conf/lightCodeTemplate.json b/AutoWeightServer/data/light/lightCodeTemplate.json
similarity index 100%
rename from AutoWeightServer/conf/lightCodeTemplate.json
rename to AutoWeightServer/data/light/lightCodeTemplate.json
diff --git a/AutoWeightServer/Voice.config b/AutoWeightServer/data/voice.config
similarity index 100%
rename from AutoWeightServer/Voice.config
rename to AutoWeightServer/data/voice.config
diff --git a/Debug.rar b/Debug.rar
deleted file mode 100644
index 410e617..0000000
Binary files a/Debug.rar and /dev/null differ
diff --git a/EC.Service/Transport/PhotoService.cs b/EC.Service/Transport/PhotoService.cs
index 061a7f9..816c78d 100644
--- a/EC.Service/Transport/PhotoService.cs
+++ b/EC.Service/Transport/PhotoService.cs
@@ -40,7 +40,7 @@ namespace EC.Service.Transport
public static string GetSaveImagePath(string license)
{
var now = DateTime.Now;
- var workPath = CommonUtil.GetWorkDirectory();
+ var workPath = EnvUtil.GetWorkDirectory();
var subPath = Path.Combine(new string[] { "cap", now.ToString("yyyy"), now.ToString("MM"), now.ToString("dd") });
//var subPath = Path.Combine("cap", now.ToString("yyyy-MM-dd"));
var fileFolder = Path.Combine(workPath, subPath);
diff --git a/EC.Utils/CommonUtil.cs b/EC.Utils/CommonUtil.cs
index 9405212..1eafd39 100644
--- a/EC.Utils/CommonUtil.cs
+++ b/EC.Utils/CommonUtil.cs
@@ -218,12 +218,5 @@ namespace EC.Utils
}
}
- private static string workDirectory;
-
- public static string GetWorkDirectory()
- {
- workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : workDirectory;
- return workDirectory;
- }
}
}
\ No newline at end of file
diff --git a/EC.Utils/EC.Utils.csproj b/EC.Utils/EC.Utils.csproj
index 224575b..266a44f 100644
--- a/EC.Utils/EC.Utils.csproj
+++ b/EC.Utils/EC.Utils.csproj
@@ -82,6 +82,7 @@
+
diff --git a/EC.Utils/EnvUtil.cs b/EC.Utils/EnvUtil.cs
new file mode 100644
index 0000000..bc1da8c
--- /dev/null
+++ b/EC.Utils/EnvUtil.cs
@@ -0,0 +1,50 @@
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace EC.Utils
+{
+ public class EnvUtil
+ {
+ private static string workDirectory;
+
+ public static void InitWorkDirectory()
+ {
+ Directory.SetCurrentDirectory(GetWorkDirectory());
+ }
+
+ public static string GetWorkDirectory()
+ {
+ workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : workDirectory;
+ return workDirectory;
+ }
+
+ public static bool AddDllPath(string dllPath)
+ {
+ if (!Directory.Exists(dllPath)) { return false; }
+ string envPath = Environment.GetEnvironmentVariable("PATH");
+ Environment.SetEnvironmentVariable("PATH", envPath + ";" + dllPath);
+ return true;
+ }
+
+ public static string CombinePath(string path1, string path2)
+ {
+ return Path.Combine(path1, path2);
+ }
+
+ public static string CombinePath(params string[] paths)
+ {
+ return Path.Combine(paths);
+ }
+
+ public static bool ExistFile(string file)
+ {
+ return File.Exists(file);
+ }
+
+ public static bool ExistDirectory(string dir)
+ {
+ return Directory.Exists(dir);
+ }
+ }
+}
\ No newline at end of file
diff --git a/dll.rar b/dll.rar
new file mode 100644
index 0000000..3c88f56
Binary files /dev/null and b/dll.rar differ