예제 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new ThreadExceptionEventHandler(MyCommonExceptionHandlingMethod);
            try
            {
                DialogResult result;
                using (var loginForm = new LoginForm())
                {
                    result = loginForm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        var server     = "localhost";
                        var port       = 50000;
                        var ipHostInfo = Dns.GetHostEntry(server);
                        var ipAddress  =
                            ipHostInfo.AddressList.FirstOrDefault(t => t.AddressFamily == AddressFamily.InterNetwork);
                        if (ipAddress == null)
                        {
                            throw new Exception("No IPv4 address for server");
                        }

                        var data = new Request()
                        {
                            Function  = Functions.Authorization,
                            Attribute = new List <Attribute>()
                            {
                                new Attribute()
                                {
                                    Name  = "login",
                                    Value = loginForm.textBox1.Text
                                },
                                new Attribute()
                                {
                                    Name  = "password",
                                    Value = loginForm.textBox2.Text
                                }
                            }
                        };

                        var testClient = new TestClient(new TcpClient());
                        testClient.Connect(server, port);
                        var response = testClient.SendRequest(data);
                        if (response.Result.Code == 0)
                        {
                            Application.Run(new MainForm(testClient));
                        }
                        else
                        {
                            throw new Exception("Пользователь не существует");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            TestClient Barcode = new TestClient();

            Console.Title = "BarcodeClient ";
            Barcode.Connect();

            Console.ReadLine();
        }
예제 #3
0
        protected virtual TestClient InitClient()
        {
            IPhontonClient photonClient = this.CreateClient();
            TestClient client = new TestClient(photonClient);

            client.Connect("localhost", 4530);
            client.SendInit(0);

            if (client.WaitForInitResponse(this.WaitTime) == false)
            {
                Assert.Fail("Didn't received init response in expected time.");
            }

            return client;
        }