492 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			492 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C#
		
	
	
	
using log4net;
 | 
						|
using Microsoft.Xaml.Behaviors;
 | 
						|
using NetTaste;
 | 
						|
using Prism.Commands;
 | 
						|
using Prism.Events;
 | 
						|
using Prism.Mvvm;
 | 
						|
using Prism.Regions;
 | 
						|
using Prism.Services.Dialogs;
 | 
						|
using SqlSugar;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Configuration;
 | 
						|
using System.Linq;
 | 
						|
using System.Speech.Synthesis;
 | 
						|
using System.Text;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using System.Windows;
 | 
						|
using DM_Weight.Models;
 | 
						|
using DM_Weight.msg;
 | 
						|
using DM_Weight.Port;
 | 
						|
using DM_Weight.select;
 | 
						|
using DM_Weight.util;
 | 
						|
using System.Threading;
 | 
						|
 | 
						|
namespace DM_Weight.ViewModels
 | 
						|
{
 | 
						|
    public class InvoiceTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
						|
    {
 | 
						|
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceTakeDialogViewModel));
 | 
						|
        public string Title => "调拨出库";
 | 
						|
 | 
						|
 | 
						|
        public event Action<IDialogResult> RequestClose;
 | 
						|
 | 
						|
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
						|
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
						|
 | 
						|
        private PortUtil _portUtil;
 | 
						|
        IEventAggregator _eventAggregator;
 | 
						|
        IDialogService _dialogService;
 | 
						|
        //private SqlSugarScope SqlSugarHelper.Db;
 | 
						|
        public InvoiceTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
 | 
						|
        {
 | 
						|
            _dialogService = DialogService;
 | 
						|
            _portUtil = portUtil;
 | 
						|
            _eventAggregator = eventAggregator;
 | 
						|
            //this.SqlSugarHelper.Db = sqlSugarScope;
 | 
						|
        }
 | 
						|
 | 
						|
        void DoMyPrismEvent(DeviceMsg msg)
 | 
						|
        {
 | 
						|
 | 
						|
            if (msg.WindowName == "InvoiceTakeDrugWindow")
 | 
						|
            {
 | 
						|
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
						|
                int DrawerNo = grouping.Key;
 | 
						|
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
						|
 | 
						|
                switch (msg.EventType)
 | 
						|
                {
 | 
						|
                    // 抽屉打开
 | 
						|
                    case EventType.DRAWEROPEN:
 | 
						|
 | 
						|
                        
 | 
						|
                        if (Status == 1)
 | 
						|
                        {
 | 
						|
                            if (channelStocks[0].process == 1)
 | 
						|
                            {
 | 
						|
                                channelStocks.ForEach(it => it.process = 2);
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
 | 
						|
                        break;
 | 
						|
                    // 抽屉关闭
 | 
						|
                    case EventType.DRAWERCLOSE:
 | 
						|
                        if (Status == 1)
 | 
						|
                        {
 | 
						|
                            if (channelStocks[0].process == 2)
 | 
						|
                            {
 | 
						|
                                channelStocks.ForEach(it => it.process = 3);
 | 
						|
                            }
 | 
						|
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
						|
                            int DrawerNoBefore = groupingBefore.Key;
 | 
						|
                            if (enumerator.MoveNext())
 | 
						|
                            {
 | 
						|
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
						|
                                int DrawerNoAfter = groupingAfter.Key;
 | 
						|
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
						|
                                {
 | 
						|
                                    Thread.Sleep(50);
 | 
						|
                                }
 | 
						|
                                OpenOneByOne();
 | 
						|
                            }
 | 
						|
                            // 已经全部取出
 | 
						|
                            else
 | 
						|
                            {
 | 
						|
                                Status = 3;
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        break;
 | 
						|
                    // 数量变化
 | 
						|
                    case EventType.UPDATEQUANTITY:
 | 
						|
                        if (Status == 1)
 | 
						|
                        {
 | 
						|
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
						|
                        }
 | 
						|
                        break;
 | 
						|
                    // 打开失败
 | 
						|
                    case EventType.OPENERROR:
 | 
						|
                        AlertMsg alertMsg = new AlertMsg
 | 
						|
                        {
 | 
						|
                            Message = msg.Message,
 | 
						|
                            Type = MsgType.ERROR,
 | 
						|
                        };
 | 
						|
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                        Status = 0;
 | 
						|
                        break;
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        private int _status = 0;
 | 
						|
 | 
						|
        public int Status
 | 
						|
        {
 | 
						|
            get => _status; set => SetProperty(ref _status, value);
 | 
						|
        }
 | 
						|
 | 
						|
        private Invoice? _invoic;
 | 
						|
 | 
						|
 | 
						|
        public Invoice? Invoice
 | 
						|
        {
 | 
						|
            get => _invoic;
 | 
						|
            set => SetProperty(ref _invoic, value);
 | 
						|
        }
 | 
						|
 | 
						|
        private List<InOutInvoice> invoices { get; set; }
 | 
						|
 | 
						|
        private List<ChannelStock> _channelStocks;
 | 
						|
 | 
						|
        public List<ChannelStock> ChannelStocks
 | 
						|
        {
 | 
						|
            get => _channelStocks;
 | 
						|
            set => SetProperty(ref _channelStocks, value);
 | 
						|
        }
 | 
						|
        
 | 
						|
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
						|
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
						|
 | 
						|
 | 
						|
        public bool CanCloseDialog()
 | 
						|
        {
 | 
						|
            return Status == 0;
 | 
						|
        }
 | 
						|
 | 
						|
        public void OnDialogClosed()
 | 
						|
        {
 | 
						|
            // 取消消息订阅
 | 
						|
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
						|
        }
 | 
						|
 | 
						|
        public void OnDialogOpened(IDialogParameters parameters)
 | 
						|
        {
 | 
						|
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
						|
            Invoice o = parameters.GetValue<Invoice>("invoice");
 | 
						|
            Invoice = o;
 | 
						|
            RequestData();
 | 
						|
        }
 | 
						|
 | 
						|
        public void RequestData()
 | 
						|
        {
 | 
						|
            invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
						|
                .Includes<DrugInfo>(i => i.DrugInfo)
 | 
						|
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs =>cs.DrugId),(i,t) => i.DrugId == t.DrugId)
 | 
						|
                .Where(i => i.InvoiceNo == Invoice.InvoiceNo)
 | 
						|
                .ToList();
 | 
						|
 | 
						|
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
						|
            List<string> msg = new List<string>();
 | 
						|
            for (int i = 0; i < invoices.Count; i++)
 | 
						|
            {
 | 
						|
                InOutInvoice invoice = invoices[i];
 | 
						|
 | 
						|
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
						|
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
						|
                    .InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
 | 
						|
                    .Where(cs => cs.Quantity > 0)
 | 
						|
                    .Where(cs => cs.DrawerType == 1)
 | 
						|
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
						|
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
 | 
						|
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
 | 
						|
                    .Where(cs => cs.DrugId == invoice.DrugId)
 | 
						|
                    .OrderBy(cs => cs.EffDate)
 | 
						|
                    .ToList();
 | 
						|
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
						|
                int TakeQ = invoice.quantity;
 | 
						|
                // 说明数量足够
 | 
						|
                if (total >= TakeQ)
 | 
						|
                {
 | 
						|
                    for (int j = 0; TakeQ > 0; j++)
 | 
						|
                    {
 | 
						|
                        ChannelStock stock = HasQChannels[j];
 | 
						|
                        if (TakeQ > stock.Quantity)
 | 
						|
                        {
 | 
						|
                            stock.TakeQuantity = stock.Quantity;
 | 
						|
                            channelStocks.Add(stock);
 | 
						|
                            TakeQ -= stock.Quantity;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            stock.TakeQuantity = TakeQ;
 | 
						|
                            channelStocks.Add(stock);
 | 
						|
                            TakeQ = 0;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    msg.Add($"药品【{invoice.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if(msg.Count > 0)
 | 
						|
            {
 | 
						|
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
						|
                //MessageBox.Show(string.Join("\n", msg));
 | 
						|
                DialogParameters dialogParameters = new DialogParameters();
 | 
						|
                dialogParameters.Add("msgInfo", msg);
 | 
						|
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
						|
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                channelStocks.Sort((a, b) =>
 | 
						|
                {
 | 
						|
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
						|
                    {
 | 
						|
                        return a.ColNo - b.ColNo;
 | 
						|
                    }
 | 
						|
                    return a.DrawerNo - b.DrawerNo;
 | 
						|
                });
 | 
						|
                ChannelStocks = channelStocks;
 | 
						|
 | 
						|
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        public DelegateCommand OpenDrawer
 | 
						|
        {
 | 
						|
            get => new DelegateCommand(() =>
 | 
						|
            {
 | 
						|
                if (Status == 0)
 | 
						|
                {
 | 
						|
 | 
						|
                    //if (App.CurrentFaUserList.Role != null)
 | 
						|
                    //{
 | 
						|
                    //    //查看当前用户是否有所在药品抽屉的权限
 | 
						|
                    //    bool bLessEight = ChannelStocks.Select(it => it.DrawerNo).Where(n => n <= 8).Any();
 | 
						|
                    //    bool bMoreEight = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 8 && n < 17).Any();
 | 
						|
                    //    bool bEqualEight = ChannelStocks.Select(it => it.DrawerNo).Where(n => n == 17).Any();
 | 
						|
                    //    if (bLessEight)
 | 
						|
                    //    {
 | 
						|
                    //        if (App.CurrentFaUserList.Role.FirstEightChecked == "0")
 | 
						|
                    //        {
 | 
						|
                    //            AlertMsg alertMsg = new AlertMsg
 | 
						|
                    //            {
 | 
						|
                    //                Message = "当前用户没有打开抽屉的权限!",
 | 
						|
                    //                Type = MsgType.ERROR,
 | 
						|
                    //            };
 | 
						|
                    //            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                    //            return;
 | 
						|
                    //        }
 | 
						|
                    //    }
 | 
						|
                    //    if (bMoreEight)
 | 
						|
                    //    {
 | 
						|
                    //        if (App.CurrentFaUserList.Role.LastEightChecked == "0")
 | 
						|
                    //        {
 | 
						|
                    //            AlertMsg alertMsg = new AlertMsg
 | 
						|
                    //            {
 | 
						|
                    //                Message = "当前用户没有打开抽屉的权限!",
 | 
						|
                    //                Type = MsgType.ERROR,
 | 
						|
                    //            };
 | 
						|
                    //            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                    //            return;
 | 
						|
                    //        }
 | 
						|
                    //    }
 | 
						|
                    //    if (bEqualEight)
 | 
						|
                    //    {
 | 
						|
                    //        if (App.CurrentFaUserList.Role.StorageBoxChecked == "0")
 | 
						|
                    //        {
 | 
						|
                    //            AlertMsg alertMsg = new AlertMsg
 | 
						|
                    //            {
 | 
						|
                    //                Message = "当前用户没有打开抽屉的权限!",
 | 
						|
                    //                Type = MsgType.ERROR,
 | 
						|
                    //            };
 | 
						|
                    //            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                    //            return;
 | 
						|
                    //        }
 | 
						|
                    //    }
 | 
						|
 | 
						|
                    //}
 | 
						|
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
						|
                    enumerator = enumerable.GetEnumerator();
 | 
						|
                    enumerator.MoveNext();
 | 
						|
                    Status = 1;
 | 
						|
                    OpenOneByOne();
 | 
						|
                }
 | 
						|
                
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        private void OpenOneByOne()
 | 
						|
        {
 | 
						|
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
						|
            int DrawerNo = grouping.Key;
 | 
						|
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
						|
            channelStocks.ForEach(it => it.process = 1);
 | 
						|
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
						|
 | 
						|
 | 
						|
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
						|
 | 
						|
            // 发送取药数量
 | 
						|
            singleChannels.ForEach(it =>
 | 
						|
            {
 | 
						|
                _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
						|
            });
 | 
						|
            _portUtil.WindowName = "InvoiceTakeDrugWindow";
 | 
						|
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
						|
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
						|
            _portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
 | 
						|
            _portUtil.DrawerNo = DrawerNo;
 | 
						|
            _portUtil.Start();
 | 
						|
        }
 | 
						|
 | 
						|
        private bool _isFinishClick = false;
 | 
						|
        // 完成按钮
 | 
						|
        public DelegateCommand TakeFinish
 | 
						|
        {
 | 
						|
            get => new DelegateCommand(() =>
 | 
						|
            {
 | 
						|
                if (!_isFinishClick)
 | 
						|
                {
 | 
						|
                    _isFinishClick = true;
 | 
						|
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
						|
                    if (record.Count > 0)
 | 
						|
                    {
 | 
						|
                        string InvoiceId = Invoice.InvoiceNo;
 | 
						|
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
						|
                        {
 | 
						|
                            SqlSugarHelper.Db.Updateable(new InOutInvoice()
 | 
						|
                            {
 | 
						|
                                Status = 1,
 | 
						|
                                InvoiceNo = Invoice.InvoiceNo
 | 
						|
                            }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
 | 
						|
 | 
						|
                            for (int i = 0; i < record.Count; i++)
 | 
						|
                            {
 | 
						|
                                ChannelStock it = record[i];
 | 
						|
                                // 更新数据 库存信息
 | 
						|
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
						|
                                {
 | 
						|
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
						|
                                    ManuNo = it.ManuNo,
 | 
						|
                                    EffDate = it.EffDate,
 | 
						|
                                    Id = it.Id,
 | 
						|
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
						|
                                // 获取更新完库存后的药品库存
 | 
						|
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
						|
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
						|
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
						|
                                    .Where(cs => cs.DrawerType == 1)
 | 
						|
                                    .ToList();
 | 
						|
 | 
						|
                                // 保存数据 出库记录
 | 
						|
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
						|
                                {
 | 
						|
                                    MachineId = it.MachineId,
 | 
						|
                                    DrawerNo = it.DrawerNo,
 | 
						|
                                    ColNo = it.ColNo,
 | 
						|
                                    DrugId = it.DrugId,
 | 
						|
                                    ManuNo = it.ManuNo,
 | 
						|
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
						|
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
						|
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
						|
                                    OperationTime = DateTime.Now,
 | 
						|
                                    Quantity = it.TakeQuantity,
 | 
						|
                                    Type = 2,
 | 
						|
                                    InvoiceId = InvoiceId,
 | 
						|
                                    StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
						|
                                    ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
 | 
						|
                                    SupplierDept = Invoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
 | 
						|
                                    ReceiveDept = Invoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
 | 
						|
                                }).ExecuteCommand();
 | 
						|
                            }
 | 
						|
                            return true;
 | 
						|
                        });
 | 
						|
                        if (f.Data)
 | 
						|
                        {
 | 
						|
                            // 更新屏显库存
 | 
						|
                            //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
						|
                            List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
 | 
						|
                                                                         .GroupBy(it => it.ColNo)
 | 
						|
                                                                         .Select(it =>
 | 
						|
                                                                         {
 | 
						|
                                                                             var ret = it.First();
 | 
						|
                                                                             ret.Quantity = it.Sum(itx => itx.Quantity);
 | 
						|
                                                                             ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
 | 
						|
                                                                             return ret;
 | 
						|
                                                                         }).ToList();
 | 
						|
                            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
						|
                            {
 | 
						|
                                //将库位多批次的总库存数更新标签
 | 
						|
                                _portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.AddQuantity));
 | 
						|
                                Thread.Sleep(200);
 | 
						|
                                //singleChannels.ForEach(it =>
 | 
						|
                                //{
 | 
						|
                                //    _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
						|
                                //});
 | 
						|
                            }
 | 
						|
                            AlertMsg alertMsg = new AlertMsg
 | 
						|
                            {
 | 
						|
                                Message = "调拨取药完成,库存已更新",
 | 
						|
                                Type = MsgType.SUCCESS,
 | 
						|
                            };
 | 
						|
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                        }
 | 
						|
                        if (!f.IsSuccess)
 | 
						|
                        {
 | 
						|
                            AlertMsg alertMsg = new AlertMsg
 | 
						|
                            {
 | 
						|
                                Message = "调拨取药完成,库存更新失败!",
 | 
						|
                                Type = MsgType.ERROR,
 | 
						|
                            };
 | 
						|
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                        }
 | 
						|
                        Status = 0;
 | 
						|
                        _isFinishClick = false;
 | 
						|
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        _isFinishClick = false;
 | 
						|
                        AlertMsg alertMsg = new AlertMsg
 | 
						|
                        {
 | 
						|
                            Message = "没有填写取药数量",
 | 
						|
                            Type = MsgType.ERROR
 | 
						|
                        };
 | 
						|
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
						|
                    }
 | 
						|
 | 
						|
                }
 | 
						|
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        public long CurrentTimeMillis()
 | 
						|
        {
 | 
						|
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
						|
        }
 | 
						|
 | 
						|
        // 取消按钮
 | 
						|
        public DelegateCommand CancleTake
 | 
						|
        {
 | 
						|
            get => new DelegateCommand(() =>
 | 
						|
            {
 | 
						|
                _portUtil.ResetData();
 | 
						|
                Status = 0;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        public DelegateCommand BtnCloseCommand
 | 
						|
        {
 | 
						|
            get => new DelegateCommand(() =>
 | 
						|
            {
 | 
						|
                if (Status != 0)
 | 
						|
                {
 | 
						|
                    _portUtil.ResetData();
 | 
						|
                    Status = 0;
 | 
						|
                }
 | 
						|
                //DialogParameters parameters = new DialogParameters();
 | 
						|
                //parameters.Add("",);
 | 
						|
                // 关闭当前窗口
 | 
						|
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        public bool KeepAlive => true;
 | 
						|
    }
 | 
						|
}
 |