コード例 #1
0
ファイル: Login.cs プロジェクト: yanqitai/GSPN-CLIENT
        public static async Task StartLoginFile()
        {
            Console.Clear();

            await ProcessHelper.CloseProcessByTitle("notepad", "Login ");

            ProcessHelper.StartProcess("notepad.exe", "database/login.json",
                                       Screen.PrimaryScreen.Bounds.Width / 30 * 14,
                                       Screen.PrimaryScreen.Bounds.Height / 8);

            Console.WriteLine();
        }
コード例 #2
0
        public static async Task StartDataSerialFile()
        {
            Console.Clear();

            if (!new FileInfo("database/data.txt").Exists)
            {
                FileHelper.SaveFile("dataSerial.txt", "");
            }

            await ProcessHelper.CloseProcessByTitle("notepad", "dataSerial ");

            ProcessHelper.StartProcess("notepad.exe", "database/dataSerial.txt",
                                       Screen.PrimaryScreen.Bounds.Width / 30 * 14,
                                       Screen.PrimaryScreen.Bounds.Height / 8);

            Console.WriteLine();
        }
コード例 #3
0
ファイル: AparelhoClass.cs プロジェクト: yanqitai/GSPN-CLIENT
        //the openData = false not open txt file
        public static async Task <List <Aparelho> > SearchAparelhoSerial(bool openData = true, bool saveData = true)
        {
            String[] sp = SerialPort.GetPortNames();

            Func <Task <bool> > taskSearchDevice = async() =>
            {
                sp = SerialPort.GetPortNames();
                var spinner = new Spinner();

                WriteConsole.WriteInLine("Pesquisando ", 1, 1);
                spinner.Start();

                int count = 0;
                while (sp.Count() == 0)
                {
                    sp = SerialPort.GetPortNames();
                    count++;
                    await Task.Delay(1000);

                    if (count >= 5)
                    {
                        spinner.Stop();
                        Console.Clear();
                        return(false);
                    }
                }

                spinner.Stop();

                return(true);
            };

            if (!await taskSearchDevice())
            {
                return(null);
            }

            var aps = await CallDeviceInfo(sp);

            if (aps == null)
            {
                return(null);
            }

            aps.ForEach(ap =>
            {
                Console.WriteLine("\n" + ap.ToString() + "\n");

                if (!saveData)
                {
                    return;
                }

                FileHelper.SaveFile("dataSerial.txt",
                                    Environment.NewLine + "\n-----------------------------"
                                    + Environment.NewLine + ap.Modelo
                                    + Environment.NewLine + ap.RN
                                    + Environment.NewLine + ap.Imei, false);
            });

            if (!openData || !saveData)
            {
                return(aps);
            }

            await ProcessHelper.CloseProcessByTitle("notepad", "dataSerial ");

            ProcessHelper.StartProcess("notepad.exe", "database/dataSerial.txt",
                                       Screen.PrimaryScreen.Bounds.Width / 20,
                                       Screen.PrimaryScreen.Bounds.Height / 8);

            return(aps);
        }