예제 #1
0
        private byte[] GenFileFromJsper(string policy, string Password)
        {
            string _Cer = "1"; //ไม่ติดCer

            if (Password != null)
            {
                _Cer = "0";
            }
            Dictionary <string, string> DataPO = new Dictionary <string, string>();

            DataPO["@cert"]         = _Cer;
            DataPO["@policy"]       = policy;
            DataPO["@print_header"] = string.Empty;
            DataPO["@sub_cls"]      = "696";

            Dictionary <string, string> DataREC = new Dictionary <string, string>();

            DataREC["@cert"]         = _Cer;
            DataREC["@policy"]       = policy;
            DataREC["@print_header"] = string.Empty;
            DataREC["@sub_cls"]      = "696";

            Dictionary <string, string> DataAt = new Dictionary <string, string>();

            DataAt["@cert"]    = _Cer;
            DataAt["@policy"]  = policy;
            DataAt["@sub_cls"] = "696";

            Byte[] file1 = ExportReport("/JRpt_696/JRpt_696_policy.PDF", DataPO);
            Byte[] file2 = ExportReport("/JRpt_602_receipt.PDF", DataREC);
            Byte[] file3 = ExportReport("/JRpt_696/JRpt_696_attached.PDF", DataAt);

            List <Byte[]> _FileStream = new List <Byte[]>();

            _FileStream.Add(file1);
            _FileStream.Add(file2);
            _FileStream.Add(file3);

            Byte[] array = CombineMultiplePDFs(_FileStream);
            if (_Cer == "0")
            {
                ClsCer CC = new ClsCer();
                array = CC.SignPdf_Byte(array, Password);
            }
            return(array);
        }
예제 #2
0
        public void GENFILEPOLCOVID_RANGE(string FlagType_Pol, DataTable ReqBody, DataTable Pass)
        {
            DataTable     _ReData     = new DataTable();
            ClsCer        CC          = new ClsCer();
            string        PathFolderS = RootPathFilePolCovid;
            string        pols        = "";
            List <string> _list_Pol   = new List <string>();

            try
            {
                //===================================================
                //                  ต่อเลขกรมธรรม์
                //===================================================
                foreach (DataRow _dr in ReqBody.Rows)
                {
                    string pol  = _dr["policy"].ToString()
                    , LocalPath = _dr["physical_path"].ToString()
                    , PDFNAME   = _dr["file_name"].ToString();
                    pols = pols + ((pols == "") ? pols = pol : "," + pol);

                    if (!Directory.Exists(LocalPath))
                    {
                        Directory.CreateDirectory(LocalPath);
                    }
                }
                //======================================================
                //                   GEN FILE JASPER
                //======================================================
                string file_attached = string.Format(@"covid_attached"); //+ user + "_" + Guid.NewGuid().ToString() + ".PDF";
                string file_policy   = string.Format(@"covid_policy");   //+ user + "_" + Guid.NewGuid().ToString() + ".PDF";
                string file_receipt  = string.Format(@"covid_receipt");  // + user + "_" + Guid.NewGuid().ToString() + ".PDF";
                string cert          = "1";
                if (FlagType_Pol == "ePolicy")
                {
                    cert = "0";
                }

                Dictionary <string, string> DataPO  = new Dictionary <string, string>();
                Dictionary <string, string> DataREC = new Dictionary <string, string>();
                Dictionary <string, string> DataAt  = new Dictionary <string, string>();
                //=============================================
                DataPO["@cert"]  = cert;
                DataREC["@cert"] = cert;
                DataAt["@cert"]  = cert;
                //=============================================
                DataPO["@policy"]       = pols;
                DataPO["@print_header"] = string.Empty;
                DataPO["@sub_cls"]      = "696";
                //=============================================
                DataREC["@policy"]       = pols;
                DataREC["@print_header"] = string.Empty;
                DataREC["@sub_cls"]      = "696";
                //=============================================
                DataAt["@policy"]  = pols;
                DataAt["@sub_cls"] = "696";
                //=============================================

                string file1 = ExportReport("/JRpt_696/JRpt_696_policy.PDF", PathFolderS, file_policy, DataPO);
                string file2 = ExportReport("/JRpt_602_receipt.PDF", PathFolderS, file_receipt, DataREC);
                string file3 = ExportReport("/JRpt_696/JRpt_696_attached.PDF", PathFolderS, file_attached, DataAt);
                //======================================================
                //                   จำนวหน้าที่ต้องแยก
                //======================================================
                List <string> _list = new List <string>();
                _list.Add(file_policy);
                _list.Add(file_receipt);
                _list.Add(file_attached);
                //======================================================
                //                      แยก ไฟล์
                //======================================================
                string PathFileName_Inp = "";//@"D:\PDF\SMKPO_Covid19.PDF";
                string PathFileName_Out = "";
                foreach (string _l in _list.ToArray())
                {
                    List <int> Page = new List <int>();
                    Page.Add(1);
                    PathFileName_Inp = PathFolderS + _l;
                    foreach (DataRow _dr in ReqBody.Rows)
                    {
                        string _file_Pol = _dr["file_name"].ToString()
                        , _file_ePol     = _dr["pwd_file_name"].ToString();
                        if (FlagType_Pol == "ePolicy")
                        {
                            PathFileName_Out = _dr["physical_path"].ToString() + _l + _file_ePol;
                        }
                        else
                        {
                            PathFileName_Out = _dr["physical_path"].ToString() + _l + _file_Pol;
                        }
                        PDFSplit(PathFileName_Inp, PathFileName_Out, Page, _l);
                    }
                    File.Delete(PathFolderS + _l);
                }
                //======================================================
                //                     รวมไฟล์
                //======================================================
                foreach (DataRow _dr in ReqBody.Rows)
                {
                    string _file_Pol = _dr["file_name"].ToString()
                    , _file_ePol     = _dr["pwd_file_name"].ToString();

                    if (FlagType_Pol == "ePolicy")
                    {
                        //======================================================
                        //                     ไฟล์ePolicy
                        //======================================================
                        MergePage(_list, _dr["physical_path"].ToString(), _file_ePol);
                        CC.SignPdf(_dr["physical_path"].ToString() + _file_ePol
                                   , _dr["physical_path"].ToString() + _dr["pwd_file_name"].ToString()
                                   , _dr["password"].ToString());
                        Pass.Rows.Add(_dr["policy"].ToString(), "ePolicy", _dr["physical_path"].ToString());
                    }
                    else
                    {
                        //======================================================
                        //                     ไฟล์ปกติ
                        //======================================================
                        MergePage(_list, _dr["physical_path"].ToString(), _file_Pol);
                        Pass.Rows.Add(_dr["policy"].ToString(), "Policy", _dr["physical_path"].ToString());
                    }
                }
                //BytStr = GenFileFromJsper(policy, password);
            }
            catch (Exception e)
            {
            }
        }