Ver a proveniência

广告缓存到本地

undefined
xxe há 2 anos
ascendente
cometimento
3cfcb60918
4 ficheiros alterados com 44 adições e 66 eliminações
  1. +2
    -8
      HKCardOUT/DTO/AdDTO.cs
  2. +29
    -42
      HKCardOUT/ViewModels/RootViewModel.cs
  3. +3
    -6
      HKCardOUT/Views/RootView.xaml
  4. +10
    -10
      HKCardOUT/Views/RootView.xaml.cs

+ 2
- 8
HKCardOUT/DTO/AdDTO.cs Ver ficheiro

@@ -6,15 +6,9 @@ using System.Windows.Controls.Primitives;

namespace DTO
{
public class AdDTO : PropertyChangedBase
public class AdDTO
{
public string Device { get; set; }
bool _IsActive;
public bool IsActive
{
get => _IsActive;
set => SetAndNotify(ref _IsActive, value);
}
public string Device { get; set; }
public string Ad { get; set; }
public string Stalls { get; set; }
}


+ 29
- 42
HKCardOUT/ViewModels/RootViewModel.cs Ver ficheiro

@@ -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])


+ 3
- 6
HKCardOUT/Views/RootView.xaml Ver ficheiro

@@ -14,8 +14,8 @@
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ShowMaxButton="False"
ShowMinButton="False"
Visibility="Hidden"
ShowTitle="True"
Visibility="Hidden"
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
mc:Ignorable="d">
@@ -111,9 +111,6 @@
Width="160"
Height="80"
Margin="20,20,0,0"
s:View.ActionTarget="{Binding DataContext, ElementName=Main}"
Command="{s:Action UpdateAction}"
CommandParameter="{Binding .}"
Style="{StaticResource ButtonDefault}">
<Button.Content>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
@@ -129,13 +126,13 @@
FontSize="18"
FontWeight="Bold"
Text="{Binding Device, StringFormat=设备:{0}}" />
<TextBlock
<!--<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="18"
FontWeight="Bold"
Foreground="Red"
Text="{Binding IsActive, Converter={StaticResource TOC}, StringFormat=广告:{0}}" />
Text="{Binding IsActive, Converter={StaticResource TOC}, StringFormat=广告:{0}}" />-->
</StackPanel>
</Button.Content>
</Button>


+ 10
- 10
HKCardOUT/Views/RootView.xaml.cs Ver ficheiro

@@ -15,16 +15,16 @@ namespace HKCardOUT.Views
public RootView()
{
InitializeComponent();
if (!StartEXE.IsExistKey("HKCardOUT"))
{
var Paths = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HKCardOUT.exe");
StartEXE.SelfRunning(true, "HKCardOUT", Paths);
}
else if (StartEXE.IsExistKey("HKCardOUT"))
{
var Paths = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HKCardOUT.exe");
StartEXE.SelfRunning(false, "HKCardOUT", Paths);
}
//if (!StartEXE.IsExistKey("HKCardOUT"))
//{
// var Paths = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HKCardOUT.exe");
// StartEXE.SelfRunning(true, "HKCardOUT", Paths);
//}
//else if (StartEXE.IsExistKey("HKCardOUT"))
//{
// var Paths = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HKCardOUT.exe");
// StartEXE.SelfRunning(false, "HKCardOUT", Paths);
//}
this.Loaded += RootView_Loaded;
}



Carregando…
Cancelar
Guardar