Example #1
0
        /**
         * This method binding the service
         */
        private Boolean bindProxyService()
        {
            Debug.Print("Binding proxy service...");
            try
            {
                WS2007HttpBinding a = new WS2007HttpBinding();
                ProtocolVersion11 b = new ProtocolVersion11();
                proxy = new IService1ClientProxy(a, b);

                // NOTE: the endpoint needs to match the endpoint of the servicehost
                proxy.EndpointAddress = SERVICE_ADDR;
            }
            catch (SocketException e)
            {
                WindowsManager.showWindowServiceDown();
                return(false);
            }
            catch (ObjectDisposedException e)
            {
                Debug.Print("Disposed object exception");
                WindowsManager.showWindowServiceDown();
                return(false);
            }


            Debug.Print("Binding proxy service COMPLETE");
            return(true);
        }
Example #2
0
        private void initServer()
        {
            if (bindProxyService())
            {
                getAddressAndPort();

                IPAddress ipAddress = IPAddress.Parse(connectionInfo[0]);
                int       port      = int.Parse(connectionInfo[1]);
                if (port == -1)
                {
                    Debug.Print("Error: Invalid Port, impossible to establish a connection!\n");
                    WindowsManager.showWindowErrorServer();
                    serverUnreacheable = true;
                    return;
                }
                if (port == 404)
                {
                    Debug.Print("Error: Server Unreacheable!\n");
                    serverUnreacheable = true;
                    WindowsManager.showWindowServerDown();
                    return;
                }
                serverEndPoint = new IPEndPoint(ipAddress, port);
                servertime    += 35000;
                try
                {
                    var data = proxy.keepAlive(new keepAlive()
                    {
                        myMacAddress  = myMac,
                        mycurrentTime = servertime,
                        port          = int.Parse(connectionInfo[1]),
                    });
                }
                catch (Exception e)
                {
                    WindowsManager.showWindowServiceDown();
                    serverUnreacheable = true;
                    return;
                }

                timer_keepAlive       = new GT.Timer(35000);
                timer_keepAlive.Tick += keepAlive;
                timer_keepAlive.Start();

                bitmapA            = null;
                serverUnreacheable = false;
                setupComplete      = true;
                Thread.Sleep(300);
                contImage = 0;
                camera.TakePicture();
            }
        }
Example #3
0
        /**
         * This method get the port of the server socket to connect from the service
         */
        private void getAddressAndPort()
        {
            try
            {
                var data = proxy.getServerAddressWithPort(new getServerAddressWithPort()
                {
                    myMacAddress = myMac,
                });

                connectionInfo[0] = data.getServerAddressWithPortResult.address;
                connectionInfo[1] = data.getServerAddressWithPortResult.port;
                Debug.Print("Server address: " + data.getServerAddressWithPortResult.address);
                Debug.Print("Server port: " + data.getServerAddressWithPortResult.port);
                servertime = data.getServerAddressWithPortResult.serverTime;
                Debug.Print("Server time: " + servertime);
            }
            catch (Exception e)
            {
                WindowsManager.showWindowServiceDown();
            }
        }
Example #4
0
        public int checkLogin(String pin)
        {
            // HashAlgorithm hashSHA256 = new HashAlgorithm(HashAlgorithmType.MD5);
            Byte[] dataToHmac = System.Text.Encoding.UTF8.GetBytes(pin);

            if ((setupComplete && !NetworkUp && VolatilePin.Length == 8) || (setupComplete && NetworkUp && VolatilePin.Length == 8))
            {
                if (VolatilePin.Equals(pin))
                {
                    deactivateSystem();
                    return(2);
                }
            }

            if (setupComplete && NetworkUp)
            {
                try
                {
                    var data = proxy.isValid(new isValid()
                    {
                        mac = myMac,
                        pin = dataToHmac
                    });

                    if (data.isValidResult)
                    {
                        deactivateSystem();
                        return(2);
                    }
                    return(-1);
                }
                catch (Exception e)
                {
                    WindowsManager.showWindowServiceDown();
                    return(1);
                }
            }

            if (!NetworkUp)
            {
                WindowsManager.showWindowNetworkDown();
                return(2);
            }


            bindProxyService();

            try
            {
                var data2 = proxy.isValid(new isValid()
                {
                    mac = myMac,
                    pin = dataToHmac
                });
                if (data2.isValidResult)
                {
                    VolatilePin = pin;
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception e)
            {
                WindowsManager.showWindowServiceDown();
                return(1);
            }
        }