Browse Source

框架搭建

master
pry 2 years ago
parent
commit
8559abbd28
34 changed files with 612 additions and 258 deletions
  1. +53
    -0
      HBLConsole.Business/APIHelper.cs
  2. +5
    -0
      HBLConsole.Business/HBLConsole.Business.csproj
  3. +19
    -0
      HBLConsole.Business/MORKS.cs
  4. +19
    -3
      HBLConsole.Business/MessageServerBase.cs
  5. +56
    -0
      HBLConsole.Business/ServerData.cs
  6. +1
    -0
      HBLConsole.Communication/HBLConsole.Communication.csproj
  7. +0
    -9
      HBLConsole.Communication/M2MQTT/MqttM2.cs
  8. +26
    -0
      HBLConsole.Communication/ModbusTcpHelper.cs
  9. +7
    -0
      HBLConsole.Factory/HBLConsole.Factory.csproj
  10. +6
    -4
      HBLConsole.Factory/SimpleFactory.cs
  11. +20
    -0
      HBLConsole.GVL/GeneralConfig.cs
  12. +3
    -0
      HBLConsole.GVL/HBLConsole.GVL.csproj
  13. +25
    -5
      HBLConsole.GVL/InternetInfo.cs
  14. +7
    -0
      HBLConsole.MainConsole/HBLConsole.MainConsole.csproj
  15. +63
    -0
      HBLConsole.MainConsole/HeartbeatReport.cs
  16. +33
    -1
      HBLConsole.MainConsole/Main.cs
  17. +6
    -0
      HBLConsole.Model/HBLConsole.Model.csproj
  18. +16
    -0
      HBLConsole.Model/KeepParameter/BatchingInfoPar.cs
  19. +1
    -0
      HBLConsole.Service/HBLConsole.Service.csproj
  20. +36
    -0
      HBLConsole.Service/Sqlite.cs
  21. +5
    -5
      HBLConsole.sln
  22. +2
    -2
      HBLConsole/App.config
  23. +13
    -2
      HBLConsole/App.xaml.cs
  24. +3
    -4
      HBLConsole/DialogWindow/View/ListDialogView.xaml
  25. +64
    -105
      HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
  26. +2
    -1
      HBLConsole/HBLConsole.csproj
  27. +14
    -0
      HBLConsole/Model/MorkOrderPushPar.cs
  28. +25
    -0
      HBLConsole/Model/OrderData.cs
  29. +0
    -109
      HBLConsole/Server/SystemHelper.cs
  30. +46
    -0
      HBLConsole/Service/InitService.cs
  31. +12
    -0
      HBLConsole/View/MainView.xaml
  32. +11
    -1
      HBLConsole/ViewModel/MainViewModel.cs
  33. +1
    -1
      HBLConsole/ViewModel/OrderStatusViewModel.cs
  34. +12
    -6
      HBLConsole/ViewModel/ViewModelBase.cs

+ 53
- 0
HBLConsole.Business/APIHelper.cs View File

@@ -0,0 +1,53 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using BPA.Utility;
using HBLConsole.GVL;

namespace HBLConsole.Business
{
public class APIHelper
{

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

public void OrderStatusChange(string suborderId, int orderStatus)
{
var m = $"[/api/RobotOrder]_[{DateTime.Now.Ticks}]".AESEncrypt();
WebApiHelper.GetInstance().HttpPost(InternetInfo.GetInstance.OrderStatusChange, "");
}

public void GetBatchingInfo()
{

//string serviceAddress = "http://1.14.74.54:7001/api/Advertisement/htmlurl?storeId=3b007e32-f1cc-4021-b4e0-f4764fa90f12";
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
//request.Method = "GET";
//request.ContentType = "text/html;charset=UTF-8";
//HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Stream myResponseStream = response.GetResponseStream();
//StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
//string retString = myStreamReader.ReadToEnd();
//myStreamReader.Close();
//myResponseStream.Close();
////Response.Write(retString);
//JObject obj = JObject.Parse(retString);
//string Data1 = obj["data"].ToString();
//string Data = string.Empty;
//if (Data1.Length > 0)
// Data = obj["data"]["data"].ToString();//获取连接
//GVL_VAR.GetInstance.SorbetesAddress = Data;
//if (SorbetesAddressNoti != null) SorbetesAddressNoti(Data);
//MessageLogOut.GetInstance.Show($"广告连接:={Data}");

}

}
}

+ 5
- 0
HBLConsole.Business/HBLConsole.Business.csproj View File

@@ -7,6 +7,8 @@
<ItemGroup>
<ProjectReference Include="..\HBLConsole.Abstract\HBLConsole.Abstract.csproj" />
<ProjectReference Include="..\HBLConsole.Communication\HBLConsole.Communication.csproj" />
<ProjectReference Include="..\HBLConsole.Factory\HBLConsole.Factory.csproj" />
<ProjectReference Include="..\HBLConsole.GVL\HBLConsole.GVL.csproj" />
<ProjectReference Include="..\HBLConsole.Interface\HBLConsole.Interface.csproj" />
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" />
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" />
@@ -16,6 +18,9 @@
<Reference Include="BPA.Message">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
<Reference Include="BPA.Utility">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Utility.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

+ 19
- 0
HBLConsole.Business/MORKS.cs View File

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

namespace HBLConsole.Business
{
public class MORKS
{

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



}
}

+ 19
- 3
HBLConsole.Business/MessageServerBase.cs View File

@@ -4,6 +4,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HBLConsole.Abstract;
using BPA.Message;
using HBLConsole.Model;
using HBLConsole.Service;
using BPA.Message.Enum;

namespace HBLConsole.Business
{
@@ -11,7 +15,11 @@ namespace HBLConsole.Business
{
public override void AddOrder<T>(T orderInfo)
{
throw new NotImplementedException();
if (orderInfo == null) return;
if (orderInfo is MorkOrderPush morkOrderpush)
{
ActionManagerment.GetInstance.Send("orderSend", morkOrderpush);
}
}

public override void BatchingCountInfo()
@@ -21,12 +29,20 @@ namespace HBLConsole.Business

public override void GetBatchingInfo<T>(T batchingInfo)
{
throw new NotImplementedException();
if (batchingInfo == null) return;
if (batchingInfo is OrderMaterialDelivery BatchingInfos)
{
Json<BatchingInfoPar>.GetInstance.Base.orderMaterialDelivery = BatchingInfos;
}
}

public override void GetRecipeBom<T>(T recipeBomInfo)
{
throw new NotImplementedException();
if (recipeBomInfo == null) return;
if (recipeBomInfo is RecipeBoms recipeBom)
{
Json<BatchingInfoPar>.GetInstance.Base.recipeBoms = recipeBom;
}
}
}
}

+ 56
- 0
HBLConsole.Business/ServerData.cs View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using HBLConsole.Service;
using System.Collections.Concurrent;
using BPA.Message;
using HBLConsole.GVL;
using HBLConsole.Interface;
using HBLConsole.Factory;

namespace HBLConsole.Business
{
public class ServerData
{

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

ConcurrentQueue<string> receives = new ConcurrentQueue<string>();

IServerMessage serverMessage = new ServerMessage();

public void Init()
{
ThreadManagerment.GetInstance.StartLong(new Action(() =>
{
while (receives.Count > 0)
{
if (receives.TryDequeue(out string msg))
{
var package = BPAPackage.Deserialize(msg);
if (package.ClientId == InternetInfo.GetInstance.ClientId)
{
if (package.Message != null)
{
serverMessage.Universal(SimpleFactory.GetInstance.GetAbsMessageServer, package.Message);
}
}
}
}
Thread.Sleep(100);
}), "");
}


public void ReceiveData(string info)
{
receives.Enqueue(info);
}

}
}

+ 1
- 0
HBLConsole.Communication/HBLConsole.Communication.csproj View File

@@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="M2Mqtt" Version="4.3.0" />
<PackageReference Include="ModbusTcp" Version="1.0.4" />
<PackageReference Include="MQTTnet" Version="3.1.2" />
</ItemGroup>



+ 0
- 9
HBLConsole.Communication/M2MQTT/MqttM2.cs View File

@@ -10,16 +10,7 @@ using System.Threading.Tasks;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
using Newtonsoft.Json;
using Communication.Model;
using System.Collections.Concurrent;
using Alarm.Enums;
using Alarm.Models;
using Alarm.Service;
using ServiceModel;
using GVL;
using BPA.Message;
using BPA.Utility;
using Communication.MQTT;
using System.Drawing;
using HBLConsole.Model;
using HBLConsole.Service;


+ 26
- 0
HBLConsole.Communication/ModbusTcpHelper.cs View File

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

namespace HBLConsole.Communication
{
public class ModbusTcpHelper
{

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

ModbusClient modbusClient;

public void Connect(string ip, int port)
{
modbusClient = new ModbusClient(ip, port);

}

}
}

+ 7
- 0
HBLConsole.Factory/HBLConsole.Factory.csproj View File

@@ -6,7 +6,14 @@

<ItemGroup>
<ProjectReference Include="..\HBLConsole.Abstract\HBLConsole.Abstract.csproj" />
<ProjectReference Include="..\HBLConsole.GVL\HBLConsole.GVL.csproj" />
<ProjectReference Include="..\HBLConsole.Interface\HBLConsole.Interface.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="BPA.Message">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

+ 6
- 4
HBLConsole.Factory/SimpleFactory.cs View File

@@ -2,6 +2,8 @@
using HBLConsole.Interface;
using System;
using System.Reflection;
using BPA.Message.Enum;
using HBLConsole.GVL;

namespace HBLConsole.Factory
{
@@ -15,14 +17,14 @@ namespace HBLConsole.Factory
public AbstractMessageServer GetAbsMessageServer => _GetAbsMessageServer ?? (_GetAbsMessageServer = GetAbstractMessageServer());
private AbstractMessageServer _GetAbsMessageServer;

public IServerMessage GetIServerMessage => _GetIServerMessage ?? (_GetIServerMessage = new ServerMessage());
private IServerMessage _GetIServerMessage;
//public IServerMessage GetIServerMessage => _GetIServerMessage ?? (_GetIServerMessage = new ServerMessage());
//private IServerMessage _GetIServerMessage;

private AbstractMessageServer GetAbstractMessageServer()
{
Type type = Assembly.Load("MqttMessageServer").GetType($"MqttMessageServer.{GVL_VAR.GetInstance.StartDeviceType.ToString()}");
Type type = Assembly.Load("HBLConsole.Business").GetType($"HBLConsole.Business.{GeneralConfig.GetInstance.DeviceType.ToString()}");
if (type == null)
type = Assembly.Load("MqttMessageServer").GetType($"MqttMessageServer.Base");
type = Assembly.Load("HBLConsole.Business").GetType($"HBLConsole.Business.MessageServerBase");
return (AbstractMessageServer)Activator.CreateInstance(type);
}
}


+ 20
- 0
HBLConsole.GVL/GeneralConfig.cs View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Message.Enum;

namespace HBLConsole.GVL
{
public class GeneralConfig
{

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

public DeviceClientType DeviceType { get; set; }

}
}

+ 3
- 0
HBLConsole.GVL/HBLConsole.GVL.csproj View File

@@ -17,6 +17,9 @@
</ItemGroup>

<ItemGroup>
<Reference Include="BPA.Message">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
<Reference Include="BPA.Utility">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Utility.dll</HintPath>
</Reference>


+ 25
- 5
HBLConsole.GVL/InternetInfo.cs View File

@@ -8,6 +8,8 @@ using BPA.Utility.Consul.YT;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Consul;
using System.Threading;
using HBLConsole.Service;

namespace HBLConsole.GVL
{
@@ -22,17 +24,30 @@ namespace HBLConsole.GVL

public void Init()
{
NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
while (!NetworkConnectState)
{
NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
Thread.Sleep(2000);
}

ConsulAddress = System.Configuration.ConfigurationManager.AppSettings["ConsulAddress"];
ClientId = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ClientId"]);

IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddConsul(ConsulAddress, "root/BQLControl/app.json", false, 5_000);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddConsul(ConsulAddress, "root/basic.json", false, 5_000);
IConfiguration config = configurationBuilder.Build();
MqttUserName = config["Server:MqttUserName"];
MqttAddress = config["Server:MqttAddress"];
MqttPassword = config["Server:MqttPassword"];
MqttPort = int.Parse(config["Server:MqttPort"]);
MqttUserName = config["MQTT:TcpAccount"];
MqttPassword = config["MQTT:TcpPwd"];
MqttAddress = config["MQTT:MqttAddress"];
MqttPort = int.Parse(config["MQTT:MqttPort"]);
OrderStatusChange = config["API:robotstatuschange"];
}

/// <summary>
/// 订单状态更改接口地址
/// </summary>
public string OrderStatusChange { get; set; }

/// <summary>
/// Consul 地址
/// </summary>
@@ -43,6 +58,11 @@ namespace HBLConsole.GVL
/// </summary>
public bool NetworkConnectState { get; set; }

/// <summary>
/// 广告地址
/// </summary>
public Uri SorbetesAddress { get; set; }

/// <summary>
/// 客户端ID
/// </summary>


+ 7
- 0
HBLConsole.MainConsole/HBLConsole.MainConsole.csproj View File

@@ -5,10 +5,17 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\HBLConsole.Business\HBLConsole.Business.csproj" />
<ProjectReference Include="..\HBLConsole.Communication\HBLConsole.Communication.csproj" />
<ProjectReference Include="..\HBLConsole.GVL\HBLConsole.GVL.csproj" />
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" />
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="BPA.Message">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

+ 63
- 0
HBLConsole.MainConsole/HeartbeatReport.cs View File

@@ -0,0 +1,63 @@
//using BPA.Message;
//using BPA.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using GVL;
//using BPA.Message.Enum;
//using BPA.Communication;
using System.Threading;
using HBLConsole.Service;
using HBLConsole.GVL;
using BPA.Message;
using HBLConsole.Communication;
using BPA.Message.Enum;
//using Communication.MQTT;
//using BPA.Message.Kafka;
//using Model.Enums;
//using ServiceModel;
//using Communication.SerialPortComm;

namespace HBLConsole.MainConsole
{
public class HeartbeatReport
{

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

/// <summary>
/// 消息包
/// </summary>
public BPAPackage MessagePackage { get; set; } = new BPAPackage();

public Func<IMessage> GetMessage { get; set; }

DeviceStatus deviceStatus = new DeviceStatus();
string Topic = string.Empty;

public void Init()
{
deviceStatus.DeviceType = GeneralConfig.GetInstance.DeviceType;
deviceStatus.BatchingInfo = new List<BatchingInfo>();
deviceStatus.Healthy = DeviceHealthy.UnHealth;
Topic = TOPIC.GetInstance.GetHeatbeatTopic(GeneralConfig.GetInstance.DeviceType);

ThreadManagerment.GetInstance.StartLong(new Action(() =>
{
MessagePackage.ClientId = InternetInfo.GetInstance.ClientId;
MessagePackage.ClientType = GeneralConfig.GetInstance.DeviceType;
MessagePackage.MessageId = MessageID.MORK_HEART_BEAT;
MessagePackage.MessageVersion = 0x01;
MessagePackage.Timestamp = DateTime.Now;
MessagePackage.Message = GetMessage == null ? deviceStatus : GetMessage();
MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize());
Thread.Sleep(1000);
}), "设备心跳上报");

}
}
}

+ 33
- 1
HBLConsole.MainConsole/Main.cs View File

@@ -3,6 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HBLConsole.Model;
using HBLConsole.Service;
using HBLConsole.GVL;
using HBLConsole.Communication;
using BPA.Message;
using HBLConsole.Business;

namespace HBLConsole.MainConsole
{
@@ -13,9 +19,35 @@ namespace HBLConsole.MainConsole
public static Main GetInstance => _Instance ?? (_Instance = new Main());
private Main() { }

public void Init()
List<string> Topics = new List<string>();

public void BusinessInit()
{
Topics.Clear();
Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.GetInstance.DeviceType, InternetInfo.GetInstance.ClientId));
Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.GetInstance.DeviceType, InternetInfo.GetInstance.ClientId));
ThreadManagerment.GetInstance.Start(new Action(() =>
{
InternetInfo.GetInstance.Init();
MqttHelper.GetInstance.ConnectOk = new Action(() =>
{
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());
HeartbeatReport.GetInstance.Init();
MqttHelper.GetInstance.MqttReceive = new Action<MQTTnet.MqttApplicationMessageReceivedEventArgs>((receivce) =>
{
ServerData.GetInstance.ReceiveData(Encoding.UTF8.GetString(receivce.ApplicationMessage.Payload));
});
});

MqttHelper.GetInstance.Reconnection = new Action(() => { MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray()); });

MqttHelper.GetInstance.MqttInitAsync(InternetInfo.GetInstance.MqttUserName,
InternetInfo.GetInstance.MqttPassword,
InternetInfo.GetInstance.MqttAddress,
InternetInfo.GetInstance.MqttPort,
DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));

}), "业务逻辑初始化");
}

}


+ 6
- 0
HBLConsole.Model/HBLConsole.Model.csproj View File

@@ -4,4 +4,10 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Reference Include="BPA.Message">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

+ 16
- 0
HBLConsole.Model/KeepParameter/BatchingInfoPar.cs View File

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

namespace HBLConsole.Model
{
public class BatchingInfoPar
{
public OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery();

public RecipeBoms recipeBoms { get; set; } = new RecipeBoms();
}
}

+ 1
- 0
HBLConsole.Service/HBLConsole.Service.csproj View File

@@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>


+ 36
- 0
HBLConsole.Service/Sqlite.cs View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Sqlite;

namespace HBLConsole.Service
{
public class Sqlite<T> : DbContext where T : class, new()
{

private volatile static Sqlite<T> _Instance;
public static Sqlite<T> GetInstance => _Instance ?? (_Instance = new Sqlite<T>());
private Sqlite() { }

public DbSet<T> Base { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"FileName={path}");
}

static string path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\{typeof(T).Name}.db";
}
}

}
}

+ 5
- 5
HBLConsole.sln View File

@@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Interface", "HBL
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Abstract", "HBLConsole.Abstract\HBLConsole.Abstract.csproj", "{366CA88C-D690-4669-9AB8-1948D3CBF127}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Factory", "Factory\HBLConsole.Factory.csproj", "{A71309D9-6791-4D0A-BFAE-7D6AD63467A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Factory", "HBLConsole.Factory\HBLConsole.Factory.csproj", "{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -71,10 +71,10 @@ Global
{366CA88C-D690-4669-9AB8-1948D3CBF127}.Debug|Any CPU.Build.0 = Debug|Any CPU
{366CA88C-D690-4669-9AB8-1948D3CBF127}.Release|Any CPU.ActiveCfg = Release|Any CPU
{366CA88C-D690-4669-9AB8-1948D3CBF127}.Release|Any CPU.Build.0 = Release|Any CPU
{A71309D9-6791-4D0A-BFAE-7D6AD63467A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A71309D9-6791-4D0A-BFAE-7D6AD63467A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A71309D9-6791-4D0A-BFAE-7D6AD63467A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A71309D9-6791-4D0A-BFAE-7D6AD63467A6}.Release|Any CPU.Build.0 = Release|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 2
- 2
HBLConsole/App.config View File

@@ -4,10 +4,10 @@
<!--通用配置-->

<!--测试服务 Consul 地址-->
<!--<add key="ConsulAddress" value="http://114.117.161.250:8500" />-->
<add key="ConsulAddress" value="http://114.117.161.250:8500" />

<!--正式服务 Consul 地址-->
<add key="ConsulAddress" value="http://162.14.105.138:9005" />
<!--<add key="ConsulAddress" value="http://162.14.105.138:9005" />-->

<!--客户端ID-->
<!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13-->


+ 13
- 2
HBLConsole/App.xaml.cs View File

@@ -10,6 +10,8 @@ using HBLConsole.View;
using HBLConsole.Server;
using System.Diagnostics;
using HBLConsole.Service;
using HBLConsole.Model;
using HBLConsole.MainConsole;

namespace HBLConsole
{
@@ -19,24 +21,33 @@ namespace HBLConsole
public partial class App : Application
{
MainView mainView = new MainView();
ListDialogView listDialogView = new ListDialogView();
ListDialogView listDialogView;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ActionManagerment.GetInstance.Register(new Func<object, object>((o) => { return new object(); }), "aa");
SystemHelper.GetInstance.AutoStart(false);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
InitService.GetInstance.Register();
InitService.GetInstance.DataInit();
mainView.Show();
if (Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Count > 0)
{
listDialogView = new ListDialogView();
listDialogView.ShowDialog();
}
MainConsole.Main.GetInstance.BusinessInit();
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
InitService.GetInstance.DataSave();
Process.Start($"{AppDomain.CurrentDomain.BaseDirectory}{AppDomain.CurrentDomain.FriendlyName}.exe");
}

protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
InitService.GetInstance.DataSave();
}
}
}

+ 3
- 4
HBLConsole/DialogWindow/View/ListDialogView.xaml View File

@@ -204,7 +204,7 @@
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding OrderLists}">
<ItemsControl ItemsSource="{Binding orderStatusLists}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Height="30">
@@ -230,16 +230,15 @@
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding SortNo}" />
Text="{Binding OrderPush.SortNum}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<TextBlock
Grid.Column="2"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding GoodName}" />
Text="{Binding OrderPush.GoodsName}" />

<Grid Grid.Column="3">
<TextBlock


+ 64
- 105
HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs View File

@@ -6,13 +6,14 @@ using System.Threading.Tasks;
//using LargeScreen.NoodleMorkS.ViewModel;
//using LargeScreen.Model;
using System.Collections.ObjectModel;
using BPA.Message.Kafka;
//using BPA.Message.Kafka;
using System.Collections.Concurrent;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
using System.Threading;
using HBLConsole.ViewModel;
//using ServiceModel;
using HBLConsole.Model;
using HBLConsole.Service;

namespace HBLConsole.DialogWindow.ViewModel
{
@@ -21,115 +22,71 @@ namespace HBLConsole.DialogWindow.ViewModel
public static bool IsAutoClose = false;
public ListDialogViewModel()
{
//List<GoodBatchings> goodBatchings = new List<GoodBatchings>();

//for (int i = 0; i < 5; i++)
//{
// goodBatchings.Add(new GoodBatchings()
// {
// BatchingCount = i,
// BatchingId = i,
// BatchingType = i,
// });
//}

//for (int i = 0; i < 10; i++)
//{
// Json<OrderData>.GetInstance.Base.morksOrderPushes.Add(new MorksOrderPush()
// {
// Bowl = i,
// GoodBatchings = goodBatchings,
// RecipeId = i,
// SortNum = i,
// SuborderId = i.ToString(),
// });

// Json<OrderData>.GetInstance.Base.orderStatusLists.Add(new OrderStatusList()
// {
// SortNo = i.ToString(),
// OrderStatus = BPA.Message.ORDER_STATUS.WAIT,
// GoodName = i.ToString(),
// SubOrderId = i.ToString(),
// });
//}


//Json<OrderData>.GetInstance.Save();


//CloseCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("false", "Close"); });

//CancelCommand = new RelayCommand(() =>
//{
// Json<OrderData>.GetInstance.Base.morksOrderPushes.Clear();
// Json<OrderData>.GetInstance.Base.orderStatusLists.Clear();
// WeakReferenceMessenger.Default.Send("false", "Close");
//});

//ConfirmCommand = new RelayCommand(() =>
//{
// foreach (var item in OrderLists)
// {
// if (!item.IsSelected)
// {
// var reslut = Json<OrderData>.GetInstance.Base.orderStatusLists.FirstOrDefault(p => p.SubOrderId == item.SubOrderId);
// if (reslut != null) Json<OrderData>.GetInstance.Base.orderStatusLists.Remove(reslut);

// var OrderPushe = Json<OrderData>.GetInstance.Base.morksOrderPushes.FirstOrDefault(p => p.SuborderId == item.SubOrderId);
// if (OrderPushe != null) Json<OrderData>.GetInstance.Base.morksOrderPushes.Remove(OrderPushe);
// }
// }
// WeakReferenceMessenger.Default.Send("true", "Close");
//});

//Json<OrderData>.GetInstance.Read();
//foreach (var item in Json<OrderData>.GetInstance.Base.morksOrderPushes)
//{
// var result = Json<OrderData>.GetInstance.Base.orderStatusLists.FirstOrDefault(p => p.SubOrderId == item.SuborderId);
// if (result != null)
// {
// orderStatusLists.Add(result);
// OrderLists.Add(new OrderList()
// {
// GoodName = result.GoodName,
// IsSelected = false,
// OrderStatus = result.OrderStatus,
// SortNo = result.SortNo,
// SubOrderId = result.SubOrderId,
// });
// }
//}

//if (Json<OrderData>.GetInstance.Base.morksOrderPushes.Count > 0)
//{
// ThreadManagerment.GetInstance.Start(new Action(() =>
// {
// Thread.Sleep(10000);
// if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");
// }), "延时退出");
//}
//AllSelected = true;
CloseCommand = new RelayCommand(() =>
{
Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Clear();
orderStatusLists.Clear();
WeakReferenceMessenger.Default.Send("false", "Close");
});

CancelCommand = new RelayCommand(() =>
{
Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Clear();
orderStatusLists.Clear();
WeakReferenceMessenger.Default.Send("false", "Close");
});

ConfirmCommand = new RelayCommand(() =>
{
foreach (var item in orderStatusLists)
{
if (!item.IsSelected)
{
var reslut = Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == item.OrderPush.SuborderId);
if (reslut != null) Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Remove(reslut);
}
}
foreach (var item in Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes)
{
orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
}
WeakReferenceMessenger.Default.Send("true", "Close");
});

foreach (var item in Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes)
{
orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
}

if (Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Count > 0)
{
ThreadManagerment.GetInstance.Start(new Action(() =>
{
Thread.Sleep(10000);
if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");
}), "延时退出");
}
AllSelected = true;
}

//public ObservableCollection<OrderList> OrderLists { get; set; } = new ObservableCollection<OrderList>();

/// <summary>
/// 全选标志
/// </summary>
//public bool AllSelected
//{
// get { return _mAllSelected; }
// set
// {
// _mAllSelected = value;
// OnPropertyChanged();
// for (int i = 0; i < OrderLists.Count; i++)
// {
// OrderLists.ElementAt(i).IsSelected = value;
// }
// }
//}
private bool _mAllSelected;
public bool AllSelected
{
get { return _mAllSelected; }
set
{
_mAllSelected = value;
OnPropertyChanged();
for (int i = 0; i < orderStatusLists.Count; i++)
{
orderStatusLists.ElementAt(i).IsSelected = value;
}
}
}
private bool _mAllSelected = true;

public RelayCommand CloseCommand { get; set; }

@@ -139,5 +96,7 @@ namespace HBLConsole.DialogWindow.ViewModel





}
}

+ 2
- 1
HBLConsole/HBLConsole.csproj View File

@@ -191,11 +191,12 @@
<Folder Include="DialogWindow\ViewModel\" />
<Folder Include="View\" />
<Folder Include="ViewModel\" />
<Folder Include="Model\" />
<Folder Include="Converter\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HBLConsole.MainConsole\HBLConsole.MainConsole.csproj" />
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" />
<ProjectReference Include="..\HBLConsole.PryUserControl\HBLConsole.PryUserControl.csproj" />
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" />
</ItemGroup>


+ 14
- 0
HBLConsole/Model/MorkOrderPushPar.cs View File

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

namespace HBLConsole
{
public class MorkOrderPushPar
{
public List<OrderData> morkOrderPushes = new List<OrderData>();
}
}

+ 25
- 0
HBLConsole/Model/OrderData.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Message;
using BPA.Message.Enum;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace HBLConsole
{
public class OrderData : ObservableObject
{
public bool IsSelected { get { return _mIsSelected; } set { _mIsSelected = value; OnPropertyChanged(); } }
private bool _mIsSelected;

public MorkOrderPush OrderPush { get { return _mOrderPush; } set { _mOrderPush = value; OnPropertyChanged(); } }
private MorkOrderPush _mOrderPush = new MorkOrderPush();

public ORDER_STATUS OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnPropertyChanged(); } }
private ORDER_STATUS _mOrderStatus;

}
}

+ 0
- 109
HBLConsole/Server/SystemHelper.cs View File

@@ -1,109 +0,0 @@
//using IWshRuntimeLibrary;
//using Microsoft.Win32;
//using System;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using System.Windows.Forms;

//namespace HBLConsole.Server
//{
// /// <summary>
// /// 系统操作类
// /// </summary>
// public class SystemHelper
// {
// private volatile static SystemHelper _Instance;
// public static SystemHelper GetInstance => _Instance ?? (_Instance = new SystemHelper());
// private SystemHelper() { }

// /// <summary>
// /// 获取当前应用程序名称,包括后缀名
// /// </summary>
// public string GetApplicationName => Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf(@"\") + 1);

// /// <summary>
// /// 获取当前应用程序完整路径
// /// </summary>
// public string GetApplicationPath => Application.ExecutablePath;

// /// <summary>
// /// 创建桌面快捷方式
// /// </summary>
// /// <returns>成功或失败</returns>
// public bool CreateDesktopShortcut()
// {
// //1、在COM对象中找到 Windows Script Host Object Model
// //2、添加引用 using IWshRuntimeLibrary;
// string deskTop = string.Empty;
// try
// {
// deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\";
// if (System.IO.File.Exists(deskTop + GetApplicationName + ".lnk")) //
// {
// return true;
// //System.IO.File.Delete(deskTop + FileName + ".lnk");//删除原来的桌面快捷键方式
// }
// WshShell shell = new WshShell();

// //快捷键方式创建的位置、名称
// IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(deskTop + GetApplicationName + ".lnk");
// shortcut.TargetPath = GetApplicationPath; //目标文件
// //该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
// shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
// shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
// shortcut.Description = GetApplicationName; //描述
// //shortcut.IconLocation = exePath + "\\logo.ico"; //快捷方式图标
// shortcut.Arguments = "";
// //shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键
// shortcut.Save(); //必须调用保存快捷才成创建成功
// return true;
// }
// catch (Exception)
// {
// return false;
// }
// }

// /// <summary>
// /// 设置开机自启动
// /// </summary>
// /// <param name="isAuto">true:开机启动,false:不开机自启</param>
// public void AutoStart(bool isAuto = true)
// {
// if (isAuto == true)
// {
// RegistryKey R_local = Registry.CurrentUser;
// RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
// R_run.SetValue(GetApplicationName, Application.ExecutablePath);
// R_run.Close();
// R_local.Close();
// }
// else
// {
// RegistryKey R_local = Registry.CurrentUser;
// RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
// R_run.DeleteValue(GetApplicationName, false);
// R_run.Close();
// R_local.Close();
// }
// }

// /// <summary>
// /// 判断是否是自动启动
// /// </summary>
// /// <returns></returns>
// public bool IsAutoStart()
// {
// //RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\");
// RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\");
// return registryKey.GetValueNames().Contains(GetApplicationName);
// }




// }
//}

+ 46
- 0
HBLConsole/Service/InitService.cs View File

@@ -0,0 +1,46 @@
using BPA.Message;
using BPA.Message.Enum;
using HBLConsole.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HBLConsole
{
public class InitService
{

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

public void DataInit()
{
Json<MorkOrderPushPar>.GetInstance.Read();
}

public void DataSave()
{
Json<MorkOrderPushPar>.GetInstance.Save();
}

public void Register()
{
ActionManagerment.GetInstance.Register(new Action<object>((o) =>
{
if (o is MorkOrderPush morkOrderPush)
{
Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Add(new OrderData()
{
OrderStatus = ORDER_STATUS.WAIT,
IsSelected = true,
OrderPush = morkOrderPush
});
}
}), "orderSend");
}

}
}

+ 12
- 0
HBLConsole/View/MainView.xaml View File

@@ -24,6 +24,8 @@
<Window.Resources>
<con:ColorConverter x:Key="color" />
<con:TextConverter x:Key="text" />
<con:NetworkColorConvert x:Key="NetworkColorConvert" />
<con:NetworkTextConvert x:Key="NetworkTextConvert" />

<Style x:Key="BeveledRadioButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="FontFamily" Value="楷体" />
@@ -232,6 +234,16 @@
FontSize="16"
Foreground="#00c2f4"
Text="{Binding OrderCount}" />

<TextBlock
Margin="10,0,0,0"
FontSize="16"
Foreground="#00c2f4"
Text="网络状态:" />
<TextBlock
FontSize="16"
Foreground="{Binding NetworkConnectState, Converter={StaticResource NetworkColorConvert}}"
Text="{Binding NetworkConnectState, Converter={StaticResource NetworkTextConvert}}" />
</StackPanel>
</Grid>



+ 11
- 1
HBLConsole/ViewModel/MainViewModel.cs View File

@@ -1,4 +1,4 @@
using BPA.Message.Kafka;
//using BPA.Message.Kafka;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,6 +10,9 @@ using BPA.Message;
using System.Windows;
using Microsoft.Toolkit.Mvvm.Input;
using System.Reflection;
using HBLConsole.Service;
using HBLConsole.GVL;
using HBLConsole.Model;

namespace HBLConsole.ViewModel
{
@@ -19,6 +22,13 @@ namespace HBLConsole.ViewModel
{
DoNavChanged("MessageLogView");
NavChangedCommand = new RelayCommand<object>(DoNavChanged);
ThreadManagerment.GetInstance.StartLong(new Action(() =>
{
InternetInfo.GetInstance.NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
NetworkConnectState = InternetInfo.GetInstance.NetworkConnectState;
OrderCount = Json<MorkOrderPushPar>.GetInstance.Base.morkOrderPushes.Count;
Thread.Sleep(1000);
}), "界面状态监控");
}




+ 1
- 1
HBLConsole/ViewModel/OrderStatusViewModel.cs View File

@@ -1,5 +1,5 @@
using BPA.Message;
using BPA.Message.Kafka;
//using BPA.Message.Kafka;
using System;
using System.Collections.Generic;
using System.Linq;


+ 12
- 6
HBLConsole/ViewModel/ViewModelBase.cs View File

@@ -8,8 +8,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using BPA.Message;
using BPA.Message.Kafka;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using HBLConsole.Service;
using HBLConsole.Model;

namespace HBLConsole.ViewModel
{
@@ -18,10 +19,10 @@ namespace HBLConsole.ViewModel

public ViewModelBase()
{
//GVL.MessageLogOut.GetInstance.InfoNotify = new Action<string>((s) =>
//{
// LogMessage = GVL.MessageLogOut.GetInstance.LogInfo;
//});
MessageLog.GetInstance.InfoNotify = new Action<string>((s) =>
{
LogMessage = MessageLog.GetInstance.LogInfo;
});
}

#region 静态通知属性
@@ -32,6 +33,11 @@ namespace HBLConsole.ViewModel
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
}


public static bool NetworkConnectState { get { return _mNetworkConnectState; } set { _mNetworkConnectState = value; OnStaticPropertyChanged(); } }
private static bool _mNetworkConnectState;


/// <summary>
/// 日志消息
/// </summary>
@@ -47,7 +53,7 @@ namespace HBLConsole.ViewModel
/// <summary>
/// 订单状态列表
/// </summary>
//public static ObservableCollection<OrderStatusList> orderStatusLists { get; set; } = new ObservableCollection<OrderStatusList>();
public static ObservableCollection<OrderData> orderStatusLists { get; set; } = new ObservableCollection<OrderData>();

/// <summary>
/// 显示当前窗体名称


Loading…
Cancel
Save