Clear buffer scanner Fujitsu Fi-7160 in c#
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 of 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 re-scan, it is necessary to close and open the application again. Already downloaded, installed and updated all drivers from the manufacturer, though still unsuccessful. I have already sought solutions directly on the manufacturer's website, but without success either. As far as I researched, the application is 32-bit, running on windows 10 64-bit, the scanner uses the hdmi port of the notebook, the application communicates with the scanner through the IP PaperStream program (TWAIN). From now on I thank you, 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;
}
}