Browse Source

实时更新卡

master
xxe 2 years ago
parent
commit
d65ea3a23e
35 changed files with 24 additions and 1944 deletions
  1. +0
    -20
      HKCard.sln
  2. +0
    -19
      HKCardIN/App.xaml
  3. +0
    -8
      HKCardIN/App.xaml.cs
  4. +0
    -84
      HKCardIN/Bootstrapper.cs
  5. +0
    -54
      HKCardIN/HKCardIN.csproj
  6. BIN
     
  7. BIN
     
  8. +0
    -34
      HKCardIN/Helper/DataBus.cs
  9. +0
    -32
      HKCardIN/Helper/HKHelper.cs
  10. +0
    -445
      HKCardIN/Helper/ThreadManage.cs
  11. +0
    -90
      HKCardIN/Logic/BaseLogic.cs
  12. +0
    -21
      HKCardIN/Logic/Model/UserAndCardInfo.cs
  13. +0
    -3
      HKCardIN/Properties/AssemblyInfo.cs
  14. +0
    -6
      HKCardIN/Properties/DesignTimeResources.xaml
  15. +0
    -23
      HKCardIN/ValidataRule.cs
  16. +0
    -182
      HKCardIN/ViewModels/RootViewModel.cs
  17. +0
    -49
      HKCardIN/Views/CardView.xaml
  18. +0
    -41
      HKCardIN/Views/CardView.xaml.cs
  19. +0
    -324
      HKCardIN/Views/RootView.xaml
  20. +0
    -14
      HKCardIN/Views/RootView.xaml.cs
  21. +0
    -6
      HKCardIN/options.json
  22. +2
    -0
      HKCardManager/Form1.cs
  23. +1
    -1
      HKCardManager/Program.cs
  24. +5
    -0
      HKCardManager/UserPages/CarMangerPage.cs
  25. +1
    -1
      HKCardOUT/Bootstrapper.cs
  26. +13
    -1
      HKCardOUT/CardHandle.cs
  27. +2
    -2
      HKLib/Interfaces/HKLibHelper.cs
  28. +0
    -9
      WpfTest/App.xaml
  29. +0
    -17
      WpfTest/App.xaml.cs
  30. +0
    -10
      WpfTest/AssemblyInfo.cs
  31. +0
    -13
      WpfTest/MainWindow.xaml
  32. +0
    -382
      WpfTest/MainWindow.xaml.cs
  33. +0
    -12
      WpfTest/Window1.xaml
  34. +0
    -27
      WpfTest/Window1.xaml.cs
  35. +0
    -14
      WpfTest/WpfTest.csproj

+ 0
- 20
HKCard.sln View File

@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardIN", "HKCardIN\HKCardIN.csproj", "{B1174E5F-41B1-447E-BCDD-3C94E311487D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardOUT", "HKCardOUT\HKCardOUT.csproj", "{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKLog", "HKLog\HKLog.csproj", "{617E076F-D422-44B7-8455-006AA34ECD45}"
@@ -21,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKLib", "HKLib\HKLib.csproj
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardManager", "HKCardManager\HKCardManager.csproj", "{96C17249-7F4A-4D25-B658-507A8E876582}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTest", "WpfTest\WpfTest.csproj", "{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -31,14 +27,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Debug|x86.ActiveCfg = Debug|x86
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Debug|x86.Build.0 = Debug|x86
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Release|Any CPU.Build.0 = Release|Any CPU
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Release|x86.ActiveCfg = Release|x86
{B1174E5F-41B1-447E-BCDD-3C94E311487D}.Release|x86.Build.0 = Release|x86
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Debug|x86.ActiveCfg = Debug|x86
@@ -103,14 +91,6 @@ Global
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|Any CPU.Build.0 = Release|Any CPU
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|x86.ActiveCfg = Release|Any CPU
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|x86.Build.0 = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|x86.ActiveCfg = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|x86.Build.0 = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|Any CPU.Build.0 = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|x86.ActiveCfg = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 0
- 19
HKCardIN/App.xaml View File

@@ -1,19 +0,0 @@
<Application x:Class="HKCardIN.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:HKCardIN">
<Application.Resources>
<s:ApplicationLoader>
<s:ApplicationLoader.Bootstrapper>
<local:Bootstrapper/>
</s:ApplicationLoader.Bootstrapper>

<s:ApplicationLoader.MergedDictionaries>
<hc:ThemeResources/>
<hc:Theme/>
</s:ApplicationLoader.MergedDictionaries>
</s:ApplicationLoader>
</Application.Resources>
</Application>

+ 0
- 8
HKCardIN/App.xaml.cs View File

@@ -1,8 +0,0 @@
using System.Windows;

namespace HKCardIN
{
public partial class App : Application
{
}
}

+ 0
- 84
HKCardIN/Bootstrapper.cs View File

@@ -1,84 +0,0 @@
using HandyControl.Controls;
using HKCardIN.ViewModels;
using Stylet;
using StyletIoC;
using System;
using System.Configuration;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows;
using Microsoft.Extensions.Configuration;
using HKCardIN.Helper;

namespace HKCardIN
{
public class Bootstrapper : Bootstrapper<RootViewModel>
{
/// <summary>
/// 程序启动
/// </summary>
protected override void OnStart()
{
HKLog.HKLogImport.Init("HKCardIN");
}

protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
}

/// <summary>
/// 初始化系统相关参数配置
/// </summary>
protected override void Configure()
{
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
DataBus.SaasRoute = configer["SaasRoute"];
DataBus.LockCode = configer["LockCode"];
base.Configure();
}

/// <summary>
/// 初始化VM
/// </summary>
protected override void Launch()
{
base.Launch();
}

/// <summary>
/// 加载首页VM
/// </summary>
/// <param name="rootViewModel"></param>
protected override void DisplayRootView(object rootViewModel)
{
base.DisplayRootView(rootViewModel);
}

/// <summary>
///VM加载完毕
/// </summary>
protected override void OnLaunch()
{
base.OnLaunch();
}

/// <summary>
/// 退出
/// </summary>
/// <param name="e"></param>
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
}

/// <summary>
/// 全局异常捕获
/// </summary>
/// <param name="e"></param>
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{
HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
GC.Collect();
}
}
}

+ 0
- 54
HKCardIN/HKCardIN.csproj View File

@@ -1,54 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<UseWPF>true</UseWPF>
<AssemblyName>HKCardIN</AssemblyName>
<RootNamespace>HKCardIN</RootNamespace>
<Version>1.0.0.0</Version>
<Configurations>Debug;Release</Configurations>
<Copyright>Copyright © HBL 2022</Copyright>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Remove="HKResouces\头像.png" />
<None Remove="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.25" />
<PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HKLog\HKLog.csproj" />
<ProjectReference Include="..\UHFHelper\UHFHelper.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="HKResouces\头像.png" />
<Resource Include="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup>
<None Update="options.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

BIN
View File


BIN
View File


+ 0
- 34
HKCardIN/Helper/DataBus.cs View File

@@ -1,34 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XExten.Advance.LinqFramework;
using XExten.Advance.StaticFramework;

namespace HKCardIN.Helper
{
public class DataBus
{
public static bool NetWordState { get; set; } = false;
public static string SaasRoute { get; set; }
public static string LockCode { get; set; }
}
public class ApiRoute
{
/// <summary>
/// 拉取用户和卡信息
/// </summary>
public static string PullUserAndCardInfo = DataBus.SaasRoute + "api/member-helper/membercardinfo";
/// <summary>
/// 推送充值到服务器
/// </summary>
public static string PushMoneyToServer = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge";
/// <summary>
/// 根据会员手机获取卡号
/// </summary>
public static string GetCardNoByPhone = DataBus.SaasRoute + "api/member-helper/membercardinfo";
}
}

+ 0
- 32
HKCardIN/Helper/HKHelper.cs View File

@@ -1,32 +0,0 @@
using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace HKCardIN.Helper
{
public class HKHelper: Singleton<HKHelper>
{
/// <summary>
/// 判断网络状况的方法,返回值true为连接,false为未连接
/// </summary>
/// <param name="conState"></param>
/// <param name="reder"></param>
/// <returns></returns>
[DllImport("wininet")]
public extern static bool InternetGetConnectedState(out int conState, int reder);
/// <summary>
/// 获取当前网络连接状态
/// </summary>
/// <returns>成功连接网络返回 true,未连接返回 false</returns>
public bool GetNetworkState()
{
return InternetGetConnectedState(out int i, 0);
}

}
}

+ 0
- 445
HKCardIN/Helper/ThreadManage.cs View File

@@ -1,445 +0,0 @@
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;

//namespace HKCardIN.Helper
//{
// public class Singleton<T> where T : new()
// {
// private static object _async = new object();

// private static T _instance;

// static readonly Lazy<T> instance = new();
// /// <summary>
// /// 获取实例
// /// </summary>
// /// <returns></returns>
// public static T GetInstance()
// {
// return instance.Value;
// }
// }
// public class ThreadManage : Singleton<ThreadManage>
// {
// string guid = "871d7e28-c413-4675-8d28-64e4dca4c2d3-";
// private static readonly object _lock = new object();
// StringBuilder callbackKey = new StringBuilder();
// List<string> keys = new List<string>();
// ConcurrentDictionary<string, Task> Threads = new ConcurrentDictionary<string, Task>();
// ConcurrentDictionary<string, CancellationTokenSource> CancellationTokenSources = new ConcurrentDictionary<string, CancellationTokenSource>();

// /// <summary>
// /// 停止指定任务
// /// </summary>
// /// <param name="key">任务名</param>
// /// <param name="ExitCallback">任务结束的回调</param>
// public void StopTask(string key, Action ExitCallback = null)
// {
// if (CancellationTokenSources.ContainsKey(guid + key))
// {
// CancellationTokenSources[guid + key]?.Cancel();
// ActionManage.GetInstance.Register(ExitCallback, guid + key);
// }
// else
// {
// if (ExitCallback != null) ExitCallback();
// }
// }

// /// <summary>
// /// 长任务,带 while true 的循环
// /// </summary>
// /// <param name="action"></param>
// /// <param name="key"></param>
// public void StartLong(Action action, string key, bool IsRestart = false, Action RunComplete = null)
// {
// CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
// bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
// {
// Thread.CurrentThread.Name = key;
// ReStart:
// try
// {
// while (!CancellationTokenSources[guid + key].IsCancellationRequested)
// {
// if (action != null) action();
// }
// }
// catch (Exception ex)
// {
// if (IsRestart)
// {
// Thread.Sleep(2000);
// goto ReStart;
// }
// else
// {
// CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
// Threads.TryRemove(guid + key, out Task temp1);
// }
// }
// }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
// {
// ThreadStatus(t, o.ToString());
// if (RunComplete != null) RunComplete();
// }), guid + key));
// }


// /// <summary>
// /// 不带 while true 的循环任务
// /// </summary>
// /// <param name="action"></param>
// /// <param name="key"></param>
// public void Start(Action action, string key, bool isRestart = false)
// {
// CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
// bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
// {
// Thread.CurrentThread.Name = key;
// try
// {
// if (action != null) action();
// }
// catch (Exception ex)
// {
// if (isRestart)
// {
// CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource item1);
// Threads.TryRemove(guid + key, out Task item2);
// Start(action, key, isRestart);
// }
// else
// {
// }
// }
// }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
// {
// ThreadStatus(t, o.ToString());
// }), guid + key));
// }

// private void ThreadStatus(Task task, string key)
// {
// bool IsRemove = false;
// string name = key.Substring(key.LastIndexOf('-') + 1);
// switch (task.Status)
// {
// case TaskStatus.RanToCompletion:
// IsRemove = true;
// break;
// case TaskStatus.Faulted:
// IsRemove = true;
// break;
// case TaskStatus.Canceled:
// IsRemove = true;
// break;
// default:
// break;
// }

// if (IsRemove)
// {
// if (Threads.ContainsKey(key))
// Threads.TryRemove(key, out Task t);
// if (CancellationTokenSources.ContainsKey(key))
// CancellationTokenSources.TryRemove(key, out CancellationTokenSource cts);
// ActionManage.GetInstance.Send(key);
// }
// }

// /// <summary>
// /// 释放所有线程资源
// /// </summary>
// public void Dispose()
// {
// for (int i = 0; i < CancellationTokenSources.Count; i++)
// {
// CancellationTokenSources.ElementAt(i).Value.Cancel();
// }
// }

// /// <summary>
// /// 判断指定线程是否完成
// /// </summary>
// /// <param name="key"></param>
// /// <returns></returns>
// public bool IsComplete(string key)
// {
// if (Threads.ContainsKey(guid + key)) return Threads[guid + key].IsCompleted;
// return false;
// }

// }
// internal class Delegation
// {
// /// <summary>
// /// 带参数的委托
// /// </summary>
// public Action<object> ActionPar { get; set; }
// /// <summary>
// /// 带参数的委托
// /// </summary>
// public Action<object[]> ActionPars { get; set; }
// /// <summary>
// /// 无参数的委托
// /// </summary>
// public Action ActionBus { get; set; }
// /// <summary>
// /// 有返回值的委托
// /// </summary>
// public Func<object> FuncObj { get; set; }
// /// <summary>
// /// 有返回值,有参数的委托
// /// </summary>
// public Func<object, object> FuncPar { get; set; }
// }
// public class ActionManage
// {

// private volatile static ActionManage _Instance;
// public static ActionManage GetInstance => _Instance ?? (_Instance = new ActionManage());
// private ActionManage() { }

// //private static ConcurrentDictionary<string, delegate> actions = new ConcurrentDictionary<string, delegate>();
// private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>();

// static readonly object SendLock = new object();
// static readonly object SendParLock = new object();
// static readonly object RegisterLock = new object();

// /// <summary>
// /// 注销委托
// /// </summary>
// /// <param name="key"></param>
// public void CancelRegister(string key)
// {
// if (actions.ContainsKey(key))
// actions.TryRemove(key, out Delegation t);
// }

// /// <summary>
// /// 执行注册过的委托
// /// </summary>
// /// <param name="key">注册委托的key</param>
// /// <param name="par">委托参数</param>
// /// <param name="Callback">委托回调</param>
// public void Send(string key, object par, Action Callback = null)
// {
// lock (SendLock)
// if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback);
// }

// /// <summary>
// /// 执行注册过的委托
// /// </summary>
// /// <param name="key">注册委托的key</param>
// /// <param name="par">委托参数</param>
// /// <param name="Callback">委托回调</param>
// public void Send(string key, object[] par, Action Callback = null)
// {
// lock (SendLock)
// if (actions.ContainsKey(key)) actions[key].ActionPars.Invokes(par, Callback);
// }

// /// <summary>
// /// 执行注册过的委托
// /// </summary>
// /// <param name="key">注册委托的key</param>
// /// <param name="Callback">委托回调</param>
// public void Send(string key, Action Callback = null)
// {
// lock (SendLock)
// if (actions.ContainsKey(key)) actions[key].ActionBus?.Invoke(Callback);
// }

// public object SendResult(string key, object par = null)
// {
// lock (SendLock)
// if (actions.ContainsKey(key))
// if (par == null)
// {
// return actions[key].FuncObj?.Invoke();
// }
// else
// {
// return actions[key].FuncPar?.Invoke(par);
// }
// return default;
// }

// public void Register<T>(T action, string key)
// {
// lock (RegisterLock)
// {
// if (action != null)
// {
// if (!actions.ContainsKey(key))
// {
// if (action is Action actionBus)
// actions.TryAdd(key, new Delegation() { ActionBus = actionBus });

// if (action is Action<object> actionObj)
// actions.TryAdd(key, new Delegation() { ActionPar = actionObj });

// if (action is Action<object[]> actionObjs)
// actions.TryAdd(key, new Delegation() { ActionPars = actionObjs });

// if (action is Func<object> funcObj)
// actions.TryAdd(key, new Delegation() { FuncObj = funcObj });

// if (action is Func<object, object> puncPar)
// actions.TryAdd(key, new Delegation() { FuncPar = puncPar });
// }
// }
// }

// }

// }
// public static class ExpandMethod
// {
// /// <summary>
// /// 获取布尔数组指定值得索引
// /// </summary>
// /// <param name="obj">要获取索引的数组</param>
// /// <param name="value">要获取索引的值</param>
// /// <returns></returns>
// public static int GetIndex(this bool[] obj, bool value)
// {
// if (obj == null) return -1;
// return Array.FindIndex(obj, p => p == value);
// }

// /// <summary>
// /// 获取字符串数组指定值得索引
// /// </summary>
// /// <param name="obj">要获取索引的数组</param>
// /// <param name="value">要获取索引的值</param>
// /// <returns></returns>
// public static int GetIndex(this string[] obj, string value)
// {
// if (obj == null || value == null) return -1;
// return Array.FindIndex(obj, p => p == value && p.Length > 0);
// }

// /// <summary>
// /// 委托回调
// /// </summary>
// /// <param name="action">要执行的委托</param>
// /// <param name="callback">委托回调</param>
// public static void Invoke(this Action action, Action callback)
// {
// action?.Invoke();
// callback?.Invoke();
// }

// /// <summary>
// /// 委托回调
// /// </summary>
// /// <param name="action">要执行的委托</param>
// /// <param name="par">要执行的委托的参数</param>
// /// <param name="callback">委托回调</param>
// public static void Invoke(this Action<object> action, object par, Action callback)
// {
// action?.Invoke(par);
// callback?.Invoke();
// }

// public static void Invokes(this Action<object[]> action, object[] par, Action callback)
// {
// action?.Invoke(par);
// callback?.Invoke();
// }


// /// <summary>
// /// 字节数组转换成32位整数
// /// </summary>
// /// <param name="bytes"></param>
// /// <returns></returns>
// public static int BytesToInt(this byte[] bytes)
// {
// if (bytes.Length > 4) return -1;
// int ReturnVlaue = 0;
// for (int i = 0; i < bytes.Length; i++)
// {
// ReturnVlaue += (int)(bytes[i] << (i * 8));
// }
// return ReturnVlaue;
// }

// /// <summary>
// /// 字节数组转换成 ushort 数组
// /// </summary>
// /// <param name="bytes">要转换的字节数组</param>
// /// <param name="reverse">字节高度顺序控制</param>
// /// <returns></returns>
// public static ushort[] BytesToUshorts(this byte[] bytes, bool reverse = false)
// {
// int len = bytes.Length;

// byte[] srcPlus = new byte[len + 1];
// bytes.CopyTo(srcPlus, 0);
// int count = len >> 1;

// if (len % 2 != 0)
// {
// count += 1;
// }

// ushort[] dest = new ushort[count];
// if (reverse)
// {
// for (int i = 0; i < count; i++)
// {
// dest[i] = (ushort)(srcPlus[i * 2] << 8 | srcPlus[2 * i + 1] & 0xff);
// }
// }
// else
// {
// for (int i = 0; i < count; i++)
// {
// dest[i] = (ushort)(srcPlus[i * 2] & 0xff | srcPlus[2 * i + 1] << 8);
// }
// }

// return dest;
// }

// /// <summary>
// /// ushort 数组转换成字节数组
// /// </summary>
// /// <param name="src">需要转换的 ushort数组</param>
// /// <param name="reverse">高低字节的设置</param>
// /// <returns></returns>
// public static byte[] UshortsToBytes(this ushort[] src, bool reverse = false)
// {

// int count = src.Length;
// byte[] dest = new byte[count << 1];
// if (reverse)
// {
// for (int i = 0; i < count; i++)
// {
// dest[i * 2] = (byte)(src[i] >> 8);
// dest[i * 2 + 1] = (byte)(src[i] >> 0);
// }
// }
// else
// {
// for (int i = 0; i < count; i++)
// {
// dest[i * 2] = (byte)(src[i] >> 0);
// dest[i * 2 + 1] = (byte)(src[i] >> 8);
// }
// }
// return dest;
// }
// }
//}

+ 0
- 90
HKCardIN/Logic/BaseLogic.cs View File

@@ -1,90 +0,0 @@
using BPA.Helper;
using HandyControl.Controls;
using HKCardIN.Helper;
using HKCardIN.Logic.Model;
using HKLog;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using XExten.Advance.HttpFramework.MultiCommon;
using XExten.Advance.HttpFramework.MultiFactory;
using XExten.Advance.LinqFramework;

namespace HKCardIN.Logic
{
public class BaseLogic : Singleton<BaseLogic>
{
/// <summary>
/// 同步用户和卡信息
/// </summary>
/// <returns></returns>
public UserAndCardInfo PullUserAndCardInfo(string CardNo)
{
try
{
return IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullUserAndCardInfo;
t.ReqType = MultiType.POST;
t.JsonParam = (new { cardNum = CardNo }).ToJson();
}).Build().RunStringFirst().ToModel<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
}
catch (Exception ex)
{
HKLogImport.WriteError(ex);
return null;
}
}
/// <summary>
/// 同步充值记录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public bool PushMoneyToServer(string CardNo, decimal Money)
{
try
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PushMoneyToServer;
t.ReqType = MultiType.POST;
t.JsonParam = (new { Money, Type = 1, CardNum = CardNo }).ToJson();
}).Build().RunStringFirst();
return bool.Parse(data.ToModel<JObject>()["data"].ToString());
}
catch (Exception ex)
{
HKLogImport.WriteError(ex);
return false;
}

}
/// <summary>
/// 根据会员手机获取卡号
/// </summary>
/// <param name="Phone"></param>
/// <returns></returns>
public UserAndCardInfo GetCardNoByPhone(string Phone)
{
try
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.GetCardNoByPhone;
t.ReqType = MultiType.POST;
t.JsonParam = (new { phone = Phone }).ToJson();
}).Build().RunStringFirst();
return data.ToModel<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
}
catch (Exception ex)
{
HKLogImport.WriteError(ex);
return null;
}
}
}
}

+ 0
- 21
HKCardIN/Logic/Model/UserAndCardInfo.cs View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HKCardIN.Logic.Model
{
public class UserAndCardInfo
{
public string MemberName { get; set; }
public string MemberPhone { get; set; }
public string MemberCardId { get; set; }
public string MemberHeadImgUrl { get; set; }
public string CardNum { get; set; }
public int CardState { get; set; }
public string Stutas => CardState == 0 ? "禁用" : (CardState == 1 ? "正常" : (CardState == 2 ? "挂失" : "作废"));
public decimal Money { get; set; }
public DateTime CreateAt { get; set; }
}
}

+ 0
- 3
HKCardIN/Properties/AssemblyInfo.cs View File

@@ -1,3 +0,0 @@
using System.Windows;

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

+ 0
- 6
HKCardIN/Properties/DesignTimeResources.xaml View File

@@ -1,6 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:hc="https://handyorg.github.io/handycontrol">
<ResourceDictionary.MergedDictionaries>
<hc:IntellisenseResources Source="/HandyControl;Component/DesignTime/DesignTimeResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

+ 0
- 23
HKCardIN/ValidataRule.cs View File

@@ -1,23 +0,0 @@
using HandyControl.Tools.Extension;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace HKCardIN
{
public class ValidataRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if(value.ToString().IsNullOrEmpty()) return ValidationResult.ValidResult;
var reg = Regex.IsMatch(value.ToString(), "\\d+");
if (!reg) return new ValidationResult(false, "请输入正整数");
else return ValidationResult.ValidResult;
}
}
}

+ 0
- 182
HKCardIN/ViewModels/RootViewModel.cs View File

@@ -1,182 +0,0 @@
using BPA.Helper;
using HandyControl.Data;
using HKCardIN.Helper;
using HKCardIN.Logic;
using HKCardIN.Logic.Model;
using HKCardIN.Views;
using HKLog;
using Stylet;
using System;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using UHFHelper;

namespace HKCardIN.ViewModels
{
public class RootViewModel : Conductor<IScreen>
{
bool IsLocker = false;

public RootViewModel()
{
CodeVisible = Visibility.Collapsed;
ContentVisible = Visibility.Visible;
}

#region 属性
decimal _ShowMoney;
public decimal ShowMoney
{
get => _ShowMoney;
set => SetAndNotify(ref _ShowMoney, value);
}
Visibility _ContentVisible;
public Visibility ContentVisible
{
get => _ContentVisible;
set => SetAndNotify(ref _ContentVisible, value);
}
Visibility _CodeVisible;
public Visibility CodeVisible
{
get => _CodeVisible;
set => SetAndNotify(ref _CodeVisible, value);
}
string _InputMoney;
public string InputMoney
{
get => _InputMoney;
set
{
SetAndNotify(ref _InputMoney, value);
decimal.TryParse(value, out decimal data);
ShowMoney = data;
}
}
string _CardNo;
public string CardNo
{
get => _CardNo;
set => SetAndNotify(ref _CardNo, value);
}
UserAndCardInfo _Info;
public UserAndCardInfo Info
{
get => _Info;
set => SetAndNotify(ref _Info, value);
}
#endregion

#region 命令

public void ReadAction()
{
if (!UHFCardHelper.GetInstance().ComOpen)
{
var res = UHFCardHelper.GetInstance().OpenPort();
HKLogImport.WriteInfo(res.ResMes);
}
var RCardNo = UHFCardHelper.GetInstance().ReadCard();
if (!Regex.IsMatch(RCardNo, "\\d{19}"))
{
var res = HandyControl.Controls.MessageBox.Show(new MessageBoxInfo
{
Button = MessageBoxButton.YesNo,
IconKey = "InfoGeometry",
IconBrushKey = "InfoBrush",
YesContent = "是",
NoContent = "否",
Message = "此卡是新卡,前往制卡",
Caption = "提示!"
});
if (res == MessageBoxResult.Yes)
{
CardView view = new CardView();
if (view.ShowDialog().Value) HandyControl.Controls.Growl.InfoGlobal("制卡成功");
else HandyControl.Controls.Growl.InfoGlobal("制卡失败");
}
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo);
UHFCardHelper.GetInstance().ClosePort();
}
else
{
CardNo = RCardNo;
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo);
UHFCardHelper.GetInstance().ClosePort();
}

}
public void InputAction(string input)
{
if (IsLocker) return;
ShowMoney = decimal.Parse(input);
}
public void LockSreenAction()
{
IsLocker = true;
ContentVisible = Visibility.Collapsed;
CodeVisible = Visibility.Visible;
}
public void UnLockAction(HandyControl.Controls.PasswordBox input)
{
if (input.Password.Equals(DataBus.LockCode))
{
IsLocker = false;
CodeVisible = Visibility.Collapsed;
ContentVisible = Visibility.Visible;
}
}
public void SaveAction()
{
if (!DataBus.NetWordState)
{
HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
return;
}

if (BaseLogic.GetInstance().PushMoneyToServer(CardNo, ShowMoney))
{
HandyControl.Controls.Growl.SuccessGlobal($"【{CardNo}】充值成功,充值金额【{ShowMoney}】");
Task.Run(() =>
{
Thread.Sleep(5 * 1000);
Info = null;
});
}
else
HandyControl.Controls.Growl.InfoGlobal($"【{CardNo}】充值失败");
}
#endregion

#region 方法
protected override void OnViewLoaded()
{
MainThread();
}
private void MainThread()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
try
{
//1.检测网络上下线
bool network = HKHelper.GetInstance().GetNetworkState();
if (network != DataBus.NetWordState)
{
if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
DataBus.NetWordState = network;
}
Thread.Sleep(3000);
}
catch (Exception ex)
{
HandyControl.Controls.Growl.InfoGlobal(ex.Message);
}
}), "循环状态监测线程", false);
}
#endregion
}
}

+ 0
- 49
HKCardIN/Views/CardView.xaml View File

@@ -1,49 +0,0 @@
<Window
x:Class="HKCardIN.Views.CardView"
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:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:HKCardIN.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="海科智慧一卡通平台"
Width="300"
Height="200"
ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.Background>
<ImageBrush ImageSource="/HKResouces/背景.jpg" />
</Window.Background>
<WrapPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<TextBox
x:Name="Phone"
Width="200"
hc:InfoElement.Placeholder="请输入手机号"
Style="{StaticResource TextBoxExtend}" />
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
<Button
x:Name="Query"
Width="80"
Height="50"
Margin="0,0,10,0"
Click="QueryClick"
Content="查询"
FontSize="18"
Style="{StaticResource ButtonDefault}" />
<Button
x:Name="Create"
Width="80"
Height="50"
Margin="10,0,0,0"
Click="CreateClick"
Content="制卡"
FontSize="18"
IsEnabled="False"
Style="{StaticResource ButtonDefault}" />
</WrapPanel>
</WrapPanel>
</Window>

+ 0
- 41
HKCardIN/Views/CardView.xaml.cs View File

@@ -1,41 +0,0 @@
using HKCardIN.Logic;
using HKCardIN.Logic.Model;
using HKLog;
using System.Text.RegularExpressions;
using System.Windows;
using UHFHelper;
using XExten.Advance.LinqFramework;

namespace HKCardIN.Views
{
/// <summary>
/// CardView.xaml 的交互逻辑
/// </summary>
public partial class CardView : System.Windows.Window
{
UserAndCardInfo info;
public CardView()
{
InitializeComponent();
}

private void QueryClick(object sender, RoutedEventArgs e)
{
if (this.Phone.Text.IsNullOrEmpty()) HandyControl.Controls.Growl.InfoGlobal("手机号不能为空!");
if (!Regex.IsMatch(this.Phone.Text, "\\d{11}")) HandyControl.Controls.Growl.InfoGlobal("请输入正确的手机号!");
info = BaseLogic.GetInstance().GetCardNoByPhone(Phone.Text);
if (info != null)
//查询接口
Create.IsEnabled = true;
}

private void CreateClick(object sender, RoutedEventArgs e)
{
if (info.CardNum == null) return;
var res = UHFCardHelper.GetInstance().WriteCard(info.CardNum);
HKLogImport.WriteInfo(res.ResMes);
DialogResult = true;
Close();
}
}
}

+ 0
- 324
HKCardIN/Views/RootView.xaml View File

@@ -1,324 +0,0 @@
<Window
x:Class="HKCardIN.Views.RootView"
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:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:HKCardIN"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:viewModels="clr-namespace:HKCardIN.ViewModels"
x:Name="Root"
Title="海科智慧一卡通平台"
Width="900"
Height="480"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.Resources>
<Style
x:Key="充值"
BasedOn="{StaticResource ButtonDefault}"
TargetType="Button">
<Setter Property="Width" Value="75" />
<Setter Property="Height" Value="75" />
<Setter Property="Margin" Value="5" />
<Setter Property="Foreground" Value="Red" />
<Setter Property="FontSize" Value="18" />
</Style>
<Style
x:Key="操作"
BasedOn="{StaticResource ButtonDefault}"
TargetType="Button">
<Setter Property="Width" Value="120" />
<Setter Property="Height" Value="75" />
<Setter Property="Margin" Value="5" />
<Setter Property="Foreground" Value="Red" />
<Setter Property="FontSize" Value="18" />
</Style>
<Style
x:Key="Title"
BasedOn="{StaticResource TextBlockDefaultBold}"
TargetType="TextBlock">
<Setter Property="Foreground" Value="WhiteSmoke" />
</Style>
</Window.Resources>
<Window.Background>
<ImageBrush ImageSource="/HKResouces/背景.jpg" />
</Window.Background>
<Window.InputBindings>
<KeyBinding
Key="E"
Command="{s:Action UnLockAction}"
CommandParameter="{Binding ., ElementName=Pwd}" />
<KeyBinding Key="R" Command="{s:Action ReadAction}" />
<KeyBinding
Key="F1"
Command="{s:Action InputAction}"
CommandParameter="50" />
<KeyBinding
Key="F2"
Command="{s:Action InputAction}"
CommandParameter="100" />
<KeyBinding
Key="F3"
Command="{s:Action InputAction}"
CommandParameter="200" />
<KeyBinding
Key="F4"
Command="{s:Action InputAction}"
CommandParameter="500" />
<KeyBinding Key="F5" Command="{s:Action LockSreenAction}" />
</Window.InputBindings>
<Grid>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding CodeVisible}">
<hc:PasswordBox
x:Name="Pwd"
Width="200"
hc:InfoElement.Placeholder="请输入解锁码"
hc:PasswordBoxAttach.PasswordLength="20"
ShowClearButton="True"
Style="{StaticResource PasswordBoxPlusBaseStyle}" />
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
<Button
Width="70"
Height="40"
Margin="0,0,10,0"
Command="{s:Action UnLockAction}"
CommandParameter="{Binding ., ElementName=Pwd}"
Content="确定[E]"
FontSize="15" />
</WrapPanel>
</StackPanel>
<Grid Visibility="{Binding ContentVisible}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="13" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Margin="0,12,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".4*" />
<ColumnDefinition Width=".6*" />
</Grid.ColumnDefinitions>
<Border
Width="100"
Height="120"
BorderBrush="BlanchedAlmond"
BorderThickness="1">
<Border.Effect>
<DropShadowEffect ShadowDepth="1" Color="Black" />
</Border.Effect>
<Image
Width="100"
Height="120"
Source="{Binding Info.MemberHeadImgUrl}"
Stretch="UniformToFill" />
</Border>
<StackPanel Grid.Column="1">
<WrapPanel>
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="姓名:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.MemberName}" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="手机:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.MemberPhone}" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="身份证:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.MemberCardId}" />
</WrapPanel>
</StackPanel>
</Grid>
<hc:Divider
Content="卡信息"
FontSize="16"
FontWeight="Bold"
Foreground="WhiteSmoke" />
<StackPanel Margin="20,0,0,0">
<WrapPanel>
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="卡号:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.CardNum}" />
</WrapPanel>
<WrapPanel Margin="0,30,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="卡状态:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.Stutas}" />
</WrapPanel>
<WrapPanel Margin="0,30,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="卡上余额:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.Money}" />
</WrapPanel>
<WrapPanel Margin="0,30,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource Title}"
Text="启用日期:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding Info.CreateAt, StringFormat={}{0:yyyy-MM-dd}}" />
</WrapPanel>
</StackPanel>
</StackPanel>
<hc:Divider
Grid.Column="1"
Height="{Binding ActualHeight, ElementName=Root}"
Orientation="Vertical" />
<StackPanel Grid.Column="2">
<hc:Divider
Content="充值金额"
FontSize="16"
FontWeight="Bold"
Foreground="WhiteSmoke" />
<TextBlock
Margin="5,0,0,0"
FontSize="18"
Style="{StaticResource Title}">
<Run Foreground="WhiteSmoke" Text="当前充值金额:" />
<Run Foreground="Red" Text="{Binding ShowMoney}" />
</TextBlock>
<WrapPanel HorizontalAlignment="Center">
<Button
Command="{s:Action InputAction}"
CommandParameter="50"
Style="{StaticResource 充值}">
<Button.Content>
<StackPanel HorizontalAlignment="Center">
<TextBlock HorizontalAlignment="Center" Text="¥50" />
<TextBlock HorizontalAlignment="Center" Text="[F1]" />
</StackPanel>
</Button.Content>
</Button>
<Button
Command="{s:Action InputAction}"
CommandParameter="100"
Style="{StaticResource 充值}">
<Button.Content>
<StackPanel HorizontalAlignment="Center">
<TextBlock HorizontalAlignment="Center" Text="¥100" />
<TextBlock HorizontalAlignment="Center" Text="[F2]" />
</StackPanel>
</Button.Content>
</Button>
<Button
Command="{s:Action InputAction}"
CommandParameter="200"
Style="{StaticResource 充值}">
<Button.Content>
<StackPanel HorizontalAlignment="Center">
<TextBlock HorizontalAlignment="Center" Text="¥200" />
<TextBlock HorizontalAlignment="Center" Text="[F3]" />
</StackPanel>
</Button.Content>
</Button>
<Button
Command="{s:Action InputAction}"
CommandParameter="500"
Style="{StaticResource 充值}">
<Button.Content>
<StackPanel HorizontalAlignment="Center">
<TextBlock HorizontalAlignment="Center" Text="¥500" />
<TextBlock HorizontalAlignment="Center" Text="[F4]" />
</StackPanel>
</Button.Content>
</Button>
</WrapPanel>
<WrapPanel HorizontalAlignment="Center">
<TextBox
Width="330"
Margin="5,10,0,10"
HorizontalAlignment="Left"
hc:InfoElement.Placeholder="请输入自定义金额"
Style="{StaticResource TextBoxExtend}">
<TextBox.Text>
<Binding Path="InputMoney" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:ValidataRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</WrapPanel>
<WrapPanel HorizontalAlignment="Center">
<TextBox
Width="330"
Margin="5,0,0,10"
HorizontalAlignment="Left"
hc:InfoElement.Placeholder="手动录入卡号"
Style="{StaticResource TextBoxExtend}"
Text="{Binding CardNo}" />
</WrapPanel>
<hc:Divider
Content="操作"
FontSize="16"
FontWeight="Bold"
Foreground="WhiteSmoke" />
<WrapPanel HorizontalAlignment="Center">
<Button
Command="{s:Action ReadAction}"
Content="读卡[R]"
IsDefault="True"
Style="{StaticResource 操作}" />
<Button
Command="{s:Action SaveAction}"
Content="确定[Enter]"
IsDefault="True"
Style="{StaticResource 操作}" />
<Button
Command="{s:Action LockSreenAction}"
Content="锁屏[F5]"
IsDefault="True"
Style="{StaticResource 操作}" />
</WrapPanel>
</StackPanel>
</Grid>
</Grid>
</Window>

+ 0
- 14
HKCardIN/Views/RootView.xaml.cs View File

@@ -1,14 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace HKCardIN.Views
{
public partial class RootView : Window
{
public RootView()
{
InitializeComponent();
}
}
}

+ 0
- 6
HKCardIN/options.json View File

@@ -1,6 +0,0 @@
{
//服务地址
"SaasRoute": "https://bpa.black-pa.com:21527/kitchen/",
//锁屏密码
"LockCode": "HK123456"
}

+ 2
- 0
HKCardManager/Form1.cs View File

@@ -6,6 +6,8 @@ using System.Text.RegularExpressions;
using HKHelper;
using UHFHelper;
using Snowflake.Core;
using HKLib.RabbitMQ.Config;
using HKLib.RabbitMQ.Publisher;

namespace HKCardManager
{


+ 1
- 1
HKCardManager/Program.cs View File

@@ -13,7 +13,7 @@ namespace HKCardManager
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
#if DEBUG
#if !DEBUG
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
#else
var configer = (new ConfigurationBuilder()).AddJsonFile("options.pro.json").Build();


+ 5
- 0
HKCardManager/UserPages/CarMangerPage.cs View File

@@ -1,7 +1,10 @@
using HKLib.Dto;
using HKLib.Interfaces;
using HKLib.RabbitMQ.Config;
using HKLib.RabbitMQ.Publisher;
using HKLib.SQLHelper;
using Snowflake.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -226,6 +229,7 @@ namespace HKCardManager.UserPages
var res = UHFCardHelper.GetInstance().WriteCard(userDto.CardNo);
if (res != null && res.Res)
{
ServiceQueryPush.QueryPush.PushMQ(new { CardNo = userDto.CardNo, Stutas = 1 }, "NewCardChanged", MQEnum.Push);
MessageLogNotify.GetInstance.Show($"用户 【{userDto.Name}】 写卡成功...");
textBox2.Text = String.Empty;
button2.Enabled = false;
@@ -387,6 +391,7 @@ namespace HKCardManager.UserPages
var result = await HKLibHelper.AddUserAndBindCard(userDto);
if (result)
{
ServiceQueryPush.QueryPush.PushMQ(new { CardNo = userDto.CardNo, Stutas = 1 }, "NewCardChanged", MQEnum.Push);
MessageLogNotify.GetInstance.Show($"用户 【{userDto.Name}】 写卡成功,卡号:{userDto.CardNo}");
MessageBox.Show($"用户 【{userDto.Name}】 写卡成功,卡号:{userDto.CardNo}");
RefreshTheData(comboBox_jglb.Text);


+ 1
- 1
HKCardOUT/Bootstrapper.cs View File

@@ -99,7 +99,7 @@ namespace HKCardOUT
ServiceQueryExcute.QueryExcute.ExtuteMQ<CardHandle, string>("CardStutasChanged", MQEnum.Push);
ServiceQueryExcute.QueryExcute.ExtuteMQ<TimeHandle, string>("TimeChanged", MQEnum.Push);
ServiceQueryExcute.QueryExcute.ExtuteMQ<FoodHandle, string>("GateFood", MQEnum.Push);
ServiceQueryExcute.QueryExcute.ExtuteMQ<RangeHandle, string>("GateSet", MQEnum.Push);
ServiceQueryExcute.QueryExcute.ExtuteMQ<NewCardHandle, string>("NewCardChanged", MQEnum.Top);
//服务器拉取数据
RemoteService.SyncTime();
DataBus.UserListDto = HKLib.Interfaces.HKLibHelper.GetUserListSync("");


+ 13
- 1
HKCardOUT/CardHandle.cs View File

@@ -1,4 +1,5 @@
using HKCardOUT.Helper;
using BPA.Models;
using HKCardOUT.Helper;
using HKCardOUT.Logic;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
@@ -22,6 +23,17 @@ namespace HKCardOUT
new HKCore().GetAllCardStatus();
}
}

public class NewCardHandle : IAccept
{
public void AcceptMQ<T>(string msg)
{

var data = msg.ToModel<CardStutas>();
HKCore.AddCard(new List<CardStutas> { data });
}
}

public class TimeHandle : IAccept
{
public void AcceptMQ<T>(string msg)


+ 2
- 2
HKLib/Interfaces/HKLibHelper.cs View File

@@ -45,7 +45,7 @@ namespace HKLib.Interfaces
var res = data.ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
if (res)
{
Task.Run(() => ServiceQueryPush.QueryPush.PushMQAsync(input, "TimeChanged", MQEnum.Push));
ServiceQueryPush.QueryPush.PushMQ(input, "TimeChanged", MQEnum.Push);
return res;
}
return false;
@@ -310,7 +310,7 @@ namespace HKLib.Interfaces
var data = res.ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
if (data)
{
Task.Run(() => ServiceQueryPush.QueryPush.PushMQAsync(input, "CardStutasChanged", MQEnum.Top));
ServiceQueryPush.QueryPush.PushMQ(input, "CardStutasChanged", MQEnum.Top);
return data;
}
return false;


+ 0
- 9
WpfTest/App.xaml View File

@@ -1,9 +0,0 @@
<Application x:Class="WpfTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfTest"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

+ 0
- 17
WpfTest/App.xaml.cs View File

@@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace WpfTest
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 0
- 10
WpfTest/AssemblyInfo.cs View File

@@ -1,10 +0,0 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 0
- 13
WpfTest/MainWindow.xaml View File

@@ -1,13 +0,0 @@
<Window x:Class="WpfTest.MainWindow"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TextBox x:Name="textwb" Background="Black" Foreground="#FFC000FB" TextWrapping="Wrap" AcceptsReturn="True" ></TextBox>
<Button Width="100" Height="100" Click="Button_Click" Visibility="Collapsed"></Button>
</Grid>
</Window>

+ 0
- 382
WpfTest/MainWindow.xaml.cs View File

@@ -1,382 +0,0 @@
using BPA.Communication;
using BPA.Helper;
using BPA.Message;
using BPA.Message.Enum;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// MQTT连接信息
/// </summary>
public string MQTTConnection { get; set; } = "10.2.1.254,1883,admin,public";

/// <summary>
/// Mqtt是否运行
/// </summary>
public bool IsRunningMqtt = false;
/// <summary>
/// Mqtt
/// </summary>
public MqttHelper mqttHelper = new MqttHelper();

public MainWindow()
{
InitializeComponent();
Connection();
ThreadServer();
//Button_Click(null, null);
}
public void ThreadServer()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
try
{
if (IsRunningMqtt)
{
Send(ScreenDeviceType.大炒);
Thread.Sleep(1000);
Send(ScreenDeviceType.小炒); Thread.Sleep(1000);

Send(ScreenDeviceType.煮面机); Thread.Sleep(1000);

Send(ScreenDeviceType.分餐机); Thread.Sleep(1000);

}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"{Name}:线程服务异常,原因:{ex.Message}");
}
Thread.Sleep(100);
}), $"{Name},线程服务");
}
/// <summary>
/// 初始化连接Redis MQTT
/// </summary>
public void Connection()
{
try
{
//2.Mqtt连接
if (!string.IsNullOrEmpty(this.MQTTConnection) && this.MQTTConnection.Contains(','))
{
string[] mqttcom = this.MQTTConnection.Split(',');
if (mqttcom != null && mqttcom.Count() == 4)
{
mqttHelper.Connect(mqttcom[2], mqttcom[3], mqttcom[0], int.Parse(mqttcom[1]), $"{Name}:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
mqttHelper.Disconnect = new Action(() =>
{
IsRunningMqtt = false;
MessageLog.GetInstance.ShowEx($"{Name}:MQTT异常断开....");
});
mqttHelper.ConnectOk = new Action(() =>
{
IsRunningMqtt = true;//连接成功
});
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"{Name}:初始化连接 MQTT,原因:{ex.Message}");
}

}

public void Send(ScreenDeviceType screen)
{
int k2 =new Random().Next(0, 2);
SendScreenDataModel sendScreenData = new SendScreenDataModel();

List<ORDER_STATUS> oRDER_STATUS = new List<ORDER_STATUS>() { ORDER_STATUS.WAIT, ORDER_STATUS.COOKING, ORDER_STATUS.COMPLETED_COOK, ORDER_STATUS.COMPLETED_TAKE, ORDER_STATUS.ERR_NOT_REPLY_WHEN_COOKING };
List<string> name_s = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花", "尖椒鸡杂", "回锅肉" };
List<string> name_s_zm = new List<string>() { "清汤面", "鸡蛋面", "火鸡面", "回锅肉面", "鸡杂面" };

List<string> name_XM = new List<string>() { "王权贵", "张哲", "李青古", "龙西", "李富贵" };
int k = new Random().Next(0, 5);
int M = new Random().Next(0, 5);
if (screen == ScreenDeviceType.大炒)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMaxWok
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus_1 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
WorkStatus_2 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel{Name= name_s[0],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[1],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[2],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[3],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[4],Count=new Random().Next(0, 100)},
},
MaxWok_Dishes_1 = "回锅肉",
MaxWok_Task_1 = "炒菜中",
MaxWok_Process_1 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(M==0) ? ProcessStatus.正在执行:((M>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(M==1) ? ProcessStatus.正在执行:((M>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(M==2) ? ProcessStatus.正在执行:((M>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(M==3) ? ProcessStatus.正在执行:((M>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(M==4) ? ProcessStatus.正在执行:((M>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MaxWok_HeatGear_1 = "1",
MaxWok_StirGear_1 = "2",
MaxWok_FlipSpeed_1 = "30",
MaxWok_Temp_1 = "102",
MaxWok_OrderCount_1 = new Random().Next(0, 100),
MaxWok_ErrorOrderCount_1 = new Random().Next(0, 100),

MaxWok_Dishes_2 = "烂肉豇豆",
MaxWok_Task_2 = "炒菜中",
MaxWok_Process_2 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(k==0) ? ProcessStatus.正在执行:((k>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(k==1) ? ProcessStatus.正在执行:((k>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(k==2) ? ProcessStatus.正在执行:((k>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(k==3) ? ProcessStatus.正在执行:((k>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(k==4) ? ProcessStatus.正在执行:((k>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MaxWok_HeatGear_2 = "2",
MaxWok_StirGear_2 = "3",
MaxWok_FlipSpeed_2 = "32",
MaxWok_Temp_2 = "132",
MaxWok_OrderCount_2 = new Random().Next(0, 100),
MaxWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
}
else if (screen == ScreenDeviceType.小炒)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMinWok
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus_1 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
WorkStatus_2 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel{Name= name_s[0],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[1],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[2],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[3],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[4],Count=new Random().Next(0, 100)},
},
MinWok_Dishes_1 = "回锅肉",
MinWok_Task_1 = "炒菜中",
MinWok_Process_1 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(M==0) ? ProcessStatus.正在执行:((M>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(M==1) ? ProcessStatus.正在执行:((M>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(M==2) ? ProcessStatus.正在执行:((M>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(M==3) ? ProcessStatus.正在执行:((M>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(M==4) ? ProcessStatus.正在执行:((M>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MinWok_HeatGear_1 = "1",
MinWok_StirGear_1 = "2",
MinWok_FlipSpeed_1 = "30",
MinWok_Temp_1 = "102",
MinWok_OrderCount_1 = new Random().Next(0, 100),
MinWok_ErrorOrderCount_1 = new Random().Next(0, 100),

MinWok_Dishes_2 = "烂肉豇豆",
MinWok_Task_2 = "炒菜中",
MinWok_Process_2 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(k==0) ? ProcessStatus.正在执行:((k>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(k==1) ? ProcessStatus.正在执行:((k>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(k==2) ? ProcessStatus.正在执行:((k>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(k==3) ? ProcessStatus.正在执行:((k>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(k==4) ? ProcessStatus.正在执行:((k>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MinWok_HeatGear_2 = "2",
MinWok_StirGear_2 = "3",
MinWok_FlipSpeed_2 = "32",
MinWok_Temp_2 = "132",
MinWok_OrderCount_2 = new Random().Next(0, 100),
MinWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
}
else if (screen == ScreenDeviceType.煮面机)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMorkS
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
Alarm = new List<AlarmModel> {
new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "煮面机警告,水温过低!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel { Name = name_s_zm[0], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[1], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[2], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[3], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[4], Count = new Random().Next(0, 100) },
},
MorkS_OrderCount = new Random().Next(0, 100),
MorkS_ErrorOrderCount = new Random().Next(0, 100),
MorkS_NoodleUpOrDown_1 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_2 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_3 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_4 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_5 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_6 = k2 == 0 ? "true" : "false",

MorkS_Temp = "false",// k2 == 0 ? "true" : "false",
MorkS_BinLocation = new Random().Next(0, 6).ToString(),
MorkS_SiloMeas = k2 == 0 ? "true" : "false",
MorkS_NoBowMeas = k2 == 0 ? "true" : "false",
MakeOrder = new List<OrderMakeModel> {
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="007".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="008".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="009".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="010".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="011".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_COOK, SortNum="006".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="005".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="004".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="003".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="002".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="001".ToString()},
},

};
}
else if (screen == ScreenDeviceType.分餐机)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelSplitMeals
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
//Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel { Name = name_s[0], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[1], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[2], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[3], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[4], Count = new Random().Next(0, 100) },
},
SplitMeals_CreditCardCount_1 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_1 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_1 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_1 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_2 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_2 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_2 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_2 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_3 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_3 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_3 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_3 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_4 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_4 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_4 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_4 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_5 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_5 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_5 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_5 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_6 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_6 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_6 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_6 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

};
}

string message = JsonConvert.SerializeObject(sendScreenData);
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), message);

System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{

if (textwb.Text.Length > 100000)
{
textwb.Text = "";
}
string text = $"{ScreenTOPIC.GetInstance.GetTopic(screen)} {message}\n";
textwb.Text += text;
}));

}

private void Button_Click(object sender, RoutedEventArgs e)
{
int i = 0;
Window1 window1 = new Window1();
foreach (System.Windows.Forms.Screen scr in System.Windows.Forms.Screen.AllScreens)
{
//if (!scr.Primary)
{
if (i == 1)
{
window1.WindowStartupLocation = WindowStartupLocation.Manual;

window1.Left = scr.WorkingArea.Left;
window1.Top = scr.WorkingArea.Top;
window1.Width = scr.Bounds.Width;
window1.Height = scr.Bounds.Height;
window1.WindowState = WindowState.Maximized;
window1.ResizeMode = ResizeMode.NoResize;
window1.WindowStyle = WindowStyle.None;
window1.WindowState = WindowState.Normal;
window1.ShowInTaskbar = false;
window1.Show();
}
else if (i == 2)
{
}
i++;
}
}

}
}
}

+ 0
- 12
WpfTest/Window1.xaml View File

@@ -1,12 +0,0 @@
<Window x:Class="WpfTest.Window1"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid>
</Grid>
</Window>

+ 0
- 27
WpfTest/Window1.xaml.cs View File

@@ -1,27 +0,0 @@
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.Shapes;

namespace WpfTest
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
}
}

+ 0
- 14
WpfTest/WpfTest.csproj View File

@@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.CustomResource" Version="1.0.14" />
</ItemGroup>

</Project>

Loading…
Cancel
Save