|
|
@@ -7,12 +7,18 @@ using NStandard; |
|
|
|
using Stylet; |
|
|
|
using StyletIoC; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using System.Threading; |
|
|
|
using System.Windows.Documents; |
|
|
|
using UHFHelper; |
|
|
|
using XExten.Advance.InternalFramework.Securities.Common; |
|
|
|
using XExten.Advance.LinqFramework; |
|
|
|
using XExten.Advance.StaticFramework; |
|
|
|
|
|
|
|
namespace HKCardOUT.ViewModels |
|
|
|
{ |
|
|
@@ -27,12 +33,12 @@ namespace HKCardOUT.ViewModels |
|
|
|
public RootViewModel(IContainer Container) |
|
|
|
{ |
|
|
|
this.Container = Container; |
|
|
|
MainThread(); |
|
|
|
|
|
|
|
|
|
|
|
this.Activated += RootViewModel_Activated; |
|
|
|
this.Closed += RootViewModel_Closed; |
|
|
|
|
|
|
|
MainThread(); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 关闭页面 |
|
|
@@ -89,16 +95,21 @@ namespace HKCardOUT.ViewModels |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DataBus.StoreInfo.Devices.ForEach(item => |
|
|
|
if (DataBus.NetWordState) |
|
|
|
{ |
|
|
|
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt()); |
|
|
|
|
|
|
|
if (res != null) |
|
|
|
DataBus.StoreInfo.Devices.ForEach(item => |
|
|
|
{ |
|
|
|
if (!res.ResData.IsMatch(new Regex("0{20}"))) |
|
|
|
ReadFunc?.Invoke(res); |
|
|
|
} |
|
|
|
}); |
|
|
|
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt()); |
|
|
|
|
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
if (!res.ResData.IsMatch(new Regex("0{20}"))) |
|
|
|
ReadFunc?.Invoke(res); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络,并重启程序!"); |
|
|
|
} |
|
|
|
}; |
|
|
|
timer1.Start(); |
|
|
@@ -109,13 +120,20 @@ namespace HKCardOUT.ViewModels |
|
|
|
var Init = DataBus.StoreInfo?.Devices.Join(DataBus.StoreInfo?.Stalls, t => t.GateId, x => x.Id, (t, x) => new AdDTO |
|
|
|
{ |
|
|
|
Ad = x.Remaek, |
|
|
|
IsActive = false, |
|
|
|
Device = t.Name, |
|
|
|
Stalls = x.Name |
|
|
|
}).ToList(); |
|
|
|
if (Init != null) |
|
|
|
{ |
|
|
|
Ad = new ObservableCollection<AdDTO>(Init); |
|
|
|
var route = SyncStatic.CreateFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")); |
|
|
|
SyncStatic.WriteFile(Encoding.UTF8.GetBytes(SyncStatic.Compress(Init.ToJson(), SecurityType.Base64)), route); |
|
|
|
AdOpen(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var jsons = SyncStatic.Decompress(SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")), SecurityType.Base64); |
|
|
|
Ad = new ObservableCollection<AdDTO>(jsons.ToModel<List<AdDTO>>()); |
|
|
|
AdOpen(); |
|
|
|
} |
|
|
|
} |
|
|
@@ -197,37 +215,6 @@ namespace HKCardOUT.ViewModels |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 命令 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 广告位置 |
|
|
|
/// </summary> |
|
|
|
/// <param name="input"></param> |
|
|
|
public void UpdateAction(AdDTO input) |
|
|
|
{ |
|
|
|
input.IsActive = !input.IsActive; |
|
|
|
var SC = System.Windows.Forms.Screen.AllScreens.Count(); |
|
|
|
if (SC >= 1) |
|
|
|
{ |
|
|
|
if (input.IsActive) |
|
|
|
{ |
|
|
|
if (!DataBus.AdStatus.ContainsKey(input.Device)) |
|
|
|
{ |
|
|
|
var win = new Views.AdWindow(input.Ad); |
|
|
|
win.Left = System.Windows.Forms.Screen.AllScreens[1].WorkingArea.Left; |
|
|
|
DataBus.AdStatus.Add(input.Device, win); |
|
|
|
win.Show(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (DataBus.AdStatus.ContainsKey(input.Device)) |
|
|
|
{ |
|
|
|
DataBus.AdStatus[input.Device].Close(); |
|
|
|
DataBus.AdStatus.Remove(input.Device); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public void ReadCard(DKoutput input) |
|
|
|
{ |
|
|
|
lock (locker) |
|
|
@@ -242,7 +229,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
{ |
|
|
|
CardNo = input.ResData.Substring(1, input.ResData.Length - 1), |
|
|
|
Location = input.Address.AsInt().ToString(), |
|
|
|
IsSync=false |
|
|
|
IsSync = false |
|
|
|
}); |
|
|
|
} |
|
|
|
if (DateTime.Now.Hour >= PM[0] && DateTime.Now.Hour < PM[1]) |
|
|
|