|
|
@ -52,7 +52,7 @@ namespace WeighAndGrading |
|
|
SerialPort weightPort; |
|
|
SerialPort weightPort; |
|
|
int maxIndex = 0; |
|
|
int maxIndex = 0; |
|
|
ConcurrentQueue<GradeAndWeight_Detail> noLivestockList; |
|
|
ConcurrentQueue<GradeAndWeight_Detail> noLivestockList; |
|
|
BackgroundWorker tangWork, maoWork, detailWork; |
|
|
|
|
|
|
|
|
|
|
|
Thread syncWork; |
|
|
Thread syncWork; |
|
|
Thread syncToServer; |
|
|
Thread syncToServer; |
|
|
#region weightNeed
|
|
|
#region weightNeed
|
|
|
@ -71,7 +71,6 @@ namespace WeighAndGrading |
|
|
maoGridView.AutoGenerateColumns = false; |
|
|
maoGridView.AutoGenerateColumns = false; |
|
|
maoGridView.DataSource = null; |
|
|
maoGridView.DataSource = null; |
|
|
historyGrid.AutoGenerateColumns = false; |
|
|
historyGrid.AutoGenerateColumns = false; |
|
|
InitBackGroundWorker(); |
|
|
|
|
|
if (!Directory.Exists(DATA_PATH)) |
|
|
if (!Directory.Exists(DATA_PATH)) |
|
|
Directory.CreateDirectory(DATA_PATH); |
|
|
Directory.CreateDirectory(DATA_PATH); |
|
|
connection = ButcherAppContext.Context.UserConfig.Connection; |
|
|
connection = ButcherAppContext.Context.UserConfig.Connection; |
|
|
@ -86,31 +85,9 @@ namespace WeighAndGrading |
|
|
syncWork.Abort(); |
|
|
syncWork.Abort(); |
|
|
if (syncToServer != null && syncToServer.IsAlive) |
|
|
if (syncToServer != null && syncToServer.IsAlive) |
|
|
syncToServer.Abort(); |
|
|
syncToServer.Abort(); |
|
|
|
|
|
|
|
|
if (tangWork != null && tangWork.IsBusy) |
|
|
|
|
|
tangWork.CancelAsync(); |
|
|
|
|
|
if (maoWork != null && maoWork.IsBusy) |
|
|
|
|
|
maoWork.CancelAsync(); |
|
|
|
|
|
if (detailWork != null && detailWork.IsBusy) |
|
|
|
|
|
detailWork.CancelAsync(); |
|
|
|
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void InitBackGroundWorker() |
|
|
|
|
|
{ |
|
|
|
|
|
tangWork = new BackgroundWorker() { WorkerSupportsCancellation = true }; |
|
|
|
|
|
tangWork.DoWork += delegate { BindTangGridFortangList(); }; |
|
|
|
|
|
tangWork.RunWorkerCompleted += delegate { BindTangGrid(); }; |
|
|
|
|
|
|
|
|
|
|
|
maoWork = new BackgroundWorker(); |
|
|
|
|
|
maoWork.DoWork += delegate { BindMaoGridFortangList(); }; |
|
|
|
|
|
maoWork.RunWorkerCompleted += BindMaoGrid(); |
|
|
|
|
|
|
|
|
|
|
|
detailWork = new BackgroundWorker(); |
|
|
|
|
|
//detailWork.DoWork += GetDetailData();
|
|
|
|
|
|
//detailWork.RunWorkerCompleted += BindDetailGrid();
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GradeAndWeight_Detail modifyDetail; |
|
|
GradeAndWeight_Detail modifyDetail; |
|
|
void JiBieButtonClick(Button btn) |
|
|
void JiBieButtonClick(Button btn) |
|
|
{ |
|
|
{ |
|
|
@ -254,12 +231,6 @@ namespace WeighAndGrading |
|
|
BindDetailGrid(); |
|
|
BindDetailGrid(); |
|
|
if (details.Any()) |
|
|
if (details.Any()) |
|
|
maxIndex = details.First().Index; |
|
|
maxIndex = details.First().Index; |
|
|
|
|
|
|
|
|
if (tangWork.CancellationPending) |
|
|
|
|
|
tangWork.RunWorkerAsync(); |
|
|
|
|
|
else |
|
|
|
|
|
tangWork.CancelAsync(); |
|
|
|
|
|
|
|
|
|
|
|
if (syncWork == null || !syncWork.IsAlive) |
|
|
if (syncWork == null || !syncWork.IsAlive) |
|
|
{ |
|
|
{ |
|
|
syncWork = new Thread(Sync); |
|
|
syncWork = new Thread(Sync); |
|
|
@ -389,7 +360,6 @@ namespace WeighAndGrading |
|
|
{ |
|
|
{ |
|
|
maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false); |
|
|
maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (TimeoutException) { } |
|
|
catch (TimeoutException) { } |
|
|
} |
|
|
} |
|
|
@ -400,9 +370,9 @@ namespace WeighAndGrading |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BindMaoGrid() |
|
|
void BindMaoGrid() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); |
|
|
maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); |
|
|
if (maoEntity == null && maoGridView.CurrentRow != null) |
|
|
if (maoEntity == null && maoGridView.CurrentRow != null) |
|
|
{ |
|
|
{ |
|
|
|