39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|
{
|
|
public class DrawPDFHelper
|
|
{
|
|
private static string PDF_PATH = @"\\192.168.1.160\plm系统文档\线材选型\图纸\";
|
|
private static Dictionary<string, byte[]> _pdfDataDict = new Dictionary<string, byte[]>();
|
|
|
|
public static void CacheAllPdfToMemory()
|
|
{
|
|
var path = PDF_PATH;
|
|
var files = Directory.GetFiles(path, "*.pdf");
|
|
foreach (var file in files)
|
|
{
|
|
var drawId = Path.GetFileNameWithoutExtension(file);
|
|
var data = File.ReadAllBytes(file);
|
|
_pdfDataDict.Add(drawId, data);
|
|
}
|
|
}
|
|
|
|
public static MemoryStream GetPDFStream(string drawId)
|
|
{
|
|
if (_pdfDataDict.ContainsKey(drawId))
|
|
{
|
|
var data = _pdfDataDict[drawId];
|
|
return new MemoryStream(data);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void ClearCache()
|
|
{
|
|
_pdfDataDict.Clear();
|
|
}
|
|
}
|
|
}
|