예제 #1
0
        /////////////////////////////////////////////////////////////////////////////////

        private void B_startParse_Click(object sender, EventArgs e)
        {
            if (writeReportThread?.IsAlive ?? false)
            {
                writeReportThread?.Abort();
                writeReportThread.Join();
                (writeReport.ecrCtrl as IDisposable).Dispose();
                writeReport.fileStream?.Close();
                writeReport.writer?.Close();
                progressBar1.Value = 0;

                B_startParse.Text = "Формировать отчет";
            }
            else
            {
                ecrCtrl = new Fw16.EcrCtrl();
                if (ConnectToFW(CB_Port.Text))
                {
                    try
                    {
                        writeReport = new WriteReport(ecrCtrl, TB_fileWay.Text, TB_fileName.ForeColor == SystemColors.ActiveCaption ? "" : TB_fileName.Text);

                        writeReportThread = new Thread((ThreadStart) delegate { writeReport.WriteReportStartParseFNS(); });
                        writeReportThread.Start();
                        B_startParse.Text = "Остановить";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length == 0)
            {
                reportFNS    = new ReportFNS();
                reportReader = new ReportReader();
                canRewrite   = true;
                var handle = GetConsoleWindow();
                ShowWindow(handle, SW_HIDE);
                form = new Form1();
                Application.Run(form);
            }
            else
            {
                EcrCtrl ecrCtrl = new Fw16.EcrCtrl();
                string  way     = "";
                string  Init    = "default";
                foreach (var item in args)
                {
                    switch (item[0])
                    {
                    case 'P':
                        Init = (item.Substring(1));
                        break;

                    case 'D':
                        way = item.Substring(1);
                        break;

                    case 'r':
                        if (item == "rw")
                        {
                            canRewrite = true;
                        }
                        break;

                    default:
                        Console.WriteLine("rw – перезаписать файл  отчёта при совпадении имени\n" +
                                          "P < Название_подключения > -Название подключения к ККТ\n" +
                                          "D”< Абсолютный_Путь_К_Директории >” – Путь к директории в которой будет создан файл отчёта.");
                        return;
                    }
                }
                try
                {
                    ecrCtrl.Init(Init);
                }
                catch { Console.WriteLine("не верно указано подключение"); }
                WriteReport writeReport = new WriteReport(ecrCtrl, way);
                writeReport.WriteReportStartParseFNS();
            }
        }