private void ClosedServer() { switch (SystemArgs.SettingsUser.TypeScan) { case 0: Status_TB.AppendText($"Отключение сканера" + Environment.NewLine); if (SystemArgs.ScannerBlankOrder.Stop()) { SystemArgs.ScannerBlankOrder.LoadResult -= LoadToDGV; SystemArgs.ScannerBlankOrder.Status -= LoadStatusOperation; } break; case 1: Status_TB.AppendText($"Выключение камеры" + Environment.NewLine); if (SystemArgs.WebcamScanBlankOrder.Stop()) { SystemArgs.WebcamScanBlankOrder.LoadResult -= LoadToDGV; SystemArgs.WebcamScanBlankOrder.LoadFrame -= LoadFrame; SystemArgs.WebcamScanBlankOrder.Status -= LoadStatusOperation; } break; case 2: Status_TB.AppendText($"Закрытие сервера" + Environment.NewLine); if (SystemArgs.ServerMobileAppBlankOrder.Stop()) { SystemArgs.ServerMobileAppBlankOrder.Load -= LoadToDGV; SystemArgs.ServerMobileAppBlankOrder.Status -= LoadStatusOperation; } break; } }
private void LoadToDGVAndTB(List <DecodeScanSession> DecodeSession) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"Получены данные" + Environment.NewLine + DecodeSession[DecodeSession.Count - 1].DataMatrix + Environment.NewLine); }); Scan_DGV.Invoke((MethodInvoker) delegate() { Scan_DGV.Rows.Add(); Scan_DGV[0, Scan_DGV.Rows.Count - 1].Value = DecodeSession[DecodeSession.Count - 1].DataMatrix; if (DecodeSession[DecodeSession.Count - 1].Unique == 1) { Scan_DGV[1, Scan_DGV.Rows.Count - 1].Value = "Найден"; Scan_DGV[1, Scan_DGV.Rows.Count - 1].Style.BackColor = Color.Lime; } else if (DecodeSession[DecodeSession.Count - 1].Unique == 0) { Scan_DGV[1, Scan_DGV.Rows.Count - 1].Value = "Уже подтвержден"; Scan_DGV[1, Scan_DGV.Rows.Count - 1].Style.BackColor = Color.Orange; } else { Scan_DGV[1, Scan_DGV.Rows.Count - 1].Value = "Не найден"; Scan_DGV[1, Scan_DGV.Rows.Count - 1].Style.BackColor = Color.Red; } }); }
private void LoadStatusOperation(String DataMatrix) { SpeechSynthesizer speechSynthesizerObj = new SpeechSynthesizer(); speechSynthesizerObj.SpeakAsync($"{DataMatrix.Split('_')[1]}"); Status_TB.AppendText(DataMatrix + Environment.NewLine); }
private void AppendToTB(String Text) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText(Text + Environment.NewLine); SystemArgs.PrintLog(Text); }); }
private void StatusFailText(String Path) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"Файл {SystemArgs.Path.GetFileName(Path)} неправильный формат DataMatrix" + Environment.NewLine); FailFileNames.Add(SystemArgs.Path.GetFileName(Path)); FileNames.Remove(Path); FailCount++; }); }
private void LoadStatusOperation(String DataMatrix) { Status_TB.Invoke((MethodInvoker) delegate() { if (DataMatrix.Split('_').Length >= 4) { SpeechSynthesizer speechSynthesizerObj = new SpeechSynthesizer(); speechSynthesizerObj.SpeakAsync($"{DataMatrix.Split('_')[1]}"); } Status_TB.AppendText("Получен: " + DataMatrix + Environment.NewLine); }); }
private void LoadToDGVAndTB(String result, String Path) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"Получены данные" + Environment.NewLine + result + Environment.NewLine); }); Scan_DGV.Invoke((MethodInvoker) delegate() { Scan_DGV.Rows.Add(); Scan_DGV[0, Scan_DGV.Rows.Count - 1].Value = result; Scan_DGV[1, Scan_DGV.Rows.Count - 1].Value = SystemArgs.Path.GetFileName(Path); }); }
private void DecodeFiles(OpenFileDialog Opd) { try { Directory.CreateDirectory("TempFile"); Int32 CountFile = Opd.FileNames.Length; Int32 i = 0; foreach (String FileName in Opd.FileNames) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"Файл" + Environment.NewLine + SystemArgs.Path.GetFileName(FileName) + Environment.NewLine + "обрабатывается, пожалуйста подождите..." + Environment.NewLine); Status_TB.AppendText($">{i + 1}|{CountFile}<" + Environment.NewLine); }); FileNames.Add(FileName); DecodeNames.Add(SystemArgs.ByteScout.SendAndRead(SystemArgs.ByteScout.GetPathTempFile(FileName, i), FileName)); if (DecodeNames[DecodeNames.Count - 1].Split('_').Length != 6) { DecodeNames.Remove(DecodeNames[DecodeNames.Count - 1]); } i++; } DeleteFilesAndDirectory(); Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"ОБРАБОТКА ЗАВЕРШЕНА!" + Environment.NewLine); Status_TB.AppendText($">{i}|{CountFile}<" + Environment.NewLine); }); Change_B.Invoke((MethodInvoker) delegate() { EnableButton(true); }); if (FailCount > 0) { AR_NotDecode_F Dialog = new AR_NotDecode_F(); Dialog.DecodeFiles_TB.Text = (Opd.FileNames.Length - FailCount).ToString() + "/" + Opd.FileNames.Length.ToString(); foreach (String item in FailFileNames) { Dialog.Report_DGV.Rows.Add(); Dialog.Report_DGV[0, Dialog.Report_DGV.Rows.Count - 1].Value = item; } Dialog.ShowDialog(); } if (DecodeNames.Count == 0) { Save_B.Invoke((MethodInvoker) delegate() { Save_B.Enabled = false; }); } } catch (InvalidOperationException) { return; } catch (Exception e) { SystemArgs.PrintLog(e.ToString()); MessageBox.Show(e.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); Save_B.Invoke((MethodInvoker) delegate() { Save_B.Enabled = true; }); return; } }
private void DecodeFiles(OpenFileDialog Opd) { try { Directory.CreateDirectory("TempFile"); Int32 CountFile = Opd.FileNames.Length; Int32 i = 0; foreach (String FileName in Opd.FileNames) { Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"Файл" + Environment.NewLine + SystemArgs.Path.GetFileName(FileName) + Environment.NewLine + "обрабатывается, пожалуйста подождите..." + Environment.NewLine); Status_TB.AppendText($">{i + 1}|{CountFile}<" + Environment.NewLine); }); FileNames.Add(FileName); SystemArgs.ByteScout.SendAndRead(SystemArgs.ByteScout.GetPathTempFile(FileName, i), FileName); i++; } DeleteFilesAndDirectory(); Status_TB.Invoke((MethodInvoker) delegate() { Status_TB.AppendText($"ОБРАБОТКА ЗАВЕРШЕНА!" + Environment.NewLine); Status_TB.AppendText($">{i}|{CountFile}<" + Environment.NewLine); }); Change_B.Invoke((MethodInvoker) delegate() { EnableButton(true); }); if (FailCount > 0) { AR_NotDecode_F Dialog = new AR_NotDecode_F(); Dialog.DecodeFiles_TB.Text = (Opd.FileNames.Length - FailCount).ToString() + "/" + Opd.FileNames.Length.ToString(); foreach (String item in FailFileNames) { Dialog.Report_DGV.Rows.Add(); Dialog.Report_DGV[0, Dialog.Report_DGV.Rows.Count - 1].Value = item; } Dialog.ShowDialog(); } if (SystemArgs.ByteScout.GetDecodeSession().Where(p => p.Unique == 1).Count() == 0) { Add_B.Invoke((MethodInvoker) delegate() { Add_B.Enabled = false; }); } } catch (InvalidOperationException) { return; } catch { Add_B.Invoke((MethodInvoker) delegate() { Add_B.Enabled = true; }); return; } }