Fórum
Ver pergunta

Impressão do Mapa de Consulta de Inventario   

23 visualizações
0
0

Estou a tentar fazer impressao do mapa de consulta de inventario o erro que tenho e de que a Tabela não existe:

Erro no arquivo CINVBLUE 29872_27220_{10A25F0E-02DF-4B7B-9BF5-AE73F3077985}.rpt:
a tabela não foi localizada.

string tempFolder = Path.Combine(Path.GetTempPath(), "DocumentosTemp");
Directory.CreateDirectory(tempFolder);

string fileName = $"{Guid.NewGuid()}.pdf";
string fullPath = Path.Combine(tempFolder, fileName);

string QueryCreate = $" IF NOT OBJECT_ID('tempdb.dbo.##TempConsInventUF3MP12248Hec04956c19714d84aa645ef9bbe8a7d5uDnJO7378jmB') " +
$" IS NULL DROP TABLE ##TempConsInventUF3MP12248Hec04956c19714d84aa645ef9bbe8a7d5uDnJO7378jmB; " +
$" CREATE TABLE ##TempConsInventUF3MP12248Hec04956c19714d84aa645ef9bbe8a7d5uDnJO7378jmB " +
$" ([Campo1] [nvarchar] (1) COLLATE Latin1_General_CI_AS NOT NULL ) ";

string QueryInsert = $" EXEC INV_ConsultaInventario " +
$" @pFiltroAdicionais = '(est.Existencias = 1)', " +
$" @pFiltroArtigos = 'mov.Artigo IN (SELECT Artigo.Artigo FROM [Artigo] WITH (NOLOCK) " +
$" LEFT JOIN [ArtigoMoeda] WITH (NOLOCK) ON [Artigo].[Artigo] = [ArtigoMoeda].[Artigo] " +
$" WHERE ([Artigo].[UnidadeBase] = [ArtigoMoeda].[Unidade]) AND ([ArtigoMoeda].[Moeda] = ''MT''))', " +
$" @pTmpTabela = '##TempConsInventUF3MP12248Hec04956c19714d84aa645ef9bbe8a7d5uDnJO7378jmB' ";

string QuerySelect = $" SELECT DISTINCT TempConsInvent.Artigo, TempConsInvent.Armazem, TempConsInvent.Localizacao, TempConsInvent.Lote, TempConsInvent.Descricao, TempConsInvent.Quantidade, TempConsInvent.Unidade, TempConsInvent.CustoMBase, TempConsInvent.TotalCustoMBase, TempConsInvent.EstadoStock FROM tempdb.dbo.##TempConsInventUF3MP12248Hec04956c19714d84aa645ef9bbe8a7d5uDnJO7378jmB TempConsInvent ";

Engine.Primavera.Engine._engine.DSO.ExecuteSQL(QueryCreate);
Engine.Primavera.Engine._engine.DSO.ExecuteSQL(QueryInsert);
Engine.Primavera.Engine._plataforma.Mapas.Inicializar("INV");
Engine.Primavera.Engine._plataforma.Mapas.Destino = CRPEExportDestino.edFicheiro;
Engine.Primavera.Engine._plataforma.Mapas.SetFileProp(CRPEExportFormat.efPdf, fullPath);
Engine.Primavera.Engine._plataforma.Mapas.ImprimeListagem("CINVBLUE", sTitulo: "Consulta De Inventario", iNumCopias: 1,
sQuerySQL: QuerySelect, bMapaSistema: false, bCategoria: false, blnModal: true);


if (!File.Exists(fullPath))
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Arquivo não encontrado");
}

// Lê o arquivo em um array de bytes
byte[] fileBytes = File.ReadAllBytes(fullPath);

// Cria um HttpResponseMessage com o conteúdo do arquivo
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(new MemoryStream(fileBytes));
response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
{
FileName = fileName
};

return response;

 

Faça login para poder traduzir
Mapas e Relatórios
Marcado como spam
Criado há 1 mês e 2 semanas felicianonhavoto