Commit 8956b014 by zxw

Merge branch 'release/充电台单机版1.0'

parents 3d36b9c8 7351ef86
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiteChannelWinXP", "LiteCha
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransmitterService", "TransmitterService\TransmitterService.csproj", "{FB7E4EB3-F9C2-42DA-89CC-D8831C462CB5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiteChannelDJB", "LiteChannelDJB\LiteChannelDJB.csproj", "{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -51,12 +53,16 @@ Global
{FB7E4EB3-F9C2-42DA-89CC-D8831C462CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB7E4EB3-F9C2-42DA-89CC-D8831C462CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB7E4EB3-F9C2-42DA-89CC-D8831C462CB5}.Release|Any CPU.Build.0 = Release|Any CPU
{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1BB736E-801B-4BAD-8BC5-A7BA50F023D7}
VisualSVNWorkingCopyRoot = .
SolutionGuid = {F1BB736E-801B-4BAD-8BC5-A7BA50F023D7}
EndGlobalSection
EndGlobal
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -126,6 +126,61 @@ namespace LiteChannel.Commons
}
/// <summary>
/// 与服务器同步时间
/// </summary>
/// <returns></returns>
public static bool SetLocalTime()
{
try
{
var json = HttpGet(LiteCaChe.SysConfig.DomainUrl + Config.GetServerime);
if (string.IsNullOrEmpty(json))
{
Log.WorkLog("服务器时间获取失败", "获取失败");
return default;
}
else
{
var res_data = JsonConvert.DeserializeObject<respone<DateTime>>(json);
if (res_data == null || res_data.code != 10000)
{
Log.WorkLog("服务器时间获取失败", "获取失败");
return default;
}
else
{
Log.WorkLog("服务器时间获取成功", "获取成功");
if (res_data.data != null && res_data.data != default)
{
SYSTEMTIME _time = new SYSTEMTIME();
_time.FromDateTime(res_data.data);
var res = Win32API.SetLocalTime(ref _time);
if (res)
{
Log.WorkLog("时间同步成功", "同步成功");
}
else
{
Log.WorkLog($"时间同步失败,时间:{res_data.data.ToString("yyyy-MM-dd HH:mm:ss")}", "同步失败");
}
return res;
}
else
{
return false;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
/// <summary>
/// 获取物资信息
/// </summary>
/// <returns></returns>
......
using System;
using System.Runtime.InteropServices;
namespace LiteChannel.Commons
{
public class Win32API
{
[DllImport("Kernel32.dll")]
public static extern bool SetLocalTime(ref SYSTEMTIME Time);
[DllImport("Kernel32.dll")]
public static extern void GetLocalTime(ref SYSTEMTIME Time);
}
/// <summary>
///
/// </summary>
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
/// <summary>
/// 从System.DateTime转换。
/// </summary>
/// <param name="time">System.DateTime类型的时间。</param>
public void FromDateTime(DateTime time)
{
wYear = (ushort)time.Year;
wMonth = (ushort)time.Month;
wDayOfWeek = (ushort)time.DayOfWeek;
wDay = (ushort)time.Day;
wHour = (ushort)time.Hour;
wMinute = (ushort)time.Minute;
wSecond = (ushort)time.Second;
wMilliseconds = (ushort)time.Millisecond;
}
/// <summary>
/// 转换为System.DateTime类型。
/// </summary>
/// <returns></returns>
public DateTime ToDateTime()
{
return new DateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds);
}
/// <summary>
/// 静态方法。转换为System.DateTime类型。
/// </summary>
/// <param name="time">SYSTEMTIME类型的时间。</param>
/// <returns></returns>
public static DateTime ToDateTime(SYSTEMTIME time)
{
return time.ToDateTime();
}
}
}
......@@ -101,6 +101,7 @@ namespace LiteChannel
public const string GetAllInventoryList = "/api/Inventory/GetAllInventoryList";
public const string AddAndApprovalBorrowOrder = "/api/Borrow/AddAndApprovalBorrowOrder";
public const string AddAndApprovalBorrowJYOrder = "/api/Borrow/AddAndApprovalBorrowJYOrder";
public const string GetServerime = "/api/ChannelCfg/GetServerTime";
public Config()
{
......
......@@ -126,6 +126,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Commons\ReaderHelper.cs" />
<Compile Include="Commons\Win32API.cs" />
<Compile Include="SelectPoliceWindow.xaml.cs">
<DependentUpon>SelectPoliceWindow.xaml</DependentUpon>
</Compile>
......
......@@ -114,7 +114,8 @@ namespace LiteChannel
});
}
//设置系统时间
HttpHelper.SetLocalTime();
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
......@@ -152,7 +153,7 @@ namespace LiteChannel
if (!IsLoaded)
return;
cbo_warehouse.ItemsSource = StoreList.Where(t => t.name.Contains(e.Text));
}
private void cbo_warehouse_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
......
......@@ -51,5 +51,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.14.01030")]
[assembly: AssemblyFileVersion("1.2.14.01030")]
[assembly: AssemblyVersion("1.2.15.03080")]
[assembly: AssemblyFileVersion("1.2.15.03080")]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.5.0" newVersion="2.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
<Application x:Class="LiteChannel.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:LiteChannel"
StartupUri="LoginWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Panuon.UI.Silver;component/Control.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="TextBlock" x:Key="FiconBase">
<Setter Property="FontFamily" Value="pack://application:,,,/font/#iconfont" />
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style x:Key="TextCenterStyle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="TextLeftStyle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
using LiteChannel.Commons;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using JmpCommon;
using LiteChannel.Models;
namespace LiteChannel
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
private System.Threading.Mutex _mutex;
public App()
{
this.Startup += App_Startup;
}
void App_Startup(object sender, StartupEventArgs e)
{
_mutex = new System.Threading.Mutex(true, Process.GetCurrentProcess().ProcessName, out var ret);
if (!ret)
{
MessageBox.Show("已有另一个程序在运行!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);//弹出提示信息
Environment.Exit(0);
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
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("检测到新版本,是否更新?", "更新提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
// {
// System.Diagnostics.Process.Start("explorer.exe", LiteCaChe.SysConfig.DomainUrl.TrimEnd('/') + "/" + update.address.TrimStart('/'));
// Process.GetCurrentProcess().Kill();
// }
// else { }
// }
//}
}
//获取供应商
LiteCaChe.EquInfos = HttpHelper.GetEquInfos();
LiteCaChe.InventoryInfos = HttpHelper.GetAllInventoryList();
}
}
}
<pu:WindowX x:Class="LiteChannel.AutoClosingMessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
Title="标题" Height="250" Width="400" Loaded="Window_Loaded" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" FontSize="14" >
<Window.Effect>
<DropShadowEffect BlurRadius="10" Color="#FF858484" Direction="90" ShadowDepth="2"/>
</Window.Effect>
<Grid >
<Grid x:Name="g_body" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Label x:Name="lb_Message" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" Margin="0,0,0,20">消息</Label>
<Button x:Name="btn_Submit" Grid.Row="2" pu:ButtonHelper.CornerRadius="4" FontSize="20" Content="确定" Margin="60,10,0,0" Height="40" Width="120" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btn_Submit_Click"/>
<Button x:Name="btn_Cancel" Grid.Row="2" pu:ButtonHelper.CornerRadius="4" FontSize="20" Content="取消" Margin="200,10,0,0" Height="40" Width="120" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btn_Cancel_Click" Grid.ColumnSpan="2"/>
</Grid>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Panuon.UI.Silver;
using Panuon.UI.Silver.Core;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
namespace LiteChannel
{
/// <summary>
/// AutoClosingMessageBox.xaml 的交互逻辑
/// </summary>
public partial class AutoClosingMessageBox : WindowX, IComponentConnector
{
private int _count = 0;
private System.Threading.Timer _timer;
private Action _callBack;
public AutoClosingMessageBox(Window window,string content, string title, int count, Action callback)
{
InitializeComponent();
Owner = window;
Title = " " + title;
lb_Message.Content = content;
_count = count;
_callBack = callback;
_timer = new System.Threading.Timer(TimerFunction, null, 0, 1000);
//居中弹出
this.Left = System.Windows.SystemParameters.PrimaryScreenWidth / 2 - this.Width / 2;
this.Top = System.Windows.SystemParameters.PrimaryScreenHeight / 2 - this.Height / 2;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void btn_Submit_Click(object sender, RoutedEventArgs e)
{
//执行
_timer.Dispose();
_callBack.BeginInvoke(null, null);
this.Close();
}
private void btn_Cancel_Click(object sender, RoutedEventArgs e)
{
_timer.Dispose();
this.Close();
}
private void TimerFunction(object state)
{
this.Dispatcher.Invoke(() => { btn_Submit.Content = $"确定({_count})"; });
if (_count < 0)
{
_timer.Dispose();
this.Dispatcher.Invoke(() => this.btn_Submit_Click(null, null));
}
_count--;
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannel.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 LiteChannel.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;
using System.Windows.Forms;
using JmpCommon;
namespace LiteChannel.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;
}
}
/// <summary>
/// 获取物资信息
/// </summary>
/// <returns></returns>
public static List<equ_info> InitEquInfos()
{
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 + Config.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<equ_info> GetEquInfos()
{
try
{
if (File.Exists("detail.json") && File.Exists("size.json"))
{
var equInfos = JsonConvert.DeserializeObject<List<equ_info>>(File.ReadAllText("detail.json"));
var sizeInfos = JsonConvert.DeserializeObject<List<equ_size_info>>(File.ReadAllText("size.json"));
foreach (var equInfo in equInfos)
{
var sizeList = sizeInfos.Where(x => x.info_id == equInfo.id).ToList();
if (!sizeList.Any())
{
sizeList.Add(new equ_size_info
{
id = Guid.Empty.ToString(),
code = "0",
info_id = equInfo.id,
name = "无号配号"
});
}
equInfo.sizeList.AddRange(sizeList);
}
return equInfos;
}
else
{
Log.ErrorLog("json不存在");
return default;
}
}
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
{
if (userName == "admin" && userPwd == "123456")
{
var user = new respone_user()
{
username = "仓管员"
};
return user;
}
else
{
return null;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n", MethodBase.GetCurrentMethod().Name);
return default;
}
}
/// <summary>
/// 获取当前仓库库存信息
/// </summary>
/// <returns></returns>
public static List<inventory_info> GetAllInventoryList()
{
try
{
var inventoryInfos = LiteDBHelper.FindAllInventory();
//var str=JsonConvert.SerializeObject(inventoryInfos);
//File.WriteAllText("invData.json",str);
return inventoryInfos;
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString() + "\r\n");
return default;
}
}
/// <summary>
/// 装备初始化
/// </summary>
/// <param name="epcs"></param>
/// <param name="info"></param>
/// <param name="size"></param>
/// <returns></returns>
public static Tuple<bool, string> RfidInitStore(List<rfid_info> epcs, equ_info info, equ_size_info size)
{
try
{
//装备初始化
foreach (var rfidInfo in epcs)
{
var inventory = new inventory_info()
{
Id = Guid.NewGuid().ToString(),
equipmentDetailId = info.id,
equipmentDetailName = info.name,
equipmentSizeId = size.id,
equipmentSizeName = size.name,
epc = rfidInfo.RFID,
state = 0,
};
LiteDBHelper.AddOrUpdateInventory(inventory);
}
//更新缓存
LiteCaChe.InventoryInfos = LiteDBHelper.FindAllInventory();
return new Tuple<bool, string>(true, "装备初始化成功");
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <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 i = 0;
//提交入库
var invList = LiteCaChe.InventoryInfos
.Where(x => eps.Select(y => y.RFID).Contains(x.epc))
.ToList();
foreach (var inventory in invList)
{
if (inventory.state == 1)
{
//入库
inventory.state = 0;
LiteDBHelper.AddOrUpdateInventory(inventory);
LiteDBHelper.AddOutInLog(new inventory_out_in_log()
{
Id = Guid.NewGuid().ToString(),
createTime = DateTime.Now,
epc = inventory.epc,
equipmentDetailId = inventory.equipmentDetailId,
equipmentDetailName = inventory.equipmentDetailName,
equipmentSizeId = inventory.equipmentSizeId,
equipmentSizeName = inventory.equipmentSizeName,
state = 0
});
i++;
}
}
return new Tuple<bool, string>(true, "本次入库成功" + i + "件");
}
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 i = 0;
//提交出库
var invList = LiteCaChe.InventoryInfos
.Where(x => eps.Select(y => y.RFID).Contains(x.epc))
.ToList();
foreach (var inventory in invList)
{
if (inventory.state == 0)
{
//出库
inventory.state = 1;
LiteDBHelper.AddOrUpdateInventory(inventory);
LiteDBHelper.AddOutInLog(new inventory_out_in_log()
{
Id = Guid.NewGuid().ToString(),
createTime = DateTime.Now,
epc = inventory.epc,
equipmentDetailId = inventory.equipmentDetailId,
equipmentDetailName = inventory.equipmentDetailName,
equipmentSizeId = inventory.equipmentSizeId,
equipmentSizeName = inventory.equipmentSizeName,
state = 1
});
i++;
}
}
return new Tuple<bool, string>(true, "本次出库成功" + i + "件");
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
/// <summary>
/// 提交出库
/// </summary>
/// <param name="order"></param>
/// <param name="eps"></param>
/// <returns></returns>
public static PagedList<inventory_out_in_log> GetOutInLogs(string type, int page, int size)
{
return LiteDBHelper.GetOutInLogs(type, page, size);
}
private static Tuple<string, string, string> GetBody(string json)
{
try
{
var timespan = GetTimeStamp();
var body = System.Web.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 LiteChannel.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 System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannel.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, [CallerMemberName] 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, [CallerMemberName] 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, [CallerMemberName] 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
{
}
}
}
}
}
}
using JmpRfidLp;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace LiteChannel.Commons
{
public interface IReaderHelper : IDisposable
{
event InvDelegate OnInventory;
delegate void InvDelegate(TagInfoData args);
bool Open();
bool Close();
bool IsOpen();
string GetFWVerion();
void InventoryStart();
void InventoryStop();
bool SetPALevel(byte level);
bool SetTxPower(byte port, bool enable, double power);
List<TagInfoData> InventorySingle();
Tuple<int, string> ReadTag(ref OperatingData tag);
Tuple<int, string> WriteTag(OperatingData tag);
}
public class TagInfoData
{
public string EPC { get; set; }
public int RSSI { get; set; }
public byte AntennaPort { get; set; }
public int SeenCount { get; set; }
}
public class OperatingData
{
public string EPC { get; set; }
public string DATA { get; set; }
public ushort Offset { get; set; }
public ushort Length { get; set; }
public RfidBankType Bank { get; set; }
public string Access { get; set; }
}
public enum RfidBankType
{
[Description("RFU")] RFU,
[Description("EPC")] EPC,
[Description("TID")] TID,
[Description("USER")] USER,
}
/// <summary>
/// 钧普读写器
/// </summary>
public class JmpRfidLpReaderHelper : IReaderHelper
{
public event IReaderHelper.InvDelegate OnInventory;
private Reader _reader;
public JmpRfidLpReaderHelper(string comPort = "COM3")
{
_reader = new Reader(comPort);
_reader.OnInventory += OnOnInventory;
}
public bool Open()
{
return _reader.Open();
}
public bool Close()
{
return _reader.Close();
}
public bool IsOpen()
{
return _reader.IsOpen();
}
public string GetFWVerion()
{
return _reader.GetFWVerion();
}
public void InventoryStart()
{
_reader.InventoryStart();
}
public void InventoryStop()
{
_reader.InventoryStop();
}
public bool SetPALevel(byte level)
{
return _reader.SetPALevel(level) == 0;
}
public bool SetTxPower(byte port, bool enable, double power)
{
return _reader.SetTxPower(port, enable, power) == 0;
}
public List<TagInfoData> InventorySingle()
{
return _reader.InventorySingle(50).Select(x => new TagInfoData
{
AntennaPort = x.AntennaPort,
EPC = x.EPC,
RSSI = x.RSSI,
SeenCount = x.SeenCount
}).ToList();
}
public Tuple<int, string> ReadTag(ref OperatingData tag)
{
var data = new OperData
{
Access = tag.Access ?? "00000000",
Bank = (BankType)tag.Bank,
DATA = tag.DATA ?? "",
EPC = tag.EPC ?? "",
Length = tag.Length,
Offset = tag.Offset
};
var res = _reader.ReadTag(ref data);
tag.Access = data.Access;
tag.Bank = (RfidBankType)data.Bank;
tag.DATA = data.DATA;
tag.EPC = data.EPC;
tag.Length = data.Length;
tag.Offset = data.Offset;
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc((int)res));
}
public Tuple<int, string> WriteTag(OperatingData tag)
{
var data = new OperData
{
Access = tag.Access ?? "00000000",
Bank = (BankType)tag.Bank,
DATA = tag.DATA ?? "",
EPC = tag.EPC ?? "",
Length = tag.Length,
Offset = tag.Offset
};
var res = _reader.WriteTag(data);
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc((int)res));
}
protected virtual void OnOnInventory(TagInfo args)
{
OnInventory?.Invoke(new TagInfoData()
{
AntennaPort = args.AntennaPort,
EPC = args.EPC,
RSSI = args.RSSI,
SeenCount = args.SeenCount
});
}
public void Dispose()
{
_reader.OnInventory -= OnOnInventory;
_reader = null;
}
}
/// <summary>
/// 索力得USBRFID读写器
/// </summary>
public class USBRFIDReaderHelper : IReaderHelper
{
private int _portHandle = -1;
private bool _isOpen = false;
private ManualResetEvent inventoryEvent = new ManualResetEvent(true);
private CancellationTokenSource _token;
public event IReaderHelper.InvDelegate OnInventory;
public USBRFIDReaderHelper()
{
}
public bool Open()
{
var res = OpenUSBPort(null, ref _portHandle);
if (res == 0)
{
_isOpen = true;
return true;
}
else
{
_isOpen = false;
Log.WorkLog("连接读写器失败:0x" + res.ToString("X2"), "读写器启动失败");
return false;
}
}
public bool Close()
{
_isOpen = false;
return CloseUSBPort(_portHandle) == 0;
}
public bool IsOpen()
{
return _isOpen;
}
public string GetFWVerion()
{
byte TrType = 0;
byte[] VersionInfo = new byte[2];
byte ReaderType = 0;
byte ScanTime = 0;
byte dfreband = 0;
byte dmaxfre = 0;
byte dminfre = 0;
byte powerdBm = 0;
byte Ant = 0;
byte BeepEn = 0;
byte CheckAnt = 0;
var res = GetReaderInfo(VersionInfo, ref ReaderType, ref TrType, ref dfreband, ref dmaxfre, ref dminfre, ref powerdBm, ref ScanTime, ref Ant, ref BeepEn, ref CheckAnt, _portHandle);
if (res == 0)
{
return string.Format("{0}.{1:d2}", VersionInfo[0], VersionInfo[1]);
}
else
{
if (res == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
return "";
}
}
public void InventoryStart()
{
//开启盘点线程
_token = new CancellationTokenSource();
Task.Run(() =>
{
int totalLen = 0, cardNum = 0, fCmdRet = 0x30;
int cardIdx = 0, epcLen = 0;
int i;
byte MaskMem = 0;
byte[] MaskAdr = new byte[2];
byte MaskLen = 0;
byte[] MaskData = null;
byte MaskFlag = 0;
byte[] EPCList = new byte[30000];
byte Ant = 0;
byte AdrTID = 0;
byte LenTID = 0;
byte TIDFlag = 0;
byte FastFlag = 1;
byte QValue = 4; //Q值 4
byte Session = 0; //Session 0
byte Target = 0; //Target A
byte Scantime = 3; //巡查时间 10*100ms
inventoryEvent = new ManualResetEvent(false);
while (!_token.IsCancellationRequested)
{
try
{
if (!_isOpen)
{
return;
}
fCmdRet = Inventory_G2(QValue, Session, MaskMem, MaskAdr, MaskLen, MaskData, MaskFlag, AdrTID,
LenTID, TIDFlag, Target, 0x80, Scantime, FastFlag, EPCList, ref Ant, ref totalLen,
ref cardNum, _portHandle);
if ((fCmdRet == 1) | (fCmdRet == 2) | (fCmdRet == 3) | (fCmdRet == 4)) //代表已查找结束,
{
if (cardNum > 0)
{
i = 0;
epcLen = 0;
for (cardIdx = 0; cardIdx < cardNum; cardIdx++)
{
epcLen = EPCList[i];
byte[] epcNo = new byte[epcLen];
Array.Copy(EPCList, i + 1, epcNo, 0, epcLen);
String strEpcNo = ByteArrToHexStr(epcNo);
byte rssi = EPCList[i + epcLen + 1];
i += epcLen + 2;
OnOnInventory(new TagInfo()
{
AntennaPort = 0,
EPC = strEpcNo,
RSSI = rssi,
SeenCount = 1
});
//AddTagToInvRealTable(strEpcNo, rssi);
}
}
}
else
{
if (fCmdRet == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
}
}
catch (Exception e)
{
Log.ErrorLog(e.Message, nameof(USBRFIDReaderHelper));
}
}
inventoryEvent.Set();
}, _token.Token);
}
public void InventoryStop()
{
//关闭盘点线程
_token?.Cancel();
inventoryEvent.WaitOne(1000);
}
public bool SetPALevel(byte level)
{
//索力得读写器无天线使能设置
return true;
}
public bool SetTxPower(byte port, bool enable, double power)
{
var res = SetRfPower((byte)Convert.ToInt32(power), _portHandle);
if (res == 0)
{
return true;
}
else
{
if (res == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
Log.ErrorLog("设置功率失败:0x" + res.ToString("X2"), nameof(USBRFIDReaderHelper));
return false;
}
}
public List<TagInfoData> InventorySingle()
{
var list = new List<TagInfoData>();
//只盘点一轮
int totalLen = 0, cardNum = 0, fCmdRet = 0x30;
int cardIdx = 0, epcLen = 0;
int i;
byte MaskMem = 0;
byte[] MaskAdr = new byte[2];
byte MaskLen = 0;
byte[] MaskData = null;
byte MaskFlag = 0;
byte[] EPCList = new byte[30000];
byte Ant = 0;
byte AdrTID = 0;
byte LenTID = 0;
byte TIDFlag = 0;
byte FastFlag = 1;
byte QValue = 1; //Q值 Q 值的设置应为场内的标签数量约等亍2的Q次方
byte Session = 0; //Session 0 建议单张或者少量标签查询选 S0
byte Target = 0; //Target A
byte Scantime = 3; //巡查时间 3*100ms
try
{
fCmdRet = Inventory_G2(QValue, Session, MaskMem, MaskAdr, MaskLen, MaskData, MaskFlag, AdrTID, LenTID, TIDFlag, Target, 0x80, Scantime, FastFlag, EPCList, ref Ant, ref totalLen, ref cardNum, _portHandle);
if ((fCmdRet == 1) | (fCmdRet == 2) | (fCmdRet == 3) | (fCmdRet == 4)) //代表已查找结束,
{
if (cardNum > 0)
{
i = 0;
epcLen = 0;
for (cardIdx = 0; cardIdx < cardNum; cardIdx++)
{
epcLen = EPCList[i];
byte[] epcNo = new byte[epcLen];
Array.Copy(EPCList, i + 1, epcNo, 0, epcLen);
String strEpcNo = ByteArrToHexStr(epcNo);
byte rssi = EPCList[i + epcLen + 1];
i += epcLen + 2;
list.Add(new TagInfoData()
{
AntennaPort = 0,
EPC = strEpcNo,
RSSI = rssi,
SeenCount = 1
});
}
}
}
else
{
if (fCmdRet == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
}
}
catch (Exception e)
{
Log.ErrorLog(e.Message, nameof(USBRFIDReaderHelper));
}
return list;
}
public Tuple<int, string> ReadTag(ref OperatingData tag)
{
byte ENum;
byte[] opWordPtr = null;
byte opLen = 0;
byte opMem = 0;
byte[] accPwd = null;
string str = "";
byte[] MaskEPC = null;
byte MaskMem = 0;
byte[] MaskAdr = null;
byte MaskLen = 0;
byte[] MaskData = null;
ENum = (byte)(str.Length / 4);
MaskEPC = new byte[ENum * 2];
MaskEPC = HexStrToByteArr(str);
opMem = (byte)tag.Bank; //0x00:保留区;0x01:EPC 存储区;0x02:TID 存储区;0x03:用户存储区。
opWordPtr = HexStrToByteArr(tag.Offset.ToString("X4"));
opLen = Convert.ToByte(tag.Length);
accPwd = HexStrToByteArr(tag.Access);
byte[] TagData = new byte[opLen * 2];
var errcode = 0;
var res = 0;
for (int retry = 0; retry < 3; retry++)
{
res = ExtReadData_G2(MaskEPC, ENum, opMem, opWordPtr, opLen, accPwd, MaskMem, MaskAdr, MaskLen, MaskData, TagData, ref errcode, _portHandle);
if (res == 0)
break;
}
if (res == 0)
{
tag.DATA = ByteArrToHexStr(TagData);
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc(res));
}
else
{
if (res == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
if (res != 0xFC)
{
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc(res));
}
else
{
return new Tuple<int, string>((int)res, typeof(ErrorCodeEnum).GetEnumDesc(errcode));
}
}
}
public Tuple<int, string> WriteTag(OperatingData tag)
{
byte ENum;
byte WNum = 0;
byte[] opWordPtr = null;
byte opMem = 0;
byte[] opData = null;
byte[] accPwd = null;
string str = "";
byte[] MaskEPC = null;
byte MaskMem = 0;
byte[] MaskAdr = null;
byte MaskLen = 0;
byte[] MaskData = null;
ENum = (byte)(str.Length / 4);
MaskEPC = new byte[ENum * 2];
MaskEPC = HexStrToByteArr(str);
opMem = (byte)tag.Bank; //0x00:保留区;0x01:EPC 存储区;0x02:TID 存储区;0x03:用户存储区。
opWordPtr = HexStrToByteArr(tag.Offset.ToString("X4"));
accPwd = HexStrToByteArr(tag.Access);
opData = HexStrToByteArr(tag.DATA);
WNum = (byte)(opData.Length / 2);
var errcode = 0;
var res = 0;
for (int retry = 0; retry < 3; retry++)
{
res = ExtWriteData_G2(MaskEPC, WNum, ENum, opMem, opWordPtr, opData, accPwd, MaskMem, MaskAdr, MaskLen, MaskData, ref errcode, _portHandle);
if (res == 0)
break;
}
if (res == 0)
{
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc(res));
}
else
{
if (res == 0x30)
{
//通讯失败,掉线
_isOpen = false;
}
if (res != 0xFC)
{
return new Tuple<int, string>((int)res, typeof(OperResult).GetEnumDesc(res));
}
else
{
return new Tuple<int, string>((int)res, typeof(ErrorCodeEnum).GetEnumDesc(errcode));
}
}
}
protected virtual void OnOnInventory(TagInfo args)
{
OnInventory?.Invoke(new TagInfoData()
{
AntennaPort = args.AntennaPort,
EPC = args.EPC,
RSSI = args.RSSI,
SeenCount = args.SeenCount
});
}
public void Dispose()
{
}
/// <summary>
/// 字符串转16进制字节数组
/// </summary>
/// <param name="hexString"></param>
/// <returns></returns>
public static byte[] HexStrToByteArr(string hexString)
{
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += "0";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
}
/// <summary>
/// 字节数组转16进制字符串
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static string ByteArrToHexStr(byte[] bytes)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < bytes.Length; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
#region USBUHFPlatform
private const string DLLNAME = @"USBUHFPlatform.dll";
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int OpenUSBPort(string DevSnr, ref int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int CloseUSBPort(int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int CompDevInterfaceName(string DevInterfaceName, int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetReaderInfo(
byte[] VersionInfo,
ref byte ReaderType,
ref byte TrType,
ref byte dfreband,
ref byte dmaxfre,
ref byte dminfre,
ref byte powerdBm,
ref byte ScanTime,
ref byte Ant,
ref byte BeepEn,
ref byte CheckAnt,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetRegion(
byte dfreband,
byte dmaxfre,
byte dminfre,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetInventoryScanTime(
byte ScanTime,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetRfPower(
byte PowerDbm,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetLedStatus(
ref byte LedPin,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetLedCtrl(
byte LedPin,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetBeep(
byte AvtiveTime,
byte SilentTime,
byte Times,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetSerialNo(
StringBuilder SeriaNo,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetSaveLen(
byte SaveLen,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetSaveLen(
ref byte SaveLen,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int ReadBuffer_G2(
ref int Totallen,
ref int CardNum,
byte[] pEPCList,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int ClearBuffer_G2(int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetBufferCnt_G2(
ref int Count,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetTagCustomFunction(
ref byte InlayType,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int Inventory_G2(
byte QValue,
byte Session,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
byte MaskFlag,
byte AdrTID,
byte LenTID,
byte TIDFlag,
byte Target,
byte InAnt,
byte Scantime,
byte FastFlag,
byte[] pEPCList,
ref byte Ant,
ref int Totallen,
ref int CardNum,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int ExtReadData_G2(
byte[] EPC,
byte ENum,
byte Mem,
byte[] WordPtr,
byte Num,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
byte[] Data,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int ExtWriteData_G2(
byte[] EPC,
byte WNum,
byte ENum,
byte Mem,
byte[] WordPtr,
byte[] Wdt,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int WriteEPC_G2(
byte[] Password,
byte[] WriteEPC,
byte ENum,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int BlockWrite_G2(
byte[] EPC,
byte WNum,
byte ENum,
byte Mem,
byte WordPtr,
byte[] Wdt,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int BlockErase_G2(
byte[] EPC,
byte ENum,
byte Mem,
byte WordPtr,
byte Num,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int Lock_G2(
byte[] EPC,
byte ENum,
byte select,
byte setprotect,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int KillTag_G2(
byte[] EPC,
byte ENum,
byte[] Killpwd,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetPrivacyByEPC_G2(
byte[] EPC,
byte ENum,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetPrivacyWithoutEPC_G2(
byte[] Password,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int ResetPrivacy_G2(
byte[] Password,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int CheckPrivacy_G2(
ref byte readpro,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int EASConfigure_G2(
byte[] EPC,
byte ENum,
byte[] Password,
byte EAS,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int EASAlarm_G2(
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int GetMonza4QTWorkParamter_G2(
byte[] EPC,
byte ENum,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref byte QTcontrol,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int SetMonza4QTWorkParamter_G2(
byte[] EPC,
byte ENum,
byte QTcontrol,
byte[] Password,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
ref int Errorcode,
int FrmHandle);
[DllImport(DLLNAME, CallingConvention = CallingConvention.StdCall)]
public static extern int InventoryBuffer_G2(
byte QValue,
byte Session,
byte MaskMem,
byte[] MaskAdr,
byte MaskLen,
byte[] MaskData,
byte MaskFlag,
byte AdrTID,
byte LenTID,
byte TIDFlag,
byte Target,
byte InAnt,
byte Scantime,
byte FastFlag,
ref int BufferCount,
ref int TagNum,
int FrmHandle);
#endregion
public enum OperResult
{
[Description("执行成功")] OK = 0x00,
[Description("扫描时间结束前返回")] Error1 = 0x01,
[Description("指定的扫描时间溢出")] Error2 = 0x02,
[Description("本条消息之后,还有消息")] Error3 = 0x03,
[Description("读写模块存储空间已满")] Error4 = 0x04,
[Description("访问密码错误")] Error5 = 0x05,
[Description("销毁密码错误")] Error9 = 0x09,
[Description("销毁密码丌能为全 0")] Error10 = 0x0A,
[Description("电子标签丌支持该命令")] Error11 = 0x0B,
[Description("对亍特定命令,访问密码丌能为 0")] Error12 = 0x0C,
[Description("电子标签已经被设置了读保护,丌能再次设置")] Error13 = 0x0D,
[Description("电子标签没有被设置读保护,丌需要解锁")] Error14 = 0x0E,
[Description("参数保存失败,设置的值仅在读写器断电前有效")] Error19 = 0x13,
[Description("无法调整功率")] Error20 = 0x14,
[Description("电子丌支持该命令或者访问密码丌能为 0")] Error25 = 0x19,
[Description("标签自定义功能执行错误")] Error26 = 0x1A,
[Description("返回指令错误")] Error238 = 0xEE,
[Description("检测丌到天线连接")] Error248 = 0xF8,
[Description("命令执行出错")] Error249 = 0xF9,
[Description("扫描到电子标签,但由亍通信丌畅,导致操作失败")] Error250 = 0xFA,
[Description("无电子标签可操作")] Error251 = 0xFB,
[Description("电子标签返回错误代码")] Error252 = 0xFC,
[Description("命令长度错误")] Error253 = 0xFD,
[Description("命令非法")] Error254 = 0xFE,
[Description("参数错误")] Error255 = 0xFF,
[Description("通讯错误")] Error48 = 0x30,
[Description("CRC 错误")] Error49 = 0x31,
[Description("通讯繁忙,设备正在执行其他命令")] Error51 = 0x33,
[Description("端口已打开")] Error53 = 0x35,
[Description("端口已关闭")] Error54 = 0x36,
[Description("无效句柄")] Error55 = 0x37,
[Description("已打开设备过多,空间丌足")] Error57 = 0x39,
}
public enum ErrorCodeEnum
{
[Description("其它错误,全部捕捉未被其它代码覆盖的错误")] Error0 = 0x00,
[Description("存储器超限或丌被支持的 PC 值,规定存储位置丌存在或标签丌支持 PC 值")] Error3 = 0x03,
[Description("存储器锁定,存储位置锁定永久锁定,且丌可写入")] Error4 = 0x04,
[Description("电源丌足,标签电源丌足,无法执行存储写入操作")] Error11 = 0x0B,
[Description("非特定错误,标签丌支持特定错误代码")] Error15 = 0x0F,
}
}
public static class EnumExtension
{
/// <summary>
/// 根据值得到中文备注
/// </summary>
/// <param name="e"></param>
/// <param name="value"></param>
/// <returns></returns>
public static string GetEnumDesc(this System.Type e, int? value)
{
string result;
try
{
System.Reflection.FieldInfo[] fields = e.GetFields();
int i = 1;
int count = fields.Length;
while (i < count)
{
if ((int)System.Enum.Parse(e, fields[i].Name) == value)
{
DescriptionAttribute[] EnumAttributes = (DescriptionAttribute[])fields[i].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (EnumAttributes.Length > 0)
{
result = EnumAttributes[0].Description;
return result;
}
}
i++;
}
result = "";
}
catch
{
result = "";
}
return result;
}
}
}
\ No newline at end of file
using System;
using System.Runtime.InteropServices;
namespace LiteChannel.Commons
{
public class Win32API
{
[DllImport("Kernel32.dll")]
public static extern bool SetLocalTime(ref SYSTEMTIME Time);
[DllImport("Kernel32.dll")]
public static extern void GetLocalTime(ref SYSTEMTIME Time);
}
/// <summary>
///
/// </summary>
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
/// <summary>
/// 从System.DateTime转换。
/// </summary>
/// <param name="time">System.DateTime类型的时间。</param>
public void FromDateTime(DateTime time)
{
wYear = (ushort)time.Year;
wMonth = (ushort)time.Month;
wDayOfWeek = (ushort)time.DayOfWeek;
wDay = (ushort)time.Day;
wHour = (ushort)time.Hour;
wMinute = (ushort)time.Minute;
wSecond = (ushort)time.Second;
wMilliseconds = (ushort)time.Millisecond;
}
/// <summary>
/// 转换为System.DateTime类型。
/// </summary>
/// <returns></returns>
public DateTime ToDateTime()
{
return new DateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds);
}
/// <summary>
/// 静态方法。转换为System.DateTime类型。
/// </summary>
/// <param name="time">SYSTEMTIME类型的时间。</param>
/// <returns></returns>
public static DateTime ToDateTime(SYSTEMTIME time)
{
return time.ToDateTime();
}
}
}
<pu:WindowX x:Class="LiteChannel.InitWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Maximized"
Title="初始化入库" FontSize="24" WindowStartupLocation="CenterScreen"
Loaded="OnWindow_Loaded" Closing="OnWindow_Closing">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="0"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<ComboBox Name="cbo_info" Grid.Row="0" pu:ComboBoxHelper.Watermark="请选择装备类型..." Height="40" Width="200" Margin="5,0,800,0"
pu:ComboBoxHelper.ItemHeight="50"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="True"
pu:ComboBoxHelper.SearchTextChanged="cbo_equInfo_SearchTextChanged"
pu:ComboBoxHelper.SearchTextBoxWatermark="在此搜索装备类型..." SelectionChanged="cbo_equInfo_SelectionChanged" HorizontalAlignment="Left"
>
</ComboBox>
<ComboBox Name="cbo_size_info" Grid.Row="0" pu:ComboBoxHelper.Watermark="请选择装备号型..." Height="40" Width="200" Margin="225,0,599,0"
pu:ComboBoxHelper.ItemHeight="50"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="True"
pu:ComboBoxHelper.SearchTextChanged="cbo_equSizeInfo_SearchTextChanged"
pu:ComboBoxHelper.SearchTextBoxWatermark="在此搜索装备号型..." SelectionChanged="cbo_equSizeInfo_SelectionChanged" HorizontalAlignment="Left"
>
</ComboBox>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" Background="#C8FF7F00" Click="OnExport_Click" pu:ButtonHelper.HoverBrush="#FF7F00" Width="150" Height="35" Margin="0,0,10,0" FontSize="24">导出物资信息</Button>
<DataGrid FontSize="24" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" EnableRowVirtualization="False" Margin="3 5 3 0" HeadersVisibility="Column"
pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False"
AutoGenerateColumns="False" LoadingRow="OnDataGridLoadingRow" SelectionMode="Single" Name="dg_epc" pu:DataGridHelper.ColumnHorizontalContentAlignment="Center" CanUserSortColumns="True"
ColumnHeaderHeight="60" RowHeight="60" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" BorderThickness="0,0,0,1" VerticalAlignment="Stretch"
>
<DataGrid.Columns>
<DataGridTemplateColumn Header="序号" MinWidth="80" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="24" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn IsReadOnly="True" Header="EPC" Binding="{Binding EPC}" Width="*"></DataGridTextColumn>
<!--<DataGridTextColumn IsReadOnly="True" Header="识别数量" Binding="{Binding scanQty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Width="150"></DataGridTextColumn>-->
</DataGrid.Columns>
</DataGrid>
<!--<ComboBox Name="cbo_type" Grid.Row="1" Grid.Column="1" pu:ComboBoxHelper.Watermark="请选择入库类型..." Height="40" Margin="5,0,5,0">
<ComboBoxItem>采购</ComboBoxItem>
<ComboBoxItem>借用</ComboBoxItem>
<ComboBoxItem>跨库借用</ComboBoxItem>
<ComboBoxItem>库存调拨</ComboBoxItem>
<ComboBoxItem>维修</ComboBoxItem>
<ComboBoxItem>跨库归还</ComboBoxItem>
</ComboBox>-->
<TextBlock Grid.Row="3" Grid.ColumnSpan="2" Margin="0,0,220,0" Foreground="Red" Name="txt_stat" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="24">状态:读写器启动失败</TextBlock>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" IsEnabled="false" Name="btn_inv" HorizontalAlignment="Right" Click="OnInv_Click" Width="120" Height="35" Margin="0,0,273,0" FontSize="24">开始读取</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="120" Height="35" Margin="0,0,140,0" Click="OnSave_Click" FontSize="24">提交入库</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Right" Background="#C8FF7F00" Click="OnExit_Click" pu:ButtonHelper.HoverBrush="#FF7F00" Width="120" Height="35" Margin="0,0,10,0" FontSize="24">返回</Button>
</Grid>
</pu:WindowX>
using JmpRfidLp;
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Panuon.UI.Silver.Core;
using MessageBox = System.Windows.MessageBox;
using System.Reflection;
using Newtonsoft.Json;
namespace LiteChannel
{
/// <summary>
/// StoreWindow.xaml 的交互逻辑
/// </summary>
public partial class InitWindow : WindowX, IComponentConnector
{
private IReaderHelper reader;
private List<TagInfoData> SourcesList = new List<TagInfoData>();
private Queue<string> _epcQueue = new Queue<string>();
private CancellationTokenSource tokenSource = new CancellationTokenSource();
private ObservableCollection<TagInfoData> RefreshSourcesList = new ObservableCollection<TagInfoData>();
private Dictionary<ulong, string> dic_equ = new Dictionary<ulong, string>();
private List<order_equ> orderWzdm = new List<order_equ>();
public event Action OnApplySuc;
public equ_info equInfo = null;
public equ_size_info equSizeInfo = null;
public InitWindow()
{
InitializeComponent();
dg_epc.AutoGenerateColumns = false;
cbo_info.ItemsSource = LiteCaChe.EquInfos;
cbo_info.DisplayMemberPath = "name";
cbo_info.SelectedValuePath = "id";
cbo_size_info.DisplayMemberPath = "name";
cbo_size_info.SelectedValuePath = "id";
}
private void OnWindow_Loaded(object sender, RoutedEventArgs e)
{
ConnectReader();
EpcHandleTask(tokenSource.Token);
}
private bool ConnectReader()
{
try
{ //启动读写器
switch (LiteCaChe.SysConfig.ReaderType)
{
case 0:
{
reader = new JmpRfidLpReaderHelper(LiteCaChe.SysConfig.ComMouth);
break;
}
case 1:
{
reader = new USBRFIDReaderHelper();
break;
}
}
reader.OnInventory += OnRadioInventory;
var state = reader.Open();
if (state)
{
var version = reader.GetFWVerion();
if (string.IsNullOrEmpty(version))
{
txt_stat.Text = "状态:读写器版本读取失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
reader.InventoryStop();
reader.SetPALevel(1);
reader.SetTxPower(0, true, 24);
txt_stat.Text = "状态:读写器连接成功";
txt_stat.Foreground = new SolidColorBrush(Colors.Green);
btn_inv.IsEnabled = true;
return true;
}
else
{
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
catch (Exception ex)
{
reader = null;
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
private void OnRadioInventory(TagInfoData args)
{
if (!SourcesList.Any(t => t.EPC == (args.EPC))
&& !LiteCaChe.InventoryInfos.Any(t => t.epc == (args.EPC))
)
{
//有效标签
lock (_epcQueue)
{
if (!_epcQueue.Contains(args.EPC))
{
_epcQueue.Enqueue(args.EPC);
}
}
}
}
private void EpcHandleTask(CancellationToken token)
{
Task.Run(() =>
{
var epcList = new List<string>();
while (true)
{
if (token.IsCancellationRequested)
{
break;
}
lock (_epcQueue)
{
if (_epcQueue.Count != 0)
{
epcList = _epcQueue.ToList();
_epcQueue.Clear();
}
else
{
Thread.Sleep(500);
continue;
}
}
foreach (var epc in epcList)
{
//再次检查是否被阻塞阶段添加标签
if (!SourcesList.Any(t => t.EPC == (epc)))
{
var tempEpc = epc;
var tmp_info = new TagInfoData()
{
EPC = tempEpc
};
SourcesList.Add(tmp_info);
Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action<List<TagInfoData>>((x) =>
{
RefreshSourcesList = new ObservableCollection<TagInfoData>(x);
dg_epc.ItemsSource = RefreshSourcesList;
}), SourcesList);
}
}
epcList.Clear();
}
}, token);
}
private void OnInv_Click(object sender, RoutedEventArgs e)
{
if (btn_inv.Content.ToString() == "开始读取")
{
reader?.InventoryStart();
btn_inv.Content = "停止读取";
}
else
{
reader?.InventoryStop();
btn_inv.Content = "开始读取";
}
}
private void OnExit_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
tokenSource.Cancel();
if (reader?.IsOpen() ?? false)
{
reader?.InventoryStop();
reader?.Close();
}
}
private void OnDataGridLoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() + 1;
}
private void OnSave_Click(object sender, RoutedEventArgs e)
{
if (SourcesList != null && SourcesList.Count > 0)
{
List<rfid_info> epcList = new List<rfid_info>();
SourcesList.Select(t => t.EPC).ToList()
.ForEach(s => epcList.Add(new rfid_info()
{
RFID = s
}));
if (btn_inv.Content.ToString() == "停止读取")
{
OnInv_Click(default, default);
}
if (epcList.Count > 0)
{
//if (string.IsNullOrEmpty(cbo_type.Text))
//{
// MessageBox.Show(this, "入库类型未选择,请选择后重试!", "出库提示", MessageBoxButton.OK, MessageBoxImage.Information);
//}
//else
{
if (btn_inv.Content.ToString() == "停止读取")
{
OnInv_Click(default, default);
}
if (equInfo == null || equSizeInfo == null)
{
MessageBox.Show(this, "请选择装备类型/号型", "初始化提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
var _res = HttpHelper.RfidInitStore(epcList, equInfo, equSizeInfo);
MessageBox.Show(this, _res.Item2, "初始化提示", MessageBoxButton.OK, MessageBoxImage.Information);
if (_res.Item1)
{
OnApplySuc?.Invoke();
this.Close();
}
}
}
else
{
MessageBox.Show(this, "未读取到可以初始化的epc", "初始化提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
private void cbo_equInfo_SearchTextChanged(object sender, SearchTextChangedEventArgs e)
{
if (!IsLoaded)
return;
cbo_info.ItemsSource = LiteCaChe.EquInfos.Where(t => t.name.Contains(e.Text));
}
private void cbo_equInfo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
equInfo = cbo_info.SelectedItem as equ_info;
if (equInfo != null)
{
//号型
cbo_size_info.ItemsSource = equInfo.sizeList;
cbo_size_info.SelectedIndex = 0;
}
else
{
//置空
cbo_size_info.ItemsSource = new List<equ_size_info>();
}
}
private void cbo_equSizeInfo_SearchTextChanged(object sender, SearchTextChangedEventArgs e)
{
if (!IsLoaded)
return;
if (string.IsNullOrEmpty(equInfo?.id))
{
//置空
cbo_size_info.ItemsSource = new List<equ_size_info>();
}
else
{
cbo_size_info.ItemsSource = LiteCaChe.EquInfos.Where(t => t.name.Contains(e.Text));
}
}
private void cbo_equSizeInfo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
equSizeInfo = cbo_size_info.SelectedItem as equ_size_info;
}
private void OnExport_Click(object sender, RoutedEventArgs e)
{
try
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "导出物资信息";
//saveFileDialog.InitialDirectory = ;
saveFileDialog.OverwritePrompt = true;
saveFileDialog.AddExtension = true;
saveFileDialog.DefaultExt = "json";
saveFileDialog.Filter = "json文件|*.json";
saveFileDialog.FileName = "invData.json";
if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return; //被点了取消
}
var filename = saveFileDialog.FileName; //得到保存路径及文件名
File.WriteAllText(filename, JsonConvert.SerializeObject(LiteCaChe.InventoryInfos.Where(x => x.state == 0)));
MessageBox.Show("导出成功");
}
catch (Exception exception)
{
MessageBox.Show("导出失败");
}
}
}
}
<pu:WindowX x:Class="LiteChannel.InvInfoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
xmlns:usControl="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Maximized"
Loaded="MainWindowLoaded" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"
Closing="OnWindow_Closing" pu:WindowXCaption.DisableCloseButton="True">
<Grid x:Name="g_main">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.3*"/>
</Grid.ColumnDefinitions>
<Button Name="btn_onInStore" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,10,0" Click="OnInit_Click" pu:ButtonHelper.Icon="&#xf085;" Content="初始化" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<!--<Button Grid.Column="1" Margin="0,0,10,0" Click="OnOutStoreNoOrder_Click" pu:ButtonHelper.Icon="&#xf085;" Content="本仓库借用出库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>-->
<Button Grid.Row="0" Grid.Column="2" Click="OnRefresh_Click" pu:ButtonHelper.Icon="&#xf202;" Margin="10,0,10,0" Content="刷新" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<Button Grid.Row="0" Grid.Column="3" Click="OnClose_Click" pu:ButtonHelper.Icon="&#xf2d3;" Margin="10,0,10,0" Content="返回主页" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22" Background="#C8FF0000" pu:ButtonHelper.HoverBrush="#FF0000" ></Button>
<DataGrid Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" EnableRowVirtualization="False" Margin="3 5 3 0" HeadersVisibility="Column"
pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False" Grid.ColumnSpan="4"
AutoGenerateColumns="False" LoadingRow="OnDataGridLoadingRow" SelectionMode="Single" Name="dg_order" pu:DataGridHelper.ColumnHorizontalContentAlignment="Center" CanUserSortColumns="True" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="序号" MinWidth="80" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="18" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn IsReadOnly="True" Header="装备类型" Width="*" MinWidth="115" FontSize="18" Binding="{Binding equipmentDetailName}" />
<DataGridTextColumn IsReadOnly="True" Header="装备号型" Width="*" MinWidth="100" FontSize="18" Binding="{Binding equipmentSizeName}" />
<DataGridTextColumn IsReadOnly="True" Header="EPC" Width="3*" MinWidth="100" FontSize="18" Binding="{Binding epc}" />
<DataGridTextColumn IsReadOnly="True" Header="在库状态" Width="*" MinWidth="100" FontSize="18" Binding="{Binding stateName}" />
<!--<DataGridTextColumn IsReadOnly="True" Header="装备信息" Width="*" MinWidth="100" FontSize="18" Binding="{Binding equNames}"/>-->
<!--<DataGridTextColumn IsReadOnly="True" Header="单据数量" Width="100" MinWidth="100" FontSize="18" Binding="{Binding orderQuantity}"/>-->
<DataGridTemplateColumn Header="操作" Width="250" MinWidth="250" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="删除" pu:ButtonHelper.Icon="&#xf20e;" pu:ButtonHelper.CornerRadius="5" Click="OnDelete_Click" Padding="8" Margin="2,8,2,8" >
</Button>
<!--<Button Content="查看明细" pu:ButtonHelper.Icon="&#xf1cb;" pu:ButtonHelper.CornerRadius="5" Click="OnShowDetail_Click" Padding="8" Margin="5,8,5,8" >
</Button>-->
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<usControl:PageControl IsEnabled="{Binding BindButton}" x:Name="d_pager" Margin="0,0,0,0" Grid.Row="2" TotalRecord="{Binding TotalRecord,Mode=TwoWay}" TotalPage="{Binding PageTotal,Mode=TwoWay}" PageSize="{Binding PageSize,Mode=TwoWay}" PageIndex="{Binding PageIndex,Mode=TwoWay}" Grid.ColumnSpan="4"
Grid.Column="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="OnPageChanged">
<i:InvokeCommandAction Command="{Binding OnPageChangeCmd}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</usControl:PageControl>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.CommandWpf;
using System.ComponentModel;
using JmpCommon;
namespace LiteChannel
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class InvInfoWindow : WindowX, IComponentConnector
{
private PageControl2Model model;
public InvInfoWindow()
{
InitializeComponent();
model = new PageControl2Model(this);
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
DataContext = model;
//加载单据数据
model.PageIndex = 1;
LoadData();
}
public void LoadData()
{
var tmp = LiteCaChe.InventoryInfos
.OrderBy(x => x.equipmentDetailName)
.ThenBy(x => x.equipmentSizeName)
.Skip((model.PageIndex - 1) * model.PageSize).Take(model.PageSize);
model.TotalRecord = LiteCaChe.InventoryInfos.Count;
model.PageTotal = model.TotalRecord == 0 ? 0 : (model.TotalRecord + model.PageSize - 1) / model.PageSize;
dg_order.ItemsSource = tmp;
}
private void OnDataGridLoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() + 1;
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
private void OnRefresh_Click(object sender, RoutedEventArgs e)
{
model.PageIndex = 1;
LoadData();
}
private void OnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
//Application.Current.Shutdown();
//Process.GetCurrentProcess().Kill();
}
private void OnInit_Click(object sender, RoutedEventArgs e)
{
var from = new InitWindow();
from.Owner = this;
//from.OnApplySuc += LoadData;
from.ShowDialog();
OnRefresh_Click(null, null);
}
private void OnDelete_Click(object sender, RoutedEventArgs e)
{
if (dg_order.SelectedItem != null)
{
var item = dg_order.SelectedItem as inventory_info;
if (MessageBox.Show($"是否确定删除装备?同时出入库记录也会被删除\r\n装备名:{item.equipmentDetailName}-{item.equipmentSizeName}\r\nEPC:{item.epc}", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
//删除装备
LiteDBHelper.DeleteInventory(item);
//更新缓存
LiteCaChe.InventoryInfos = LiteDBHelper.FindAllInventory();
LoadData();
}
}
}
}
public class PageControl2Model : INotifyPropertyChanged
{
private bool _bindButton = true;
public bool BindButton
{
get { return _bindButton; }
set
{
_bindButton = value;
OnPropertyChanged("BindButton");
}
}
private int _total = 0;
public int TotalRecord
{
get { return _total; }
set
{
_total = value;
OnPropertyChanged("TotalRecord");
}
}
private int _page = 0;
public int PageIndex
{
get { return _page; }
set
{
_page = value;
OnPropertyChanged("PageIndex");
}
}
private int _pageTotal = 0;
public int PageTotal
{
get { return _pageTotal; }
set
{
_pageTotal = value;
OnPropertyChanged("PageTotal");
}
}
private int _pageSize = 50;
public int PageSize
{
get { return _pageSize; }
set
{
_pageSize = value;
OnPropertyChanged("PageSize");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string strPropertyInfo)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(strPropertyInfo));
}
}
private readonly InvInfoWindow _mainWindow;
public RelayCommand OnPageChangeCmd { get; set; }
public PageControl2Model(InvInfoWindow mainWindow)
{
_mainWindow = mainWindow;
PageSize = 10;
OnPageChangeCmd = new RelayCommand(OnPageChange);
}
private void OnPageChange()
{
_mainWindow.LoadData();
}
}
}
using GalaSoft.MvvmLight;
using LiteChannel.Commons;
using LiteChannel.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace LiteChannel
{
public static class LiteCaChe
{
public static List<sync_police> PoliceList { get; set; }
public static string OrgId { get; set; }
public static string OrgCode { get; set; }
public static string PoliceId { get; set; }
public static string UserId { get; set; }
public static string UserName { get; set; }
public static List<equ_info> EquInfos { get; set; }
public static List<inventory_info> InventoryInfos { 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);
//预处理
if (config.DomainUrl == "http://41.204.7.134:18761/api/service")
{
config.DomainUrl = "http://41.190.20.132:18761/api/service";
}
if (config.UserLogin == "http://41.204.7.134:10004/auth/userLogin")
{
config.UserLogin = "http://41.190.20.132:10004/auth/userLogin";
}
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 : ViewModelBase
{
public const string SoftUpdate = "/api/SoftUpdate/GetLastUpdate";
public const string GetEquInfo = "/api/EquipmentDetail/GetListEquipmentDetail";
public const string GetStoreInfo = "/api/Warehouse/GetListOrgWarehouse";
public const string GetOrderInfo = "/api/Inventory/GetOrderInfo";
public const string GetOrderDetail = "/api/Inventory/GetOrderDetail";
public const string OpenOrderWorkUrl = "/api/Inventory/OpenThisOrderAndCloseOther";
public const string UploadUrl = "/api/Inventory/UploadRFIDNew";
public const string CloseOrderUrl = "/api/Inventory/CloseOrder";
public const string GetPolices = "/api/ChannelCfg/GetOrgStaff";
public const string UploadFace = "/api/ChannelCfg/UploadFace";
public const string UpdateFinger = "/api/ChannelCfg/UpdateFinger";
public const string GetInvListByEpc = "/api/Inventory/GetInvListByEpc";
public const string GetWarehouseById = "/api/Warehouse/GetWarehouseById";
public const string SetWarehouseState = "/api/Inventory/SetWarehouseState";
public const string GetEpcListByBoxMarkEpc = "/api/EquipmentBoxMark/GetEpcListByBoxMarkEpc";
public const string GetAllInventoryList = "/api/Inventory/GetAllInventoryList";
public const string AddAndApprovalBorrowOrder = "/api/Borrow/AddAndApprovalBorrowOrder";
public const string AddAndApprovalBorrowJYOrder = "/api/Borrow/AddAndApprovalBorrowJYOrder";
public const string GetServerime = "/api/ChannelCfg/GetServerTime";
public Config()
{
AppTitle = "充电台出入库v" + Application.ResourceAssembly.GetName().Version;
AppVersion = Application.ResourceAssembly.GetName().Version.ToString();
AppCode = "10003";
DomainUrl = "http://41.190.20.132:18761/api/service";
UserLogin = "http://41.190.20.132:10004/auth/userLogin";
ComMouth = "COM4";
WarehouseID = "d8192b23-0ec9-4b2e-a47d-f6780a66a880";
ApiVersion = "1.0";
AppKey = "q6t0lEKOmMg5Tm+dg3XdZQ==";
SecretKey = "ba4d855b3b83eab441a51ea9bd9d9671";
FaceAddress = "192.168.8.35";
FaceUser = "admin";
FacePwd = "junmp123";
FacePort = "8000";
IsUseFace = true;
IsEnabledShelf = false;
ShelfAddress = "http://192.168.3.128:38080/api/BoundDocuments";
IsAutoUpdate = true;
AutoUpdateTime = 0;
ReaderType = 0;
}
/// <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 ComMouth { get; set; }
public string WarehouseID { get; set; }
public string ApiVersion { get; set; }
public string AppKey { get; set; }
public string SecretKey { get; set; }
public string FaceAddress { get; set; }
public string FaceUser { get; set; }
public string FacePwd { get; set; }
public string FacePort { get; set; }
public bool IsUseFace { get; set; }
public bool IsEnabledShelf { get; set; }
public string ShelfAddress { get; set; }
/// <summary>
/// 是否自动更新
/// </summary>
public bool IsAutoUpdate { get; set; }
/// <summary>
/// 自动更新时间(小时)
/// </summary>
public int AutoUpdateTime { get; set; }
/// <summary>
/// 读写器类型
/// 0 钧普
/// 1 索力得
/// </summary>
public int ReaderType { get; set; }
[JsonIgnore]
public static new bool IsInDesignModeStatic { get; }
}
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; }
}
}
<?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>{105D4340-4411-4B91-AD04-7A1EF2F7D3C8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>LiteChannel</RootNamespace>
<AssemblyName>LiteChannelDJB</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<IsWebBootstrapper>false</IsWebBootstrapper>
<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>
<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>
<LangVersion>latest</LangVersion>
</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>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>1.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonServiceLocator, Version=2.0.5.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.2.0.5\lib\net46\CommonServiceLocator.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.4.1.0, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="JmpRfidLp">
<HintPath>..\Lib\JmpRfidLp.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.8.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.8\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignColors, Version=1.2.6.1513, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.6\lib\net45\MaterialDesignColors.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignThemes.Wpf, Version=3.1.3.1513, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.3.1.3\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Panuon.UI.Silver, Version=1.1.3.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.UI.Silver.1.1.3.2\lib\net45\Panuon.UI.Silver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Commons\ReaderHelper.cs" />
<Compile Include="Commons\Win32API.cs" />
<Compile Include="CHCNetSDK.cs" />
<Compile Include="Commons\EpcConvert.cs" />
<Compile Include="Commons\HttpHelper.cs" />
<Compile Include="Commons\JmpDes.cs" />
<Compile Include="Commons\Log.cs" />
<Compile Include="LiteCaChe.cs" />
<Compile Include="AutoClosingMessageBox.xaml.cs">
<DependentUpon>AutoClosingMessageBox.xaml</DependentUpon>
</Compile>
<Compile Include="LiteDBHelper.cs" />
<Compile Include="Models\inventory_out_in_log.cs" />
<Compile Include="InvInfoWindow.xaml.cs">
<DependentUpon>InvInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="OutInWindow.xaml.cs">
<DependentUpon>OutInWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Models\BaseJpWarehouse.cs" />
<Compile Include="Models\respone_upload.cs" />
<Compile Include="Models\request_sign.cs" />
<Compile Include="Models\response_BoxMarkModel.cs" />
<Compile Include="Models\inventory_info.cs" />
<Compile Include="Models\sync_police.cs" />
<Compile Include="Models\rfid_res.cs" />
<Compile Include="Models\upload_info.cs" />
<Compile Include="Models\scan_info.cs" />
<Compile Include="Models\order_equ.cs" />
<Compile Include="Models\equ_info.cs" />
<Compile Include="Models\order_info.cs" />
<Compile Include="Models\respone.cs" />
<Compile Include="Models\soft_update.cs" />
<Compile Include="Models\store_info.cs" />
<Compile Include="Setting.xaml.cs">
<DependentUpon>Setting.xaml</DependentUpon>
</Compile>
<Compile Include="InitWindow.xaml.cs">
<DependentUpon>InitWindow.xaml</DependentUpon>
</Compile>
<Compile Include="StoreInWindow.xaml.cs">
<DependentUpon>StoreInWindow.xaml</DependentUpon>
</Compile>
<Compile Include="UsControl\PageControl.xaml.cs">
<DependentUpon>PageControl.xaml</DependentUpon>
</Compile>
<Compile Include="VOrderInfo.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="StoreOutWindow.xaml.cs">
<DependentUpon>StoreOutWindow.xaml</DependentUpon>
</Compile>
<Page Include="AutoClosingMessageBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="LoginWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="LoginWindow.xaml.cs">
<DependentUpon>LoginWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="InvInfoWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="OutInWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Setting.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="InitWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="StoreInWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="StoreOutWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UsControl\PageControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="ThirdPackages\plugin\hik\GdiPlus.lib" />
<None Include="ThirdPackages\plugin\hik\HCCore.lib" />
<None Include="ThirdPackages\plugin\hik\HCNetSDK.lib" />
<None Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCAlarm.lib" />
<None Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCGeneralCfgMgr.lib" />
<None Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCPreview.lib" />
<None Include="ThirdPackages\plugin\hik\LocalXml.zip" />
<None Include="ThirdPackages\plugin\hik\log4cxx.properties" />
<None Include="ThirdPackages\plugin\hik\PlayCtrl.lib" />
<None Include="ThirdPackages\tts\common.jet" />
<None Include="ThirdPackages\tts\xiaofeng.jet" />
<None Include="ThirdPackages\tts\xiaoyan.jet" />
<Resource Include="Font\iconfont.ttf" />
<None Include="config.json" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\1.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="1.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\3.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\4.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\2.png" />
</ItemGroup>
<ItemGroup>
<Content Include="ThirdPackages\msc.dll" />
<Content Include="ThirdPackages\msc_x64.dll" />
<Content Include="ThirdPackages\plugin\hik\AudioRender.dll" />
<Content Include="ThirdPackages\plugin\hik\EagleEyeRender.dll" />
<Content Include="ThirdPackages\plugin\hik\gdiplus.dll" />
<Content Include="ThirdPackages\plugin\hik\HCCore.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDK.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\AnalyzeData.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\AudioIntercom.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCAlarm.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCCoreDevCfg.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCDisplay.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCGeneralCfgMgr.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCIndustry.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCPlayBack.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCPreview.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\HCVoiceTalk.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\libiconv2.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\msvcr90.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\OpenAL32.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\StreamTransClient.dll" />
<Content Include="ThirdPackages\plugin\hik\HCNetSDKCom\SystemTransform.dll" />
<Content Include="ThirdPackages\plugin\hik\hlog.dll" />
<Content Include="ThirdPackages\plugin\hik\hpr.dll" />
<Content Include="ThirdPackages\plugin\hik\HXVA.dll" />
<Content Include="ThirdPackages\plugin\hik\libeay32.dll" />
<Content Include="ThirdPackages\plugin\hik\MP_Render.dll" />
<Content Include="ThirdPackages\plugin\hik\MP_VIE.dll" />
<Content Include="ThirdPackages\plugin\hik\NPQos.dll" />
<Content Include="ThirdPackages\plugin\hik\PlayCtrl.dll" />
<Content Include="ThirdPackages\plugin\hik\ssleay32.dll" />
<Content Include="ThirdPackages\plugin\hik\SuperRender.dll" />
<Content Include="ThirdPackages\plugin\hik\YUVProcess.dll" />
<Content Include="ThirdPackages\plugin\hik\zlib1.dll" />
<Content Include="ThirdPackages\USBUHFPlatform.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.3.1.3\build\MaterialDesignThemes.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</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'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>xcopy $(ProjectDir)ThirdPackages\* $(TargetDir) /S /Y
</PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using LiteChannel.Commons;
using LiteChannel.Models;
namespace JmpCommon
{
public static class LiteDBHelper
{
public static bool AddOrUpdate(TagCacheInfo entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
if (entity.Id == null || entity.Id == 0)
{
var res = col.Insert(entity).AsInt32 > 0;
if (!res) { Log.WorkLog("EPC缓存写入失败", "写入失败"); }
else { Log.WorkLog("EPC缓存写入成功", "写入成功"); }
return res;
}
else
{
entity.LastDate = DateTime.Now;
var res = col.Update(entity);
if (!res) { Log.WorkLog("EPC缓存更新失败", "更新失败"); }
else { Log.WorkLog("EPC缓存更新成功", "更新成功"); }
return res;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static TagCacheInfo FindByEpc(string epc, string warehouseId, int state = -1)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
if (state == -1)
{
return col.FindOne(x => x.Epc.Contains(epc) && x.WarehouseId == warehouseId);
}
else
{
return col.FindOne(x => x.Epc.Contains(epc) && x.CurrentState == state && x.WarehouseId == warehouseId);
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static TagCacheInfo FindByEpc(string epc, string warehouseId)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
return col.FindOne(x => x.Epc.Contains(epc) && x.WarehouseId == warehouseId);
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static bool DeleteAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
return col.DeleteAll() >= 0;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static void RefreshAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
var list = col.FindAll().ToList();
list.ForEach(s =>
{
s.LastDate = DateTime.Now.Date;
col.Update(s);
});
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
}
}
public static List<SyncCardInfo> FindAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
return col.FindAll().ToList();
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static bool AddOrUpdate(SyncCardInfo entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
if (entity == null || entity.Id == 0)
{
var res = col.Insert(entity).AsInt32 > 0;
if (!res) { Log.WorkLog("人员数据写入失败", "写入失败"); }
else { Log.WorkLog("人员数据写入成功", "写入成功"); }
return res;
}
else
{
var res = col.Update(entity);
if (!res) { Log.WorkLog("人员数据更新失败", "更新失败"); }
else { Log.WorkLog("人员数据更新成功", "更新成功"); }
return res;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool DeleteByCard(string cardNo)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
return col.DeleteMany(t => t.CardNo == cardNo) >= 0;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool DeleteByCard(Expression<Func<SyncCardInfo, bool>> predicate)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
var res = col.DeleteMany(predicate) >= 0;
return res;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool AddOrUpdateInventory(inventory_info entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<inventory_info>(nameof(inventory_info));
var old = col.FindById(entity.Id);
if (old == null)
{
col.Insert(entity);
}
else
{
old.state = entity.state;
col.Update(old);
}
return true;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool DeleteInventory(inventory_info entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<inventory_info>(nameof(inventory_info));
var col2 = db.GetCollection<inventory_out_in_log>(nameof(inventory_out_in_log));
col2.DeleteMany(x => x.epc == entity.epc);
col.Delete(entity.Id);
return true;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static List<inventory_info> FindAllInventory()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<inventory_info>(nameof(inventory_info));
return col.FindAll().ToList();
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static PagedList<inventory_out_in_log> GetOutInLogs(string type, int page, int size)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<inventory_out_in_log>(nameof(inventory_out_in_log));
var data = col.Find(x => x.state == (type == "出库" ? 1 : 0))
.OrderByDescending(x => x.createTime)
.ToList();
var pagedList = new PagedList<inventory_out_in_log>()
{
totalElements = data.Count,
content = data.Skip((page - 1) * size).Take(size).ToList()
};
return pagedList;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static bool AddOutInLog(inventory_out_in_log entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<inventory_out_in_log>(nameof(inventory_out_in_log));
col.Insert(entity);
return true;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
}
public class TagCacheInfo
{
public string WarehouseId { get; set; }
public int Id { get; set; }
public string Epc { get; set; }
public DateTime LastDate { get; set; }
public int CurrentState { get; set; }
}
public class SyncCardInfo
{
public string orgId { get; set; }
public int Id { get; set; }
public string PoliceId { get; set; }
public string CardNo { get; set; }
public string OrgId { get; set; }
public string FacePic { get; set; }
public DateTime SyncDate { get; set; }
public bool IsSyncCard { get; set; }
public bool IsSyncFace { get; set; }
public bool IsSyncFinger { get; set; }
public bool IsPushedPic { get; set; }
public List<FingerInfo> FingerList { get; set; }
}
}
<pu:WindowX x:Class="LiteChannel.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
mc:Ignorable="d" Icon="1.ico"
Title="射频出入库系统" Height="250" Width="400" Loaded="Window_Loaded" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" >
<Window.Resources>
<ResourceDictionary>
<RoutedUICommand x:Key="OnShowConfig" Text="配置管理"/>
</ResourceDictionary>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+ALT+J" Command="{ StaticResource OnShowConfig}" />
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource OnShowConfig}"
CanExecute="OnShowConfig_CanExecute"
Executed="OnShowConfig_Executed"/>
</Window.CommandBindings>
<Window.Effect>
<DropShadowEffect BlurRadius="10" Color="#FF858484" Direction="90" ShadowDepth="2"/>
</Window.Effect>
<Grid >
<Grid x:Name="g_body" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="300">
<TextBox Height="30" Name="txtUser"
Width="300"
pu:TextBoxHelper.Watermark="请输入用户名"
pu:TextBoxHelper.Icon="&#xf11c;"
FontFamily="/Font/#iconfont"
pu:TextBoxHelper.FocusedBorderBrush="#B5B5B5"
pu:TextBoxHelper.FocusedShadowColor="#B5B5B5"
pu:TextBoxHelper.IsClearButtonVisible="True" />
</StackPanel>
<StackPanel Margin="0 0 0 0" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Width="300">
<PasswordBox Height="30" Name="txtPwd" KeyDown="OnKeyDown"
Width="300"
FontFamily="/Font/#iconfont"
pu:PasswordBoxHelper.Watermark="请输入密码"
pu:PasswordBoxHelper.Icon="&#xf11c;"
pu:PasswordBoxHelper.FocusedBorderBrush="#B5B5B5"
pu:PasswordBoxHelper.FocusedShadowColor="#B5B5B5"
pu:PasswordBoxHelper.IsShowPwdButtonVisible="True" />
</StackPanel>
<Button Grid.Row="3" pu:ButtonHelper.CornerRadius="4" FontSize="20" Content="登录" Margin="127,10,116.6,0" Height="45" Width="150" HorizontalAlignment="Center" VerticalAlignment="Top" Click="OnLoginClick"/>
</Grid>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Panuon.UI.Silver;
using Panuon.UI.Silver.Core;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
namespace LiteChannel
{
/// <summary>
/// Login.xaml 的交互逻辑
/// </summary>
public partial class LoginWindow : WindowX, IComponentConnector
{
private bool bLogin = false;
public LoginWindow()
{
InitializeComponent();
txtUser.Focus();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ReadHistory();
}
private void Sb_Completed(object sender, EventArgs e)
{
this.Close();
Process.GetCurrentProcess().Kill();
}
private async void OnLoginClick(object sender, RoutedEventArgs e)
{
if (bLogin) { return; }
if (string.IsNullOrEmpty(txtUser.Text))
{
bLogin = false;
MessageBox.Show(this, "用户名未填写", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (string.IsNullOrEmpty(txtPwd.Password))
{
bLogin = false;
MessageBox.Show(this, "密码未填写", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
var handler = PendingBox.Show("系统登录中...", "", false, Application.Current.MainWindow, new PendingBoxConfigurations()
{
LoadingForeground = "#5DBBEC".ToColor().ToBrush(),
MaxWidth = 250,
MinHeight = 110,
MinWidth = 250,
MaxHeight = 110,
ButtonBrush = "#5DBBEC".ToColor().ToBrush(),
});
var user = txtUser.Text;
var pwd = txtPwd.Password;
var lg_res = await Task.Run(() =>
{
var result = HttpHelper.UserLogin(user, pwd);
return result;
});
if (lg_res != null)
{
SaveHistory();
handler.UpdateMessage("系统登录成功!");
LiteCaChe.OrgId = lg_res.baseJpOrganization?.id ?? "";
LiteCaChe.OrgCode = lg_res.baseJpOrganization?.code?.Substring(0, 6) ?? "";
LiteCaChe.PoliceId = lg_res.policeman?.id ?? "";
LiteCaChe.UserId = lg_res.id;
LiteCaChe.UserName = lg_res.username;
new MainWindow().Show();
this.ShowInTaskbar = false;
this.Hide();
}
else
{
handler.UpdateMessage("系统登录失败!");
}
await Task.Delay(500);
handler.Close();
}
private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
OnLoginClick(sender, new RoutedEventArgs());
}
}
private void OnShowConfig_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void OnShowConfig_Executed(object sender, ExecutedRoutedEventArgs e)
{
Setting settings = new Setting();
settings.ShowDialog();
}
private void SaveHistory()
{
var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "history.txt";
if (!File.Exists(path))
{
File.Create(path);
}
var txt = txtUser.Text + "|" + txtPwd.Password;
File.WriteAllText(path, txt, 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)
{
txtUser.Text = record[0];
txtPwd.Password = record[1];
}
}
}
}
}
<pu:WindowX x:Class="LiteChannel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
xmlns:usControl="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Maximized"
Loaded="MainWindowLoaded" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"
Closing="OnWindow_Closing" pu:WindowXCaption.DisableCloseButton="True">
<pu:WindowX.Background>
<ImageBrush ImageSource="Resources/1.png"/>
</pu:WindowX.Background>
<Grid x:Name="g_main">
<Grid.RowDefinitions>
<RowDefinition Height="0.18*"/>
<RowDefinition Height="0.06*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.4*"/>
<RowDefinition Height="0.28*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<!--<ComboBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" x:Name="cbo_warehouse"
Width="auto" Height="50" Margin="10,0,10,0"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
FontSize="20"
MaxDropDownHeight="400"
pu:ComboBoxHelper.ItemHeight="50"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="True"
pu:ComboBoxHelper.SearchTextChanged="cbo_warehouse_SearchTextChanged"
pu:ComboBoxHelper.SearchTextBoxWatermark="在此搜索仓库..." SelectionChanged="cbo_warehouse_SelectionChanged"></ComboBox>-->
<Border Grid.Row="3" Grid.Column="1" Margin="25,0,25,0">
<Border.BorderBrush>
<ImageBrush ImageSource="Resources/3.png"/>
</Border.BorderBrush>
<Border.Background>
<ImageBrush ImageSource="Resources/3.png"/>
</Border.Background>
<Button Click="OnInStore_Click" FontFamily="{StaticResource FontAwesome}" FontSize="30" Foreground="{x:Null}" Margin="0,75,0,0">
<pu:ButtonHelper.ButtonStyle>
<pu:ButtonStyle>Link</pu:ButtonStyle>
</pu:ButtonHelper.ButtonStyle>
</Button>
</Border>
<Border Grid.Row="3" Grid.Column="2" Margin="25,0,25,0">
<Border.BorderBrush>
<ImageBrush ImageSource="Resources/4.png"/>
</Border.BorderBrush>
<Border.Background>
<ImageBrush ImageSource="Resources/4.png"/>
</Border.Background>
<Button Click="OnOutStore_Click" FontFamily="{StaticResource FontAwesome}" FontSize="30" Foreground="{x:Null}" Margin="0,75,0,0">
<pu:ButtonHelper.ButtonStyle>
<pu:ButtonStyle>Link</pu:ButtonStyle>
</pu:ButtonHelper.ButtonStyle>
</Button>
</Border>
<Border Grid.Row="3" Grid.Column="3" Margin="25,0,25,0">
<Border.BorderBrush>
<ImageBrush ImageSource="Resources/2.png"/>
</Border.BorderBrush>
<Border.Background>
<ImageBrush ImageSource="Resources/2.png"/>
</Border.Background>
<Button Click="OnInit_Click" FontFamily="{StaticResource FontAwesome}" FontSize="30" Foreground="{x:Null}" Margin="0,75,0,0">
<pu:ButtonHelper.ButtonStyle>
<pu:ButtonStyle>Link</pu:ButtonStyle>
</pu:ButtonHelper.ButtonStyle>
</Button>
</Border>
<Button Grid.Row="0" Grid.Column="4" Background="Transparent" MouseDoubleClick="OnClose_Click" pu:ButtonHelper.ButtonStyle="Link">
</Button>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.CommandWpf;
using System.ComponentModel;
namespace LiteChannel
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : WindowX, IComponentConnector
{
private List<store_info> StoreList { get; set; }
public MainWindow()
{
InitializeComponent();
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
//this.Topmost = true;
}
private void OnOutStore_Click(object sender, RoutedEventArgs e)
{
var from = new OutInWindow("出库");
from.Owner = this;
//from.OnApplySuc += LoadData;
from.ShowDialog();
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Process.GetCurrentProcess().Kill();
}
private void OnInStore_Click(object sender, RoutedEventArgs e)
{
var from = new OutInWindow("入库");
from.Owner = this;
//from.OnApplySuc += LoadData;
from.ShowDialog();
}
private void OnInit_Click(object sender, RoutedEventArgs e)
{
var from = new InvInfoWindow();
from.Owner = this;
//from.OnApplySuc += LoadData;
from.ShowDialog();
}
private void OnClose_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
//Process.GetCurrentProcess().Kill();
}
}
}
<pu:WindowX x:Class="LiteChannel.OutInWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
xmlns:usControl="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Maximized"
Loaded="MainWindowLoaded" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"
Closing="OnWindow_Closing" pu:WindowXCaption.DisableCloseButton="True">
<Grid x:Name="g_main">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.3*"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Margin="0,0,10,0" Click="OnInStore_Click" pu:ButtonHelper.Icon="&#xf085;" Content="快捷创建单据" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<Button Grid.Column="1" Margin="0,0,10,0" Click="OnOutStoreNoOrder_Click" pu:ButtonHelper.Icon="&#xf085;" Content="本仓库借用出库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<Button Grid.Row="0" Grid.Column="2" Click="OnRefresh_Click" pu:ButtonHelper.Icon="&#xf202;" Margin="10,0,10,0" Content="刷新单据" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<Button Grid.Row="0" Grid.Column="3" Click="OnClose_Click" pu:ButtonHelper.Icon="&#xf2d3;" Margin="10,0,10,0" Content="返回主页" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22" Background="#C8FF0000" pu:ButtonHelper.HoverBrush="#FF0000" ></Button>
<DataGrid Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" EnableRowVirtualization="False" Margin="3 5 3 0" HeadersVisibility="Column"
pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False" Grid.ColumnSpan="4"
AutoGenerateColumns="False" LoadingRow="OnDataGridLoadingRow" SelectionMode="Single" Name="dg_order" pu:DataGridHelper.ColumnHorizontalContentAlignment="Center" CanUserSortColumns="True" >
<DataGrid.Columns>
<!--<DataGridTemplateColumn Header="序号" MinWidth="80" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="18" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
<DataGridTextColumn IsReadOnly="True" Header="单据编号(后6位)" Width="115" MinWidth="115" FontSize="18" Binding="{Binding orderCodeLast6}" />
<DataGridTextColumn IsReadOnly="True" Header="单据类型" Width="100" MinWidth="100" FontSize="18" Binding="{Binding orderType}" />
<DataGridTextColumn IsReadOnly="True" Header="借用警员(借用)" Width="*" MinWidth="100" FontSize="18" Binding="{Binding borrowPolice}" />
<DataGridTextColumn IsReadOnly="True" Header="目标仓库(调拨)" Width="*" MinWidth="100" FontSize="18" Binding="{Binding receiveWarehouseName}" />
<DataGridTextColumn IsReadOnly="True" Header="申请日期" Width="*" MinWidth="205" FontSize="18" Binding="{Binding createTime}"/>
<!--<DataGridTextColumn IsReadOnly="True" Header="装备信息" Width="*" MinWidth="100" FontSize="18" Binding="{Binding equNames}"/>-->
<!--<DataGridTextColumn IsReadOnly="True" Header="单据数量" Width="100" MinWidth="100" FontSize="18" Binding="{Binding orderQuantity}"/>-->
<DataGridTemplateColumn Header="操作" Width="250" MinWidth="250" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="开始出库" pu:ButtonHelper.Icon="&#xf20e;" pu:ButtonHelper.CornerRadius="5" Click="OnOutStore_Click" Padding="8" Margin="5,8,5,8" >
</Button>
<Button Content="查看明细" pu:ButtonHelper.Icon="&#xf1cb;" pu:ButtonHelper.CornerRadius="5" Click="OnShowDetail_Click" Padding="8" Margin="5,8,5,8" >
</Button>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<usControl:PageControl IsEnabled="{Binding BindButton}" x:Name="d_pager" Margin="0,0,0,0" Grid.Row="2" TotalRecord="{Binding TotalRecord,Mode=TwoWay}" TotalPage="{Binding PageTotal,Mode=TwoWay}" PageSize="{Binding PageSize,Mode=TwoWay}" PageIndex="{Binding PageIndex,Mode=TwoWay}" Grid.ColumnSpan="4"
Grid.Column="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="OnPageChanged">
<i:InvokeCommandAction Command="{Binding OnPageChangeCmd}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</usControl:PageControl>
</Grid>
</pu:WindowX>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannel.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 LiteChannel.Models
{
public class equ_info
{
public equ_info()
{
sizeList = new List<equ_size_info>();
}
public string id { get; set; }
public string code { get; set; }
public string name { get; set; }
public List<equ_size_info> sizeList { get; set; }
}
public class equ_size_info
{
public string id { get; set; }
public string info_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;
using LiteDB;
namespace LiteChannel.Models
{
public class inventory_info
{
/// <summary>
/// id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 装备类型id
/// </summary>
public string equipmentDetailId { get; set; }
/// <summary>
/// 装备类型名
/// </summary>
public string equipmentDetailName { get; set; }
/// <summary>
/// 装备号型id
/// </summary>
public string equipmentSizeId { get; set; }
/// <summary>
/// 装备号型名
/// </summary>
public string equipmentSizeName { get; set; }
/// <summary>
/// epc
/// </summary>
public string epc { get; set; }
/// <summary>
/// 状态 0 在库 1 出库
/// </summary>
public int state { get; set; }
/// <summary>
/// 状态 0 入库 1 出库
/// </summary>
[BsonIgnore]
public string stateName
{
get { return state == 0 ? "在库" : "出库"; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LiteDB;
namespace LiteChannel.Models
{
public class inventory_out_in_log
{
/// <summary>
/// id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime createTime { get; set; }
/// <summary>
/// 装备类型id
/// </summary>
public string equipmentDetailId { get; set; }
/// <summary>
/// 装备类型名
/// </summary>
public string equipmentDetailName { get; set; }
/// <summary>
/// 装备号型id
/// </summary>
public string equipmentSizeId { get; set; }
/// <summary>
/// 装备号型名
/// </summary>
public string equipmentSizeName { get; set; }
/// <summary>
/// epc
/// </summary>
public string epc { get; set; }
/// <summary>
/// 状态 0 入库 1 出库
/// </summary>
public int state { get; set; }
/// <summary>
/// 状态 0 入库 1 出库
/// </summary>
[BsonIgnore]
public string stateName
{
get { return state == 0 ? "入库" : "出库"; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannel.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 LiteChannel.Models
{
public class order_info
{
public string id { get; set; }
public string warehouseId { get; set; }
public string orderCode { get; set; }
public string orderCodeLast6 => orderCode.Substring(16);
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 LiteChannel.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 LiteChannel.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 LiteChannel.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 LiteChannel.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 LiteChannel.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 LiteChannel.Models
{
public class scan_info : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public int equRem { get; set; }
public string equCode { get; set; }
public string equId { get; set; }
public string equSizeId { get; set; }
public string equName { get; set; }
public string equSizeName { 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 LiteChannel.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 LiteChannel.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 LiteChannel.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 LiteChannel.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; }
}
}
<pu:WindowX x:Class="LiteChannel.OutInWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
xmlns:usControl="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Maximized"
Loaded="MainWindowLoaded" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"
Closing="OnWindow_Closing" pu:WindowXCaption.DisableCloseButton="True">
<Grid x:Name="g_main">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.3*"/>
</Grid.ColumnDefinitions>
<Button Name="btn_onInStore" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,10,0" Click="OnInStore_Click" pu:ButtonHelper.Icon="&#xf085;" Content="出库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<!--<Button Grid.Column="1" Margin="0,0,10,0" Click="OnOutStoreNoOrder_Click" pu:ButtonHelper.Icon="&#xf085;" Content="本仓库借用出库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>-->
<Button Grid.Row="0" Grid.Column="2" Click="OnRefresh_Click" pu:ButtonHelper.Icon="&#xf202;" Margin="10,0,10,0" Content="刷新" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22"></Button>
<Button Grid.Row="0" Grid.Column="3" Click="OnClose_Click" pu:ButtonHelper.Icon="&#xf2d3;" Margin="10,0,10,0" Content="返回主页" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="22" Background="#C8FF0000" pu:ButtonHelper.HoverBrush="#FF0000" ></Button>
<DataGrid Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" EnableRowVirtualization="False" Margin="3 5 3 0" HeadersVisibility="Column"
pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False" Grid.ColumnSpan="4"
AutoGenerateColumns="False" LoadingRow="OnDataGridLoadingRow" SelectionMode="Single" Name="dg_order" pu:DataGridHelper.ColumnHorizontalContentAlignment="Center" CanUserSortColumns="True" >
<DataGrid.Columns>
<!--<DataGridTemplateColumn Header="序号" MinWidth="80" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="18" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
<DataGridTextColumn IsReadOnly="True" Header="装备类型" Width="*" MinWidth="115" FontSize="18" Binding="{Binding equipmentDetailName}" />
<DataGridTextColumn IsReadOnly="True" Header="装备号型" Width="*" MinWidth="100" FontSize="18" Binding="{Binding equipmentSizeName}" />
<DataGridTextColumn IsReadOnly="True" Header="出入类型" Width="*" MinWidth="100" FontSize="18" Binding="{Binding stateName}" />
<DataGridTextColumn IsReadOnly="True" Header="出入时间" Width="*" MinWidth="100" FontSize="18" Binding="{Binding createTime,StringFormat='yyyy-MM-dd HH:mm:ss'}" />
<!--<DataGridTextColumn IsReadOnly="True" Header="装备信息" Width="*" MinWidth="100" FontSize="18" Binding="{Binding equNames}"/>-->
<!--<DataGridTextColumn IsReadOnly="True" Header="单据数量" Width="100" MinWidth="100" FontSize="18" Binding="{Binding orderQuantity}"/>-->
<!--<DataGridTemplateColumn Header="操作" Width="250" MinWidth="250" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="开始出库" pu:ButtonHelper.Icon="&#xf20e;" pu:ButtonHelper.CornerRadius="5" Click="OnOutStore_Click" Padding="8" Margin="5,8,5,8" >
</Button>
<Button Content="查看明细" pu:ButtonHelper.Icon="&#xf1cb;" pu:ButtonHelper.CornerRadius="5" Click="OnShowDetail_Click" Padding="8" Margin="5,8,5,8" >
</Button>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
</DataGrid.Columns>
</DataGrid>
<usControl:PageControl IsEnabled="{Binding BindButton}" x:Name="d_pager" Margin="0,0,0,0" Grid.Row="2" TotalRecord="{Binding TotalRecord,Mode=TwoWay}" TotalPage="{Binding PageTotal,Mode=TwoWay}" PageSize="{Binding PageSize,Mode=TwoWay}" PageIndex="{Binding PageIndex,Mode=TwoWay}" Grid.ColumnSpan="4"
Grid.Column="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="OnPageChanged">
<i:InvokeCommandAction Command="{Binding OnPageChangeCmd}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</usControl:PageControl>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.CommandWpf;
using System.ComponentModel;
namespace LiteChannel
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class OutInWindow : WindowX, IComponentConnector
{
private PageControlModel model;
private readonly string _Type;
public OutInWindow(string type)
{
InitializeComponent();
model = new PageControlModel(this);
_Type = type;
switch (type)
{
case "出库":
{
btn_onInStore.Content = "物资出库";
break;
}
case "入库":
{
btn_onInStore.Content = "物资入库";
break;
}
}
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
DataContext = model;
//加载单据数据
model.PageIndex = 1;
LoadData();
}
public void LoadData()
{
var tmp = HttpHelper.GetOutInLogs(_Type, model.PageIndex, model.PageSize);
model.TotalRecord = tmp?.totalElements ?? 0;
model.PageTotal = model.TotalRecord == 0 ? 0 : (model.TotalRecord + model.PageSize - 1) / model.PageSize;
dg_order.ItemsSource = tmp?.content;
}
private void OnDataGridLoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() + 1;
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
private void OnInStore_Click(object sender, RoutedEventArgs e)
{
switch (_Type)
{
case "出库":
{
var from = new StoreOutWindow("", "NoOrder", null);
from.Owner = this;
from.ShowDialog();
OnRefresh_Click(null, null);
break;
}
case "入库":
{
var from = new StoreInWindow();
from.Owner = this;
from.ShowDialog();
OnRefresh_Click(null, null);
break;
}
}
}
private void OnRefresh_Click(object sender, RoutedEventArgs e)
{
model.PageIndex = 1;
LoadData();
}
private void OnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
//Application.Current.Shutdown();
//Process.GetCurrentProcess().Kill();
}
}
public class PageControlModel : INotifyPropertyChanged
{
private bool _bindButton = true;
public bool BindButton
{
get { return _bindButton; }
set
{
_bindButton = value;
OnPropertyChanged("BindButton");
}
}
private int _total = 0;
public int TotalRecord
{
get { return _total; }
set
{
_total = value;
OnPropertyChanged("TotalRecord");
}
}
private int _page = 0;
public int PageIndex
{
get { return _page; }
set
{
_page = value;
OnPropertyChanged("PageIndex");
}
}
private int _pageTotal = 0;
public int PageTotal
{
get { return _pageTotal; }
set
{
_pageTotal = value;
OnPropertyChanged("PageTotal");
}
}
private int _pageSize = 50;
public int PageSize
{
get { return _pageSize; }
set
{
_pageSize = value;
OnPropertyChanged("PageSize");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string strPropertyInfo)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(strPropertyInfo));
}
}
private readonly OutInWindow _mainWindow;
public RelayCommand OnPageChangeCmd { get; set; }
public PageControlModel(OutInWindow mainWindow)
{
_mainWindow = mainWindow;
PageSize = 10;
OnPageChangeCmd = new RelayCommand(OnPageChange);
}
private void OnPageChange()
{
_mainWindow.LoadData();
}
}
}
<pu:WindowX x:Class="LiteChannel.OutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
xmlns:usControl="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" Loaded="MainWindowLoaded" ResizeMode="NoResize"
AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"
WindowState="Maximized" pu:WindowXCaption.DisableCloseButton="True">
<Grid x:Name="g_main">
<Grid.RowDefinitions>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.3*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="10,10,10,10" Click="OnOutStoreNoOrder_Click" pu:ButtonHelper.Icon="&#xf085;" Content="无单据出库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="30"></Button>
<Button Grid.Row="2" Grid.Column="1" Margin="10,10,10,10" Click="OnOutStoreJY_Click" pu:ButtonHelper.Icon="&#xf085;" Content="借用" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="30"></Button>
<Button Grid.Row="2" Grid.Column="2" Margin="10,10,10,10" Click="OnOutStoreLY_Click" pu:ButtonHelper.Icon="&#xf085;" Content="领用" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="30"></Button>
<Button Grid.Row="3" Grid.Column="1" Margin="10,10,10,10" Click="OnOutStoreDB_Click" pu:ButtonHelper.Icon="&#xf085;" Content="调拨" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="30"></Button>
<Button Grid.Row="3" Grid.Column="2" Margin="10,10,10,10" Click="OnOutStoreKK_Click" pu:ButtonHelper.Icon="&#xf085;" Content="跨库" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="30"></Button>
<Button Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Click="OnClose_Click" pu:ButtonHelper.Icon="&#xf2d3;" Margin="10,10,10,10" Content="返回上级" FontFamily="{StaticResource FontAwesome}" pu:ButtonHelper.CornerRadius="5" FontSize="24" Background="#C8FF0000" pu:ButtonHelper.HoverBrush="#FF0000" ></Button>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.CommandWpf;
using System.ComponentModel;
namespace LiteChannel
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class OutWindow : WindowX, IComponentConnector
{
public OutWindow()
{
InitializeComponent();
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
}
private void OnOutStoreNoOrder_Click(object sender, RoutedEventArgs e)
{
var from = new StoreOutWindow("", "NoOrder", null);
from.Owner = this;
from.ShowDialog();
}
private void OnOutStoreJY_Click(object sender, RoutedEventArgs e)
{
var from = new MainWindow2("借用");
from.Owner = this;
from.ShowDialog();
}
private void OnOutStoreLY_Click(object sender, RoutedEventArgs e)
{
var from = new MainWindow2("领用");
from.Owner = this;
from.ShowDialog();
}
private void OnOutStoreDB_Click(object sender, RoutedEventArgs e)
{
var from = new MainWindow2("调拨");
from.Owner = this;
from.ShowDialog();
}
private void OnOutStoreKK_Click(object sender, RoutedEventArgs e)
{
var from = new MainWindow2("跨库");
from.Owner = this;
from.ShowDialog();
}
private void OnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LiteChannel")]
[assembly: AssemblyDescription("充电台出入库程序,提供出入库信息上报功能。")]
[assembly: AssemblyConfiguration("充电台出入库程序,提供出入库信息上报功能。")]
[assembly: AssemblyCompany("Junmp")]
[assembly: AssemblyProduct("LiteChannel")]
[assembly: AssemblyCopyright("Copyright © Junmp 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.15.03080")]
[assembly: AssemblyFileVersion("1.2.15.03080")]
[assembly: Guid("2a903ab7-96f9-435b-b29a-5acf29b34ce8")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiteChannel.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("LiteChannel.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;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap _1 {
get {
object obj = ResourceManager.GetObject("_1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap _2 {
get {
object obj = ResourceManager.GetObject("_2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap _3 {
get {
object obj = ResourceManager.GetObject("_3", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap _4 {
get {
object obj = ResourceManager.GetObject("_4", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="_1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiteChannel.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.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="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
\ No newline at end of file
<pu:WindowX x:Class="LiteChannel.Setting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
mc:Ignorable="d"
Title="系统配置" Height="500" Loaded="OnWindow_Loaded" Width="800" Icon="1.ico" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="10"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="1" Text="软件版本:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="2" Name="txt_ver" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="0" Grid.Column="3" Text="软件编码:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="4" Name="txt_code" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<!--<TextBlock Grid.Row="1" Grid.Column="1" Text="接口域名:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="2" x:Name="txt_domain" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" Grid.Column="3" Text="登录接口:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="4" x:Name="txt_login" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>-->
<TextBlock Grid.Row="1" Grid.Column="1" Text="程序标题:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="2" x:Name="txt_title" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="门禁地址:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="2" x:Name="txt_ip" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" Grid.Column="3" Text="门禁端口:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="4" x:Name="txt_port" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="门禁用户:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="2" x:Name="txt_user" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="3" Text="门禁密码:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="4" x:Name="txt_pwd" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="4" Grid.Column="1" Text="门禁状态:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<ComboBox Grid.Row="4" Grid.Column="2" x:Name="cbo_state" Width="auto" Height="25"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="False">
<ComboBoxItem>启用</ComboBoxItem>
<ComboBoxItem>禁用</ComboBoxItem>
</ComboBox>
<TextBlock Grid.Row="5" Grid.Column="1" Text="启用智能货架:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<ComboBox Grid.Row="5" Grid.Column="2" x:Name="cbo_shelf" Width="auto" Height="25"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="False">
<ComboBoxItem>启用</ComboBoxItem>
<ComboBoxItem>禁用</ComboBoxItem>
</ComboBox>
<TextBlock Grid.Row="5" Grid.Column="3" Text="智能货架地址:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="4" x:Name="txt_shelf" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="6" Grid.Column="1" Text="AppKey:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="2" x:Name="txt_appkey" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="6" Grid.Column="3" Text="SecretKey:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="4" x:Name="txt_secretkey" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="7" Grid.Column="1" Text="自动更新:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<CheckBox Grid.Row="7" Grid.Column="2" x:Name="cb_autoUpdate" Width="auto" Height="25" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,8,0,8" Click="cb_autoUpdate_Click">启用自动更新,检查时间:</CheckBox>
<ComboBox Grid.Row="7" Grid.Column="2" x:Name="cbb_autoUpdate" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="188,0,0,0"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="False">
<ComboBoxItem>0:00</ComboBoxItem>
<ComboBoxItem>1:00</ComboBoxItem>
<ComboBoxItem>2:00</ComboBoxItem>
<ComboBoxItem>3:00</ComboBoxItem>
<ComboBoxItem>4:00</ComboBoxItem>
<ComboBoxItem>5:00</ComboBoxItem>
<ComboBoxItem>6:00</ComboBoxItem>
<ComboBoxItem>7:00</ComboBoxItem>
<ComboBoxItem>8:00</ComboBoxItem>
<ComboBoxItem>9:00</ComboBoxItem>
<ComboBoxItem>10:00</ComboBoxItem>
<ComboBoxItem>11:00</ComboBoxItem>
<ComboBoxItem>12:00</ComboBoxItem>
<ComboBoxItem>13:00</ComboBoxItem>
<ComboBoxItem>14:00</ComboBoxItem>
<ComboBoxItem>15:00</ComboBoxItem>
<ComboBoxItem>16:00</ComboBoxItem>
<ComboBoxItem>17:00</ComboBoxItem>
<ComboBoxItem>18:00</ComboBoxItem>
<ComboBoxItem>19:00</ComboBoxItem>
<ComboBoxItem>20:00</ComboBoxItem>
<ComboBoxItem>21:00</ComboBoxItem>
<ComboBoxItem>22:00</ComboBoxItem>
<ComboBoxItem>23:00</ComboBoxItem>
</ComboBox>
<TextBlock Grid.Row="8" Grid.Column="1" Text="读写器类型:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<ComboBox Grid.Row="8" Grid.Column="2" x:Name="cbo_readerType" Width="auto" Height="25"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
pu:ComboBoxHelper.HoverBackground="#1EB5B5B5"
pu:ComboBoxHelper.SelectedBackground="#32B5B5B5"
pu:ComboBoxHelper.IsSearchTextBoxVisible="False" SelectionChanged="cbo_readerType_SelectionChanged">
<ComboBoxItem>钧普</ComboBoxItem>
<ComboBoxItem>索力得</ComboBoxItem>
</ComboBox>
<TextBlock Grid.Row="8" Grid.Column="3" x:Name="tb_com" Text="串口编号:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<ComboBox Grid.Row="8" Grid.Column="4" x:Name="cbo_com" Width="auto" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<Button Grid.Row="11" Grid.ColumnSpan="6" Click="OnSave_Click" HorizontalAlignment="Right" Width="90" Margin="0,0,110,0">保存配置</Button>
<!--<Button Grid.Row="14" Grid.ColumnSpan="6" Click="OnRefresh_Click" HorizontalAlignment="Right" Width="90" Margin="0,0,110,0">刷新仓库</Button>-->
<Button Grid.Row="11" Grid.ColumnSpan="6" Click="OnCancel_Click" HorizontalAlignment="Right" Background="#C8FF7F00" pu:ButtonHelper.HoverBrush="#FF7F00" Width="90" Margin="0,0,10,0">关闭</Button>
</Grid>
</pu:WindowX>
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace LiteChannel
{
/// <summary>
/// Setting.xaml 的交互逻辑
/// </summary>
public partial class Setting : WindowX, IComponentConnector
{
private bool IsLoaded = false;
private List<store_info> StoreList { get; set; }
public Setting()
{
InitializeComponent();
}
private void OnSave_Click(object sender, RoutedEventArgs e)
{
//int.TryParse(txt_ver.Text, out int ver);
//LiteCaChe.SysConfig.UserLogin = txt_login.Text;
LiteCaChe.SysConfig.AppCode = txt_code.Text;
//LiteCaChe.SysConfig.DomainUrl = txt_domain.Text;
//LiteCaChe.SysConfig.AppTitle = txt_title.Text;
//LiteCaChe.SysConfig.AppVersion = ver;
//LiteCaChe.SysConfig.WarehouseID = cbo_warehouse.SelectedValue?.ToString() ?? "";
LiteCaChe.SysConfig.FaceAddress = txt_ip.Text;
LiteCaChe.SysConfig.FacePort = txt_port.Text;
LiteCaChe.SysConfig.FaceUser = txt_user.Text;
LiteCaChe.SysConfig.FacePwd = txt_pwd.Text;
LiteCaChe.SysConfig.IsUseFace = cbo_state.Text == "启用" ? true : false;
LiteCaChe.SysConfig.AppKey = txt_appkey.Text;
LiteCaChe.SysConfig.SecretKey = txt_secretkey.Text;
LiteCaChe.SysConfig.IsEnabledShelf = cbo_shelf.Text == "启用";
LiteCaChe.SysConfig.ShelfAddress = txt_shelf.Text;
LiteCaChe.SysConfig.IsAutoUpdate = cb_autoUpdate.IsChecked == true;
LiteCaChe.SysConfig.AutoUpdateTime = cbb_autoUpdate.SelectedIndex;
LiteCaChe.SysConfig.ReaderType = cbo_readerType.SelectedIndex;
if (LiteCaChe.SysConfig.ReaderType == 0)
{
LiteCaChe.SysConfig.ComMouth = cbo_com.Text;
}
LiteCaChe.SaveSystemStep(LiteCaChe.SysConfig);
MessageBox.Show("配置保存成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
this.Close();
}
private void OnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
//private void OnRefresh_Click(object sender, RoutedEventArgs e)
//{
// StoreList = HttpHelper.GetStoreInfos();
// cbo_warehouse.ItemsSource = StoreList;
//}
private void OnWindow_Loaded(object sender, RoutedEventArgs e)
{
cbo_com.ItemsSource = SerialPort.GetPortNames();
//StoreList = HttpHelper.GetStoreInfos();
//cbo_warehouse.ItemsSource = StoreList;
//cbo_warehouse.DisplayMemberPath = "name";
//cbo_warehouse.SelectedValuePath = "id";
//txt_login.Text = LiteCaChe.SysConfig.UserLogin;
txt_code.Text = LiteCaChe.SysConfig.AppCode;
//txt_domain.Text = LiteCaChe.SysConfig.DomainUrl;
txt_title.Text = LiteCaChe.SysConfig.AppTitle;
txt_ver.Text = LiteCaChe.SysConfig.AppVersion.ToString();
//cbo_warehouse.SelectedValue = LiteCaChe.SysConfig.WarehouseID;
txt_ip.Text = LiteCaChe.SysConfig.FaceAddress;
txt_port.Text = LiteCaChe.SysConfig.FacePort;
txt_user.Text = LiteCaChe.SysConfig.FaceUser;
txt_pwd.Text = LiteCaChe.SysConfig.FacePwd;
cbo_state.SelectedIndex = LiteCaChe.SysConfig.IsUseFace ? 0 : 1;
txt_appkey.Text = LiteCaChe.SysConfig.AppKey;
txt_secretkey.Text = LiteCaChe.SysConfig.SecretKey;
cbo_shelf.SelectedIndex = LiteCaChe.SysConfig.IsEnabledShelf ? 0 : 1;
txt_shelf.Text = LiteCaChe.SysConfig.ShelfAddress;
cb_autoUpdate.IsChecked = LiteCaChe.SysConfig.IsAutoUpdate;
if (cb_autoUpdate.IsChecked == true)
{
cbb_autoUpdate.IsEnabled = true;
}
else
{
cbb_autoUpdate.IsEnabled = false;
}
cbb_autoUpdate.SelectedIndex = LiteCaChe.SysConfig.AutoUpdateTime;
IsLoaded = true;
cbo_readerType.SelectedIndex = LiteCaChe.SysConfig.ReaderType;
if (LiteCaChe.SysConfig.ReaderType == 0)
{
tb_com.Visibility = Visibility.Visible;
cbo_com.Visibility = Visibility.Visible;
cbo_com.Text = LiteCaChe.SysConfig.ComMouth;
}
else
{
tb_com.Visibility = Visibility.Hidden;
cbo_com.Visibility = Visibility.Hidden;
}
}
//private void cbo_warehouse_SearchTextChanged(object sender, Panuon.UI.Silver.Core.SearchTextChangedEventArgs e)
//{
// if (!IsLoaded)
// return;
// cbo_warehouse.ItemsSource = StoreList.Where(t => t.name.Contains(e.Text));
//}
private void OnSldCornerRadius_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!IsLoaded)
return;
}
private void cb_autoUpdate_Click(object sender, RoutedEventArgs e)
{
if (cb_autoUpdate.IsChecked == true)
{
cbb_autoUpdate.IsEnabled = true;
}
else
{
cbb_autoUpdate.IsEnabled = false;
}
}
private void cbo_readerType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbo_readerType.SelectedIndex == 0)
{
tb_com.Visibility = Visibility.Visible;
cbo_com.Visibility = Visibility.Visible;
cbo_com.Text = LiteCaChe.SysConfig.ComMouth;
}
else
{
tb_com.Visibility = Visibility.Hidden;
cbo_com.Visibility = Visibility.Hidden;
}
}
}
}
<pu:WindowX x:Class="LiteChannel.StoreInWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Normal"
Title="盘点入库" FontSize="24" WindowStartupLocation="CenterScreen"
Loaded="OnWindow_Loaded" Closing="OnWindow_Closing">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="0"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!--<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="150" Height="35" Margin="0,0,150,0" Click="OnInit_Click" FontSize="24" Background="Red" pu:ButtonHelper.HoverBrush="Red">初始化物资</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="120" Height="35" Margin="0,0,20,0" Click="OnInLog_Click" FontSize="24">入库记录</Button>-->
<DataGrid FontSize="24" ColumnHeaderHeight="60" RowHeight="60" Grid.Row="1" Grid.ColumnSpan="2" x:Name="dg_epc" HorizontalAlignment="Stretch" BorderThickness="0,0,0,1" VerticalAlignment="Stretch" pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False" >
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="装备名称" Binding="{Binding equName}" Width="*"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="装备号型" Binding="{Binding equSizeName}" Width="*"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="识别数量" Binding="{Binding scanQty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Width="150"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<!--<ComboBox Name="cbo_type" Grid.Row="1" Grid.Column="1" pu:ComboBoxHelper.Watermark="请选择入库类型..." Height="40" Margin="5,0,5,0">
<ComboBoxItem>采购</ComboBoxItem>
<ComboBoxItem>借用</ComboBoxItem>
<ComboBoxItem>跨库借用</ComboBoxItem>
<ComboBoxItem>库存调拨</ComboBoxItem>
<ComboBoxItem>维修</ComboBoxItem>
<ComboBoxItem>跨库归还</ComboBoxItem>
</ComboBox>-->
<TextBlock Grid.Row="3" Grid.ColumnSpan="2" Margin="0,0,220,0" Foreground="Red" Name="txt_stat" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="24">状态:读写器启动失败</TextBlock>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" IsEnabled="false" Name="btn_inv" HorizontalAlignment="Right" Click="OnInv_Click" Width="120" Height="35" Margin="0,0,273,0" FontSize="24">开始读取</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="120" Height="35" Margin="0,0,140,0" Click="OnSave_Click" FontSize="24">提交入库</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Right" Background="#C8FF7F00" Click="OnExit_Click" pu:ButtonHelper.HoverBrush="#FF7F00" Width="120" Height="35" Margin="0,0,10,0" FontSize="24">返回</Button>
</Grid>
</pu:WindowX>
using JmpRfidLp;
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Panuon.UI.Silver.Core;
namespace LiteChannel
{
/// <summary>
/// StoreWindow.xaml 的交互逻辑
/// </summary>
public partial class StoreInWindow : WindowX, IComponentConnector
{
private IReaderHelper reader;
private List<scan_info> SourcesList = new List<scan_info>();
private List<scan_info> BoxMarkList = new List<scan_info>();
private Queue<string> _epcQueue = new Queue<string>();
private CancellationTokenSource tokenSource = new CancellationTokenSource();
private ObservableCollection<scan_info> RefreshSourcesList = new ObservableCollection<scan_info>();
private Dictionary<ulong, string> dic_equ = new Dictionary<ulong, string>();
private List<order_equ> orderWzdm = new List<order_equ>();
public event Action OnApplySuc;
public StoreInWindow()
{
InitializeComponent();
dg_epc.AutoGenerateColumns = false;
}
private void OnWindow_Loaded(object sender, RoutedEventArgs e)
{
ConnectReader();
EpcHandleTask(tokenSource.Token);
}
private bool ConnectReader()
{
try
{ //启动读写器
switch (LiteCaChe.SysConfig.ReaderType)
{
case 0:
{
reader = new JmpRfidLpReaderHelper(LiteCaChe.SysConfig.ComMouth);
break;
}
case 1:
{
reader = new USBRFIDReaderHelper();
break;
}
}
reader.OnInventory += OnRadioInventory;
var state = reader.Open();
if (state)
{
var version = reader.GetFWVerion();
if (string.IsNullOrEmpty(version))
{
txt_stat.Text = "状态:读写器版本读取失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
reader.InventoryStop();
reader.SetPALevel(1);
reader.SetTxPower(0, true, 24);
txt_stat.Text = "状态:读写器连接成功";
txt_stat.Foreground = new SolidColorBrush(Colors.Green);
btn_inv.IsEnabled = true;
return true;
}
else
{
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
catch (Exception ex)
{
reader = null;
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
private void OnRadioInventory(TagInfoData args)
{
if (!SourcesList.Any(t => t.epcList.Contains(args.EPC)) &&
!BoxMarkList.Any(t => t.epcList.Contains(args.EPC))
)
{
//有效标签
lock (_epcQueue)
{
if (!_epcQueue.Contains(args.EPC))
{
_epcQueue.Enqueue(args.EPC);
}
}
}
}
private void EpcHandleTask(CancellationToken token)
{
Task.Run(() =>
{
var epcList = new List<string>();
while (true)
{
if (token.IsCancellationRequested)
{
break;
}
lock (_epcQueue)
{
if (_epcQueue.Count != 0)
{
epcList = _epcQueue.ToList();
_epcQueue.Clear();
}
else
{
Thread.Sleep(500);
continue;
}
}
foreach (var epc in epcList)
{
//再次检查是否被阻塞阶段添加标签
if (!SourcesList.Any(t => t.epcList.Contains(epc)))
{
var tempEpc = epc;
var inv = LiteCaChe.InventoryInfos.FirstOrDefault(x => x.epc == tempEpc);
if (inv != null)
{
var tmp_info = SourcesList.FirstOrDefault(t => t.equId == inv.equipmentDetailId && t.equSizeId == inv.equipmentSizeId);
if (tmp_info == null)
{
tmp_info = new scan_info()
{
epcList = new List<string>() { tempEpc },
equId = inv.equipmentDetailId,
equName = inv.equipmentDetailName,
equSizeId = inv.equipmentSizeId,
equSizeName = inv.equipmentSizeName,
scanQty = 1
};
SourcesList.Add(tmp_info);
Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action<List<scan_info>>((x) =>
{
RefreshSourcesList = new ObservableCollection<scan_info>(x);
dg_epc.ItemsSource = RefreshSourcesList;
}), SourcesList);
}
else
{
tmp_info.scanQty += 1;
tmp_info.epcList.Add(tempEpc);
}
}
}
}
epcList.Clear();
}
}, token);
}
private void OnInv_Click(object sender, RoutedEventArgs e)
{
if (btn_inv.Content.ToString() == "开始读取")
{
reader?.InventoryStart();
btn_inv.Content = "停止读取";
}
else
{
reader?.InventoryStop();
btn_inv.Content = "开始读取";
}
}
private void OnExit_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
tokenSource.Cancel();
if (reader?.IsOpen() ?? false)
{
reader?.InventoryStop();
reader?.Close();
}
}
private void OnSave_Click(object sender, RoutedEventArgs 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 (string.IsNullOrEmpty(cbo_type.Text))
//{
// MessageBox.Show(this, "入库类型未选择,请选择后重试!", "出库提示", MessageBoxButton.OK, MessageBoxImage.Information);
//}
//else
{
if (btn_inv.Content.ToString() == "停止读取")
{
OnInv_Click(default, default);
}
var _res = HttpHelper.RfidInStore("", epcList);
MessageBox.Show(this, _res.Item2, "出库提示", MessageBoxButton.OK, MessageBoxImage.Information);
if (_res.Item1)
{
OnApplySuc?.Invoke();
this.Close();
}
}
}
}
}
}
}
<pu:WindowX x:Class="LiteChannel.StoreOutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LiteChannel"
mc:Ignorable="d" Icon="1.ico"
Height="720" Width="1024" ResizeMode="NoResize" WindowState="Normal"
Title="盘点出库" FontSize="24" WindowStartupLocation="CenterScreen"
Loaded="OnWindow_Loaded" Closing="OnWindow_Closing">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!--<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="120" Height="35" Margin="0,0,20,0" Click="OnOutLog_Click" FontSize="24">出库记录</Button>-->
<DataGrid Grid.Row="1" FontSize="24" ColumnHeaderHeight="60" RowHeight="60" x:Name="dg_epc" HorizontalAlignment="Stretch" BorderThickness="0,0,0,1" VerticalAlignment="Stretch" pu:DataGridHelper.SelectedBackground="#44B5B5B5" pu:DataGridHelper.HoverBackground="#22B5B5B5" CanUserAddRows="False" >
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="装备名称" Binding="{Binding equName}" Width="*"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="装备号型" Binding="{Binding equSizeName}" Width="*"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="申领数量" Binding="{Binding equCount}" Width="150" x:Name="equCountGridTextColumn"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="剩余数量" Binding="{Binding equRem}" Width="150" x:Name="equRemGridTextColumn"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="识别数量" Binding="{Binding scanQty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Width="150"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<TextBlock Grid.Row="2" Margin="0,0,220,0" Foreground="Red" Name="txt_stat" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="24">状态:读写器启动失败</TextBlock>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="2" IsEnabled="false" Name="btn_inv" HorizontalAlignment="Right" Click="OnInv_Click" Width="120" Height="35" Margin="0,0,270,0" FontSize="24">开始读取</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="2" HorizontalAlignment="Right" Width="120" Height="35" Margin="0,0,140,0" Click="OnSave_Click" FontSize="24">提交出库</Button>
<Button pu:ButtonHelper.CornerRadius="4" Grid.Row="2" HorizontalAlignment="Right" Background="#C8FF7F00" Click="OnExit_Click" pu:ButtonHelper.HoverBrush="#FF7F00" Width="120" Height="35" Margin="0,0,10,0" FontSize="24">返回</Button>
</Grid>
</pu:WindowX>
using JmpRfidLp;
using LiteChannel.Commons;
using LiteChannel.Models;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Panuon.UI.Silver.Core;
namespace LiteChannel
{
/// <summary>
/// StoreWindow.xaml 的交互逻辑
/// </summary>
public partial class StoreOutWindow : WindowX, IComponentConnector
{
private IReaderHelper reader;
private List<scan_info> SourcesList = new List<scan_info>();
private List<scan_info> BoxMarkList = new List<scan_info>();
private Queue<string> _epcQueue = new Queue<string>();
private CancellationTokenSource tokenSource = new CancellationTokenSource();
private ObservableCollection<scan_info> RefreshSourcesList = new ObservableCollection<scan_info>();
private Dictionary<ulong, string> dic_equ = new Dictionary<ulong, string>();
private List<order_equ> orderWzdm = new List<order_equ>();
private string type, id, order_code;
private order_info _orderInfo;
public event Action OnApplySuc;
private readonly bool isNoOrder;
private readonly bool isHaveBoxMark;
public StoreOutWindow(string id, string type, order_info orderInfo)
{
InitializeComponent();
if (type == "NoOrder")
{
isNoOrder = true;
dg_epc.AutoGenerateColumns = false;
equCountGridTextColumn.Visibility = Visibility.Hidden;
equRemGridTextColumn.Visibility = Visibility.Hidden;
}
else
{
this.id = id;
this.order_code = orderInfo.orderCode;
this.type = type;
dg_epc.AutoGenerateColumns = false;
_orderInfo = orderInfo;
}
}
private void OnWindow_Loaded(object sender, RoutedEventArgs e)
{
if (isNoOrder)
{
ConnectReader();
EpcHandleTask(tokenSource.Token);
return;
}
//var detail_info = HttpHelper.GetOrderDetails(id, type);
//if (detail_info == null)
//{
// txt_stat.Text = "状态:单据明细获取失败";
// txt_stat.Foreground = new SolidColorBrush(Colors.Red);
//}
//else
//{
// detail_info.ForEach(s =>
// {
// orderWzdm.Add(new order_equ()
// {
// equCode = s.equCode,
// equUsed = s.equUsed,
// equRem = s.equCount - s.equUsed,
// equCount = s.equCount
// });
// SourcesList.Add(new scan_info()
// {
// epcList = new List<string>(),
// equCode = s.equCode,
// equName = s.equName,
// scanQty = 0,
// equCount = s.equCount,
// equRem = s.equCount - s.equUsed
// });
// });
// Dispatcher.BeginInvoke(DispatcherPriority.Background,
// new Action<List<scan_info>>((x) =>
// {
// RefreshSourcesList = new ObservableCollection<scan_info>(x);
// dg_epc.ItemsSource = RefreshSourcesList;
// }), SourcesList);
// ConnectReader();
// EpcHandleTask(tokenSource.Token);
//}
}
private bool ConnectReader()
{
try
{ //启动读写器
switch (LiteCaChe.SysConfig.ReaderType)
{
case 0:
{
reader = new JmpRfidLpReaderHelper(LiteCaChe.SysConfig.ComMouth);
break;
}
case 1:
{
reader = new USBRFIDReaderHelper();
break;
}
}
reader.OnInventory += OnRadioInventory;
var state = reader.Open();
if (state)
{
var version = reader.GetFWVerion();
if (string.IsNullOrEmpty(version))
{
txt_stat.Text = "状态:读写器版本读取失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
reader.InventoryStop();
reader.SetPALevel(1);
reader.SetTxPower(0, true, 24);
txt_stat.Text = "状态:读写器连接成功";
txt_stat.Foreground = new SolidColorBrush(Colors.Green);
btn_inv.IsEnabled = true;
return true;
}
else
{
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
catch (Exception ex)
{
reader = null;
txt_stat.Text = "状态:读写器连接失败";
txt_stat.Foreground = new SolidColorBrush(Colors.Red);
return false;
}
}
private void OnRadioInventory(TagInfoData args)
{
if (!SourcesList.Any(t => t.epcList.Contains(args.EPC)) &&
!BoxMarkList.Any(t => t.epcList.Contains(args.EPC)) )
{
//有效标签
lock (_epcQueue)
{
if (!_epcQueue.Contains(args.EPC))
{
_epcQueue.Enqueue(args.EPC);
}
}
}
}
private void EpcHandleTask(CancellationToken token)
{
Task.Run(() =>
{
var epcList = new List<string>();
while (true)
{
if (token.IsCancellationRequested)
{
break;
}
lock (_epcQueue)
{
if (_epcQueue.Count != 0)
{
epcList = _epcQueue.ToList();
_epcQueue.Clear();
}
else
{
Thread.Sleep(500);
continue;
}
}
foreach (var epc in epcList)
{
//再次检查是否被阻塞阶段添加标签
if (!SourcesList.Any(t => t.epcList.Contains(epc)))
{
var tempEpc = epc;
var inv = LiteCaChe.InventoryInfos.FirstOrDefault(x => x.epc == tempEpc);
if (inv != null)
{
var tmp_info = SourcesList.FirstOrDefault(t => t.equId == inv.equipmentDetailId && t.equSizeId == inv.equipmentSizeId);
if (tmp_info == null)
{
tmp_info = new scan_info()
{
epcList = new List<string>() { tempEpc },
equId = inv.equipmentDetailId,
equName = inv.equipmentDetailName,
equSizeId = inv.equipmentSizeId,
equSizeName = inv.equipmentSizeName,
scanQty = 1
};
SourcesList.Add(tmp_info);
Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action<List<scan_info>>((x) =>
{
RefreshSourcesList = new ObservableCollection<scan_info>(x);
dg_epc.ItemsSource = RefreshSourcesList;
}), SourcesList);
}
else
{
tmp_info.scanQty += 1;
tmp_info.epcList.Add(tempEpc);
}
}
}
}
epcList.Clear();
}
}, token);
}
private void OnInv_Click(object sender, RoutedEventArgs e)
{
if (btn_inv.Content.ToString() == "开始读取")
{
reader?.InventoryStart();
btn_inv.Content = "停止读取";
}
else
{
reader.InventoryStop();
btn_inv.Content = "开始读取";
}
}
private void OnExit_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void OnSave_Click(object sender, RoutedEventArgs 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 (btn_inv.Content.ToString() == "停止读取")
{
OnInv_Click(default, default);
}
var _res = HttpHelper.RfidOutStore(order_code, type, epcList);
MessageBox.Show(this, _res.Item2, "出库提示", MessageBoxButton.OK, MessageBoxImage.Information);
if (_res.Item1)
{
OnApplySuc?.Invoke();
this.Close();
}
}
}
}
private void OnWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (reader?.IsOpen() ?? false)
{
reader?.InventoryStop();
reader?.Close();
}
}
/// <summary>
/// 出库记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <exception cref="NotImplementedException"></exception>
private void OnOutLog_Click(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
}
}
#缺省不输出日志到控制台
#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
<UserControl x:Class="LiteChannel.UsControl.InputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" MaxWidth="400">
<Grid Margin="16">
<StackPanel Margin="16">
<TextBlock>请输入打印数量.</TextBlock>
<TextBox Margin="0 8 0 10" HorizontalAlignment="Stretch" x:Name="FruitTextBox" Background="White">
</TextBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<Button Style="{StaticResource MaterialDesignFlatButton}"
IsDefault="True"
Margin="0 8 8 0"
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="{Binding ElementName=FruitTextBox,Path=Text}">
<!--<Button.CommandParameter>
<system:Boolean>True</system:Boolean>
</Button.CommandParameter>-->
确定
</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}"
IsCancel="True"
Margin="0 8 8 0"
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="close">
<!--<Button.CommandParameter>
<system:Boolean>False</system:Boolean>
</Button.CommandParameter>-->
取消
</Button>
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
using System.Windows.Controls;
namespace LiteChannel.UsControl
{
/// <summary>
/// WaitDialog.xaml 的交互逻辑
/// </summary>
public partial class InputDialog : UserControl
{
public InputDialog()
{
InitializeComponent();
}
}
}
<UserControl x:Class="LiteChannel.UsControl.PageControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
d:DesignHeight="65" Background="white" Loaded="DataPageControl_Loaded">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border BorderBrush="#d9d9d9" BorderThickness="1,0,1,1">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.50*"/>
<ColumnDefinition Width="0.0*"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0">
<TextBlock Name="tbTip" FontSize="20" Grid.Column="0" Foreground="CadetBlue" HorizontalAlignment="Left" Margin="5,0,0,0" Padding="0" VerticalAlignment="Center">第0页,共0页;单页0条记录!</TextBlock>
</StackPanel>
<Button Width="60" Height="60" Click="OnFirPageClick" HorizontalAlignment="Center" ToolTip="第一页" VerticalAlignment="Center" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}" Grid.Column="2" BorderThickness="0" Name="btnFirst" Cursor="Hand">
<materialDesign:PackIcon Kind="ArrowCollapseLeft" Height="32" Width="32" />
</Button>
<Button Width="60" Height="60" Click="OnPrePageClick" HorizontalAlignment="Center" ToolTip="上一页" VerticalAlignment="Center" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}" Grid.Column="3" BorderThickness="0" Name="btnUp" Cursor="Hand">
<materialDesign:PackIcon Kind="ArrowLeft" Height="32" Width="32"/>
</Button>
<Button Width="60" Height="60" Click="OnNexPageClick" HorizontalAlignment="Center" ToolTip="下一页" VerticalAlignment="Center" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}" Grid.Column="4" BorderThickness="0" Name="btnNext" Cursor="Hand">
<materialDesign:PackIcon Kind="ArrowRight" Height="32" Width="32"/>
</Button>
<Button Width="60" Height="60" Click="OnEndPageClick" HorizontalAlignment="Center" ToolTip="最后一页" VerticalAlignment="Center" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}" Grid.Column="5" BorderThickness="0" Name="btnEnd" Cursor="Hand">
<materialDesign:PackIcon Kind="ArrowCollapseRight" Height="32" Width="32" />
</Button>
</Grid>
</Border>
</UserControl>
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace LiteChannel.UsControl
{
/// <summary>
/// PageControl.xaml 的交互逻辑
/// </summary>
public partial class PageControl : UserControl
{
#region 委托事件
//定义一个事件
public event RoutedEventHandler OnPageChanged;
#endregion
public PageControl()
{
InitializeComponent();
}
/// <summary>
/// 总页数
/// </summary>
private int pageCount = 0;
/// <summary>
/// 当前页
/// </summary>
private int pageIndex = 0;
#region 每页条数
/// <summary>
/// 注册当前页
/// </summary>
public static readonly DependencyProperty PageSizeProperty = DependencyProperty.Register("PageSize", typeof(string),
typeof(PageControl), new FrameworkPropertyMetadata("0", FrameworkPropertyMetadataOptions.AffectsMeasure), new ValidateValueCallback(PageIndexValidation));
/// <summary>
/// 当前页
/// </summary>
public string PageSize
{
get { return GetValue(PageSizeProperty).ToString(); }
set
{
SetValue(PageSizeProperty, value);
}
}
#endregion
#region 当前页
/// <summary>
/// 注册当前页
/// </summary>
public static readonly DependencyProperty PageIndexProperty = DependencyProperty.Register("PageIndex", typeof(string),
typeof(PageControl), new FrameworkPropertyMetadata("0", FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnPageIndexChanged)), new ValidateValueCallback(PageIndexValidation));
/// <summary>
/// 验证当前页
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool PageIndexValidation(object value)
{
return true;
}
/// <summary>
/// 当前页
/// </summary>
public string PageIndex
{
get { return GetValue(PageIndexProperty).ToString(); }
set
{
//if (int.Parse(value) <= 0) { value = "1"; }
SetValue(PageIndexProperty, value);
}
}
#endregion
#region 总页数
/// <summary>
/// 总页数
/// </summary>
public static readonly DependencyProperty TotalPageProperty = DependencyProperty.Register("TotalPage", typeof(string), typeof(PageControl), new FrameworkPropertyMetadata("0", FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnTotalPageChanged)), new ValidateValueCallback(PageCountPageValidation));
/// <summary>
/// 总页数进行验证
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool PageCountPageValidation(object value)
{
return true;
}
/// <summary>
/// 总页数
/// </summary>
public string TotalPage
{
get { return GetValue(TotalPageProperty).ToString(); }
set
{
SetValue(TotalPageProperty, value);
}
}
/// <summary>
/// 总数据条数
/// </summary>
public static readonly DependencyProperty TotalRecordProperty = DependencyProperty.Register("TotalRecord", typeof(string), typeof(PageControl), new FrameworkPropertyMetadata("0", FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnTotalRecodChanged)), new ValidateValueCallback(TotalRecordPageValidation));
/// <summary>
/// 总页数进行验证
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool TotalRecordPageValidation(object value)
{
return true;
}
/// <summary>
/// 总页数
/// </summary>
public string TotalRecord
{
get { return GetValue(TotalRecordProperty).ToString(); }
set
{
SetValue(TotalRecordProperty, value);
}
}
#endregion
#region 私有方法
/// <summary>
/// 值改变方法将由此方法来引发事件
/// </summary>
private void PageChangedTrigger()
{
///引发事件
OnPageChanged?.Invoke(this, new RoutedEventArgs());
}
#endregion
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnFirPageClick(object sender, RoutedEventArgs e)
{
PageIndex = "1";
PageChangedTrigger();
}
/// <summary>
/// 前一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnPrePageClick(object sender, RoutedEventArgs e)
{
pageCount = GetIntVal(TotalPage);
pageIndex = GetIntVal(PageIndex);
if (pageIndex > 1)
{
pageIndex = pageIndex - 1;
PageIndex = pageIndex.ToString();
}
PageChangedTrigger();
}
/// <summary>
/// 后一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnNexPageClick(object sender, RoutedEventArgs e)
{
pageIndex = GetIntVal(PageIndex);
pageCount = GetIntVal(TotalPage);
if (pageIndex < pageCount)
{
pageIndex = pageIndex + 1;
PageIndex = pageIndex.ToString();
}
PageChangedTrigger();
}
/// <summary>
/// 尾页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnEndPageClick(object sender, RoutedEventArgs e)
{
pageIndex = GetIntVal(TotalPage);
PageIndex = pageIndex.ToString();
PageChangedTrigger();
}
/// <summary>
/// 刷新当前页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRefresh_Click(object sender, RoutedEventArgs e)
{
PageChangedTrigger();
}
/// <summary>
/// 索引转换int
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
private int GetIntVal(string val)
{
if (!int.TryParse(val, out int temp))
{
temp = 1;
}
return temp;
}
/// <summary>
/// 画每页显示等数据
/// </summary>
private static void DisplayPagingInfo(PageControl datapage)
{
if (int.Parse(datapage.PageIndex) == 1)
{
datapage.btnUp.IsEnabled = false;
datapage.btnFirst.IsEnabled = false;
}
else
{
datapage.btnUp.IsEnabled = true;
datapage.btnFirst.IsEnabled = true;
}
if (int.Parse(datapage.PageIndex) == int.Parse(datapage.TotalPage == "" ? "0" : datapage.TotalPage))
{
datapage.btnNext.IsEnabled = false;
datapage.btnEnd.IsEnabled = false;
}
else
{
datapage.btnNext.IsEnabled = true;
datapage.btnEnd.IsEnabled = true;
}
datapage.tbTip.Text = $"第{datapage.PageIndex}页,共{datapage.TotalPage}页。共{datapage.TotalRecord}条记录!";
}
/// <summary>
/// 当当前页值改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnTotalPageChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
DisplayPagingInfo(sender as PageControl);
//MyButton hsb = (MyButton)sender;
// SetValue(PageControl.CurrentPageProperty, "1");
// SetFunc();
//Image image = hsb.tehImage;
//CurrentPage = "1";
//image.Source = new BitmapImage((Uri)e.NewValue);
}
/// <summary>
/// 当当前页值改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnTotalRecodChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
DisplayPagingInfo(sender as PageControl);
}
/// <summary>
/// 当当前页值改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnPageIndexChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
DisplayPagingInfo(sender as PageControl);
//MyButton hsb = (MyButton)sender;
// SetValue(PageControl.CurrentPageProperty, "1");
// ShowMsg("event");
//Image image = hsb.tehImage;
//CurrentPage = "1";
//image.Source = new BitmapImage((Uri)e.NewValue);
}
private void DataPageControl_Loaded(object sender, RoutedEventArgs e)
{
if (this.pageCount == 1 && pageIndex == 1)
{
btnEnd.IsEnabled = false;
btnFirst.IsEnabled = false;
btnNext.IsEnabled = false;
btnUp.IsEnabled = false;
}
}
}
}
<UserControl x:Class="LiteChannel.UsControl.WaitDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:LiteChannel.UsControl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel Margin="16">
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" x:Name="progress" Minimum="0" Value="0" Maximum="100" HorizontalAlignment="Center" Margin="16" IsIndeterminate="True" />
<TextBlock FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" Name="txtTip" Text="数据加载中...."></TextBlock>
</StackPanel>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace LiteChannel.UsControl
{
/// <summary>
/// InputDialog.xaml 的交互逻辑
/// </summary>
public partial class WaitDialog : UserControl
{
public WaitDialog()
{
InitializeComponent();
}
public void SetToolTop(string str, bool flag=false)
{
this.Dispatcher.Invoke(() =>
{
if (flag) { progress.Value = 99; }
this.txtTip.Text = str;
});
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiteChannel
{
public class VOrderInfo
{
public string Id { get; set; }
public string WarehouseId { get; set; }
public string OrderCode { get; set; }
public string OrgId { get; set; }
public DateTime CreateTime { get; set; }
public bool? IsWork { get; set; }
public string OrderType { get; set; }
}
}
qlY+cqBpLohGwnUHjysa+Xmllzuo+epWE1WatyIJg58QRCqFDWJnTpKftJAuzZk29ZfTyhRP2+vOqH0dfo7riorAXQpkerJ19cFrUTZy6zAjnF5qycCEvuz1YcQZ7B/3LuZZh6So0VrYLtNWTIce8gWn+rPraQwX85wXJrJHaKJfJTnl1yPMiwxrbOOpF7Awu6bkVCH5HS4gx+VVv/RHkW1mRlg6/WQUrY6otQmydjG8XEWVuuEoq8DndAjaNU2V5FtiaoLv1ANWRz8K6KXVv2eX+u+6rAdRpwohxen5dLXP1+5wFv27JYuXI2JIPg7pOqy2Di/WuzNo8k4kzA2lRenq3PFWXNRAN+ainUWXczkEKVwAJtL9OzFhMv0YGIqOZDyyFsfxM3C3gDvJ1lXgGvqaJE46oncD3s04b/m9/BXP5ahL+kWVm5KH0o1zB7tY0x5OBhikvc3DN4FTb/TlP63k9Mbvfb6yxXLAJZPEt3Sbqwz5EkqBi3Y8RBgaoi+7+B3iZgN+rxDOFGQwzCTzVzzi0Q9TheOGLTEfPIgjEUJNSfZxpIqR57WtKQ4gXTVuJ0ltVswBbsicuQj1M3Dz5ubKbVNU67e1czxiKzh7s/MdmIDGULAv/HIvyt1RapDwYbfXTLimBbogmibBy3dzdOHzCXv/rEnE6y6O0rgSBxhnA9KZ/BP9BccxSHFah57LVfOTDT73TNSvhzTk9024JhpVeGoTH0CqTOrLeMxdzzEuAGQ0x0uSyxPRKeiyhvPhIwob0Uh+otI7fB1LMEo1G66DJF8tQgTjpqeau3lOjg9ACq2bplplqh399QoSzs1D5rEl07fboQpQ8sy+L3US7R3UPnaks51bnRCbcBtjT5Z4t4d+KLhgJT8nAP8luPhGSRhwbjRdj2LE0GzcL0F2abDaOCv7JN8tkC+hOsuknXYYWryBvGwOpcU/1NJ66Yqm0t8/NQHSajDlt0CxmQBZxWWe5saw1HoLmuDaHckWN/Rf8C8R7MoP6zhS/c0SF1ZS1GUnoh5QGN39rxoP4WzK0wqGVy1VGd3pQiVVxT1MdAWQN7KZsK2LY9oy12LyBc8Xs5MNcuEQDNqJtMevebRkhq6Au6ghx+RqzG9rrWraiq5hRE56G2yXEY/oceToIuHTnhGYcyjGpv1FMBtqcNv714pI/9k6AwnaOPSmmMO5lqARoxUvyfqPDXRY06Y/+dv89fU3q1jTNndNY7atGJ+g1kWaD7ECYToul5QGsVVaHBB/AS6cz9QjuylB0HZ2F3Msg/M1VtYbaatlrBI/bU8kRdGXhJ0m5eVI0ybtDotBFvr01g23Af6V7rZQrBqRwfctfVp0WpyyMmhOF2c2p0GFY701XU4MYEn8P+atDWgz4Gxti97vvDpVKhiQp9HIqfllUztuvThHOVaMctXRYhPopw==
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="2.0.5" targetFramework="net46" />
<package id="LiteDB" version="5.0.8" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.2.6" targetFramework="net46" />
<package id="MaterialDesignThemes" version="3.1.3" targetFramework="net46" />
<package id="Microsoft.CSharp" version="4.6.0" targetFramework="net46" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.19" targetFramework="net46" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net46" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" />
<package id="Panuon.UI.Silver" version="1.1.3.2" targetFramework="net46" />
<package id="System.Data.DataSetExtensions" version="4.6.0-preview3.19128.7" targetFramework="net46" />
</packages>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论