예제 #1
0
        protected void btn5_Click(object sender, EventArgs e)
        {
            var biz = new BLL.FileBiz();

            //var res = biz.DownloadFile(Page.Response, @"desert.jpg", @"\\192.168.15.10\IASFileUpload\desert.jpg");

            biz.DownloadFile(Page.Response, "", "Jellyfish.jpg");
        }
예제 #2
0
        protected void btn2_Click(object sender, EventArgs e)
        {
            BLL.FileBiz biz          = new BLL.FileBiz();
            string      targetFolder = "5678";

            biz.UploadToOIC(fUpload.PostedFile.InputStream, fUpload.FileName, targetFolder, fUpload.FileName);
            Response.Write(Resources.errorwebTestUpload_003);
        }
예제 #3
0
        private void InitData()
        {
            string Click = Request.QueryString["Click"];

            string ReportFolder = base.ReportFilePath_Key;

            //string PDFFolder = base.PDFPath_Key;

            string PDF_Temp = base.PDFPath_Temp_Key;

            string PDF_OIC = base.PDFPath_OIC_Key;

            string PDF_Users = base.PDFPath_Users_Key;

            string FileNameInput = "RptRecive.pdf";

            string FileNameOutput = "RptRecive.pdf";

            var    ls      = new List <RptReciveClassService>();
            var    data    = new List <DTO.SubPaymentDetail>();
            string mapPath = "~/IASFileUpload";

            if (Click == "Print")
            {
                //var para = Request.QueryString["Invoice"];

                //var biz = new BLL.PaymentBiz();

                for (int i = 0; i < lsPaymentPrint.Count; i++)
                {
                    RptReciveClassService rcv = new RptReciveClassService();

                    BLL.FileBiz bizfile = new BLL.FileBiz();
                    //   // string dd = item.ReceiptNumber;
                    rcv.BillNumber  = lsPaymentPrint[i].ReceiptNumber;
                    rcv.ReceiptDate = lsPaymentPrint[i].ReceiptDate;
                    rcv.FirstName   = lsPaymentPrint[i].FirstName;
                    rcv.LastName    = lsPaymentPrint[i].LastName;
                    rcv.AMOUNT      = lsPaymentPrint[i].Amt;
                    rcv.PaymentType = lsPaymentPrint[i].PaymentType;
                    rcv.BathThai    = ConvertMoneyToThai(rcv.AMOUNT);

                    rcv.SigImgPathArray = bizfile.Signature_Img(Page.Response, "", lsPaymentPrint[i].SigImgPath.ToString());
                    rcv.QRcordPathArray = bizfile.Signature_Img(Page.Response, "", lsPaymentPrint[i].QRcordPath.ToString());
                    rcv.GUID            = lsPaymentPrint[i].GUID;
                    ls.Add(rcv);
                    ////data.Add(new DTO.SubPaymentDetail
                    ////{
                    ////    HEAD_REQUEST_NO = lsPaymentPrint[i].HEAD_REQUEST_NO,
                    ////    PAYMENT_NO = lsPaymentPrint[i].PAYMENT_NO,
                    ////    Click = "Print"
                    ////});
                }
                //data.Add(new DTO.SubPaymentDetail
                //{
                //    HEAD_REQUEST_NO = lsPaymentPrint[1].HEAD_REQUEST_NO,
                //    PAYMENT_NO = lsPaymentPrint[1].PAYMENT_NO,
                //    Click = "Print"
                //});
                if (base.UserProfile.MemberType == DTO.RegistrationType.General.GetEnumValue())
                {
                    var biz = new BLL.PaymentBiz();
                    var res = biz.PrintDownloadCount(data.ToArray(), "", base.UserId);

                    ReportDocument rpt = new ReportDocument();

                    rpt.Load(Server.MapPath(ReportFolder + "RptRecive.rpt"));
                    rpt.SetDataSource(ls);

                    BindReport(rpt);

                    rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath(PDF_Temp + FileNameInput));

                    using (Stream input = new FileStream(Server.MapPath(PDF_Temp + FileNameInput), FileMode.Open, FileAccess.Read, FileShare.Read))
                        using (Stream output = new FileStream(Server.MapPath(PDF_Users + FileNameOutput), FileMode.Create, FileAccess.Write, FileShare.None))
                        {
                            PdfReader reader = new PdfReader(input);


                            /*ใส่ Password*/
                            //PdfEncryptor.Encrypt(reader, output, true, "test", "test", PdfWriter.AllowPrinting);
                            /*ใส่ Password*/

                            PdfEncryptor.Encrypt(reader, output, true, string.Empty, string.Empty, PdfWriter.AllowPrinting);
                        }

                    //ลบไฟล์ ใน Folder PDF_Temp ทิ้ง
                    string   PathDelete = Server.MapPath(PDF_Temp + FileNameInput);
                    FileInfo File       = new FileInfo(PathDelete);

                    if (File.Exists)
                    {
                        File.Delete();
                    }
                    //ลบไฟล์ ใน Folder PDF_Temp ทิ้ง

                    string    FilePath   = Server.MapPath(PDF_Users + FileNameOutput);
                    WebClient User       = new WebClient();
                    Byte[]    FileBuffer = User.DownloadData(FilePath);
                    if (FileBuffer != null)
                    {
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("content-length", FileBuffer.Length.ToString());
                        Response.BinaryWrite(FileBuffer);
                    }

                    upd.Update();
                }
                else
                {
                    var            biz = new BLL.PaymentBiz();
                    var            res = biz.PrintDownloadCount(data.ToArray(), "", base.UserId);
                    ReportDocument rpt = new ReportDocument();

                    rpt.Load(Server.MapPath(ReportFolder + "RptRecive.rpt"));

                    rpt.SetDataSource(ls);

                    BindReport(rpt);

                    rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath(PDF_Temp + FileNameInput));

                    using (Stream input = new FileStream(Server.MapPath(PDF_Temp + FileNameInput), FileMode.Open, FileAccess.Read, FileShare.Read))
                        using (Stream output = new FileStream(Server.MapPath(PDF_OIC + FileNameOutput), FileMode.Create, FileAccess.Write, FileShare.None))
                        {
                            PdfReader reader = new PdfReader(input);
                            /*ใส่ Password*/
                            //PdfEncryptor.Encrypt(reader, output, true, "test", "test", PdfWriter.AllowPrinting);
                            /*ใส่ Password*/

                            PdfEncryptor.Encrypt(reader, output, true, string.Empty, string.Empty, PdfWriter.AllowPrinting);
                        }

                    //ลบไฟล์ ใน Folder PDF_Temp ทิ้ง
                    string   PathDelete = Server.MapPath(PDF_Temp + FileNameInput);
                    FileInfo File       = new FileInfo(PathDelete);

                    if (File.Exists)
                    {
                        File.Delete();
                    }
                    //ลบไฟล์ ใน Folder PDF_Temp ทิ้ง

                    string    FilePath   = Server.MapPath(PDF_OIC + FileNameOutput);
                    WebClient User       = new WebClient();
                    Byte[]    FileBuffer = User.DownloadData(FilePath);
                    if (FileBuffer != null)
                    {
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("content-length", FileBuffer.Length.ToString());
                        Response.BinaryWrite(FileBuffer);
                    }

                    upd.Update();
                }
            }
            else if (Click == "Download")
            {
                for (int i = 0; i < lsPaymentPrint.Count; i++)
                {
                    RptReciveClassService rcv = new RptReciveClassService();
                    //  FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient();
                    //   // string dd = item.ReceiptNumber;
                    BLL.FileBiz bizfile = new BLL.FileBiz();
                    rcv.BillNumber  = lsPaymentPrint[i].ReceiptNumber;
                    rcv.ReceiptDate = lsPaymentPrint[i].ReceiptDate;
                    rcv.FirstName   = lsPaymentPrint[i].FirstName;
                    rcv.LastName    = lsPaymentPrint[i].LastName;
                    rcv.AMOUNT      = lsPaymentPrint[i].Amt;
                    rcv.PaymentType = lsPaymentPrint[i].PaymentType;
                    rcv.BathThai    = ConvertMoneyToThai(rcv.AMOUNT);

                    rcv.SigImgPathArray = bizfile.Signature_Img(Page.Response, "", lsPaymentPrint[i].SigImgPath.ToString());
                    ls.Add(rcv);

                    data.Add(new DTO.SubPaymentDetail
                    {
                        HEAD_REQUEST_NO = lsPaymentPrint[i].HEAD_REQUEST_NO,
                        PAYMENT_NO      = lsPaymentPrint[i].PAYMENT_NO,
                        Click           = "Download"
                    });
                }



                if (base.UserProfile.MemberType == DTO.RegistrationType.General.GetEnumValue())
                {
                    GenPDFDownload1(ReportFolder, PDF_OIC, FileNameInput, ls, data);

                    Response.ContentType = "Application/pdf";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileNameOutput);
                    Response.TransmitFile(Server.MapPath(PDF_OIC + FileNameOutput));

                    Response.End();

                    upd.Update();
                }
                else
                {
                    GenPDFDownload2(ReportFolder, PDF_OIC, FileNameInput, ls, data);
                    #region TempCode
                    //using (Stream input = new FileStream(Server.MapPath(PDF_Temp + FileNameInput), FileMode.Open, FileAccess.Read, FileShare.Read))

                    //using (Stream output = new FileStream(Server.MapPath(PDF_OIC + FileNameOutput), FileMode.Create, FileAccess.Write, FileShare.None))
                    //{
                    //    //  PdfReader reader = new PdfReader(input);

                    //    /*ใส่ Password*/
                    //    //PdfEncryptor.Encrypt(reader, output, true, "test", "test", PdfWriter.AllowPrinting);
                    //    /*ใส่ Password*/
                    //}

                    ////ลบไฟล์ ใน Folder PDF_Temp ทิ้ง
                    //string PathDelete = Server.MapPath(PDF_Temp + FileNameInput);
                    //FileInfo File = new FileInfo(PathDelete);

                    //if (File.Exists)
                    //{
                    //    File.Delete();
                    //}

                    #endregion

                    //Response.ContentType = "Application/pdf";
                    //Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileNameOutput);
                    //Response.TransmitFile(Server.MapPath(PDF_Temp + FileNameOutput));
                    //Response.TransmitFile(Server.MapPath(PDF_OIC + FileNameOutput));
                    //string passDownload =   String.Format("window.open('{0}?targetImage={1}','','')"
                    //         , UrlHelper.Resolve("/UserControl/PDFRender.aspx"), IAS.Utils.CryptoBase64.Encryption("RptRecive.pdf"));
                    //ScriptManager.RegisterClientScriptBlock(Page, GetType(), "alert", passDownload, true);
                    string path     = Server.MapPath("~/PDF/PDF_OIC/") + FileNameInput;
                    String FileName = FileNameInput;
                    String FilePath = "~/PDF/PDF_OIC/"; //Replace this


                    string dd = "http://www.qworld-plus.com/download/QWorldPlus_Patch_V0.14.163.exe";
                    //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + dd + "','_blank')", true);
                    //Response.Redirect("" + dd + "");
                    string ff = "window.open('http://www.qworld-plus.com/download/QWorldPlus_Patch_V0.14.163.exe');";

                    string newwin = "window.open('http://www.qworld-plus.com/download/QWorldPlus_Patch_V0.14.163.exe' , 'mypopup1' , 'nenuber=no,toorlbar=no,location=no,scrollbars=no, status=no,resizable=no,width=180,height=180,top=220,left=650 ' );";
                    AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup",
                                                                                  newwin, true);
                    //Response.Write("<script>window.open('" + path + "');<script>");
                    //System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                    //response.ClearContent();
                    //response.Clear();
                    //response.ContentType = "Application/pdf";
                    //response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
                    //response.TransmitFile(FilePath + FileName);
                    //response.Flush();

                    //response.End();
                    // Response.End();

                    //upd.Update();
                }
            }
        }