public static void ShowLoading(Control Frame)
        {
            try
            {
                if (wFTranparentLoading == null)
                {
                    Point p = Frame.PointToScreen(Point.Empty);
                    wFTranparentLoading      = new WFTranparentLoading();
                    wFTranparentLoading.Left = (int)(p.X + ((Frame.Width / 2) - (wFTranparentLoading.Width / 2)));
                    wFTranparentLoading.Top  = (int)(p.Y + ((Frame.Height / 2) - (wFTranparentLoading.Height / 2)));
                    wFTranparentLoading.Show();
                    wFTranparentLoading.Invalidate();
                    wFTranparentLoading.pictureBox1.Invalidate();

                    OpacityMainForm(90, false);
                    if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
                    {
                        Application.DoEvents();
                    }
                }
            }
            catch
            {
                try
                {
                    CloseLoading();
                }
                catch
                {
                    OpacityMainForm(100, true);
                }
            }
        }
        List <GED_PROC_CodigosBarras_Result> OCRImage(OCR ocr, ListView listView)
        {
            if (!CopyImage())
            {
                return(AfterProcess_Start(ocr, listView));
            }

            ocr.BitmapImage.Dispose();
            ocr.BitmapImageFile = this.fileName;
            ocr.Process_Start();
            var timeOutAbout = DateTime.Now.AddSeconds(this.TimeOut);

            while (ocr.Process_Thread.IsAlive)
            {
                if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
                {
                    Application.DoEvents();
                }
                if (timeOutAbout < DateTime.Now)
                {
                    ocr.Process_Thread.Abort();
                }
            }

            SettingOCR(ref ocr);

            return(AfterProcess_Start(ocr, listView));
        }
        public void StopAcquire()
        {
            TwUserInterface guif = new TwUserInterface();
            var             rc   = DSuserif(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.StopFeeder, guif);

            if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
            {
                Application.DoEvents();
            }
        }
 public void Finish()
 {
     if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
     {
         TwRC rc;
         CloseSrc();
         if (appid.Id != IntPtr.Zero)
         {
             rc = DSMparent(appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.CloseDSM, ref hwnd);
         }
         appid.Id = IntPtr.Zero;
     }
 }
예제 #5
0
 public void EndingScan(bool Scanned = true)
 {
     if (msgfilter)
     {
         Application.RemoveMessageFilter(this);
         msgfilter = false;
         if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
         {
             tw.Dispose();
         }
         tw = null;
         if (this.AfterEndingScanEvent != null)
         {
             this.AfterEndingScanEvent(this, Scanned);
         }
     }
 }
 public void CloseSrc()
 {
     try
     {
         if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
         {
             TwRC rc;
             if (srcds.Id != IntPtr.Zero)
             {
                 TwUserInterface guif = new TwUserInterface();
                 rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.DisableDS, guif);
                 rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.CloseDS, srcds);
             }
         }
     }
     catch (Exception)
     {
     }
 }
예제 #7
0
        public virtual void Scan(short CountPages = 200, AxFiScnLib.AxFiScn _driverFujitsu = null, WFCapture wfCapture = null)
        {
            try
            {
                if (this.BeforeScanEvent != null)
                {
                    this.BeforeScanEvent(this);
                }

                if (!msgfilter)
                {
                    msgfilter = true;
                    Application.AddMessageFilter(this);
                }

                this.tw = new Twain(this.Handle);
                this.tw.TransferPictureEvent += TransferPictureEvent;
                this.tw.Brightness            = ACSConfig.GetImages().Brightness;
                this.tw.Contrast              = ACSConfig.GetImages().Contrast;
                this.tw.Resolution            = ACSConfig.GetImages().Resolution;
                this.tw.ScanAs = ACSConfig.GetScanner().ScanAs;
                this.tw.SetDevice(ACSConfig.GetScanner().Driver);

                var nameDriver = ACSConfig.GetScanner().Driver;

                if (nameDriver.ToUpper().Contains("SP-1120"))
                {
                    Fujitsu clsFujitsu = new Fujitsu(_driverFujitsu, wfCapture, ACSGlobal.LoteSelecionado.DIRLOTEINBOX);
                    if (clsFujitsu.AcquireFujitsu() == 1)
                    {
                        if (this.AfterScanEvent != null)
                        {
                            //  this.AfterScanEvent(true);
                            EndingScan(false);
                        }
                    }
                    else
                    {
                        EndingScan(false);
                        WFMessageBox.Show("Sem comunicação com scanner!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                if (nameDriver.ToUpper().Contains("LEXMARK"))
                {
                    //WFLoading.ShowLoad();
                    bool isDuplex = ACSGlobal.Duplex;

                    if (this.tw.AcquireLexmark(CountPages, 0, 0, isDuplex) == TwRC.Success)
                    {
                        if (this.AfterScanEvent != null)
                        {
                            this.AfterScanEvent(true);
                        }     //WFLoading.CloseLoad();
                    }
                    else
                    {
                        if (this.AfterScanEvent != null)
                        {
                            this.AfterScanEvent(false);
                        }
                        EndingScan(false);
                        WFMessageBox.Show("Sem comunicação com scanner!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    bool isDuplex = ACSGlobal.Duplex;

                    if (this.tw.Acquire(CountPages, 0, 0, isDuplex) == TwRC.Success)
                    {
                        if (this.AfterScanEvent != null)
                        {
                            this.AfterScanEvent(true);
                        }
                        WFLoading.CloseLoad();
                    }
                    else
                    {
                        if (this.AfterScanEvent != null)
                        {
                            this.AfterScanEvent(false);
                        }
                        EndingScan(false);
                        WFMessageBox.Show("Sem comunicação com scanner!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }



                if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
                {
                    Application.DoEvents();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void btnEscanear_Click(object sender, EventArgs e)
        {
            // verifica se interação é do tipo escaner e se tem escaner configurado

            // verificar se existe o driver no config

            var    driverValido = false;
            var    confValida   = true;
            string mensagem     = "Verifique os seguinte problemas de configuração: ";

            if (!String.IsNullOrEmpty(ACSConfig.GetScanner().Driver))
            {
                using (var tw = new Twain(this.Handle))
                {
                    foreach (var device in tw.GetDevices())
                    {
                        if (device.ProductName == ACSConfig.GetScanner().Driver)
                        {
                            driverValido = true;
                            break;
                        }
                    }

                    //cbDrivers.Text = ACSConfig.GetScanner().Driver;
                }
            }

            if ((ACSConfig.SystemAction & ModeSystem.Scan) == ModeSystem.Scan && !driverValido)
            {
                //WFMessageBox.Show("Driver de escâner não configurado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                mensagem  += "\n\tDriver de escâner não configurado";
                confValida = false;
            }


            //  if (String.IsNullOrEmpty(ACSGlobal.UsuarioLogado.USR_SERIALNUMBERCERT))
            //  {
            //      mensagem += "\n\tUsuário sem certificado digital vinculado";
            //      confValida = false;
            //  }

            //  if (!Assinador.IsCetificadoComputador())
            //  {
            //      mensagem += "\n\tCertificado do usuário não encontrado";
            //      confValida = false;
            //  }

            Global.ACSGlobal.configScanValida = confValida;
            if (!confValida)
            {
                if (ACSGlobal.GrupoUsuario.GRP_FLAGPREFERENCIA == 0)
                {
                    mensagem += "\nEntre em contato com o suporte";
                    WFMessageBox.Show(mensagem, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.Close();
                }
                else
                {
                    WFMessageBox.Show(mensagem, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            ACSConfig.SystemAction       = ModeSystem.Scan;
            Global.ACSGlobal.TipoCaptura = 1;

            if (ACSConfig.GetApp().User == ModeUser.Mono)
            {
                ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Process;
            }

            this.Close();
        }
예제 #9
0
        public int AcquireFujitsu()
        {
            try
            {
                int status;
                int ErrorCode;


                //Open the scanner (method)
                status = driverFujitsu.OpenScanner2(driverFujitsu.Handle.ToInt32()); //OpenScanner2 is recommended

                if (status == -1)
                {
                    //Display the error information
                    ErrorCode = driverFujitsu.ErrorCode;
                    return(ErrorCode);
                }


                driverFujitsu.ShowSourceUI    = false;
                driverFujitsu.ScanTo          = 0; //Data output method: file
                driverFujitsu.CompressionType = 5; //Compression format: JPEG compression
                driverFujitsu.FileType        = 3; //File format: JPEG file

                var BRss  = (short)(ACSConfig.GetImages().Brightness);
                var CONss = (short)(ACSConfig.GetImages().Contrast);
                driverFujitsu.Brightness = BRss;
                driverFujitsu.Contrast   = CONss;
                //set color
                if (ACSConfig.GetScanner().ScanAs == 0)
                {
                    driverFujitsu.PixelType = 0;
                }                                                                       //Branco e Preto  }
                else if (ACSConfig.GetScanner().ScanAs == 1)
                {
                    driverFujitsu.PixelType = 1;
                }                                                                            //Escala de cinza  }
                else
                {
                    driverFujitsu.PixelType = 2;
                }                                     //Colorido }


                if (ACSConfig.GetImages().Resolution <= 200)
                {
                    driverFujitsu.Resolution = 0;
                }
                else if (ACSConfig.GetImages().Resolution < 300)
                {
                    driverFujitsu.Resolution = 1;
                }
                else if (ACSConfig.GetImages().Resolution < 400)
                {
                    driverFujitsu.Resolution = 2;
                }
                else if (ACSConfig.GetImages().Resolution < 500)
                {
                    driverFujitsu.Resolution = 3;
                }
                else if (ACSConfig.GetImages().Resolution < 600)
                {
                    driverFujitsu.Resolution = 4;
                }
                else if (ACSConfig.GetImages().Resolution < 700)
                {
                    driverFujitsu.Resolution = 5;
                }
                else if (ACSConfig.GetImages().Resolution < 800)
                {
                    driverFujitsu.Resolution = 6;
                }
                else if (ACSConfig.GetImages().Resolution < 900)
                {
                    driverFujitsu.Resolution = 7;
                }
                else
                {
                    driverFujitsu.Resolution = 9;
                }


                setDuplex = ACSGlobal.Duplex;

                //set duplex
                if (setDuplex)
                {
                    driverFujitsu.PaperSupply = 2;
                }
                else
                {
                    driverFujitsu.PaperSupply = 1;
                }

                driverFujitsu.FileName         = pathSaveInbox + "\\000";
                driverFujitsu.BarcodeDetection = true;

                if (!driverFujitsu.FeederLoaded(driverFujitsu.Handle.ToInt32()))
                {
                    return(-1);
                }

                driverFujitsu.SetCapability(0x1013, 1, 1);

                driverFujitsu.SetCapability(0x1012, 1, 3);


                status = driverFujitsu.StartScan(driverFujitsu.Handle.ToInt32());
                // WFCapture_AfterScanEvent();

                // An error occurred during a scan
                if (status == -1)
                {
                    //Display the error information
                    ErrorCode = driverFujitsu.ErrorCode;
                    return(ErrorCode);
                }



                return(1);
            }
            catch (Exception a)
            {
                ACSLog.InsertLog(MessageBoxIcon.Error, a);
                throw;
            }
        }
예제 #10
0
        void BeforeExitwfCapture(object sender)
        {
            Global.ACSGlobal.TipoCaptura = 0;
            if (ACSGlobal.UsuarioLogado.USR_FLAGDIGITALIZACAO == 1)
            {
                ACSConfig.SystemAction = ModeSystem.Scan;
            }

            if (ACSGlobal.UsuarioLogado.USR_FLAGIMPORTACAO == 1)
            {
                ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Import;
            }

            if (ACSGlobal.UsuarioLogado.USR_FLAGPROCESSAMENTO == 1 || ACSConfig.GetApp().User == ModeUser.Mono)
            {
                ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Process;
            }



            if (((ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import | ModeSystem.Process)) ||
                 (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import)) ||
                 (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Process)) ||
                 (ACSConfig.SystemAction == (ModeSystem.Import | ModeSystem.Process))) &&
                ACSGlobal.UsuarioLogado.USR_NIVELASSINA > 1
                )
            {
                var wfTA = new WFTipoAcao();
                wfTA.btnEscanear.Visible = true;
                //
                wfTA.btnEscanear.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Scan)) == ModeSystem.Scan);
                wfTA.btnImportar.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Import)) == ModeSystem.Import);
                wfTA.btnProcessar.Visible = ((ACSConfig.SystemAction & (ModeSystem.Process)) == ModeSystem.Process) && (ACSConfig.GetApp().User == ModeUser.Multi);
                wfTA.MdiParent            = this;
                wfTA.WindowState          = FormWindowState.Normal;
                wfTA.BeforeExitEvent     += BeforeExitTipoAcao;
                wfTA.Dock = DockStyle.Fill;
                wfTA.Show();
            }
            else
            if (ACSGlobal.UsuarioLogado.USR_NIVELASSINA > 1)
            {
                var wfTAs = new WFAssinaNivel2();
                wfTAs.MdiParent        = this;
                wfTAs.WindowState      = FormWindowState.Normal;
                wfTAs.Dock             = DockStyle.Fill;
                wfTAs.BeforeExitEvent += BeforeExitwfAssinatura;
                wfTAs.Show();
            }
            else if ((ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import | ModeSystem.Process)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Process)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Import | ModeSystem.Process)))
            {
                var wfTA = new WFTipoAcao();

                wfTA.btnAssinar.Visible   = false;
                wfTA.btnEscanear.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Scan)) == ModeSystem.Scan);
                wfTA.btnImportar.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Import)) == ModeSystem.Import);
                wfTA.btnProcessar.Visible = ((ACSConfig.SystemAction & (ModeSystem.Process)) == ModeSystem.Process) && (ACSConfig.GetApp().User == ModeUser.Multi);
                wfTA.MdiParent            = this;
                wfTA.WindowState          = FormWindowState.Normal;
                wfTA.BeforeExitEvent     += BeforeExitTipoAcao;
                wfTA.Dock = DockStyle.Fill;
                if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
                {
                    Application.DoEvents();
                }
                wfTA.Show();
            }
        }
예제 #11
0
        void BeforeExitLogin(object sender)
        {
            //teste nova tela assinador 05012016

            (sender as WFLogin).Hide();
            if (ACSGlobal.UsuarioLogado == null || ACSGlobal.UsuarioLogado.USR_IDUSUARIO == 0)
            {
                Application.Exit();
            }
            else
            {
                int iQntAcao = 0;

                if (ACSGlobal.UsuarioLogado.USR_FLAGDIGITALIZACAO == 1)
                {
                    ACSConfig.SystemAction = ModeSystem.Scan;
                    iQntAcao++;
                }

                if (ACSGlobal.UsuarioLogado.USR_FLAGIMPORTACAO == 1)
                {
                    ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Import;
                    iQntAcao++;
                }

                if (ACSGlobal.UsuarioLogado.USR_FLAGPROCESSAMENTO == 1 || ACSConfig.GetApp().User == ModeUser.Mono)
                {
                    ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Process;
                }



                if (((ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import | ModeSystem.Process)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Process)) ||
                     (ACSConfig.SystemAction == (ModeSystem.Import | ModeSystem.Process))) &&
                    ACSGlobal.UsuarioLogado.USR_NIVELASSINA > 1
                    )
                {
                    iQntAcao++;
                    var wfTA = new WFTipoAcao();
                    wfTA.btnEscanear.Visible = true;
                    //
                    wfTA.btnEscanear.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Scan)) == ModeSystem.Scan);
                    wfTA.btnImportar.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Import)) == ModeSystem.Import);
                    wfTA.btnProcessar.Visible = ((ACSConfig.SystemAction & (ModeSystem.Process)) == ModeSystem.Process) && (ACSConfig.GetApp().User == ModeUser.Multi);
                    wfTA.btnAssinar.Visible   = true;
                    wfTA.MdiParent            = this;
                    wfTA.WindowState          = FormWindowState.Normal;
                    wfTA.BeforeExitEvent     += BeforeExitTipoAcao;
                    wfTA.Dock = DockStyle.Fill;
                    if (iQntAcao > 1)
                    {
                        wfTA.Show();
                    }
                    else
                    {
                        if (ACSGlobal.UsuarioLogado.USR_FLAGDIGITALIZACAO == 1)
                        {
                            changeScanOneAction();
                            attrAreas();
                            BeforeExitTipoAcao(sender);
                        }


                        if (ACSGlobal.UsuarioLogado.USR_FLAGIMPORTACAO == 1)
                        {
                            ACSConfig.SystemAction       = ModeSystem.Import;
                            Global.ACSGlobal.TipoCaptura = 2;

                            if (ACSConfig.GetApp().User == ModeUser.Mono)
                            {
                                ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Process;
                            }

                            attrAreas();
                            BeforeExitTipoAcao(sender);
                        }
                    }
                }
                else
                if (ACSGlobal.UsuarioLogado.USR_NIVELASSINA > 1)
                {
                    var wfTAs = new WFAssinaNivel2();
                    wfTAs.MdiParent        = this;
                    wfTAs.WindowState      = FormWindowState.Normal;
                    wfTAs.Dock             = DockStyle.Fill;
                    wfTAs.BeforeExitEvent += BeforeExitwfAssinatura;
                    wfTAs.Show();
                }
                else if ((ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import | ModeSystem.Process)) ||
                         (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Import)) ||
                         (ACSConfig.SystemAction == (ModeSystem.Scan | ModeSystem.Process)) ||
                         (ACSConfig.SystemAction == (ModeSystem.Import | ModeSystem.Process)))
                {
                    var wfTA = new WFTipoAcao();

                    wfTA.btnAssinar.Visible   = false;
                    wfTA.btnEscanear.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Scan)) == ModeSystem.Scan);
                    wfTA.btnImportar.Visible  = ((ACSConfig.SystemAction & (ModeSystem.Import)) == ModeSystem.Import);
                    wfTA.btnProcessar.Visible = ((ACSConfig.SystemAction & (ModeSystem.Process)) == ModeSystem.Process) && (ACSConfig.GetApp().User == ModeUser.Multi);
                    wfTA.MdiParent            = this;
                    wfTA.WindowState          = FormWindowState.Normal;
                    wfTA.BeforeExitEvent     += BeforeExitTipoAcao;
                    wfTA.Dock = DockStyle.Fill;
                    if (!ACSConfig.GetScanner().Driver.ToUpper().Contains("FUJITSU") && !ACSConfig.GetScanner().Driver.ToUpper().Contains("SP-1120"))
                    {
                        Application.DoEvents();
                    }
                    if (iQntAcao > 1)
                    {
                        wfTA.Show();
                    }
                    else
                    {
                        if (ACSGlobal.UsuarioLogado.USR_FLAGDIGITALIZACAO == 1)
                        {
                            changeScanOneAction();
                            attrAreas();
                            BeforeExitTipoAcao(sender);
                        }


                        if (ACSGlobal.UsuarioLogado.USR_FLAGIMPORTACAO == 1)
                        {
                            ACSConfig.SystemAction       = ModeSystem.Import;
                            Global.ACSGlobal.TipoCaptura = 2;

                            if (ACSConfig.GetApp().User == ModeUser.Mono)
                            {
                                ACSConfig.SystemAction = ACSConfig.SystemAction | ModeSystem.Process;
                            }

                            attrAreas();
                            BeforeExitTipoAcao(sender);
                        }
                    }
                }
                else
                {
                    WFMessageBox.Show("Usuário sem Acesso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ACSDataBase.StopSession();
                    Application.ExitThread();
                }
            }
        }
        private bool SaveSettings()
        {
            List <string> UsuariosInvalidos = new List <string>();


            ///GRID ASSINATURAS
            if (dataGridView1.Rows.Count > 0)
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    bool fInsert = true;
                    DataGridViewTextBoxCell  txtNome = (DataGridViewTextBoxCell)(row.Cells[0]);
                    DataGridViewComboBoxCell combo   = (DataGridViewComboBoxCell)(row.Cells[1]);

                    if (txtNome.Tag != null)
                    {
                        var    id       = ((GEDPESSOAS)txtNome.Tag).PES_IDPESSOA;
                        int    idPessoa = (int)id;
                        var    sNome    = txtNome.Value;
                        string chave    = (combo.Value == null) ? "" : combo.Value.ToString();

                        if (chave != "")
                        {
                            string sCpfCertificado = Assinador.BuscaCPFCertificadosValidos(chave);
                            string sVefica         = ACSConfig.GetApp().CPFValidateCertificado;

                            if (sVefica == "YES")
                            {
                                if (sCpfCertificado != "" && ((GEDPESSOAS)txtNome.Tag).PES_CPF != sCpfCertificado)
                                {
                                    fInsert = false;
                                    UsuariosInvalidos.Add("Usuário " + sNome + ", possui um CPF diferente ao do Certificado. Impossível fazer a vinculação do Certificado");
                                }
                            }
                        }

                        if (fInsert)
                        {
                            var fVerifica = DataBase.ACSDataBase.UpdateCertificadoUsuario(idPessoa, chave);
                            if (idPessoa == ACSGlobal.UsuarioLogado.USR_IDPESSOA)
                            {
                                ACSGlobal.UsuarioLogado.USR_SERIALNUMBERCERT = chave;
                            }
                        }
                    }
                }
            }

            ////GRID ASSINATURAS



            ACSConfig.GetStorage().Input  = tbInput.Text;
            ACSConfig.GetStorage().Output = tbOutput.Text;


            if (rbJPG.Checked)
            {
                ACSConfig.GetImages().Format = ImageFormat.Jpeg;
            }
            if (rbPNG.Checked)
            {
                ACSConfig.GetImages().Format = ImageFormat.Png;
            }
            if (rbTIF.Checked)
            {
                ACSConfig.GetImages().Format = ImageFormat.Tiff;
            }

            ACSConfig.GetImages().Resolution = float.Parse(dudResolution.SelectedItem.ToString());

            ACSConfig.GetBarCodeSettings().MaxLength = int.Parse(tbMaxLength.Text);

            ACSConfig.GetScanner().Driver = cbDrivers.Text;

            if (cbDrivers.Text.Contains("Lexmark"))
            {
                ACSMinCapture.Controls.UCImagesManipulation ucImagem = new Controls.UCImagesManipulation(null);
                ucImagem.btnDuplex.Visible = true;
                ucImagem.btnDuplex.Refresh();
            }
            else
            {
                ACSMinCapture.Controls.UCImagesManipulation ucImagem = new Controls.UCImagesManipulation(null);
                ucImagem.btnDuplex.Visible = false;
                ucImagem.btnDuplex.Refresh();
            }

            if (rbPretoBranco.Checked)
            {
                ACSConfig.GetScanner().ScanAs = 0;
            }

            if (rbTonsCinza.Checked)
            {
                ACSConfig.GetScanner().ScanAs = 1;
            }

            if (rbColorido.Checked)
            {
                ACSConfig.GetScanner().ScanAs = 2;
            }


            ACSConfig.GetImages().Brightness       = (int)tbBrightness.Value;
            ACSConfig.GetImages().BrightnessReload = (int)tbBrightness.Value;
            ACSConfig.GetImages().Contrast         = (int)tbContrast.Value;

            ACSConfig.GetNetworkAccesser().Valid    = cbAutentica.Checked;
            ACSConfig.GetNetworkAccesser().Domain   = tbDominio.Text;
            ACSConfig.GetNetworkAccesser().User     = tbUsuario.Text;
            ACSConfig.GetNetworkAccesser().Password = tbSenha.Text;
            if (UsuariosInvalidos.Count > 0)
            {
                foreach (var item in UsuariosInvalidos)
                {
                    WFMessageBox.Show(item, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                return(false);
            }
            return(true);
        }
        private void WFPreferencias_Load(object sender, EventArgs e)
        {
            tbInput.Text  = ACSConfig.GetStorage().Input;
            tbOutput.Text = ACSConfig.GetStorage().Output;

            rbJPG.Checked = ACSConfig.GetImages().Format == ImageFormat.Jpeg;
            rbPNG.Checked = ACSConfig.GetImages().Format == ImageFormat.Png;
            rbTIF.Checked = ACSConfig.GetImages().Format == ImageFormat.Tiff;

            dudResolution.SelectedIndex = dudResolution.Items.IndexOf(ACSConfig.GetImages().Resolution.ToString());

            tbMaxLength.Text = ACSConfig.GetBarCodeSettings().MaxLength.ToString();

            try
            {
                using (var tw = new Twain(this.Handle))
                {
                    this.cbDrivers.Items.Clear();

                    foreach (var device in tw.GetDevices())
                    {
                        this.cbDrivers.Items.Add(device.ProductName);
                    }

                    cbDrivers.Text = ACSConfig.GetScanner().Driver;
                }
            }
            catch (Exception)
            {
                WFMessageBox.Show("Reinicie a aplicação para realizar alguma alteração!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            switch (ACSConfig.GetScanner().ScanAs)
            {
            case 0:
            {
                rbPretoBranco.Checked = true;
                break;
            }

            case 1:
            {
                rbTonsCinza.Checked = true;
                break;
            }

            case 2:
            {
                rbColorido.Checked = true;
                break;
            }
            }

            nudBrightness.Maximum = tbBrightness.Maximum;
            nudBrightness.Minimum = tbBrightness.Minimum;

            nudBrightnessReload.Maximum = tbBrightnessReload.Maximum;
            nudBrightnessReload.Minimum = tbBrightnessReload.Minimum;

            nudContrast.Maximum = tbContrast.Maximum;
            nudContrast.Minimum = tbContrast.Minimum;

            tbBrightness.Value       = (int)ACSConfig.GetImages().Brightness;
            tbBrightnessReload.Value = (int)ACSConfig.GetImages().BrightnessReload;
            tbContrast.Value         = (int)ACSConfig.GetImages().Contrast;

            nudBrightness.Value       = tbBrightness.Value;
            nudBrightnessReload.Value = tbBrightnessReload.Value;
            nudContrast.Value         = tbContrast.Value;

            cbAutentica.Checked = ACSConfig.GetNetworkAccesser().Valid;
            tbDominio.Text      = ACSConfig.GetNetworkAccesser().Domain;
            tbUsuario.Text      = ACSConfig.GetNetworkAccesser().User;
            tbSenha.Text        = ACSConfig.GetNetworkAccesser().Password;

            this.imageBox1.GridDisplayMode = Cyotek.Windows.Forms.ImageBoxGridDisplayMode.Client;
            this.imageBox1.Invalidate();
        }