I'm working on a Company project, C # Windows Form and I'm still new to the dot net platform. I would like to know with my friends, if there is any way I can clean the buffer of the Fujitsu Fi-7160 Scanner, after scanning about 1500 sheets, because the application always shows a memory out of memory, full buffer and to scan again, you must close and reopen the application. I have already downloaded, installed and updated all the drivers of the manufacturer, but still without success. I have already searched for solutions directly on the Manufacturer's website, but without success as well. As far as I've researched, the application is 32-bit, running on windows 10 64-bit, the scanner uses the notebook's hdmi port, the application communicates with the scanner through the PaperStream IP (TWAIN) program. Thanks in advance, if 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;
}
}