/// <summary>
        /// Helper function which shows a message dialog box for the given message.
        /// </summary>
        /// <param name="message">The error message to display</param>
        private void ShowInvalidPINMessage(string message)
        {
            var result = MessageBox.Show(message);

            if (result == MessageBoxResult.OK)
            {
                TxtPin.Password = "";
                TxtPin.Focus();
            }
        }
Beispiel #2
0
 private void LimpiarDatos()
 {
     TxtPath.Clear();
     TxtPin.Clear();
     TxtInfoLlaveCriptografica.Clear();
     LblDragAndDrop.Visible     = true;
     LblTiempoTranscurrido.Text = "";
     TxtValorInicial.Clear();
     TxtValorFinal.Clear();
 }
Beispiel #3
0
        private void ObtenerInfo()
        {
            if (certificadoP12 == null)
            {
                MessageBox.Show("Debe de seleccionar una llave criptográfica", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                TxtPin.Focus();
            }

            string certTemp = certificadoP12;

            if (!certTemp.EndsWith(".p12"))
            {
                MessageBox.Show("El archivo seleccionado no es una llave criptográfica", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!string.IsNullOrEmpty(TxtPin.Text))
            {
                try
                {
                    pinCertificado = TxtPin.Text;
                    cert           = new X509Certificate2(rutayArchivo, pinCertificado);
                    MostrarDatosCertificado();
                }
                catch (Exception)
                {
                    MessageBox.Show("El PIN ingresado es incorrecto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar un PIN numérico de 4 digitos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void OnErrorOccurred(object sender, EventArgs e)
        {
            if (_manageDriverViewModel.IsErrorInFirstName)
            {
                LblErrorMsg.Text = "First Name must be not null and contains alphabet only.";
                TxtFirstName.Focus();
                return;
            }

            if (_manageDriverViewModel.IsErrorInLastName)
            {
                LblErrorMsg.Text = "Last Name must be not null and contains alphabet only.";
                TxtLastName.Focus();
                return;
            }

            if (_manageDriverViewModel.IsErrorInUsername && _manageDriverViewModel.IsAddingDriver)
            {
                LblErrorMsg.Text = string.IsNullOrEmpty(_manageDriverViewModel.ErrorMessage) ? "Username must be not null and contains alphanumberic only." : _manageDriverViewModel.ErrorMessage;;
                TxtUsername.Focus();
                return;
            }

            if (_manageDriverViewModel.IsErrorInPin)
            {
                LblErrorMsg.Text = "Pin number must be four digit only, no any aphabet allowed.";
                TxtPin.Focus();
                return;
            }

            if (_manageDriverViewModel.IsErrorInGroup)
            {
                LblErrorMsg.Text = "Please select any Group.";
                CBGroup.Focus();
                return;
            }
        }
Beispiel #5
0
        //private void BtnAveriguarPIN_Click(object sender, EventArgs e)
        private async void BtnAveriguarPIN_Click(object sender, EventArgs e)
        {
            TxtInfoLlaveCriptografica.Clear();
            TxtPin.Clear();
            BtnObtenerInfo.Enabled = false;

            PicProcesando.Visible = true;
            DateTime tiempoInicio = DateTime.Now;

            if (!string.IsNullOrEmpty(TxtValorInicial.Text))
            {
                valorInicial = Int32.Parse(TxtValorInicial.Text);
            }
            else
            {
                valorInicial = 1;
            }

            if (!string.IsNullOrEmpty(TxtValorFinal.Text))
            {
                valorFinal = Int32.Parse(TxtValorFinal.Text);
            }
            else
            {
                valorFinal = 9999;
            }


            //var task1 = Task1ObtenerPIN();
            //var task2 = Task2ObtenerPIN();
            //await Task.WhenAll(task1, task2);

            // var resultado = await TaskAObtenerPIN();
            var resultado = await Task.WhenAll(TaskAObtenerPIN());

            // var resultado = await Task.WhenAll(Task3ObtenerPIN(), Task4ObtenerPIN());

            //var resultado = await Task.WhenAll(Task1ObtenerPIN(), Task2ObtenerPIN(), Task3ObtenerPIN(), Task4ObtenerPIN(), Task5ObtenerPIN());



            // ObtenerPIN();                    // Esta llamada se usa con el metodo sincronico ObtenerPin
            // pinBuscado = await ObtenerPIN();    // Esta llamada se usa con el metodo asincronico ObtenerPin

            DateTime tiempoFin             = DateTime.Now;
            TimeSpan span                  = tiempoFin - tiempoInicio;
            double   segundosTranscurridos = (double)span.TotalMilliseconds / 1000;

            LblTiempoTranscurrido.Text = segundosTranscurridos.ToString();
            TxtPin.Text = pinBuscado;

            if (pinBuscado != string.Empty)
            {
                MostrarDatosCertificado();
                PicProcesando.Visible  = false;
                BtnObtenerInfo.Enabled = true;
            }
            else
            {
                PicProcesando.Visible = false;
            }
        }