Commit 8f20143f by zxw

winxp充电台

parent 241fef9e
...@@ -334,6 +334,7 @@ namespace JmpServiceMgr ...@@ -334,6 +334,7 @@ namespace JmpServiceMgr
try try
{ {
new DevService().OnStart(MyCache.SysConfig.DomainUrl); new DevService().OnStart(MyCache.SysConfig.DomainUrl);
Log.WorkLog("除湿机启动成功");
} }
catch (Exception e) catch (Exception e)
{ {
......
...@@ -14,6 +14,7 @@ using System.ServiceProcess; ...@@ -14,6 +14,7 @@ using System.ServiceProcess;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JmpCommon;
namespace JmpServiceMgr.Helper namespace JmpServiceMgr.Helper
{ {
...@@ -34,7 +35,7 @@ namespace JmpServiceMgr.Helper ...@@ -34,7 +35,7 @@ namespace JmpServiceMgr.Helper
try try
{ {
//获取接口地址 //获取接口地址
//URL = Properties.Settings.Default.URL; this.URL = URL;
devCode = GetMacAddress().ToUpper(); devCode = GetMacAddress().ToUpper();
#region 开启一个线程 #region 开启一个线程
...@@ -109,6 +110,7 @@ namespace JmpServiceMgr.Helper ...@@ -109,6 +110,7 @@ namespace JmpServiceMgr.Helper
string retrundata = GetHttpRqst(serviceUrl, data); string retrundata = GetHttpRqst(serviceUrl, data);
JsonData json = JsonMapper.ToObject(retrundata); JsonData json = JsonMapper.ToObject(retrundata);
if (getKey(json, "code").Equals("10000")) if (getKey(json, "code").Equals("10000"))
{ {
if (JsonDataContainsKey(json, "msg")) if (JsonDataContainsKey(json, "msg"))
...@@ -149,7 +151,7 @@ namespace JmpServiceMgr.Helper ...@@ -149,7 +151,7 @@ namespace JmpServiceMgr.Helper
Thread.Sleep(5000); Thread.Sleep(5000);
} }
} }
private void OnStatusChanged(MachineStatus args) private void OnStatusChanged(MachineStatus args)
{ {
...@@ -167,7 +169,7 @@ namespace JmpServiceMgr.Helper ...@@ -167,7 +169,7 @@ namespace JmpServiceMgr.Helper
else else
{ {
foreach (var item in devList) foreach (var item in devList)
{ {
if (item.Key.Equals(args.ip)) if (item.Key.Equals(args.ip))
{ {
Dehumidifier dev = new Dehumidifier(args.ip, args.port); Dehumidifier dev = new Dehumidifier(args.ip, args.port);
......
...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; ...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.15.09260")] [assembly: AssemblyVersion("1.2.16.09270")]
[assembly: AssemblyFileVersion("1.2.15.09260")] [assembly: AssemblyFileVersion("1.2.16.09270")]
...@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiteChannel", "LiteChannel\ ...@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiteChannel", "LiteChannel\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightCtrl", "LightCtrl\LightCtrl.csproj", "{01C90EA0-0E78-4A2C-8D72-BE8101932585}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightCtrl", "LightCtrl\LightCtrl.csproj", "{01C90EA0-0E78-4A2C-8D72-BE8101932585}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiteChannelWinXP", "LiteChannelWinXP\LiteChannelWinXP.csproj", "{48900448-82F0-4876-9987-0AAB845027D5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -39,12 +41,16 @@ Global ...@@ -39,12 +41,16 @@ Global
{01C90EA0-0E78-4A2C-8D72-BE8101932585}.Debug|Any CPU.Build.0 = Debug|Any CPU {01C90EA0-0E78-4A2C-8D72-BE8101932585}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01C90EA0-0E78-4A2C-8D72-BE8101932585}.Release|Any CPU.ActiveCfg = Release|Any CPU {01C90EA0-0E78-4A2C-8D72-BE8101932585}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01C90EA0-0E78-4A2C-8D72-BE8101932585}.Release|Any CPU.Build.0 = Release|Any CPU {01C90EA0-0E78-4A2C-8D72-BE8101932585}.Release|Any CPU.Build.0 = Release|Any CPU
{48900448-82F0-4876-9987-0AAB845027D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48900448-82F0-4876-9987-0AAB845027D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48900448-82F0-4876-9987-0AAB845027D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48900448-82F0-4876-9987-0AAB845027D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1BB736E-801B-4BAD-8BC5-A7BA50F023D7}
VisualSVNWorkingCopyRoot = . VisualSVNWorkingCopyRoot = .
SolutionGuid = {F1BB736E-801B-4BAD-8BC5-A7BA50F023D7}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
...@@ -273,4 +273,8 @@ ...@@ -273,4 +273,8 @@
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets'))" /> <Error Condition="!Exists('..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets'))" />
</Target> </Target>
<PropertyGroup>
<PostBuildEvent>xcopy $(ProjectDir)ThirdPackages\* $(TargetDir) /S /Y
</PostBuildEvent>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
#缺省不输出日志到控制台
#FATAL、ERROR、WARN、INFO、DEBUG 优先级顺序 如果子模块和根模块都匹配,那么都会输出
log4j.rootLogger=DEBUG, default
#log4j.rootLogger=DEBUG
##hlog.async=false
##hlog.secret.show=true
##hlog.secret.encrypt=false
#log4j.logger用于控制日志采集级别及采集内容,Threshold用于控制日志输出级别
#应用于控制台
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d][%t][%-5p]- %m%n
log4j.logger.NPQ=TRACE, NPQ
log4j.appender.NPQ=org.apache.log4j.RollingFileAppender
log4j.appender.NPQ.File=./NPQLog/NPQ.log
log4j.appender.NPQ.MaxFileSize=80MB
log4j.appender.NPQ.MaxBackupIndex=12
log4j.appender.NPQ.Append=false
log4j.appender.NPQ.Threshold=TRACE
log4j.appender.NPQ.layout=org.apache.log4j.PatternLayout
log4j.appender.NPQ.layout.ConversionPattern=[%d][%t][%-5p]- %m%n
log4j.additivity.NPQ = false
#最后一位修改为true 既可以控制台输出又可以文件输出
#log4j.logger用于控制日志采集级别及采集内容,Threshold用于控制日志输出级别
#应用于控制台
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p - %m%n
#应用于文件回滚
log4j.appender.default=org.apache.log4j.RollingFileAppender
log4j.appender.default.File=./log/DefaultClient.log
log4j.appender.default.MaxBackupIndex=12
log4j.appender.default.MaxFileSize=20MB
log4j.appender.default.Append=true
log4j.appender.default.Threshol= TRACE
log4j.appender.default.layout=org.apache.log4j.PatternLayout
log4j.appender.default.layout.ConversionPattern=%d [%t] %-5p %.16c - %m%n
#设置VMS
log4j.logger.Crash=TRACE, Crash
#每天产生一个日志文件
log4j.appender.Crash=org.apache.log4j.DailyRollingFileAppender
log4j.appender.Crash.File=./log/CrashClient.log
log4j.appender.Crash.DatePattern='.'yyyy-MM-dd
log4j.appender.Crash.Append=true
log4j.appender.Crash.Threshold=TRACE
log4j.appender.Crash.layout=org.apache.log4j.PatternLayout
log4j.appender.Crash.layout.ConversionPattern=%d [%t] %-5p %.16c - %m%n
##hlog.async=false
##hlog.secret.show=false
##hlog.secret.encrypt=true
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Commons
{
public class Analyzingepc
{
public byte Header; // 标头(8bits): JY物资专用标头 0x11(00010001b)
public byte IssuerId; // 发行机构标识符(6bits):GA组织机构: 0x01(000001b) 国家组织机构:0x02(000010b)
public string OrganizationCode; // 组织机构代码(54bits):JY物资生产厂商使用GA或国家组织机构代码, 英文字母及数字的每一个字符转换为六位二进制
public byte WzdmLen; // 物资代码长度(4bits): 指定物资代码的长度(N*8bits), 此处为0x7
public UInt64 Wzdm; // 物资代码(56bits): 使用警用物资编目数据的物资代码,按十进制转换成十六进制存储
public UInt64 Hxdm;
public byte SerialLen; // 序列号长度(4bits): 指定序列号长度(N*8bits), 此处为0xD
public byte Ver; // 版本号(8bits): 0x01
public byte TagType; // 标签类型(8bits): 0x00 件标 0x01 箱标
public byte PackingType; // 包装类型(4bits): 0x1 单品, 0x2 外包装, 0x3 内包装, 0xF 零头配箱
public UInt32 ProductionDate; // 生产日期(24bits): 0x161201
public byte ExpiryDate; // 有效期值(6bits): 0-63
public byte ExpiryDateUnit; // 有效期时间单位(2bits): 1:01b-日, 2:10b-月, 3:11b-年
public byte SubPackageNum; // 下级包装内数量(8bits):最大255
public UInt16 WzCount; // 包装数量(12bits): MAX:4095, 每箱内产品总数
public UInt32 BoxNo; // 包装箱序列号(20bits): MAX:65535
public UInt16 NoInBox; // 箱内序列号(12bits): 每箱内产品序号, MAX4095
}
public static class EpcConvert
{
private readonly static string strKeyWords = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 无源标签6位字段对应表
/// <summary>
/// 此方法用于将普通字符串转换成16进制的字符串。
/// </summary>
/// <param name="_str">要转换的字符串。</param>
/// <returns></returns>
public static string StringToHex16String(string _str)
{
//将字符串转换成字节数组。
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(_str);
//定义一个string类型的变量,用于存储转换后的值。
string result = string.Empty;
for (int i = 0; i < buffer.Length; i++)
{
//将每一个字节数组转换成16进制的字符串,以空格相隔开。
result += Convert.ToString(buffer[i], 16) + " ";
}
return result;
}
/// <summary>
/// 此方法用于将16进制的字节数组转换成16进制的字符串。
/// </summary>
/// <param name="_hex16Byte">要转换的16进制的字节数组。</param>
/// <returns></returns>
public static string Hex16ByteToHex16String(byte[] _hex16Byte)
{
string result = string.Empty;
//如果字节数组不为空。
if (_hex16Byte != null)
{
for (int i = 0; i < _hex16Byte.Length; i++)
{
//将每一个字节数组转换成16进制string类型的字符串,用空格分隔开。
result += _hex16Byte[i].ToString("X2") + " ";
}
}
return result;
}
public static byte[] ToHexByte(string hexString)
{
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
{
hexString = hexString + " ";
}
byte[] buffer = new byte[hexString.Length / 2];
for (int i = 0; i < buffer.Length; i++)
{
buffer[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 0x10);
}
return buffer;
}
/// <summary>
/// 生成EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public static byte[] EpcGen(Analyzingepc epc)
{
byte[] buf = new byte[40];
int pos = 0;
SetData(ref buf, pos, 8, epc.Header);
pos += 8;
SetData(ref buf, pos, 6, epc.IssuerId);
pos += 6;
SetData(ref buf, pos, 54, OrganizationCodeTo6Bin(epc.OrganizationCode.ToUpper()));
pos += 54;
SetData(ref buf, pos, 4, epc.WzdmLen);
pos += 4;
var wzlen = ((epc.WzdmLen - 1) % 8) * 8;
SetData(ref buf, pos, wzlen, epc.Wzdm); // 物资代码暂时定义最长为64bits
pos += wzlen;
SetData(ref buf, pos, 8, epc.Hxdm); // 物资代码暂时定义最长为64bits
pos += 8;
SetData(ref buf, pos, 4, epc.SerialLen);
pos += 4;
SetData(ref buf, pos, 8, epc.Ver);
pos += 8;
SetData(ref buf, pos, 8, epc.TagType);
pos += 8;
SetData(ref buf, pos, 4, epc.PackingType);
pos += 4;
SetData(ref buf, pos, 24, epc.ProductionDate);
pos += 24;
SetData(ref buf, pos, 6, epc.ExpiryDate);
pos += 6;
SetData(ref buf, pos, 2, epc.ExpiryDateUnit);
pos += 2;
SetData(ref buf, pos, 8, epc.SubPackageNum);
pos += 8;
SetData(ref buf, pos, 12, epc.WzCount);
pos += 12;
SetData(ref buf, pos, 20, epc.BoxNo);
pos += 20;
SetData(ref buf, pos, 12, epc.NoInBox);
pos += 12;
// 双字节对齐, 剩余保留区
if (pos % 16 != 0)
{
pos += 16 - pos % 16;
}
// 数据体长度
var len = pos / 8;
var crc = Crc16(buf, len);
SetData(ref buf, pos, 16, crc);
byte[] rtn = new byte[len + 2];
Array.Copy(buf, rtn, len + 2);
return rtn;
}
/// <summary>
/// 解析EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public static Analyzingepc EpcAnlysing(byte[] epc)
{
// CRC 校验
var crc_chk = Crc16(epc, epc.Length - 2);
var crc_src = epc[epc.Length - 2] << 8 | epc[epc.Length - 1];
if (crc_src != crc_chk)
{
throw new Exception("CRC校验失败");
}
// 数据解析
Analyzingepc rtn = new Analyzingepc();
int pos = 0;
rtn.Header = (byte)GetData(epc, pos, 8);
pos += 8;
rtn.IssuerId = (byte)GetData(epc, pos, 6);
pos += 6;
var oc = GetData(epc, pos, 54);
rtn.OrganizationCode = OrganizationCodeToStr(oc);
pos += 54;
rtn.WzdmLen = (byte)(GetData(epc, pos, 4));
pos += 4;
var wzlen = ((rtn.WzdmLen - 1) % 8) * 8;
rtn.Wzdm = GetData(epc, pos, wzlen);
pos += wzlen;
rtn.Hxdm = GetData(epc, pos, 8);
pos += 8;
rtn.SerialLen = (byte)GetData(epc, pos, 4);
pos += 4;
rtn.Ver = (byte)GetData(epc, pos, 8);
pos += 8;
rtn.TagType = (byte)GetData(epc, pos, 8);
pos += 8;
rtn.PackingType = (byte)GetData(epc, pos, 4);
pos += 4;
rtn.ProductionDate = (UInt32)GetData(epc, pos, 24);
pos += 24;
rtn.ExpiryDate = (byte)GetData(epc, pos, 6);
pos += 6;
rtn.ExpiryDateUnit = (byte)GetData(epc, pos, 2);
pos += 2;
rtn.SubPackageNum = (byte)GetData(epc, pos, 8);
pos += 8;
rtn.WzCount = (UInt16)GetData(epc, pos, 12);
pos += 12;
rtn.BoxNo = (UInt32)GetData(epc, pos, 20);
pos += 20;
rtn.NoInBox = (UInt16)GetData(epc, pos, 12);
pos += 12;
return rtn;
}
/// <summary>
/// 向目标数组指定位置插入数据
/// </summary>
/// <param name="data">待操作数组</param>
/// <param name="pos">起始位置</param>
/// <param name="len">写入长度bits</param>
/// <param name="value">写入的值</param>
private static void SetData(ref byte[] data, int pos, int len, UInt64 value)
{
int p = pos;
while (--len >= 0)
{
var bitPos = 7 - p % 8;
data[p++ / 8] |= (byte)(((value >> len) & 1) << bitPos);
}
}
/// <summary>
/// 从目标数组获取成员变量
/// </summary>
/// <param name="data"></param>
/// <param name="pos"></param>
/// <param name="len"></param>
/// <returns></returns>
private static UInt64 GetData(byte[] data, int pos, int len)
{
UInt64 rtn = 0;
int p = pos;
while (len-- > 0)
{
var bitPos = 7 - p % 8;
rtn <<= 1;
rtn |= (byte)((data[p++ / 8] >> bitPos) & 1);
}
return rtn;
}
/// <summary>
/// 转换成字符串
/// </summary>
/// <param name="icode"></param>
/// <returns></returns>
private static string OrganizationCodeToStr(UInt64 icode)
{
string code = "";
for (int i = 0; i < 9; i++)
{
var v = (byte)((icode >> (i * 6)) & 0x3f);
code = strKeyWords[v] + code;
}
return code;
}
/// <summary>
/// 生成十六进制组织代码, 6Bin
/// </summary>
/// <param name="code"></param>
/// <returns>0 失败, 其它:正常的组织代码编号</returns>
private static UInt64 OrganizationCodeTo6Bin(string code)
{
UInt64 iCode = 0;
if (code.Length == 9)
{
for (int i = 0; i < code.Length; i++)
{
var index = strKeyWords.IndexOf(code[i]);
if (index == -1)
{
throw new Exception("输入字符非法!");
}
iCode <<= 6;
iCode |= (byte)index;
}
}
else
{
throw new Exception("输入长度非法!");
}
return iCode;
}
/// <summary>
/// CRC运算
/// </summary>
/// <param name="data"></param>
/// <param name="len">必须是偶数</param>
/// <returns></returns>
public static UInt16 Crc16(byte[] data, int lenth)
{
ushort crc = 0x8791;
for (int i = 0; i < lenth; ++i)
{
ushort temp = 0;
ushort a = (ushort)(((crc >> 8) ^ (0xff & data[i])) << 8);
for (int j = 0; j < 8; ++j)
{
if (((temp ^ a) & 0x8000) != 0)
{
temp = (ushort)((temp << 1) ^ 0x1021);
}
else
{
temp <<= 1;
}
a <<= 1;
}
crc = (ushort)((crc << 8) ^ temp);
}
return crc;
}
}
}
using LiteChannelWinXP.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace LiteChannelWinXP.Commons
{
/// <summary>
/// 接口调用类
/// </summary>
public class HttpHelper
{
public static string HttpPost(string strUrl, string json = "")
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
request.Method = "POST";
if (!string.IsNullOrEmpty(json))
{
request.ContentType = "application/json";
byte[] data = Encoding.UTF8.GetBytes(json);
request.ContentLength = data.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
}
else { request.ContentLength = 0; }
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
string retString = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
response.Close();
return retString;
}
catch (Exception ex)
{
Log.ErrorLog(ex.Message.ToString() + "\r\n" + strUrl);
return string.Empty;
}
}
public static string HttpGet(string strUrl)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
string retString = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
response.Close();
return retString;
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n" + strUrl);
return string.Empty;
}
}
/// <summary>
/// 获取软件更新
/// </summary>
/// <param name="appCode"></param>
/// <returns></returns>
public static soft_update GetUpdate(string appCode)
{
try
{
var parame = JsonConvert.SerializeObject(new
{
appCode = appCode
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.SoftUpdate, parame);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("获取更新信息失败", "更新失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<soft_update>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("获取更新信息失败", "更新失败");
return default;
}
else
{
Log.WorkLog("获取更新信息成功", "更新成功");
return res_data.data;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取物资信息
/// </summary>
/// <returns></returns>
public static List<equ_info> GetEquInfos()
{
try
{
var body_par = string.Empty;
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new List<equ_info>();
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetEquInfo, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("获取获取装备基础信息失败", "获取失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<equ_info>>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("获取获取装备基础信息失败", "获取失败");
return default;
}
else
{
Log.WorkLog("获取获取装备基础信息成功", "获取成功");
return res_data.data;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取仓库信息
/// </summary>
/// <returns></returns>
public static List<store_info> GetStoreInfos(string orgId)
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
orgizationId = orgId
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new List<store_info>();
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetStoreInfo, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("获取获取仓库基础信息失败", "获取失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<store_info>>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("获取获取仓库基础信息失败", "获取失败");
return default;
}
else
{
Log.WorkLog("获取获取仓库基础信息成功", "获取成功");
return res_data.data;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取单据信息
/// </summary>
/// <returns></returns>
public static PagedList<order_info> GetOrderInfos(int page = 1, int size = 10, string orderType = "")
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
page = page - 1,
size = size,
orderType = orderType,
warehouseId = LiteCaChe.SysConfig.WarehouseID
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new PagedList<order_info>();
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetOrderInfo, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("获取获取单据信息失败", "获取失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("获取获取单据信息失败", "获取失败");
return default;
}
else
{
Log.WorkLog("获取获取单据信息成功", "获取成功");
JObject obj = JObject.Parse(json);
var orders = JsonConvert.DeserializeObject<PagedList<order_info>>(obj["data"].ToString());
return orders;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取单据信息
/// </summary>
/// <returns></returns>
public static List<order_detail> GetOrderDetails(string orderid, string type)
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
id = orderid,
warehouseId = LiteCaChe.SysConfig.WarehouseID,
type = type
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new List<order_detail>();
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetOrderDetail, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("获取获取单据明细信息失败", "获取失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<order_detail>>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("获取获取单据明细信息失败", "获取失败");
return default;
}
else
{
Log.WorkLog("获取获取单据明细信息成功", "获取成功");
return res_data.data;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="userName"></param>
/// <param name="userPwd"></param>
/// <returns></returns>
public static respone_user UserLogin(string userName, string userPwd)
{
try
{
var param = JsonConvert.SerializeObject(new { username = userName, password = userPwd });
var json = HttpPost(LiteCaChe.SysConfig.UserLogin, param);
if (string.IsNullOrEmpty(json))
{
return null;
}
else
{
var res_data = JObject.Parse(json);
var jobj = JObject.Parse(json);
if (!jobj.HasValues)
{
return null;
}
else
{
var user = JsonConvert.DeserializeObject<respone_user>(json);
return user;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n", MethodBase.GetCurrentMethod().Name);
return default;
}
}
/// <summary>
/// 获取平台警员信息
/// </summary>
/// <returns></returns>
public static List<sync_police> GetPoliceInfo()
{
try
{
if (string.IsNullOrEmpty(LiteCaChe.OrgId ?? ""))
{
Log.WorkLog($"平台人员同步信息获取失败,组织机构为空");
return default;
}
else
{
var body_par = JsonConvert.SerializeObject(new { orgId = LiteCaChe.OrgId });
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new List<sync_police>();
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetPolices, param);
if (string.IsNullOrEmpty(json))
{
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<sync_police>>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"平台人员同步信息获取失败,{json}");
return default;
}
else
{
return res_data.data;
}
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n");
return default;
}
}
/// <summary>
/// 获取警员图片
/// </summary>
/// <returns></returns>
public static byte[] GetPoliceImg(string url)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(LiteCaChe.SysConfig.DomainUrl + url);
request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream st = response.GetResponseStream())
{
using (MemoryStream ms = new MemoryStream())
{
st.CopyTo(ms);
var buffer = ms.GetBuffer();
st.Close();
ms.Close();
response.Close();
return buffer;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 上传人脸照片
/// </summary>
/// <param name="buffer"></param>
/// <param name="fileName"></param>
/// <param name="directoy"></param>
/// <returns></returns>
public static bool UploadFace(byte[] buffer, string fileName, string id)
{
try
{
if (buffer == null || buffer.Length == 0)
{
return false;
}
else if (string.IsNullOrEmpty(id))
{
return false;
}
else
{
var _url = LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.UploadFace;
using (HttpClient client = new HttpClient())
{
var postContent = new MultipartFormDataContent();
string boundary = string.Format("--{0}", DateTime.Now.Ticks.ToString("x"));
postContent.Headers.Add("ContentType", $"multipart/form-data, boundary={boundary}");
postContent.Add(new ByteArrayContent(buffer), "picture", fileName);
postContent.Add(new StringContent(id), "id");
using (HttpResponseMessage response = client.PostAsync(_url, postContent).Result)
{
var str = response.Content.ReadAsStringAsync().Result;
var res = JsonConvert.DeserializeObject<respone_upload>(str);
if (res.code == 10000)
{
Log.WorkLog("人脸图片上传成功", "图片上传");
return true;
}
else
{
Log.WorkLog(res.msg);
return false;
}
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
/// <summary>
/// 更新指纹信息
/// </summary>
/// <param name="fingerList"></param>
/// <param name="policeId"></param>
/// <returns></returns>
public static bool UpdateFinger(string policeId, List<FingerInfo> fingerList)
{
try
{
if (fingerList == null || fingerList.Count == 0)
{
return false;
}
else if (string.IsNullOrEmpty(policeId))
{
return false;
}
else
{
var body_par = JsonConvert.SerializeObject(new
{
policeId = policeId,
fingerList = fingerList
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return false;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.UpdateFinger, param);
if (string.IsNullOrEmpty(json))
{
return false;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"指纹数据更新失败,JSON\r\n {json} ");
return false;
}
else
{
return true;
}
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
/// <summary>
/// 提交入库
/// </summary>
/// <param name="type"></param>
/// <param name="eps"></param>
/// <returns></returns>
public static Tuple<bool, string> RfidInStore(string type, List<rfid_info> eps)
{
try
{
var body_par = JsonConvert.SerializeObject(new upload_info
{
orgId = LiteCaChe.OrgId,
currentState = "1",
picUrl = string.Empty,
policeId = LiteCaChe.PoliceId,
RFIDList = eps,
warehouseId = LiteCaChe.SysConfig.WarehouseID
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new Tuple<bool, string>(false, "签名值生成失败");
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.UploadUrl, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("装备入库失败", "入库失败");
return new Tuple<bool, string>(false, "装备入库失败");
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<rfid_res>>>(json);
if (res_data == null || res_data.code != 10000
|| res_data.data == null || res_data.data.Count == 0)
{
Log.WorkLog($"装备入库失败,{json}", "入库失败");
if (res_data != null && res_data.code != 10000)
{
return new Tuple<bool, string>(false, "装备入库失败:" + res_data.msg);
}
else
{
return new Tuple<bool, string>(false, "装备入库失败");
}
}
else
{
var successCount = res_data.data.Count(x => x.currentState == 0);
var failCount = eps.Count - successCount;
var failEpcList = eps.Where(x =>
res_data.data.Where(y => y.currentState == 0).Count(y => y.epc == x.RFID) == 0)
.Select(x => x.RFID);
Log.WorkLog(
$"装备入库成功{successCount}条,失败{failCount}条:{JsonConvert.SerializeObject(failEpcList)}",
"入库成功");
//智能货架推送
if (LiteCaChe.SysConfig.IsEnabledShelf && successCount > 0)
{
var epcListRes = GetInvListByEpc(res_data.data.Where(x => x.currentState == 0).Select(x => x.epc).ToList());
if (epcListRes.Item1)
{
//直接推送
var shelfRes = HttpPost(LiteCaChe.SysConfig.ShelfAddress, epcListRes.Item2);
if (string.IsNullOrEmpty(shelfRes))
{
Log.WorkLog("智能货架推送响应失败", "智能货架推送失败");
return new Tuple<bool, string>(true, $"装备入库成功{successCount}条,失败{failCount}条,智能货架推送响应失败");
}
else
{
var shelfRes_data = JsonConvert.DeserializeObject<respone>(shelfRes);
if (shelfRes_data == null || shelfRes_data.code != 1000)
{
Log.WorkLog($"智能货架推送响应失败,{shelfRes_data}", "智能货架推送失败");
return new Tuple<bool, string>(true, $"装备入库成功{successCount}条,失败{failCount}条,智能货架推送响应失败");
}
else
{
return new Tuple<bool, string>(true, $"装备入库成功{successCount}条,失败{failCount}条,智能货架推送成功");
}
}
}
else
{
Log.WorkLog($"获取物资信息失败", "智能货架推送失败");
return new Tuple<bool, string>(true, $"装备入库成功{successCount}条,失败{failCount}条,,获取物资信息失败");
}
}
return new Tuple<bool, string>(true, $"装备入库成功{successCount}条,失败{failCount}条");
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 提交出库
/// </summary>
/// <param name="order"></param>
/// <param name="eps"></param>
/// <returns></returns>
public static Tuple<bool, string> RfidOutStore(string order, string type, List<rfid_info> eps)
{
try
{
var body_par = JsonConvert.SerializeObject(new upload_info
{
orgId = LiteCaChe.OrgId,
currentState = "0",
picUrl = string.Empty,
policeId = LiteCaChe.PoliceId,
RFIDList = eps,
warehouseId = LiteCaChe.SysConfig.WarehouseID
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new Tuple<bool, string>(false, "签名值生成失败");
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.UploadUrl, param);
//Log.DebugLog("jsonres" + json);
//Log.DebugLog("jsonreq" + param);
//Log.DebugLog("url" + LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.UploadUrl);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("装备出库失败", "出库失败");
return new Tuple<bool, string>(false, "装备出库失败");
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<rfid_res>>>(json);
if (res_data == null || res_data.code != 10000
|| res_data.data == null || res_data.data.Count == 0)
{
Log.WorkLog($"装备出库失败,{json}", "出库失败");
if (res_data != null && res_data.code != 10000)
{
return new Tuple<bool, string>(false, "装备出库失败:" + res_data.msg);
}
else
{
return new Tuple<bool, string>(false, "装备出库失败");
}
}
else
{
var successCount = res_data.data.Count(x => new[] { 1, 2, 8, 14, 15, 17 }.Contains(x.currentState));
var failCount = eps.Count - successCount;
var failEpcList = eps.Where(x =>
res_data.data.Where(y => new[] { 1, 2, 8, 14, 15, 17 }.Contains(y.currentState)).Count(y => y.epc == x.RFID) == 0)
.Select(x => x.RFID);
var message = $"装备出库成功{successCount}条,失败{failCount}条";
var safeWarringList = res_data.data.Where(x => x.safeLevel == 1).ToList();
var safeDangerList = res_data.data.Where(x => x.safeLevel == 2).ToList();
if (safeDangerList.Count > 0)
{
message += $"\r\n警告:存在已过期装备{safeDangerList.Count}件。装备名:{string.Join(",", safeDangerList.Select(x => x.name).Distinct())},请立即联系仓管员处理";
}
if (safeWarringList.Count > 0)
{
message += $"\r\n提醒:存在即将过期装备{safeWarringList.Count}件。装备名:{string.Join(",", safeWarringList.Select(x => x.name).Distinct())}";
}
Log.WorkLog($"{message}:{JsonConvert.SerializeObject(failEpcList)}", "出库成功");
return new Tuple<bool, string>(true, message);
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取箱标内epc信息
/// </summary>
/// <param name="appCode"></param>
/// <returns></returns>
public static List<response_BoxMarkModel> GetEpcListByBoxMarkEpc(List<string> boxMarkEpcList)
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
epcList = boxMarkEpcList.Select(x => new
{
epc = x
})
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return default;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetEpcListByBoxMarkEpc, param);
if (string.IsNullOrEmpty(json))
{
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<response_BoxMarkModel>>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"箱标获取失败,JSON\r\n {json} ");
return default;
}
else
{
return res_data.data;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 获取仓库信息(锁库情况)
/// </summary>
/// <returns></returns>
public static BaseJpWarehouse GetWarehouseState()
{
try
{
if (string.IsNullOrEmpty(LiteCaChe.SysConfig.WarehouseID ?? ""))
{
Log.WorkLog($"仓库信息获取失败,仓库id为空");
return default;
}
var body_par = JsonConvert.SerializeObject(new { id = LiteCaChe.SysConfig.WarehouseID });
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return default;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetWarehouseById, param);
if (string.IsNullOrEmpty(json))
{
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<BaseJpWarehouse>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"仓库信息获取失败,{json}");
return default;
}
else
{
return res_data.data;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n");
return default;
}
}
/// <summary>
/// 设置仓库锁库状态
/// </summary>
/// <param name="isLocked">0:解除锁库,1:锁库</param>
/// <returns></returns>
public static bool SetWarehouseState(int isLocked)
{
try
{
if (string.IsNullOrEmpty(LiteCaChe.SysConfig.WarehouseID ?? ""))
{
Log.WorkLog($"设置仓库锁库状态,仓库id为空");
return default;
}
var body_par = JsonConvert.SerializeObject(new
{
warehouseId = LiteCaChe.SysConfig.WarehouseID,
isLocked = isLocked
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return default;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.SetWarehouseState, param);
if (string.IsNullOrEmpty(json))
{
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"设置仓库锁库状态,{json}");
return default;
}
else
{
return true;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n");
return default;
}
}
/// <summary>
/// 根据EPC集合获取物资信息
/// </summary>
/// <param name="type"></param>
/// <param name="eps"></param>
/// <returns></returns>
public static Tuple<bool, string> GetInvListByEpc(List<string> eps)
{
try
{
var data = new
{
EPCList = new List<dynamic>()
};
foreach (var epc in eps)
{
data.EPCList.Add(new { epc = epc });
}
var body_par = JsonConvert.SerializeObject(data);
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return new Tuple<bool, string>(false, "签名值生成失败");
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.GetInvListByEpc, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("根据EPC集合获取物资信息失败", "入库失败");
return new Tuple<bool, string>(false, "根据EPC集合获取物资信息失败");
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<List<dynamic>>>(json);
if (res_data == null || res_data.code != 10000
|| res_data.data == null || res_data.data.Count == 0)
{
Log.WorkLog($"根据EPC集合获取物资信息失败,{json}", "入库失败");
return new Tuple<bool, string>(false, "根据EPC集合获取物资信息失败");
}
else
{
//返回json
return new Tuple<bool, string>(true, json);
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 开启单据(出库用)
/// </summary>
/// <param name="order"></param>
/// <param name="eps"></param>
/// <returns></returns>
public static bool OpenOrderWork(order_info order)
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
id = order.id,
type = order.orderType,
warehouseId = LiteCaChe.SysConfig.WarehouseID
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return false;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.OpenOrderWorkUrl, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("开启单据失败,请重试", "开启单据失败");
return false;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"$开启单据失败:{res_data?.msg},请重试", "开启单据失败");
return false;
}
else
{
//Log.WorkLog($"开启单据成功,{json}", "开启单据成功");
return true;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 关闭单据(借用 调拨使用)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static bool CloseOrder(string id, string type)
{
try
{
var body_par = JsonConvert.SerializeObject(new
{
id = id,
organizationId = LiteCaChe.OrgId,
userId = LiteCaChe.UserId,
type = type,
});
var body_result = GetBody(body_par);
if (body_result == null)
{
Log.WorkLog("签名值生成失败。");
return false;
}
else
{
var param = JsonConvert.SerializeObject(new request_sign
{
appKey = LiteCaChe.SysConfig.AppKey,
body = body_result.Item1,
sign = body_result.Item2,
timestamp = body_result.Item3,
version = LiteCaChe.SysConfig.ApiVersion,
orgId = LiteCaChe.OrgId,
});
var json = HttpPost(LiteCaChe.SysConfig.DomainUrl + LiteCaChe.SysConfig.CloseOrderUrl, param);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("关闭单据失败,请重试", "关闭单据失败");
return false;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog($"$关闭单据失败:{res_data?.msg},请重试", "关闭单据失败");
return false;
}
else
{
//Log.WorkLog($"开启单据成功,{json}", "开启单据成功");
return true;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// http下载文件
/// </summary>
/// <param name="url">下载文件地址</param>
/// <param name="path">文件存放地址,包含文件名</param>
/// <returns></returns>
public static bool HttpDownload(string url, string path)
{
string tempPath = System.IO.Path.GetDirectoryName(path) + @"\temp";
System.IO.Directory.CreateDirectory(tempPath); //创建临时文件目录
string tempFile = tempPath + @"\" + System.IO.Path.GetFileName(path) + ".temp"; //临时文件
if (System.IO.File.Exists(tempFile))
{
System.IO.File.Delete(tempFile); //存在则删除
}
try
{
FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
// 设置参数
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
//创建本地文件写入流
//Stream stream = new FileStream(tempFile, FileMode.Create);
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
while (size > 0)
{
//stream.Write(bArr, 0, size);
fs.Write(bArr, 0, size);
size = responseStream.Read(bArr, 0, (int)bArr.Length);
}
//stream.Close();
fs.Close();
responseStream.Close();
System.IO.File.Move(tempFile, path);
return true;
}
catch (Exception ex)
{
return false;
}
}
/// <summary>
/// 获取文件的MD5码
/// </summary>
/// <param name="fileName">传入的文件名(含路径及后缀名)</param>
/// <returns></returns>
public static string GetMD5HashFromFile(string fileName)
{
try
{
FileStream file = new FileStream(fileName, System.IO.FileMode.Open);
MD5 md5 = new MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch (Exception ex)
{
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
}
}
private static Tuple<string, string, string> GetBody(string json)
{
try
{
var timespan = GetTimeStamp();
var body = HttpUtility.UrlEncode(json);
var content = $"{LiteCaChe.SysConfig.SecretKey}{timespan}{LiteCaChe.SysConfig.ApiVersion}{body}";
var sign = GetMd5(content);
return new Tuple<string, string, string>(body, sign, timespan);
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return null;
}
}
private static string GetMd5(string txt)
{
//初始化MD5对象
using (MD5 md5 = MD5.Create())
{
//将源字符串转化为byte数组
byte[] soucebyte = Encoding.UTF8.GetBytes(txt);
//soucebyte转化为mf5的byte数组
byte[] md5bytes = md5.ComputeHash(soucebyte);
//将md5的byte数组再转化为MD5数组
StringBuilder sb = new StringBuilder();
foreach (byte b in md5bytes)
{
//x表示16进制,2表示2位
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
}
private static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds).ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Commons
{
public class JmpDes
{
/// <summary> 加密字符串
/// </summary>
/// <param name="strText">需被加密的字符串</param>
/// <param name="strEncrKey">密钥</param>
/// <returns></returns>
public static string Encrypt(string strText, string strKey = "jMp838668")
{
try
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byKey = Encoding.UTF8.GetBytes(strKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch
{
return "";
}
}
/// <summary> 解密字符串
/// </summary>
/// <param name="strText">需被解密的字符串</param>
/// <param name="sDecrKey">密钥</param>
/// <returns></returns>
public static string Decrypt(string strText, string strKey = "jMp838668")
{
try
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byte[] inputByteArray = new Byte[strText.Length];
byKey = Encoding.UTF8.GetBytes(strKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
return encoding.GetString(ms.ToArray());
}
catch
{
return string.Empty;
}
}
}
}
using LiteChannelWinXP.Commons;
using LiteChannelWinXP.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
namespace LiteChannelWinXP
{
public static class LiteCaChe
{
public static List<sync_police> PoliceList { get; set; }
public static List<store_info> warehouseList { get; set; }
public static string OrgId { get; set; }
public static string PoliceId { get; set; }
public static string UserId { get; set; }
public static List<equ_info> EquInfos { get; set; }
public static Config SysConfig { get; set; }
public static Config LoadSystemStep()
{
var v_path = AppDomain.CurrentDomain.BaseDirectory + "config.json";
if (!File.Exists(v_path))
{
return null;
}
else
{
var v_json = File.ReadAllText(v_path, Encoding.Default);
var des_str = JmpDes.Decrypt(v_json);
if (string.IsNullOrEmpty(des_str))
{
return null;
}
else
{
var config = JsonConvert.DeserializeObject<Config>(des_str);
return config;
}
}
}
public static bool SaveSystemStep(Config config)
{
try
{
if (config == null) { return false; }
else
{
var json = JsonConvert.SerializeObject(config, Formatting.Indented);
if (string.IsNullOrEmpty(json))
{
return false;
}
else
{
System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "config.json", JmpDes.Encrypt(json), Encoding.UTF8);
return true;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString(), MethodBase.GetCurrentMethod().Name);
return false;
}
}
}
public class Config
{
public Config()
{
AppTitle = "充电台入库-WinXP v" + FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;
AppVersion = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;
AppCode = "10066";
DomainUrl = "http://41.190.20.132:18761/api/service";
UserLogin = "http://41.190.20.132:10004/auth/userLogin";
SoftUpdate = "/api/SoftUpdate/GetLastUpdate";
GetEquInfo = "/api/EquipmentDetail/GetListEquipmentDetail";
GetStoreInfo = "/api/Warehouse/GetListWarehouse";
GetOrderInfo = "/api/Inventory/GetOrderInfo";
GetOrderDetail = "/api/Inventory/GetOrderDetail";
ComMouth = "COM4";
WarehouseID = "d8192b23-0ec9-4b2e-a47d-f6780a66a880";
UploadUrl = "/api/Inventory/UploadRFIDNew";
OpenOrderWorkUrl = "/api/Inventory/OpenThisOrderAndCloseOther";
CloseOrderUrl = "/api/Inventory/CloseOrder";
ApiVersion = "1.0";
AppKey = "q6t0lEKOmMg5Tm+dg3XdZQ==";
SecretKey = "ba4d855b3b83eab441a51ea9bd9d9671";
GetPolices = "/api/ChannelCfg/GetOrgStaff";
FaceAddress = "192.168.8.35";
FaceUser = "admin";
FacePwd = "junmp123";
FacePort = "8000";
UploadFace = "/api/ChannelCfg/UploadFace";
UpdateFinger = "/api/ChannelCfg/UpdateFinger";
IsUseFace = true;
IsEnabledShelf = false;
ShelfAddress = "http://192.168.3.128:38080/api/BoundDocuments";
GetInvListByEpc = "/api/Inventory/GetInvListByEpc";
IsAutoUpdate = true;
AutoUpdateTime = 0;
GetWarehouseById = "/api/Warehouse/GetWarehouseById";
SetWarehouseState = "/api/Inventory/SetWarehouseState";
GetEpcListByBoxMarkEpc = "/api/EquipmentBoxMark/GetEpcListByBoxMarkEpc";
}
/// <summary>
/// 接口域名
/// </summary>
public string DomainUrl { get; set; }
/// <summary>
/// 登录
/// </summary>
public string UserLogin { get; set; }
[JsonIgnore]
public string AppTitle { get; set; }
[JsonIgnore]
public string AppVersion { get; set; }
[JsonIgnore]
public string AppCode { get; set; }
public string SoftUpdate { get; set; }
public string GetEquInfo { get; set; }
public string GetStoreInfo { get; set; }
public string GetOrderInfo { get; set; }
public string GetOrderDetail { get; set; }
public string ComMouth { get; set; }
public string WarehouseID { get; set; }
public string UploadUrl { get; set; }
public string OpenOrderWorkUrl { get; set; }
public string CloseOrderUrl { get; set; }
public string ApiVersion { get; set; }
public string AppKey { get; set; }
public string SecretKey { get; set; }
public string GetPolices { get; set; }
public string FaceAddress { get; set; }
public string FaceUser { get; set; }
public string FacePwd { get; set; }
public string FacePort { get; set; }
public string UploadFace { get; set; }
public string UpdateFinger { get; set; }
public bool IsUseFace { get; set; }
public bool IsEnabledShelf { get; set; }
public string ShelfAddress { get; set; }
public string GetInvListByEpc { get; set; }
public string GetWarehouseById { get; set; }
public string SetWarehouseState { get; set; }
/// <summary>
/// 是否自动更新
/// </summary>
public bool IsAutoUpdate { get; set; }
/// <summary>
/// 自动更新时间(小时)
/// </summary>
public int AutoUpdateTime { get; set; }
[JsonIgnore]
public static new bool IsInDesignModeStatic { get; }
public string GetEpcListByBoxMarkEpc { get; set; }
}
public class respone_user
{
public string id { get; set; }
public string username { get; set; }
public bool enabled { get; set; }
public respone_org baseJpOrganization { get; set; }
public respone_policeman policeman { get; set; }
}
public class respone_org
{
public string id { get; set; }
public string name { get; set; }
public string code { get; set; }
public string findCode { get; set; }
}
public class respone_policeman
{
public string id { get; set; }
public string name { get; set; }
public string policeCode { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Commons
{
public class Log
{
//private static
private static StreamWriter sr;
private static readonly object syncWorkObj = new object();
private static readonly object syncErrorObj = new object();
private static readonly object syncDebugObj = new object();
private static bool bEnableWorkLog = true;
private static bool bEnableErrorLog = true;
private static bool bEnableDebugLog = true;
public Log()
{
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableWorkLog(bool enable)
{
bEnableWorkLog = enable;
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableErrorLog(bool enable)
{
bEnableErrorLog = enable;
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableDebugLog(bool enable)
{
bEnableDebugLog = enable;
}
/// <summary>
/// 工作日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void WorkLog(string logTxt, string ModuleName = default)
{
lock (syncWorkObj)
{
if (bEnableWorkLog)
{
WriteLine(logTxt, ModuleName, "WorkLog/");
}
}
}
/// <summary>
/// 异常日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void ErrorLog(string logTxt,string ModuleName = default)
{
lock (syncErrorObj)
{
if (bEnableErrorLog)
{
WriteLine(logTxt, ModuleName, "ErrorLog/");
}
}
}
/// <summary>
/// 异常日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void DebugLog(string logTxt, string ModuleName = null)
{
lock (syncDebugObj)
{
if (bEnableDebugLog)
{
WriteLine(logTxt, ModuleName, "WorkLog/");
}
}
}
/// <summary>
/// 写日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
/// <param name="pathName"></param>
private static void WriteLine(string logTxt, string ModuleName, string pathName)
{
try
{
string logPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pathName
+ DateTime.Now.ToString("yyyyMMdd") + ".log";
ClearFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pathName);
logTxt = string.Format(" {0}|{1}|{2}",
DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
ModuleName,
logTxt);
sr = new StreamWriter(logPath, true, Encoding.Default);
sr.WriteLine(logTxt);
sr.Close();
}
catch { }
}
/// <summary>
/// 日志清除文件
/// </summary>
/// <param name="FilePath"></param>
private static void ClearFile(string FilePath)
{
if (!Directory.Exists(FilePath))
{
Directory.CreateDirectory(FilePath);
}
String[] Files = Directory.GetFiles(FilePath);
if (Files.Length > 30)
{
for (int i = 0; i < 1; i++)
{
try
{
File.Delete(Files[i]);
}
catch
{
}
}
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{48900448-82F0-4876-9987-0AAB845027D5}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>LiteChannelWinXP</RootNamespace>
<AssemblyName>LiteChannelWinXP</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="JmpRfidLp">
<HintPath>..\Lib\JmpRfidLp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commons\EpcConvert.cs" />
<Compile Include="Commons\HttpHelper.cs" />
<Compile Include="Commons\JmpDes.cs" />
<Compile Include="Commons\Log.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Commons\LiteCaChe.cs" />
<Compile Include="Login.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Login.Designer.cs">
<DependentUpon>Login.cs</DependentUpon>
</Compile>
<Compile Include="Setting.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Setting.Designer.cs">
<DependentUpon>Setting.cs</DependentUpon>
</Compile>
<Compile Include="Models\BaseJpWarehouse.cs" />
<Compile Include="Models\equ_info.cs" />
<Compile Include="Models\order_equ.cs" />
<Compile Include="Models\order_info.cs" />
<Compile Include="Models\request_sign.cs" />
<Compile Include="Models\respone.cs" />
<Compile Include="Models\respone_upload.cs" />
<Compile Include="Models\response_BoxMarkModel.cs" />
<Compile Include="Models\rfid_res.cs" />
<Compile Include="Models\scan_info.cs" />
<Compile Include="Models\soft_update.cs" />
<Compile Include="Models\store_info.cs" />
<Compile Include="Models\sync_police.cs" />
<Compile Include="Models\upload_info.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Login.resx">
<DependentUpon>Login.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Setting.resx">
<DependentUpon>Setting.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

namespace LiteChannelWinXP
{
partial class Login
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.tb_user = new System.Windows.Forms.TextBox();
this.tb_password = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.cb_saveHistory = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(51, 39);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "账号:";
//
// tb_user
//
this.tb_user.Location = new System.Drawing.Point(98, 36);
this.tb_user.Name = "tb_user";
this.tb_user.Size = new System.Drawing.Size(100, 21);
this.tb_user.TabIndex = 1;
//
// tb_password
//
this.tb_password.Location = new System.Drawing.Point(98, 63);
this.tb_password.Name = "tb_password";
this.tb_password.PasswordChar = '*';
this.tb_password.Size = new System.Drawing.Size(100, 21);
this.tb_password.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(51, 66);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 2;
this.label2.Text = "密码:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(85, 114);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "登录";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// cb_saveHistory
//
this.cb_saveHistory.AutoSize = true;
this.cb_saveHistory.Location = new System.Drawing.Point(53, 92);
this.cb_saveHistory.Name = "cb_saveHistory";
this.cb_saveHistory.Size = new System.Drawing.Size(72, 16);
this.cb_saveHistory.TabIndex = 5;
this.cb_saveHistory.Text = "记住密码";
this.cb_saveHistory.UseVisualStyleBackColor = true;
//
// Login
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(251, 162);
this.Controls.Add(this.cb_saveHistory);
this.Controls.Add(this.button1);
this.Controls.Add(this.tb_password);
this.Controls.Add(this.label2);
this.Controls.Add(this.tb_user);
this.Controls.Add(this.label1);
this.Name = "Login";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "射频入库系统";
this.Activated += new System.EventHandler(this.Login_Activated);
this.Leave += new System.EventHandler(this.Login_Leave);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tb_user;
private System.Windows.Forms.TextBox tb_password;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox cb_saveHistory;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using LiteChannelWinXP.Commons;
namespace LiteChannelWinXP
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
ReadHistory();
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(tb_user.Text))
{
MessageBox.Show("用户名未填写");
return;
}
if (string.IsNullOrEmpty(tb_password.Text))
{
MessageBox.Show("密码未填写");
return;
}
button1.Text = "登录中";
button1.Enabled = false;
Task.Factory.StartNew(() =>
{
var result = HttpHelper.UserLogin(tb_user.Text, tb_password.Text);
this.Invoke(new Action(() =>
{
button1.Text = "登录";
button1.Enabled = true;
if (result != null)
{
LiteCaChe.OrgId = result.baseJpOrganization.id;
LiteCaChe.PoliceId = result.policeman?.id;
LiteCaChe.warehouseList = HttpHelper.GetStoreInfos(LiteCaChe.OrgId);
if (LiteCaChe.warehouseList.Count == 0)
{
MessageBox.Show("当前账号组织机构下无仓库,程序将自动退出");
this.Close();
return;
}
SaveHistory();
this.Hide();
Login_Leave(null, null);
new MainForm(this).Show();
}
else
{
MessageBox.Show("系统登录失败!");
}
}));
});
}
private void SaveHistory()
{
var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "history.txt";
if (!File.Exists(path))
{
File.Create(path);
}
if (cb_saveHistory.Checked)
{
var txt = tb_user.Text + "|" + tb_password.Text;
File.WriteAllText(path, txt, Encoding.UTF8);
}
else
{
File.WriteAllText(path, "", Encoding.UTF8);
}
}
public void ReadHistory()
{
var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "history.txt";
if (!File.Exists(path))
{
File.CreateText(path).Dispose();
}
var txt = File.ReadAllText(path, Encoding.UTF8);
if (!string.IsNullOrEmpty(txt))
{
var record = txt.Split('|');
if (record.Length == 2)
{
tb_user.Text = record[0];
tb_password.Text = record[1];
cb_saveHistory.Checked = true;
}
}
}
protected override void WndProc(ref Message m)
{
const int WM_HOTKEY = 0x0312;
//按快捷键
switch (m.Msg)
{
case WM_HOTKEY:
switch (m.WParam.ToInt32())
{
case 100:
OpenSetting();
break;
}
break;
}
base.WndProc(ref m);
}
private void Login_Leave(object sender, EventArgs e)
{
HotKey.UnregisterHotKey(this.Handle, 100);
}
private void Login_Activated(object sender, EventArgs e)
{
HotKey.RegisterHotKey(this.Handle, 100, HotKey.KeyModifiers.Ctrl | HotKey.KeyModifiers.Alt, (int)Keys.J);
}
private void OpenSetting()
{
try
{
//判断是否已经打开配置界面
bool isContuine = true;
foreach (var frm in Application.OpenForms)
{
if (frm is Setting)
{
isContuine = false;
break;
}
}
if (!isContuine) { return; }
var config = new Setting();
config.ShowDialog();
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
}
}
}
public class HotKey
{
//如果函数执行成功,返回值不为0。
//如果函数执行失败,返回值为0。要得到扩展错误信息,调用GetLastError。
[DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(
IntPtr hWnd, //要定义热键的窗口的句柄
int id, //定义热键ID(不能与其它ID重复)
KeyModifiers fsModifiers, //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效
int vk //定义热键的内容
);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(
IntPtr hWnd, //要取消热键的窗口的句柄
int id //要取消热键的ID
);
//定义了辅助键的名称(将数字转变为字符以便于记忆,也可去除此枚举而直接使用数值)
[Flags()]
public enum KeyModifiers
{
None = 0,
Alt = 1,
Ctrl = 2,
Shift = 4,
WindowsKey = 8
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file

namespace LiteChannelWinXP
{
partial class MainForm
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.cb_SerialPort = new System.Windows.Forms.ComboBox();
this.rb_Net = new System.Windows.Forms.RadioButton();
this.rb_Serial = new System.Windows.Forms.RadioButton();
this.tb_IP = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.nud_NetPort = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.btn_Open = new System.Windows.Forms.Button();
this.lb_status = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.equName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.scanQty = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.cbb_warehouse = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nud_NetPort)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// groupBox2
//
this.groupBox2.Controls.Add(this.cb_SerialPort);
this.groupBox2.Controls.Add(this.rb_Net);
this.groupBox2.Controls.Add(this.rb_Serial);
this.groupBox2.Controls.Add(this.tb_IP);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.nud_NetPort);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.btn_Open);
this.groupBox2.Location = new System.Drawing.Point(12, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(411, 77);
this.groupBox2.TabIndex = 19;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设备连接";
//
// cb_SerialPort
//
this.cb_SerialPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cb_SerialPort.FormattingEnabled = true;
this.cb_SerialPort.Location = new System.Drawing.Point(112, 48);
this.cb_SerialPort.Name = "cb_SerialPort";
this.cb_SerialPort.Size = new System.Drawing.Size(99, 20);
this.cb_SerialPort.TabIndex = 14;
//
// rb_Net
//
this.rb_Net.AutoSize = true;
this.rb_Net.Location = new System.Drawing.Point(14, 22);
this.rb_Net.Name = "rb_Net";
this.rb_Net.Size = new System.Drawing.Size(47, 16);
this.rb_Net.TabIndex = 13;
this.rb_Net.Text = "网络";
this.rb_Net.UseVisualStyleBackColor = true;
//
// rb_Serial
//
this.rb_Serial.AutoSize = true;
this.rb_Serial.Checked = true;
this.rb_Serial.Location = new System.Drawing.Point(14, 49);
this.rb_Serial.Name = "rb_Serial";
this.rb_Serial.Size = new System.Drawing.Size(47, 16);
this.rb_Serial.TabIndex = 12;
this.rb_Serial.TabStop = true;
this.rb_Serial.Text = "串口";
this.rb_Serial.UseVisualStyleBackColor = true;
this.rb_Serial.CheckedChanged += new System.EventHandler(this.rb_Serial_CheckedChanged);
//
// tb_IP
//
this.tb_IP.Enabled = false;
this.tb_IP.Location = new System.Drawing.Point(111, 20);
this.tb_IP.Name = "tb_IP";
this.tb_IP.Size = new System.Drawing.Size(100, 21);
this.tb_IP.TabIndex = 11;
this.tb_IP.Text = "192.168.10.101";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(84, 24);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(17, 12);
this.label8.TabIndex = 10;
this.label8.Text = "IP";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(226, 24);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(29, 12);
this.label7.TabIndex = 8;
this.label7.Text = "端口";
//
// nud_NetPort
//
this.nud_NetPort.Enabled = false;
this.nud_NetPort.Location = new System.Drawing.Point(256, 20);
this.nud_NetPort.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.nud_NetPort.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.nud_NetPort.Name = "nud_NetPort";
this.nud_NetPort.Size = new System.Drawing.Size(47, 21);
this.nud_NetPort.TabIndex = 7;
this.nud_NetPort.Value = new decimal(new int[] {
9701,
0,
0,
0});
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(78, 52);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(23, 12);
this.label1.TabIndex = 1;
this.label1.Text = "COM";
//
// btn_Open
//
this.btn_Open.Location = new System.Drawing.Point(324, 18);
this.btn_Open.Name = "btn_Open";
this.btn_Open.Size = new System.Drawing.Size(75, 23);
this.btn_Open.TabIndex = 2;
this.btn_Open.Text = "打开";
this.btn_Open.UseVisualStyleBackColor = true;
this.btn_Open.Click += new System.EventHandler(this.btn_Open_Click);
//
// lb_status
//
this.lb_status.AutoSize = true;
this.lb_status.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_status.Location = new System.Drawing.Point(12, 460);
this.lb_status.Name = "lb_status";
this.lb_status.Size = new System.Drawing.Size(82, 24);
this.lb_status.TabIndex = 20;
this.lb_status.Text = "状态:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.dataGridView1);
this.groupBox3.Enabled = false;
this.groupBox3.Location = new System.Drawing.Point(12, 117);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(411, 340);
this.groupBox3.TabIndex = 22;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "任务";
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.equName,
this.scanQty});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 17);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(405, 320);
this.dataGridView1.TabIndex = 0;
//
// equName
//
this.equName.DataPropertyName = "equName";
this.equName.HeaderText = "装备名称";
this.equName.Name = "equName";
this.equName.ReadOnly = true;
this.equName.Width = 200;
//
// scanQty
//
this.scanQty.DataPropertyName = "scanQty";
this.scanQty.HeaderText = "数量";
this.scanQty.Name = "scanQty";
this.scanQty.ReadOnly = true;
this.scanQty.Width = 150;
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(264, 466);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 23;
this.button1.Text = "读取";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(345, 466);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 24;
this.button2.Text = "上报";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// cbb_warehouse
//
this.cbb_warehouse.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbb_warehouse.FormattingEnabled = true;
this.cbb_warehouse.Location = new System.Drawing.Point(60, 95);
this.cbb_warehouse.Name = "cbb_warehouse";
this.cbb_warehouse.Size = new System.Drawing.Size(360, 20);
this.cbb_warehouse.TabIndex = 25;
this.cbb_warehouse.SelectedIndexChanged += new System.EventHandler(this.cbb_warehouse_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 98);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 26;
this.label2.Text = "仓库:";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(432, 505);
this.Controls.Add(this.label2);
this.Controls.Add(this.cbb_warehouse);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.lb_status);
this.Controls.Add(this.groupBox2);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "充电台入库-WinXP";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nud_NetPort)).EndInit();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox cb_SerialPort;
private System.Windows.Forms.RadioButton rb_Net;
private System.Windows.Forms.RadioButton rb_Serial;
private System.Windows.Forms.TextBox tb_IP;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.NumericUpDown nud_NetPort;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btn_Open;
private System.Windows.Forms.Label lb_status;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.DataGridViewTextBoxColumn equName;
private System.Windows.Forms.DataGridViewTextBoxColumn scanQty;
private System.Windows.Forms.ComboBox cbb_warehouse;
private System.Windows.Forms.Label label2;
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using JmpRfidLp;
using Newtonsoft.Json;
using System.Configuration;
using System.Diagnostics;
using System.IO.Ports;
using LiteChannelWinXP.Commons;
using LiteChannelWinXP.Models;
namespace LiteChannelWinXP
{
public partial class MainForm : Form
{
private List<scan_info> SourcesList = new List<scan_info>();
private ObservableCollection<scan_info> RefreshSourcesList = new ObservableCollection<scan_info>();
private Reader reader = null;
private Dictionary<string, TagInfo> dic_Tag = new Dictionary<string, TagInfo>();
private Queue<TagInfo> queTags = new Queue<TagInfo>();
private int totalCount = 0;
private long tickStart = DateTime.Now.Ticks;
private bool isStop = true;
private DeviceStatus deviceStatus = DeviceStatus.未连接;
private Login _loginForm;
public MainForm(Login loginForm)
{
_loginForm = loginForm;
InitializeComponent();
this.Text = LiteCaChe.SysConfig.AppTitle;
cb_SerialPort.Items.AddRange(SerialPort.GetPortNames());
if (cb_SerialPort.Items.Count > 0)
{
cb_SerialPort.SelectedIndex = cb_SerialPort.Items.Count - 1;
}
dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = RefreshSourcesList;
cbb_warehouse.DataSource = LiteCaChe.warehouseList;
cbb_warehouse.DisplayMember = "name";
cbb_warehouse.SelectedIndex = 0;
}
private void btn_Open_Click(object sender, EventArgs e)
{
try
{
if (rb_Serial.Checked)
{
if (cb_SerialPort.Text.Length > 0)
{
reader = new Reader(cb_SerialPort.Text);
}
else
{
MessageBox.Show("读选择串口!");
}
}
else
{
reader = new Reader(tb_IP.Text, (int)nud_NetPort.Value);
}
if (reader.Open())
{
reader.OnInventory += new Reader.InvDeleg(OnRadioInventory);
var fw = reader.GetFWVerion();
lb_status.Text = "已连接";
lb_status.ForeColor = Color.Blue;
this.Text += string.Format(" 固件:{0}", fw);
deviceStatus = DeviceStatus.已连接;
groupBox3.Enabled = true;
groupBox2.Enabled = false;
button1.Enabled = true;
button2.Enabled = true;
reader.InventoryStop();
reader.SetPALevel(1);
reader.SetTxPower(0, true, 24);
MessageBox.Show("打开成功");
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show("打开失败");
}
private void OnRadioInventory(TagInfo args)
{
if (!SourcesList.Any(t => t.epcList.Contains(args.EPC)) && args.EPC.Length == 64)
{
var buffer = EpcConvert.ToHexByte(args.EPC);
var epc_info = EpcConvert.EpcAnlysing(buffer);
if (epc_info != null)
{
var equ_info = LiteCaChe.EquInfos?.FirstOrDefault(t => t.code == epc_info.Wzdm.ToString("X"));
if (equ_info != null)
{
//有效标签
var tmp_info = SourcesList.FirstOrDefault(t => t.equCode == epc_info.Wzdm.ToString("X"));
if (tmp_info == null)
{
tmp_info = new scan_info()
{
epcList = new List<string>() { args.EPC },
equCode = epc_info.Wzdm.ToString("X"),
equName = equ_info.name,
scanQty = 1
};
SourcesList.Add(tmp_info);
RefreshSourcesList = new ObservableCollection<scan_info>(SourcesList);
this.Invoke(new Action(() =>
{
dataGridView1.DataSource = RefreshSourcesList;
}));
}
else
{
tmp_info.scanQty += 1;
tmp_info.epcList.Add(args.EPC);
RefreshSourcesList = new ObservableCollection<scan_info>(SourcesList);
this.Invoke(new Action(() =>
{
dataGridView1.DataSource = RefreshSourcesList;
}));
}
}
}
}
}
private void rb_Serial_CheckedChanged(object sender, EventArgs e)
{
if (rb_Serial.Checked)
{
cb_SerialPort.Enabled = true;
tb_IP.Enabled = false;
nud_NetPort.Enabled = false;
}
else
{
cb_SerialPort.Enabled = false;
tb_IP.Enabled = true;
nud_NetPort.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (isStop)
{
//开启
isStop = false;
button1.Text = "停止";
reader?.InventoryStart();
}
else
{
//停止
isStop = true;
button1.Text = "读取";
reader?.InventoryStop();
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
_loginForm.Close();
}
private void button2_Click(object sender, EventArgs e)
{
//上报数据
if (SourcesList != null && SourcesList.Count > 0)
{
List<rfid_info> epcList = new List<rfid_info>();
SourcesList.SelectMany(t => t.epcList).ToList()
.ForEach(s => epcList.Add(new rfid_info()
{
RFID = s
}));
if (epcList.Count > 0)
{
{
if (button1.Text == "停止")
{
button1_Click(null, null);
}
var _res = HttpHelper.RfidInStore("", epcList);
MessageBox.Show(this, _res.Item2, "入库提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
SourcesList.Clear();
RefreshSourcesList = new ObservableCollection<scan_info>(SourcesList);
this.Invoke(new Action(() =>
{
dataGridView1.DataSource = RefreshSourcesList;
}));
}
}
}
}
private void cbb_warehouse_SelectedIndexChanged(object sender, EventArgs e)
{
LiteCaChe.SysConfig.WarehouseID = (cbb_warehouse.SelectedItem as store_info)?.id;
}
}
public enum DeviceStatus
{
未连接,
已连接
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class BaseJpWarehouse
{
public string id { get; set; }
public int? sort { get; set; }
public string name { get; set; }
public string location { get; set; }
public string locationDetail { get; set; }
public string orgizationId { get; set; }
public string phone { get; set; }
public DateTime createTime { get; set; }
public DateTime updateTime { get; set; }
public string updateUser { get; set; }
/// <summary>
/// 是否锁库,0:未锁库,1:锁库中
/// </summary>
public bool? isLocked { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class equ_info
{
public string id { get; set; }
public string code { get; set; }
public string name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class order_equ
{
public string equCode { get; set; }
public int equRem { get; set; }
public int equCount { get; set; }
public int equUsed { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class order_info
{
public string id { get; set; }
public string warehouseId { get; set; }
public string orderCode { get; set; }
public string orgId { get; set; }
public string createTime { get; set; }
public bool? isWork { get; set; }
public string orderType { get; set; }
public int orderQuantity { get; set; }
public string equNames { get; set; }
public string borrowPolice { get; set; }
public string receiveWarehouseId { get; set; }
public string receiveWarehouseName { get; set; }
}
public class order_detail
{
public string id { get; set; }
public string equId { get; set; }
public string equName { get; set; }
public string equCode { get; set; }
public int equCount { get; set; }
public int equUsed { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class request_sign
{
public string appKey { get; set; } = string.Empty;
public string orgId { get; set; } = string.Empty;
public string version { get; set; } = "1.0";
public string timestamp { get; set; }
public string body { get; set; }
public string sign { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class respone<T>
{
public int code { get; set; }
public string msg { get; set; }
public T data { get; set; }
}
public class respone
{
public int code { get; set; }
public string msg { get; set; }
}
public class PagedList<T>
{
public int totalElements { get; set; }
public List<T> content { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class respone_upload
{
public int code { get; set; }
public string msg { get; set; }
public int timestamp { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class response_BoxMarkModel
{
public string id { get; set; }
public string createTime { get; set; }
public string epc { get; set; }
public string oneBoxNum { get; set; }
public string warehouseId { get; set; }
public string warehouseName { get; set; }
public string orgizationId { get; set; }
public string equipmentInfoId { get; set; }
public string equipmentDetailId { get; set; }
public string equipmentDetailName { get; set; }
public string equipmentDetailCode { get; set; }
public string sizeId { get; set; }
public string sizeName { get; set; }
public string sizeCode { get; set; }
public string sizeEpcType { get; set; }
public string supplierId { get; set; }
public string supplierCode { get; set; }
public string supplierName { get; set; }
public List<string> epcList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class rfid_res
{
public string epc { get; set; }
public string name { get; set; }
public int currentState { get; set; }
public int safeLevel { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class scan_info : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public int equRem { get; set; }
public string equCode { get; set; }
public string equName { get; set; }
private int _scan_qty = 0;
public int scanQty
{
get { return _scan_qty; }
set
{
_scan_qty = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("scanQty"));
}
}
public int equCount { get; set; }
public List<string> epcList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class soft_update
{
public string version2 { get; set; }
public int version { get; set; }
public string name { get; set; }
public string appCode { get; set; }
public string note { get; set; }
public string address { get; set; }
public string updateTime { get; set; }
public string fileMd5 { get; set; }
public bool isAutoUpdate { get; set; }
public string autoUpdateAddress { get; set; }
public string autoUpdateFileMd5 { get; set; }
public string autoUpdateVersion2 { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class store_info
{
public string id { get; set; }
public string name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class sync_police
{
public string orgId { get; set; }
public string id { get; set; }
public string name { get; set; }
public string policeCode { get; set; }
public string photo { get; set; }
public DateTime udateTime { get; set; }
public DateTime createTime { get; set; }
public List<FingerInfo> fingerList { get; set; }
}
public class FingerInfo
{
public int fingerNum { get; set; }
public string fingerInfo { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannelWinXP.Models
{
public class upload_info
{
public string orgId { get; set; }
public string warehouseId { get; set; }
/// <summary>
/// "当前出入库状态",//0出库,1入库
/// </summary>
public string currentState { get; set; }
public string policeId { get; set; } = string.Empty;
public string picUrl { get; set; }
public List<rfid_info> RFIDList { get; set; }
}
public class rfid_info
{
public string RFID { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using LiteChannelWinXP.Commons;
namespace LiteChannelWinXP
{
static class Program
{
private static System.Threading.Mutex _mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
_mutex = new System.Threading.Mutex(true, Process.GetCurrentProcess().ProcessName, out var ret);
if (!ret)
{
MessageBox.Show("已有另一个程序在运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);//弹出提示信息
Environment.Exit(0);
}
LiteCaChe.SysConfig = LiteCaChe.LoadSystemStep();
if (LiteCaChe.SysConfig == null)
{
//MessageBox.Show("配置文件加载失败,请检查", "文件错误", MessageBoxButton.OK, MessageBoxImage.Error);
//Process.GetCurrentProcess().Kill();
MessageBox.Show("配置文件加载失败,创建默认配置文件");
LiteCaChe.SysConfig = new Config();
LiteCaChe.SaveSystemStep(LiteCaChe.SysConfig);
}
else
{
var update = HttpHelper.GetUpdate(LiteCaChe.SysConfig?.AppCode ?? "");
if (update == null)
{
}
else
{
if (Version.TryParse(update.version2, out var version) && version > new Version(LiteCaChe.SysConfig.AppVersion))
{
if (MessageBox.Show("检测到新版本,是否更新?", "更新提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
System.Diagnostics.Process.Start("explorer.exe", LiteCaChe.SysConfig.DomainUrl.TrimEnd('/') + "/" + update.address.TrimStart('/'));
Process.GetCurrentProcess().Kill();
}
else { }
}
}
}
//获取供应商
LiteCaChe.EquInfos = HttpHelper.GetEquInfos();
Application.Run(new Login());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LiteChannelWinXP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("LiteChannelWinXP")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("48900448-82f0-4876-9987-0aab845027d5")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiteChannelWinXP.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LiteChannelWinXP.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiteChannelWinXP.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

namespace LiteChannelWinXP
{
partial class Setting
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.tb_domainUrl = new System.Windows.Forms.TextBox();
this.tb_loginUrl = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.tb_appkey = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.tb_secretkey = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.cb_autoUpdate = new System.Windows.Forms.CheckBox();
this.cbb_autoUpdateTime = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 0;
this.label1.Text = "接口域名:";
//
// tb_domainUrl
//
this.tb_domainUrl.Location = new System.Drawing.Point(93, 19);
this.tb_domainUrl.Name = "tb_domainUrl";
this.tb_domainUrl.Size = new System.Drawing.Size(219, 21);
this.tb_domainUrl.TabIndex = 1;
//
// tb_loginUrl
//
this.tb_loginUrl.Location = new System.Drawing.Point(93, 51);
this.tb_loginUrl.Name = "tb_loginUrl";
this.tb_loginUrl.Size = new System.Drawing.Size(219, 21);
this.tb_loginUrl.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(22, 54);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 2;
this.label2.Text = "登录接口:";
//
// tb_appkey
//
this.tb_appkey.Location = new System.Drawing.Point(93, 83);
this.tb_appkey.Name = "tb_appkey";
this.tb_appkey.Size = new System.Drawing.Size(219, 21);
this.tb_appkey.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(22, 86);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 4;
this.label3.Text = "AppKey:";
//
// tb_secretkey
//
this.tb_secretkey.Location = new System.Drawing.Point(93, 116);
this.tb_secretkey.Name = "tb_secretkey";
this.tb_secretkey.Size = new System.Drawing.Size(219, 21);
this.tb_secretkey.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(22, 119);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(71, 12);
this.label4.TabIndex = 6;
this.label4.Text = "SecretKey:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(22, 150);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(65, 12);
this.label5.TabIndex = 8;
this.label5.Text = "自动更新:";
//
// cb_autoUpdate
//
this.cb_autoUpdate.AutoSize = true;
this.cb_autoUpdate.Location = new System.Drawing.Point(93, 150);
this.cb_autoUpdate.Name = "cb_autoUpdate";
this.cb_autoUpdate.Size = new System.Drawing.Size(138, 16);
this.cb_autoUpdate.TabIndex = 9;
this.cb_autoUpdate.Text = "启用自动更新 时间:";
this.cb_autoUpdate.UseVisualStyleBackColor = true;
this.cb_autoUpdate.CheckedChanged += new System.EventHandler(this.cb_autoUpdate_CheckedChanged);
//
// cbb_autoUpdateTime
//
this.cbb_autoUpdateTime.FormattingEnabled = true;
this.cbb_autoUpdateTime.Items.AddRange(new object[] {
"0:00",
"1:00",
"2:00",
"3:00",
"4:00",
"5:00",
"6:00",
"7:00",
"8:00",
"9:00",
"10:00",
"11:00",
"12:00"});
this.cbb_autoUpdateTime.Location = new System.Drawing.Point(227, 148);
this.cbb_autoUpdateTime.Name = "cbb_autoUpdateTime";
this.cbb_autoUpdateTime.Size = new System.Drawing.Size(85, 20);
this.cbb_autoUpdateTime.TabIndex = 10;
//
// button1
//
this.button1.Location = new System.Drawing.Point(227, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 11;
this.button1.Text = "保存";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Setting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(328, 450);
this.Controls.Add(this.button1);
this.Controls.Add(this.cbb_autoUpdateTime);
this.Controls.Add(this.cb_autoUpdate);
this.Controls.Add(this.label5);
this.Controls.Add(this.tb_secretkey);
this.Controls.Add(this.label4);
this.Controls.Add(this.tb_appkey);
this.Controls.Add(this.label3);
this.Controls.Add(this.tb_loginUrl);
this.Controls.Add(this.label2);
this.Controls.Add(this.tb_domainUrl);
this.Controls.Add(this.label1);
this.Name = "Setting";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "设置";
this.Load += new System.EventHandler(this.Setting_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tb_domainUrl;
private System.Windows.Forms.TextBox tb_loginUrl;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox tb_appkey;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tb_secretkey;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox cb_autoUpdate;
private System.Windows.Forms.ComboBox cbb_autoUpdateTime;
private System.Windows.Forms.Button button1;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LiteChannelWinXP
{
public partial class Setting : Form
{
public Setting()
{
InitializeComponent();
}
private void Setting_Load(object sender, EventArgs e)
{
tb_domainUrl.Text = LiteCaChe.SysConfig.DomainUrl;
tb_loginUrl.Text = LiteCaChe.SysConfig.UserLogin;
tb_appkey.Text = LiteCaChe.SysConfig.AppKey;
tb_secretkey.Text = LiteCaChe.SysConfig.SecretKey;
cb_autoUpdate.Checked = LiteCaChe.SysConfig.IsAutoUpdate;
if (cb_autoUpdate.Checked)
{
cbb_autoUpdateTime.Enabled = true;
cbb_autoUpdateTime.SelectedIndex = LiteCaChe.SysConfig.AutoUpdateTime;
}
else
{
cbb_autoUpdateTime.Enabled = false;
}
}
private void button1_Click(object sender, EventArgs e)
{
LiteCaChe.SysConfig.DomainUrl = tb_domainUrl.Text;
LiteCaChe.SysConfig.UserLogin = tb_loginUrl.Text;
LiteCaChe.SysConfig.AppKey = tb_appkey.Text;
LiteCaChe.SysConfig.SecretKey = tb_secretkey.Text;
LiteCaChe.SysConfig.IsAutoUpdate = cb_autoUpdate.Checked;
if (cb_autoUpdate.Checked)
{
LiteCaChe.SysConfig.AutoUpdateTime = cbb_autoUpdateTime.SelectedIndex;
}
LiteCaChe.SaveSystemStep(LiteCaChe.SysConfig);
MessageBox.Show("保存成功");
this.Close();
}
private void cb_autoUpdate_CheckedChanged(object sender, EventArgs e)
{
if (cb_autoUpdate.Checked)
{
cbb_autoUpdateTime.Enabled = true;
}
else
{
cbb_autoUpdateTime.Enabled = false;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net40" />
</packages>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论