Bladeren bron

刷卡端

Lishi
xxe 2 jaren geleden
bovenliggende
commit
11ec04a640
11 gewijzigde bestanden met toevoegingen van 217 en 57 verwijderingen
  1. +20
    -0
      HKCardOUT/DTO/AdDTO.cs
  2. +1
    -0
      HKCardOUT/HKCardOUT.csproj
  3. +31
    -1
      HKCardOUT/Helper/DataBus.cs
  4. +1
    -1
      HKCardOUT/Helper/HKHelper.cs
  5. +1
    -1
      HKCardOUT/Helper/ThreadManage.cs
  6. +5
    -0
      HKCardOUT/Logic/Model/SaleLog.cs
  7. +20
    -0
      HKCardOUT/Logic/RemoteService.cs
  8. +42
    -1
      HKCardOUT/ViewModels/RootViewModel.cs
  9. +5
    -3
      HKCardOUT/Views/AdWindow.xaml.cs
  10. +91
    -43
      HKCardOUT/Views/RootView.xaml
  11. +0
    -7
      HKCardOUT/Views/RootView.xaml.cs

+ 20
- 0
HKCardOUT/DTO/AdDTO.cs Bestand weergeven

@@ -0,0 +1,20 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls.Primitives;

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

+ 1
- 0
HKCardOUT/HKCardOUT.csproj Bestand weergeven

@@ -23,6 +23,7 @@
<None Remove="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CalcBinding" Version="2.5.2" />
<PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />


+ 31
- 1
HKCardOUT/Helper/DataBus.cs Bestand weergeven

@@ -1,9 +1,12 @@
using System;
using HKCardOUT.Views;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using XExten.Advance.StaticFramework;

namespace HKCardOUT.Helper
@@ -23,10 +26,37 @@ namespace HKCardOUT.Helper
public static bool NetWordState { get; set; } = false;
public static string Cron { get; set; }
public static string SaasRoute { get; set; }
public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>();
}
public class ApiRoute
{
/// <summary>
/// 检查卡的状态
/// </summary>
public static string CheckCardStatus = DataBus.SaasRoute + "";
/// <summary>
/// 同步消费记录
/// </summary>
public static string SyncSaleLog = DataBus.SaasRoute + "";
/// <summary>
/// 获取档口信息
/// </summary>
public static string PullWindow = DataBus.SaasRoute + "";
/// <summary>
/// 获取店铺信息
/// </summary>
public static string PullShopInfo = DataBus.SaasRoute + "";
}
public class HKConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? "启用" : "禁用";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}

+ 1
- 1
HKCardOUT/Helper/HKHelper.cs Bestand weergeven

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace HKCardOut.Helper
namespace HKCardOUT.Helper
{
public class HKHelper: Singleton<HKHelper>
{


+ 1
- 1
HKCardOUT/Helper/ThreadManage.cs Bestand weergeven

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace HKCardOut.Helper
namespace HKCardOUT.Helper
{
public class Singleton<T> where T : new()
{


+ 5
- 0
HKCardOUT/Logic/Model/SaleLog.cs Bestand weergeven

@@ -25,5 +25,10 @@ namespace HKCardOUT.Logic.Model
/// </summary>
[SugarColumn(IsNullable = false)]
public string Location { get; set; }
/// <summary>
/// 是否同步过了
/// </summary>
[SugarColumn(IsNullable = false)]
public bool IsSync { get; set; }
}
}

+ 20
- 0
HKCardOUT/Logic/RemoteService.cs Bestand weergeven

@@ -32,5 +32,25 @@ namespace HKCardOUT.Logic
t.NodePath = ApiRoute.SyncSaleLog;
}).Build().RunStringFirst();
}
/// <summary>
/// 获取档口信息
/// </summary>
public static void PullWindow()
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullWindow;
}).Build().RunStringFirst();
}
/// <summary>
/// 获取店铺信息
/// </summary>
public static void PullShopInfo()
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullShopInfo;
}).Build().RunStringFirst();
}
}
}

+ 42
- 1
HKCardOUT/ViewModels/RootViewModel.cs Bestand weergeven

@@ -1,12 +1,15 @@
using HKCardOut.Helper;
using DTO;
using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using Stylet;
using StyletIoC;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Windows.Documents;

namespace HKCardOUT.ViewModels
{
@@ -35,6 +38,12 @@ namespace HKCardOUT.ViewModels
get => _Result;
set => SetAndNotify(ref _Result, value);
}
ObservableCollection<AdDTO> _Ad;
public ObservableCollection<AdDTO> Ad
{
get => _Ad;
set => SetAndNotify(ref _Ad, value);
}
#endregion

#region 方法
@@ -61,5 +70,37 @@ namespace HKCardOUT.ViewModels
}), "循环状态监测线程", false);
}
#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);
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);
}
}
}
}
#endregion
}
}

+ 5
- 3
HKCardOUT/Views/AdWindow.xaml.cs Bestand weergeven

@@ -19,12 +19,14 @@ namespace HKCardOUT.Views
/// </summary>
public partial class AdWindow : HandyControl.Controls.Window
{
public AdWindow()

public AdWindow(string input)
{
InitializeComponent();
InitView2();
InitView2(input);
}
public async void InitView2()

public async void InitView2(string input)
{
await view2.EnsureCoreWebView2Async(null);
view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;


+ 91
- 43
HKCardOUT/Views/RootView.xaml Bestand weergeven

@@ -2,10 +2,14 @@
x:Class="HKCardOUT.Views.RootView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:helper="clr-namespace:HKCardOUT.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels"
x:Name="Main"
Title="海科智慧一卡通平台"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ShowMaxButton="False"
@@ -15,6 +19,7 @@
WindowState="Maximized"
mc:Ignorable="d">
<hc:Window.Resources>
<helper:HKConverter x:Key="TOC" />
<Style x:Key="SaleLogHeader" TargetType="DataGridColumnHeader">
<Setter Property="FontSize" Value="18" />
<Setter Property="Background" Value="Transparent" />
@@ -34,47 +39,90 @@
<hc:Window.Background>
<ImageBrush ImageSource="/HKResouces/背景.jpg" />
</hc:Window.Background>
<DataGrid
AutoGenerateColumns="False"
Background="Transparent"
IsReadOnly="True"
ItemsSource="{Binding Result}"
Style="{StaticResource DataGridBaseStyle}">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
<Setter Property="Background" Value="Transparent" />
<Style.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn
Width="260"
Binding="{Binding CardNo}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="卡号"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding Money}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="金额"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding Location}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="档口"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="消费时间"
HeaderStyle="{StaticResource SaleLogHeader}" />
</DataGrid.Columns>
</DataGrid>
<StackPanel>
<ListBox
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Ad}"
Style="{StaticResource WrapPanelHorizontalListBox}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Center" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Button
Width="100"
Height="80"
Margin="20,0,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">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="18"
FontWeight="Bold"
Text="{Binding Device}" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="18"
FontWeight="Bold"
Foreground="Red"
Text="{Binding IsActive, Converter={StaticResource TOC}}" />
</StackPanel>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DataGrid
AutoGenerateColumns="False"
Background="Transparent"
IsReadOnly="True"
ItemsSource="{Binding Result}"
Style="{StaticResource DataGridBaseStyle}">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
<Setter Property="Background" Value="Transparent" />
<Style.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn
Width="260"
Binding="{Binding CardNo}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="卡号"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding Money}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="金额"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding Location}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="档口"
HeaderStyle="{StaticResource SaleLogHeader}" />
<DataGridTextColumn
Width="260"
Binding="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"
ElementStyle="{StaticResource CenterAlignmentStyle}"
Header="消费时间"
HeaderStyle="{StaticResource SaleLogHeader}" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</hc:Window>

+ 0
- 7
HKCardOUT/Views/RootView.xaml.cs Bestand weergeven

@@ -11,13 +11,6 @@ namespace HKCardOUT.Views
public RootView()
{
InitializeComponent();
if (Screen.AllScreens.Count() >= 2)
{
Dispatcher.Invoke(() =>
{
//显示广告屏幕
});
}
}
}
}

Laden…
Annuleren
Opslaan