Exemple #1
0
        private void Btn_Generate_Image_Click(object sender, EventArgs e)
        {
            try
            {
                _capDevice.CaptureMode = CaptureMode.LIVE_IMAGE;

                if (_capDevice != null && _capDevice.IsCapturing && _capDevice.CaptureMode == CaptureMode.LIVE_IMAGE)
                {
                    _capDevice.Freeze(true);
                    imageHolder.Image = _capDevice.GetImage();


                    if (imageHolder.Image != null)
                    {
                        Bitmap bitmap = (Bitmap)imageHolder.Image;

                        try
                        {
                            RawImage rawImage = RawImageHelperForms.FromBitmap(bitmap);
                            encoder.Format         = Dermalog.Afis.FingerCode3.Enums.TemplateFormat.ISO19794_2_2005;
                            encoder.ImpressionType = 0;
                            rightTemplate          = encoder.Encode(bitmap);

                            txtFingerPrintFormat.Text = rightTemplate.Format.ToString();


                            string covertedDataTemplate = BitConverter.ToString(rightTemplate.Data);

                            txtImageData.Text = covertedDataTemplate;
                            //txtImageData.Text = Encoding.UTF8.GetString(rightTemplate.Data);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (DeviceErrorException ex)
            {
                System.Diagnostics.Trace.WriteLine("An exception occurred while trying to generate image from scanner. Message - " + ex.Message + "|Stacktrace - " + ex.StackTrace);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("An exception occurred while trying to generate image from scanner. Message - " + ex.Message + "|Stacktrace - " + ex.StackTrace);
            }
        }
        private void Button2_Click(object sender, EventArgs e)
        {
            FileStream fs = File.OpenRead("D:\\_ad_PVT\\_ah_wsqtodat\\13922_left_little.wsq");

            //
            byte[] bytes = new byte[fs.Length];
            fs.Read(bytes, 0, (int)fs.Length);

            var mensaje = "NADA";

            try
            {
                // 2. Create decode the WSQ file and create a RawImage
                using (Dermalog.Afis.ImageContainer.Decoder decoder = new Dermalog.Afis.ImageContainer.Decoder())
                {
                    Dermalog.Afis.ImageContainer.RawImage rawImage = decoder.Decode(bytes);

                    // 3. Create a FingerCode3 encoder and create a template
                    using (Dermalog.Afis.FingerCode3.Encoder encoder = new Dermalog.Afis.FingerCode3.Encoder())
                    {
                        Dermalog.Afis.FingerCode3.Template template = encoder.Encode(rawImage);
                        // The function template.GetData() returns the raw byte data, which can be saved as a *.dat file.
                        //String templateString = String.Format("template{0}.dat",
                        //localUser.Fingerprints[i].Position.ToString("D2"));
                        //String templatePath = Path.Combine(idPath, templateString);
                        FileStream fs2  = File.Create("D:\\_ad_PVT\\_ah_wsqtodat\\template00.dat");
                        byte[]     data = template.GetData();
                        fs2.Write(data, 0, data.Length);
                        fs2.Flush();
                        fs2.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                // Qué ha sucedido
                mensaje = "Error message: " + ex.Message;

                // Información sobre la excepción interna
                if (ex.InnerException != null)
                {
                    mensaje = mensaje + " Inner exception: " + ex.InnerException.Message;
                }

                // Dónde ha sucedido
                mensaje = mensaje + " Stack trace: " + ex.StackTrace;
            }



            MessageBox.Show(mensaje);



/*
 *                                              try
 *                                              {
 *
 *
 *                                              }
 *                                              catch (Exception ex)
 *                                              {
 *                                                              // Qué ha sucedido
 *                                                              var mensaje = "Error message: " + ex.Message;
 *
 *                                                              // Información sobre la excepción interna
 *                                                              if (ex.InnerException != null)
 *                                                              {
 *                                                                              mensaje = mensaje + " Inner exception: " + ex.InnerException.Message;
 *                                                              }
 *
 *                                                              // Dónde ha sucedido
 *                                                              mensaje = mensaje + " Stack trace: " + ex.StackTrace;
 *
 *
 *                                              }
 */
        }
        private void Button1_Click_1(object sender, EventArgs e)
        {
            //DATASYSTEM
            string path_fingerprint = "\\\\192.168.2.120\\pvt\\fingerprint";
            string path_target      = "\\\\192.168.2.120\\pvt\\fingerprint_dat";


            Dictionary <string, string> errorArray = new Dictionary <string, string>();

            //Dictionary<string, string> afiliado_id = new Dictionary<string, string>();

            //string path_picture = "\\\\192.168.2.120\\pvt\\picture";
            //REMOTE
            string path_remote_user     = "******";
            string path_remote_password = "******";

            //verificar la red
            bool newtworkConnectionExist = false;

            try
            {
                using (new NetworkConnection(path_fingerprint, new NetworkCredential(path_remote_user, path_remote_password)))
                {
                    //_directoryPath = "\\\\192.168.2.120\\utic\\PVT\\fingerprint\\3.txt";
                    //File.Copy("D:\\2.txt", _directoryPath);
                    //   MessageBox.Show("hola");
                }
                newtworkConnectionExist = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
            if (!newtworkConnectionExist)
            {
                MessageBox.Show("No se pudo conectar a la direccion 192.168.2.120 verifique la conexion de red");
                return;
            }



            //DATASYSTEM
            string file_name = "";

            string[] file_split;

            //DirectoryInfo d = new DirectoryInfo(@"fingerprint");//Assuming Test is your Folder
            DirectoryInfo d = new DirectoryInfo(path_fingerprint);                                    //Assuming Test is your Folder


            FileInfo[] Files = d.GetFiles("*.wsq");                                     //Getting Text files

            //MessageBox.Show("hola como esta");

            foreach (FileInfo file in Files)
            {
                //datasystem
                file_name = file.Name;
                file_name = file_name.Replace(".wsq", "");
                //file_split = file_name.Split("_".ToCharArray());
                //MessageBox.Show(file_name.ToString());

                /*
                 * //Data
                 * f_id = file_split[0];
                 * f_hand = file_split[1];
                 * f_finger = file_split[2];
                 *
                 * afiliado_id[f_id] = f_id;
                 * afiliado_hand[f_id] = f_hand;
                 */



                //MessageBox.Show(file.FullName);

                FileStream fs = File.OpenRead(file.FullName);
                //
                byte[] bytes = new byte[fs.Length];
                fs.Read(bytes, 0, (int)fs.Length);


                bool existError = true;

                try
                {
                    // 2. Create decode the WSQ file and create a RawImage
                    using (Dermalog.Afis.ImageContainer.Decoder decoder = new Dermalog.Afis.ImageContainer.Decoder())
                    {
                        Dermalog.Afis.ImageContainer.RawImage rawImage = decoder.Decode(bytes);

                        // 3. Create a FingerCode3 encoder and create a template
                        using (Dermalog.Afis.FingerCode3.Encoder encoder = new Dermalog.Afis.FingerCode3.Encoder())
                        {
                            Dermalog.Afis.FingerCode3.Template template = encoder.Encode(rawImage);
                            // The function template.GetData() returns the raw byte data, which can be saved as a *.dat file.
                            //String templateString = String.Format("template{0}.dat",
                            //localUser.Fingerprints[i].Position.ToString("D2"));
                            //String templatePath = Path.Combine(idPath, templateString);
                            FileStream fs2  = File.Create(path_target + "\\" + file_name + ".dat");
                            byte[]     data = template.GetData();
                            fs2.Write(data, 0, data.Length);
                            fs2.Flush();
                            fs2.Close();
                        }
                    }


                    existError = false;
                }
                catch (Exception ex)
                {
                    // Qué ha sucedido
                    var mensaje = "Error message: " + ex.Message;

                    // Información sobre la excepción interna
                    if (ex.InnerException != null)
                    {
                        mensaje = mensaje + " Inner exception: " + ex.InnerException.Message;
                    }

                    // Dónde ha sucedido
                    mensaje = mensaje + " Stack trace: " + ex.StackTrace;
                }

                if (existError)
                {
                    errorArray[file_name] = file_name;
                }
            }


            //DATAINPUT
            //errorArray
            //
            //DATASYSTEM
            dataGridView1.ColumnCount = 2;
            //

            //HEADER
            dataGridView1.Columns[0].HeaderText = "#";
            dataGridView1.Columns[1].HeaderText = "Afiliado";
            dataGridView1.Columns[1].Width      = 100;
            //

            int    i = 0;
            string k, v;

            foreach (KeyValuePair <string, string> kv in errorArray)
            {
                k = kv.Key.ToString();
                v = kv.Key.ToString();



                DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[i].Clone();
                row.Cells[0].Value = i + 1;
                row.Cells[1].Value = k;
                dataGridView1.Rows.Add(row);

                i++;
            }
        }