Clear Fujitsu Fi-7160 buffer scanner in c#

Asked

Viewed 154 times

0

I’m working on a Company project, C# Windows Form and I’m still a beginner on the dot net platform. I would like to know with friends by profession, if there is any way I can clean the buffer of the Fujitsu Fi-7160 Scanner, after scanning about 1500 sheets, because always the application presents message of lack of memory, full buffer and to be able to scan again, you need to close and open the application again. I already downloaded, installed and updated all the drivers of the manufacturer, but not yet successful. I have already looked for solutions directly on the Manufacturer’s website, but without success as well. As far as I searched, the application is 32 bits, running on windows 10 64 bits, the scanner uses the notebook’s hdmi port, the application communicates with the scanner through the program Paperstream IP (TWAIN). Thanks in advance, in case friends can help me with some guidance.

private string scannearParaArquivo(string arquivo, bool mostraConfig)
    {
        //
        string ret = "";
        AcquireModalState acquireModalState;
        using (DeviceManager deviceManager = new DeviceManager())
        {
            deviceManager.Open();

            Device device = deviceManager.Devices.Current;



            try
            {
                // open the device 
                device.Open();
            }
            catch (Exception ex)
            {
                return string.Concat("Não foi possivel acessar o scanner: ",ex.Message.ToString());
            }

            try
            {
                // set acquisition parameters 


                device.ShowUI = mostraConfig;
                device.DisableAfterAcquire = true;
                device.TransferMode = TransferMode.Memory;
                device.FileFormat = TwainImageFileFormat.Tiff;


                device.AcquiredImages.TiffMultiPage = false;
                device.AcquiredImages.TiffCompression = TiffCompression.Auto;

                device.AcquiredImages.AutoClean = true;
            }
            catch (Exception ex)
            {
                return string.Concat("Erro na configuração do Scanner: ", ex.Message.ToString());
            }


            // set filename the first acquired image
            imageIndex++;
            device.FileName = string.Concat(arquivo, imageIndex.ToString("00000000"), ".tif");

            bool atingiuMaximoDocto = false;

            // acquire images from device 
            acquireModalState = AcquireModalState.None;
            do
            {
                int ponto = 0;
                try
                {
                    acquireModalState = device.AcquireModal();
                    switch (acquireModalState)
                    {
                        case AcquireModalState.ImageAcquired:
                            //
                            ponto = 1;
                            string i = device.FileName;
                            device.AcquiredImages.Last.Save(i);
                            mostraCaptura(imageIndex, i);
                            //set filename for next acquired image 
                            imageIndex++;
                            device.FileName = string.Concat(arquivo, imageIndex.ToString("00000000"), ".tif");
                            GC.Collect(); // 10/07/2018
                            break;
                        case AcquireModalState.ScanCompleted:
                            // Fim de captura saida normal
                            // close the device 
                            ponto = 2;
                            device.Dispose();
                            device.Close();
                            // close the device manager 
                            device.AcquiredImages.Clear();
                            deviceManager.Dispose();
                            deviceManager.Close();
                            GC.Collect(); // 10/07/2018
                            break;
                        case AcquireModalState.ScanCanceled:
                            // Fim da captura por atingir maximo de documento ou por cancelamento
                            ponto = 3;
                            if (atingiuMaximoDocto == true)
                            {
                                MessageBox.Show("Quantidade de documentos digitalizados ultrapassou o limite. \n Feche este lote e inicie um novo Lote. \n\n Atenção, verifique os ultimos documento digitalizado.\n\n\n Digitalização encerrada, confira os ultimos documentos", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            // close the device 
                            device.Dispose();
                            device.Close();
                            // close the device manager 
                            deviceManager.Dispose();
                            deviceManager.Close();
                            GC.Collect(); // 10/07/2018
                            break;
                        case AcquireModalState.ScanFailed:
                            // close the device 
                            ponto = 4;
                            device.Dispose();
                            device.Close();
                            // close the device manager 
                            deviceManager.Dispose();
                            deviceManager.Close();
                            GC.Collect(); // 10/07/2018
                            ret = "Verifique se há documento";
                            break;
                    }
                    if (imageIndex > 111 & atingiuMaximoDocto == false)
                    {
                        if (device != null)
                        {
                            // send command to cancel the transfer  
                            if (device.State == DeviceState.Transferring || device.State == DeviceState.TransferReady)
                            {
                                ponto = 5;
                                device.CancelTransfer();
                            }
                        }
                        atingiuMaximoDocto = true;
                    }
                }
                catch (Exception ex)
                {
                    // Erro inesperado na Captura
                    ret = ex.Message.ToString();
                    LogSistema.logProcessamento(string.Concat("Erro inesperado na captura no ponto ", ponto.ToString()), pathLog);
                    LogSistema.logProcessamento(string.Concat("Pasta ", arquivo, " - " , this.labNumeroEquipamento.Text), pathLog);
                    LogSistema.logProcessamento(ret, pathLog);
                    LogSistema.logProcessamento("======================================================================", pathLog);
                }

            }
            while (acquireModalState != AcquireModalState.None);
            imageIndex--;
            return ret;
        }
    }
  • Where is this buffer stored? If it is in GC, you can clean with GC.Collect().

  • 1

    Add code scanning to question.

  • 1

    @Cypherpotato tomorrow morning at the service, I will post the snippet of the code that is scanning the documents and more information about my environment. I will check right where this buffer is stored and then inform you. I thank you for the feedback from friends.

  • I’d like to see where the Device and DeviceManager, are from some library ? When I implemented scanning, I used TwainDotNet. For me it works smoothly, just not tested with 1500 pages rs

  • @Rovannlinhalis I’m using the library Vintasoft.Twain.dll. If it’s not too much abuse on my part, you could get me the link from where I can download this Twaindotnet Library you mentioned. I thank you so much for the time you’ve devoted to trying to help me.

  • @Gabrielfilipecarvalho saved mistake, I got in some project on codeproject.com. But I don’t remember. Anyway, I sent it to git: https://github.com/rovannlinhalis/SOpt/tree/master/Teste%20Scanner

  • 1

    Wonder @Rovannlinhalis I thank you for your kindness. I will download and use this library and will program myself to post a response on the test today. Again I thank you.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.