using Aucma.Core.Palletiz.Business; using Aucma.Core.Palletiz.Models; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using log4net; using System; using System.Windows.Forms; namespace Aucma.Core.Palletiz.ViewModels { public partial class HandPalletizViewModel : ObservableObject { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(HandPalletizViewModel)); #region 货道信息 private int LevelNo = 1; private int BinNo = 1; private int PortNo = 1; private int RangeNo = 1; #endregion public static StackInfoModel tempStackInfo = new StackInfoModel(); public HandPalletizViewModel() { PromptInfo("请选择信息下传......", "White"); } #region 分垛信息下传 /// /// 分垛信息下传 /// [RelayCommand] public void Save() { try { PromptInfo("分垛信息下传中......", "White"); DialogResult cr = MessageBox.Show("是否确认下传分垛信息?", "系统提醒", MessageBoxButtons.OKCancel); if (cr != DialogResult.OK) { return; } tempStackInfo.LevelNo = LevelNo; tempStackInfo.BinNo = (BinNo - 1) * 2 + PortNo + ((LevelNo - 1) * 10); tempStackInfo.PortNo = PortNo; tempStackInfo.RangeNo = RangeNo; bool backResult = InstoreBusiness.WritePlc(tempStackInfo); if (backResult) { PromptInfo("分垛信息下传成功!", "White"); } else { PromptInfo("分垛信息下传失败!", "Red"); } } catch (Exception ex) { PromptInfo($"分垛信息下传失败:{ex.Message}", "Red"); } } #endregion #region 提示信息 private string? msgTxt; public string? MsgTxt { get => msgTxt; set => SetProperty(ref msgTxt, value); } #endregion #region 字体颜色 private string? msgColor; public string? MsgColor { get => msgColor; set => SetProperty(ref msgColor, value); } #endregion #region 提示信息 /// /// 提示信息 /// /// 提示信息 /// 提示信息颜色 public void PromptInfo(string mesg, string color) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { MsgTxt = mesg; MsgColor = color; })); } #endregion } }