Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i can send the memory stream data.

What I have tried:

private void btn_Send_PDF_Click(object sender, EventArgs e)
       {
           int Patient_Master_Id = Convert.ToInt16(txt_Patient_No.Tag);
           XtraReport report = new XtraReport();
           string[,] paramsArray = new string[,]
               {
                   {"@Patient_Master_Id", Patient_Master_Id.ToString()},
                   {"@Test_Group_Id",TestGroupId.ToString()},
                   {"@stSearh",""},
               };
           report = new Print_Test_Patient_Report();
           report.DataSource = _Master_Repository.Run_Dynamic_SP("Print_Patient_Test_Report", paramsArray);
           MemoryStream mem = new MemoryStream();
           report.ExportToPdf(mem);
           mem.Seek(0, System.IO.SeekOrigin.Begin);

           HttpClient client = new HttpClient();
           client.DefaultRequestHeaders.Accept.Clear();
           client.BaseAddress = new Uri("http://localhost:4079/");
           client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
           Laboratory_Reports LR = new Laboratory_Reports();
           LR.Laboratory_Id = 0;
           LR.Register_No = "Reg001"; ;
           LR.Laboratory_Name = "Rsoft Laboratory";
           LR.Patient_No = txt_Patient_No.Text;
           LR.Patient_Name = txt_Name.Text;
           LR.Password = "007";
           LR.Report_Url = "";
           LR.Report_Extension = ".pdf";
           LR.Upload_Date = DateTime.Now;

           StreamReader reader = new StreamReader(mem);
           string text = reader.ReadToEnd();


           LR.MemSrm = text;

           //string memString = text;
           //// convert string to stream
           //byte[] buffer = Encoding.ASCII.GetBytes(memString);
           //MemoryStream ms = new MemoryStream(buffer);
           //write to file
           FileStream file = new FileStream("d:\\file.pdf", FileMode.Create, FileAccess.Write);
           mem.WriteTo(file);
           file.Close();
           mem.Close();


       }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900