Example #1
0
    private bool CheckInDb(IRegisterServiceJugador jugador)
    {
        bool result = false;
        RegisterServiceClient register;

        register = new RegisterServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/RegisterServices"));
        IRegisterServiceJugador player = jugador;

        switch (register.SerachUserInDB(player))
        {
        case DBOperationResultAddResult.Success:
            result = true;
            break;

        case DBOperationResultAddResult.ExistingRecord:
            Debug.Log("entra aquí");
            throw new DuplicateRecordException();

        case DBOperationResultAddResult.SQLError:
            Debug.Log("sql error");
            throw new TimeoutException();

        case DBOperationResultAddResult.NullObject:
            throw new SocketException();
        }

        return(result);
    }
Example #2
0
    private void SendEmail(IRegisterServiceJugador jugador)
    {
        ConfirmationServicesClient confirmation;

        confirmation = new ConfirmationServicesClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/ConfirmationServices"));
        IConfirmationServicesJugador player = new IConfirmationServicesJugador();

        player.Correo = jugador.Correo;
        player.Código = jugador.Código;
        confirmation.SendEmail(player);
    }
Example #3
0
    public Task RegisterPlayer()
    {
        System.Random         generator     = new System.Random();
        UtilitiesHash         utilitiesHash = new UtilitiesHash();
        RegisterServiceClient register;

        register = new RegisterServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/RegisterServices"));
        IRegisterServiceJugador player = new IRegisterServiceJugador();

        player.Correo   = Email_InputField.text;
        player.Nombre   = Name_InputField.text;
        player.Username = User_InputField.text;
        player.Password = utilitiesHash.PassHash(Password_InputField.text);
        player.Código   = generator.Next(0, 999999).ToString("D6");

        try
        {
            if (CheckInDb(player))
            {
                switch (register.AddUser(player))
                {
                case DBOperationResultAddResult.Success:
                    SendEmail(player);
                    break;

                case DBOperationResultAddResult.SQLError:
                    throw new TimeoutException();

                case DBOperationResultAddResult.NullObject:
                    throw new SocketException();
                }
            }
        }
        catch (SocketException)
        {
            throw new SocketException();
        }
        catch (TimeoutException)
        {
            throw new TimeoutException();
        }
        catch (DuplicateRecordException)
        {
            throw new DuplicateRecordException();
        }
        CurrentPlayer.Username = player.Username;
        CurrentPlayer.Email    = player.Correo;
        CurrentPlayer.Código   = player.Código;
        return(Task.CompletedTask);
    }