|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Threading;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Windows.Input;
|
|
|
using GummingCommon;
|
|
|
using GummingEntity;
|
|
|
using GummingSupport;
|
|
|
using GummingControl;
|
|
|
using System.Text;
|
|
|
using GummingBusiness;
|
|
|
using Newtonsoft.Json;
|
|
|
using GummingLine;
|
|
|
|
|
|
namespace Gumming
|
|
|
{
|
|
|
public class UnitViewModule : ViewModelBase
|
|
|
{
|
|
|
#region base parameters
|
|
|
private int rows = 20;
|
|
|
private int pagenumber = 1;
|
|
|
public UnitView View { get; set; }
|
|
|
private bool IsConfirm;
|
|
|
private bool isLoading;
|
|
|
#endregion
|
|
|
|
|
|
#region constructor
|
|
|
public UnitViewModule()
|
|
|
{
|
|
|
View = new UnitView();
|
|
|
View.DataContext = this;
|
|
|
|
|
|
InitializeCommands();
|
|
|
InitializeParameters();
|
|
|
}
|
|
|
|
|
|
private void InitializeCommands()
|
|
|
{
|
|
|
NewCommand = new DelegateCommand(OnNewCommand);
|
|
|
AddStepCommand = new DelegateCommand(OnAddStepCommand);
|
|
|
InsertStepCommand = new DelegateCommand(OnInsertStepCommand);
|
|
|
DeleteStepCommand = new DelegateCommand(OnDeleteStepCommand);
|
|
|
SaveStepCommand = new DelegateCommand(OnSaveStepCommand);
|
|
|
AllowCommand = new DelegateCommand(OnAllowCommand);
|
|
|
SelectStepCommand = new DelegateCommand(OnSelectStepCommand);
|
|
|
CopyStepCommand = new DelegateCommand(OnCopyStepCommand);
|
|
|
DisabledCommand = new DelegateCommand(OnDisabledCommand);
|
|
|
UnitClickCommand = new DelegateCommand(OnUnitClickCommand);
|
|
|
SelectFlowCommand = new DelegateCommand(OnSelectFlowCommand);
|
|
|
SaveAsFormulaCommand = new DelegateCommand(OnSaveAsFormulaCommand);
|
|
|
DeleteFormulaCommand = new DelegateCommand(OnDeleteFormulaCommand);
|
|
|
}
|
|
|
|
|
|
public override void InitializeParameters(object content = null)
|
|
|
{
|
|
|
IsConfirm = false;
|
|
|
WindowTitle = "";
|
|
|
AllowEdit = false;
|
|
|
CreateBy = Global.CurrentUserCode;
|
|
|
HardUnits = new ObservableCollection<HardUnitFlowStepEntity>();
|
|
|
|
|
|
StartLoadFlow();
|
|
|
}
|
|
|
|
|
|
~UnitViewModule()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Binding Properties
|
|
|
public string WindowTitle { get; private set; }
|
|
|
|
|
|
private ObservableCollection<HardUnitFlowEntity> _HardFlows;
|
|
|
public ObservableCollection<HardUnitFlowEntity> HardFlows
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _HardFlows;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_HardFlows = value;
|
|
|
OnPropertyChanged("HardFlows");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private HardUnitFlowEntity _SelectedFlow;
|
|
|
public HardUnitFlowEntity SelectedFlow
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectedFlow;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectedFlow = value;
|
|
|
OnPropertyChanged("SelectedFlow");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ObservableCollection<HardUnitFlowStepEntity> _HardUnits;
|
|
|
public ObservableCollection<HardUnitFlowStepEntity> HardUnits
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _HardUnits;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_HardUnits = value;
|
|
|
OnPropertyChanged("HardUnits");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private HardUnitFlowStepEntity _SelectedStep;
|
|
|
public HardUnitFlowStepEntity SelectedStep
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectedStep;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectedStep = value;
|
|
|
OnPropertyChanged("SelectedStep");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private string _FlowName;
|
|
|
public string FlowName
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _FlowName;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_FlowName = value;
|
|
|
OnPropertyChanged("FlowName");
|
|
|
}
|
|
|
}
|
|
|
private string _CreateBy;
|
|
|
public string CreateBy
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _CreateBy;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_CreateBy = value;
|
|
|
OnPropertyChanged("CreateBy");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private HardStationType _SelectedFormulaType;
|
|
|
public HardStationType SelectedFormulaType
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectedFormulaType;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectedFormulaType = value;
|
|
|
OnPropertyChanged("SelectedFormulaType");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private HardFormulaEntity _SelectedFormula;
|
|
|
public HardFormulaEntity SelectedFormula
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectedFormula;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectedFormula = value;
|
|
|
OnPropertyChanged("SelectedFormula");
|
|
|
}
|
|
|
}
|
|
|
private bool _AllowEdit;
|
|
|
public bool AllowEdit
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _AllowEdit;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_AllowEdit = value;
|
|
|
OnPropertyChanged("AllowEdit");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Binding Commands
|
|
|
private ICommand _NewCommand;
|
|
|
public ICommand NewCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _NewCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_NewCommand = value;
|
|
|
OnPropertyChanged("NewCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _AddStepCommand;
|
|
|
public ICommand AddStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _AddStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_AddStepCommand = value;
|
|
|
OnPropertyChanged("AddStepCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _DeleteStepCommand;
|
|
|
public ICommand DeleteStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _DeleteStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_DeleteStepCommand = value;
|
|
|
OnPropertyChanged("DeleteStepCommand");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ICommand _SaveStepCommand;
|
|
|
public ICommand SaveStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SaveStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SaveStepCommand = value;
|
|
|
OnPropertyChanged("SaveStepCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _AllowCommand;
|
|
|
public ICommand AllowCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _AllowCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_AllowCommand = value;
|
|
|
OnPropertyChanged("AllowCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _InsertStepCommand;
|
|
|
public ICommand InsertStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _InsertStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_InsertStepCommand = value;
|
|
|
OnPropertyChanged("InsertStepCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _SelectStepCommand;
|
|
|
public ICommand SelectStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectStepCommand = value;
|
|
|
OnPropertyChanged("SelectStepCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _CopyStepCommand;
|
|
|
public ICommand CopyStepCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _CopyStepCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_CopyStepCommand = value;
|
|
|
OnPropertyChanged("CopyStepCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _DisabledCommand;
|
|
|
public ICommand DisabledCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _DisabledCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_DisabledCommand = value;
|
|
|
OnPropertyChanged("DisabledCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _UnitClickCommand;
|
|
|
public ICommand UnitClickCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _UnitClickCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_UnitClickCommand = value;
|
|
|
OnPropertyChanged("UnitClickCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _SelectFlowCommand;
|
|
|
public ICommand SelectFlowCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectFlowCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectFlowCommand = value;
|
|
|
OnPropertyChanged("SelectFlowCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _DeleteFormulaCommand;
|
|
|
public ICommand DeleteFormulaCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _DeleteFormulaCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_DeleteFormulaCommand = value;
|
|
|
OnPropertyChanged("DeleteFormulaCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _SaveAsFormulaCommand;
|
|
|
public ICommand SaveAsFormulaCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SaveAsFormulaCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SaveAsFormulaCommand = value;
|
|
|
OnPropertyChanged("SaveAsFormulaCommand");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Private Methods
|
|
|
public void StartLoadFlow()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
isLoading = true;
|
|
|
HardFlows = new ObservableCollection<HardUnitFlowEntity>();
|
|
|
var flow = HardUnitFlowDA.Load(new PagerEntity() { PageIndex = 1, Rows = 999, Conditions = " and 1=1 " });
|
|
|
List<HardUnitFlowEntity> flows = (List<HardUnitFlowEntity>)flow.rows;
|
|
|
View.Dispatcher.Invoke((Action)(() =>
|
|
|
{
|
|
|
foreach (var s in flows)
|
|
|
{
|
|
|
HardFlows.Add(s);
|
|
|
}
|
|
|
OnPropertyChanged("HardFlows");
|
|
|
isLoading = false;
|
|
|
}));
|
|
|
if (HardFlows != null && HardFlows.Count > 0)
|
|
|
{
|
|
|
SelectedFlow = HardFlows[0];
|
|
|
LoadFlowUnit();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OnNewCommand(null);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogService.WriteErrorLog(ex);
|
|
|
ShowErrorBox("Error:" + ex.Message);
|
|
|
return;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
CloseProgressView();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void LoadFlowUnit()
|
|
|
{
|
|
|
if (SelectedFlow != null)
|
|
|
{
|
|
|
string flowId = SelectedFlow.RecId;
|
|
|
FlowName = SelectedFlow.FlowName;
|
|
|
HardUnits = new ObservableCollection<HardUnitFlowStepEntity>();
|
|
|
var record = HardUnitFlowStepDA.Load(new PagerEntity() { PageIndex = pagenumber, Rows = rows, Conditions = " and FlowId='" + flowId + "' " });
|
|
|
List<HardUnitFlowStepEntity> logs = (List<HardUnitFlowStepEntity>)record.rows;
|
|
|
logs.Sort((x, y) => x.StepIndex - y.StepIndex);
|
|
|
View.Dispatcher.Invoke((Action)(() =>
|
|
|
{
|
|
|
for (int i = 0; i < logs.Count; i++)
|
|
|
{
|
|
|
var cp = logs[i];
|
|
|
cp.StepIndex = i + 1;
|
|
|
cp.Unit1Tag = new UnitTag();
|
|
|
cp.Unit1Tag.Row = i;
|
|
|
cp.Unit1Tag.FormulaId = cp.Unit1;
|
|
|
var formual1 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit1);
|
|
|
if (formual1 != null)
|
|
|
{
|
|
|
cp.Unit1Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual1?.StationCode, formual1?.FormulaName);
|
|
|
}
|
|
|
cp.Unit1Tag.Column = 1;
|
|
|
cp.Unit2Tag = new UnitTag();
|
|
|
cp.Unit2Tag.Row = i;
|
|
|
cp.Unit2Tag.Column = 1;
|
|
|
cp.Unit2Tag.FormulaId = cp.Unit2;
|
|
|
var formual2 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit2);
|
|
|
if (formual2 != null)
|
|
|
{
|
|
|
cp.Unit2Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual2?.StationCode, formual2?.FormulaName);
|
|
|
}
|
|
|
cp.Unit3Tag = new UnitTag();
|
|
|
cp.Unit3Tag.Row = i;
|
|
|
cp.Unit3Tag.Column = 1;
|
|
|
cp.Unit3Tag.FormulaId = cp.Unit3;
|
|
|
var formual3 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit3);
|
|
|
if (formual3 != null)
|
|
|
{
|
|
|
cp.Unit3Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual3?.StationCode, formual3?.FormulaName);
|
|
|
}
|
|
|
cp.Unit4Tag = new UnitTag();
|
|
|
cp.Unit4Tag.Row = i;
|
|
|
cp.Unit4Tag.Column = 1;
|
|
|
cp.Unit4Tag.FormulaId = cp.Unit4;
|
|
|
var formual4 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit4);
|
|
|
if (formual4 != null)
|
|
|
{
|
|
|
cp.Unit4Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual4?.StationCode, formual4?.FormulaName);
|
|
|
}
|
|
|
cp.Unit5Tag = new UnitTag();
|
|
|
cp.Unit5Tag.Row = i;
|
|
|
cp.Unit5Tag.Column = 1;
|
|
|
cp.Unit5Tag.FormulaId = cp.Unit5;
|
|
|
var formual5 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit5);
|
|
|
if (formual5 != null)
|
|
|
{
|
|
|
cp.Unit5Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual5?.StationCode, formual5?.FormulaName);
|
|
|
}
|
|
|
cp.Unit6Tag = new UnitTag();
|
|
|
cp.Unit6Tag.Row = i;
|
|
|
cp.Unit6Tag.Column = 1;
|
|
|
cp.Unit6Tag.FormulaId = cp.Unit6;
|
|
|
var formual6 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit6);
|
|
|
if (formual6 != null)
|
|
|
{
|
|
|
cp.Unit6Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual6?.StationCode, formual6?.FormulaName);
|
|
|
}
|
|
|
cp.Unit7Tag = new UnitTag();
|
|
|
cp.Unit7Tag.Row = i;
|
|
|
cp.Unit7Tag.Column = 1;
|
|
|
cp.Unit7Tag.FormulaId = cp.Unit7;
|
|
|
var formual7 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit7);
|
|
|
if (formual7 != null)
|
|
|
{
|
|
|
cp.Unit7Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual7?.StationCode, formual7?.FormulaName);
|
|
|
}
|
|
|
cp.Unit8Tag = new UnitTag();
|
|
|
cp.Unit8Tag.Row = i;
|
|
|
cp.Unit8Tag.Column = 1;
|
|
|
cp.Unit8Tag.FormulaId = cp.Unit8;
|
|
|
var formual8 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit8);
|
|
|
if (formual8 != null)
|
|
|
{
|
|
|
cp.Unit8Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual8?.StationCode, formual8?.FormulaName);
|
|
|
}
|
|
|
cp.Unit9Tag = new UnitTag();
|
|
|
cp.Unit9Tag.Row = i;
|
|
|
cp.Unit9Tag.Column = 1;
|
|
|
cp.Unit9Tag.FormulaId = cp.Unit9;
|
|
|
var formual9 = Global.Formulas.FirstOrDefault(q => q.RecId == cp.Unit9);
|
|
|
if (formual9 != null)
|
|
|
{
|
|
|
cp.Unit9Tag.FormulaText = string.Format(Constant.DefaultWarningCode, formual9?.StationCode, formual9?.FormulaName);
|
|
|
}
|
|
|
HardUnits.Add(cp);
|
|
|
}
|
|
|
OnPropertyChanged("HardUnits");
|
|
|
isLoading = false;
|
|
|
}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnAddStepCommand(Object sender)
|
|
|
{
|
|
|
if (HardUnits.Count == 1)
|
|
|
{
|
|
|
ShowMessageBox("<22><><EFBFBD>費<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>20<32><30>");
|
|
|
return;
|
|
|
}
|
|
|
var cp = new HardUnitFlowStepEntity();
|
|
|
cp.StepIndex = HardUnits.Count + 1;
|
|
|
SetDefaultUnit(cp, HardUnits.Count);
|
|
|
HardUnits.Add(cp);
|
|
|
}
|
|
|
private void OnInsertStepCommand(Object sender)
|
|
|
{
|
|
|
if (HardUnits.Count == 20)
|
|
|
{
|
|
|
ShowMessageBox("<22><><EFBFBD>費<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>20<32><30>");
|
|
|
return;
|
|
|
}
|
|
|
if (SelectedStep == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD>в<EFBFBD><D0B2>룡");
|
|
|
return;
|
|
|
}
|
|
|
int curIndex = HardUnits.IndexOf(SelectedStep);
|
|
|
var cp = new HardUnitFlowStepEntity();
|
|
|
SetDefaultUnit(cp, curIndex);
|
|
|
HardUnits.Insert(curIndex, cp);
|
|
|
for (int i = 0; i < HardUnits.Count; i++)
|
|
|
{
|
|
|
HardUnits[i].StepIndex = i + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnDeleteStepCommand(Object sender)
|
|
|
{
|
|
|
if (SelectedStep == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
HardUnits.Remove(SelectedStep);
|
|
|
for (int i = 0; i < HardUnits.Count; i++)
|
|
|
{
|
|
|
HardUnits[i].StepIndex = i + 1;
|
|
|
}
|
|
|
}
|
|
|
private void OnSaveStepCommand(Object sender)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(FlowName))
|
|
|
{
|
|
|
ShowMessageBox("<22><>Ƭ<EFBFBD><C6AC><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
return;
|
|
|
}
|
|
|
/*<2A><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
List<int> stationTypes = new List<int>();
|
|
|
for (int i = 0; i < HardUnits.Count; i++)
|
|
|
{
|
|
|
string stationCode = string.Empty;
|
|
|
var unit = HardUnits[i];
|
|
|
var formual1 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit1Tag?.FormulaId);
|
|
|
if (formual1 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual1.StationType);
|
|
|
string formulaStationCode = formual1.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual2 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit2Tag?.FormulaId);
|
|
|
if (formual2 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual2.StationType);
|
|
|
string formulaStationCode = formual2.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual3 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit3Tag?.FormulaId);
|
|
|
if (formual3 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual3.StationType);
|
|
|
string formulaStationCode = formual3.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual4 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit4Tag?.FormulaId);
|
|
|
if (formual4 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual4.StationType);
|
|
|
string formulaStationCode = formual4.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual5 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit5Tag?.FormulaId);
|
|
|
if (formual5 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual5.StationType);
|
|
|
string formulaStationCode = formual5.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual6 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit6Tag?.FormulaId);
|
|
|
if (formual6 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual6.StationType);
|
|
|
string formulaStationCode = formual6.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual7 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit7Tag?.FormulaId);
|
|
|
if (formual7 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual7.StationType);
|
|
|
string formulaStationCode = formual7.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual8 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit8Tag?.FormulaId);
|
|
|
if (formual8 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual8.StationType);
|
|
|
string formulaStationCode = formual8.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
var formual9 = Global.Formulas.FirstOrDefault(q => q.RecId == unit.Unit9Tag?.FormulaId);
|
|
|
if (formual9 != null)
|
|
|
{
|
|
|
stationTypes.Add(formual9.StationType);
|
|
|
string formulaStationCode = formual9.StationCode;
|
|
|
if (string.IsNullOrWhiteSpace(stationCode) && !string.IsNullOrWhiteSpace(formulaStationCode))
|
|
|
{
|
|
|
stationCode = formual1.StationCode;
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(formulaStationCode) && !string.IsNullOrWhiteSpace(stationCode) && !StationCompare(stationCode, formulaStationCode))
|
|
|
{
|
|
|
ShowMessageBox(string.Format("<22><>{0}<7D><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ͬһ<CDAC><D2BB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>䷽", i + 1));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (stationTypes.Any(q => (StationTypeEnum)q == StationTypeEnum.COT) && stationTypes.Any(q => (StationTypeEnum)q == StationTypeEnum.DEV))
|
|
|
{
|
|
|
ShowMessageBox("<22><>ͬһ<CDAC><D2BB>Ƭ<EFBFBD>в<EFBFBD><D0B2><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>COT<4F><54>DEV<45><56><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}//*/
|
|
|
HardUnitFlowEntity hfe = new HardUnitFlowEntity();
|
|
|
hfe.FlowCode = FlowName;
|
|
|
hfe.FlowName = FlowName;
|
|
|
hfe.CreateBy = Global.CurrentUserCode;
|
|
|
hfe.RecId = SelectedFlow?.RecId;
|
|
|
hfe.RecId = HardUnitFlowDA.Save(hfe, HardUnits.ToList());
|
|
|
if (string.IsNullOrWhiteSpace(SelectedFlow?.RecId))
|
|
|
{
|
|
|
HardFlows.Add(hfe);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var flow = HardFlows.FirstOrDefault(q => q.RecId == hfe.RecId);
|
|
|
if (flow != null)
|
|
|
{
|
|
|
flow.FlowName = FlowName;
|
|
|
}
|
|
|
}
|
|
|
AllowEdit = false;
|
|
|
}
|
|
|
|
|
|
private bool StationCompare(string station1, string station2)
|
|
|
{
|
|
|
station1 = station1.Remove(station1.Length - 1, 1);
|
|
|
station2 = station2.Remove(station2.Length - 1, 1);
|
|
|
return string.Equals(station1, station2);
|
|
|
}
|
|
|
|
|
|
private void OnAllowCommand(Object sender)
|
|
|
{
|
|
|
AllowEdit = true;
|
|
|
}
|
|
|
|
|
|
private void OnDisabledCommand(Object sender)
|
|
|
{
|
|
|
AllowEdit = false;
|
|
|
StartLoadFlow();
|
|
|
}
|
|
|
|
|
|
private void OnSelectStepCommand(Object sender)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnCopyStepCommand(Object sender)
|
|
|
{
|
|
|
if (HardUnits.Count == 20)
|
|
|
{
|
|
|
ShowMessageBox("<22><><EFBFBD>費<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>20<32><30>");
|
|
|
return;
|
|
|
}
|
|
|
if (SelectedStep == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var Unit = (HardUnitFlowStepEntity)SelectedStep.Clone();
|
|
|
HardUnits.Add(Unit);
|
|
|
for (int i = 0; i < HardUnits.Count; i++)
|
|
|
{
|
|
|
HardUnits[i].StepIndex = i + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnUnitClickCommand(Object sender)
|
|
|
{
|
|
|
var hufse = ((UnitTag)sender);
|
|
|
if (hufse != null)
|
|
|
{
|
|
|
UnitViewFormulaViewModule uvfv = new UnitViewFormulaViewModule();
|
|
|
uvfv.ShowDialog();
|
|
|
if (uvfv.IsConfirm)
|
|
|
{
|
|
|
if (uvfv.SelectedFormula != null)
|
|
|
{
|
|
|
hufse.FormulaId = uvfv.SelectedFormula.RecId;
|
|
|
hufse.FormulaText = string.Format(Constant.DefaultWarningCode, uvfv.SelectedFormula.StationCode, uvfv.SelectedFormula.FormulaName);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
hufse.FormulaId = "";
|
|
|
hufse.FormulaText = "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnSelectFlowCommand(Object sender)
|
|
|
{
|
|
|
LoadFlowUnit();
|
|
|
}
|
|
|
private void OnNewCommand(Object sender)
|
|
|
{
|
|
|
SelectedFlow = null;
|
|
|
FlowName = string.Empty;
|
|
|
HardUnits.Clear();
|
|
|
//Ĭ<><C4AC><EFBFBD><D7B7>10<31><30><EFBFBD>հײ<D5B0><D7B2><EFBFBD>
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
{
|
|
|
HardUnitFlowStepEntity cp = new HardUnitFlowStepEntity();
|
|
|
cp.StepIndex = i + 1;
|
|
|
SetDefaultUnit(cp, i);
|
|
|
HardUnits.Add(cp);
|
|
|
}
|
|
|
AllowEdit = true;
|
|
|
}
|
|
|
private void SetDefaultUnit(HardUnitFlowStepEntity cp, int i)
|
|
|
{
|
|
|
cp.Unit1Tag = new UnitTag();
|
|
|
cp.Unit1Tag.Row = i;
|
|
|
cp.Unit1Tag.Column = 1;
|
|
|
cp.Unit2Tag = new UnitTag();
|
|
|
cp.Unit2Tag.Row = i;
|
|
|
cp.Unit2Tag.Column = 2;
|
|
|
cp.Unit3Tag = new UnitTag();
|
|
|
cp.Unit3Tag.Row = i;
|
|
|
cp.Unit3Tag.Column = 3;
|
|
|
cp.Unit4Tag = new UnitTag();
|
|
|
cp.Unit4Tag.Row = i;
|
|
|
cp.Unit4Tag.Column = 4;
|
|
|
cp.Unit5Tag = new UnitTag();
|
|
|
cp.Unit5Tag.Row = i;
|
|
|
cp.Unit5Tag.Column = 5;
|
|
|
cp.Unit6Tag = new UnitTag();
|
|
|
cp.Unit6Tag.Row = i;
|
|
|
cp.Unit6Tag.Column = 6;
|
|
|
cp.Unit7Tag = new UnitTag();
|
|
|
cp.Unit7Tag.Row = i;
|
|
|
cp.Unit7Tag.Column = 7;
|
|
|
cp.Unit8Tag = new UnitTag();
|
|
|
cp.Unit8Tag.Row = i;
|
|
|
cp.Unit8Tag.Column = 8;
|
|
|
cp.Unit9Tag = new UnitTag();
|
|
|
cp.Unit9Tag.Row = i;
|
|
|
cp.Unit9Tag.Column = 9;
|
|
|
}
|
|
|
|
|
|
private void OnSaveAsFormulaCommand(Object sender)
|
|
|
{
|
|
|
if (SelectedFlow == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
InputViewModule ivm = new InputViewModule();
|
|
|
ivm.InputTitle = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>";
|
|
|
ivm.InputText = SelectedFlow.FlowCode;
|
|
|
ivm.ShowDialog();
|
|
|
if (ivm.IsConfirm)
|
|
|
{
|
|
|
if (SelectedFlow.FlowCode == ivm.InputText)
|
|
|
{
|
|
|
ShowMessageBox("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
HardUnitFlowEntity hfe = new HardUnitFlowEntity();
|
|
|
hfe.FlowCode = ivm.InputText;
|
|
|
hfe.FlowName = ivm.InputText;
|
|
|
hfe.CreateBy = Global.CurrentUserCode;
|
|
|
string newId = HardUnitFlowDA.Copy(hfe, SelectedFlow.RecId);
|
|
|
HardUnitFlowEntity s = new HardUnitFlowEntity();
|
|
|
s.RecId = newId;
|
|
|
s.FlowCode = ivm.InputText;
|
|
|
s.FlowName = ivm.InputText;
|
|
|
s.CreateBy = Global.CurrentUserCode;
|
|
|
HardFlows.Add(s);
|
|
|
SelectedFlow = s;
|
|
|
}
|
|
|
}
|
|
|
private void OnDeleteFormulaCommand(Object sender)
|
|
|
{
|
|
|
if (SelectedFlow == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
IMessageBoxService confirm = new MessageBoxServiceViewModule();
|
|
|
confirm.ShowOkCancel(string.Format("ȷ<><C8B7>ɾ<EFBFBD><C9BE><EFBFBD>䷽<EFBFBD><E4B7BD>{0}<7D><>?", SelectedFlow.FlowCode), CustomDialogIcons.OK);
|
|
|
if (confirm.DialogState == DialogState.Ok)
|
|
|
{
|
|
|
HardUnitFlowDA.Delete(SelectedFlow.RecId);
|
|
|
HardFlows.Remove(SelectedFlow);
|
|
|
if (HardFlows?.Count > 0)
|
|
|
{
|
|
|
SelectedFlow = HardFlows[0];
|
|
|
OnSelectFlowCommand(SelectedFlow);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|