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;
            }
        }
Exemple #2
0
        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;
            }
        }