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.Tasks;

namespace CCDCount.DLL.AuditTrail
{
    public class FormulationRecordClass
    {
        private byte[] imageBytes = null;
        public void GetRecordLogo(byte[] LogoPath)
        {
            imageBytes = LogoPath;
        }
        public string FormulationRecordToPDF(FormulationConfigClass FormulationRecords)
        {
            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\FormulationRecord.pdf";
            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
            pDFGenerate.InsertText("生产配方记录", 20, 3);
            pDFGenerate.InsertNewLine();
            if (imageBytes != null)
            {
                pDFGenerate.InsertImage(imageBytes);
            }
            pDFGenerate.InsertNewLine();
            pDFGenerate.InsertTable(FormulationRecords, "生产配方记录");
            pDFGenerate.SavePDF();
            return SavePath;
        }

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

        public string FormulationRecordToPDF(FormulationConfigClass FormulationRecords, 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(FormulationRecords, "批记录");
            pDFGenerate.SavePDF();
            return SavePath;
        }
    }
}
