using CCDCount.DLL.SqlDataClass;
using CCDCount.DLL.Tools;
using CCDCount.MODEL.AuditTrailModel;
using CCDCount.MODEL.ConfigModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace CCDCount.DLL.AuditTrail
{
    public class BatchRecordClass
    {
        private byte[] imageBytes = null;
        public void GetRecordLogo(byte[] LogoPath)
        {
            imageBytes = LogoPath;
        }
        public string BatchRecordToPDF(List<BatchRecordModel> batchRecords) 
        {
            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\BatchRecord.pdf";
            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
            pDFGenerate.InsertText("批记录", 20, 3);
            pDFGenerate.InsertNewLine();
            if (imageBytes != null)
            {
                pDFGenerate.InsertImage(imageBytes);
            }
            pDFGenerate.InsertNewLine();
            pDFGenerate.InsertTable(batchRecords, "批记录");
            pDFGenerate.SavePDF();
            return SavePath;
        }

        public string BatchRecordToPDFReColspan(List<BatchRecordModel> batchRecords,List<string> ColSpanNames)
        {
            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\BatchRecord.pdf";
            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
            pDFGenerate.InsertText("批记录", 20, 3);
            pDFGenerate.InsertNewLine();
            if (imageBytes != null)
            {
                pDFGenerate.InsertImage(imageBytes);
            }
            pDFGenerate.InsertNewLine();
            pDFGenerate.InsertTable(batchRecords, ColSpanNames, "批记录");
            pDFGenerate.SavePDF();
            return SavePath;
        }

        public string BatchRecordToPDF(List<BatchRecordModel> batchRecords,string FileName)
        {
            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\{FileName}.pdf";
            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
            pDFGenerate.InsertText("批记录", 20, 3);
            pDFGenerate.InsertNewLine();
            if (imageBytes != null)
            {
                pDFGenerate.InsertImage(imageBytes);
            }
            pDFGenerate.InsertNewLine();
            pDFGenerate.InsertTable(batchRecords, "批记录");
            pDFGenerate.SavePDF();
            return SavePath;
        }
    }
}
