首次提交:添加src文件夹代码
This commit is contained in:
155
Cowain.Bake.Main/ViewModels/BasicInfoViewModel.cs
Normal file
155
Cowain.Bake.Main/ViewModels/BasicInfoViewModel.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model.Entity;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Media;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.Main.ViewModels
|
||||
{
|
||||
public class BasicInfoViewModel : BindableBase
|
||||
{
|
||||
public static ObservableCollection<string> EventListNoticfication = new ObservableCollection<string>();
|
||||
private string _userName;
|
||||
public string UserName
|
||||
{
|
||||
get { return _userName; }
|
||||
set { SetProperty<string>(ref _userName, value); }
|
||||
}
|
||||
|
||||
private string _currentJobNum;
|
||||
public string CurrentJobNum
|
||||
{
|
||||
get { return _currentJobNum; }
|
||||
set { SetProperty<string>(ref _currentJobNum, value); }
|
||||
}
|
||||
|
||||
private string _dispMode;
|
||||
public string DispMode
|
||||
{
|
||||
get { return _dispMode; }
|
||||
set { SetProperty<string>(ref _dispMode, value); }
|
||||
}
|
||||
|
||||
private string _currentOperation;
|
||||
public string CurrentOperation
|
||||
{
|
||||
get { return _currentOperation; }
|
||||
set { SetProperty<string>(ref _currentOperation, value); }
|
||||
}
|
||||
private string _userId;
|
||||
public string UserId
|
||||
{
|
||||
get { return _userId; }
|
||||
set { SetProperty<string>(ref _userId, value); }
|
||||
}
|
||||
private string _startStatusName;
|
||||
public string StartStatusName
|
||||
{
|
||||
get { return _startStatusName; }
|
||||
set { SetProperty<string>(ref _startStatusName, value); }
|
||||
}
|
||||
|
||||
private string _failPointData;
|
||||
public string FailPointData
|
||||
{
|
||||
get { return _failPointData; }
|
||||
set { SetProperty<string>(ref _failPointData, value); }
|
||||
}
|
||||
|
||||
private string _deviceStatusName;
|
||||
public string DeviceStatusName
|
||||
{
|
||||
get { return _deviceStatusName; }
|
||||
set { SetProperty<string>(ref _deviceStatusName, value); }
|
||||
}
|
||||
|
||||
//EventList
|
||||
private ObservableCollection<string> _eventList = new ObservableCollection<string>();
|
||||
public ObservableCollection<string> EventList
|
||||
{
|
||||
get => _eventList;
|
||||
set => SetProperty(ref _eventList, value);
|
||||
}
|
||||
|
||||
private bool _mesStatus;
|
||||
public bool MesStatus
|
||||
{
|
||||
get { return _mesStatus; }
|
||||
set { SetProperty(ref _mesStatus, value); RaisePropertyChanged(nameof(StatusColor)); }
|
||||
}
|
||||
|
||||
public SolidColorBrush StatusColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!MesStatus)
|
||||
{
|
||||
return new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
|
||||
public BasicInfoViewModel(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
ShowInfo();
|
||||
}
|
||||
|
||||
public void ShowInfo()
|
||||
{
|
||||
UserEntity userInfo = _unityContainer.Resolve<MemoryDataProvider>().CurrentUser;
|
||||
userInfo.JobNum = _unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo().JobNum;
|
||||
userInfo.ProcessParamName = _unityContainer.Resolve<ProcessParamService>().Get(_unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo().ProcessParamId).ProcessParamName;
|
||||
|
||||
FailPointData = "0";
|
||||
UserName = userInfo.UserName;
|
||||
UserId = userInfo.UserId;
|
||||
CurrentJobNum = userInfo.JobNum;
|
||||
CurrentOperation = userInfo.ProcessParamName;
|
||||
DeviceStatusName = EDeviceStatus.None.GetDescription();
|
||||
DispMode = SettingProvider.Instance.DispMode.GetDescription();
|
||||
}
|
||||
|
||||
public void SetTempData(string value)
|
||||
{
|
||||
System.Threading.SynchronizationContext.SetSynchronizationContext(new
|
||||
System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Application.Current.Dispatcher));
|
||||
System.Threading.SynchronizationContext.Current.Post(p1 =>
|
||||
{
|
||||
FailPointData = value;
|
||||
}, null);
|
||||
}
|
||||
|
||||
public void SetEvent(string msg)
|
||||
{
|
||||
// 在第一个位置插入新元素
|
||||
System.Threading.SynchronizationContext.SetSynchronizationContext(new
|
||||
System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Application.Current.Dispatcher));
|
||||
System.Threading.SynchronizationContext.Current.Post(p1 =>
|
||||
{
|
||||
/*
|
||||
RemoveAt:放在外面,会崩
|
||||
该类型的 CollectionView 不支持从调度程序线程以外的线程对其 SourceCollection 进行的更改。, 在 System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
|
||||
在 System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
|
||||
在 System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
|
||||
*/
|
||||
if (EventList.Count > Bake.Common.Global.MAX_QUEUE_SIGNAL)
|
||||
{
|
||||
EventList.RemoveAt(EventList.Count - 1);
|
||||
}
|
||||
|
||||
EventList.Insert(0, $"{ DateTime.Now.ToString("HH:mm:ss")}: {msg}");
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user