Hi There
Is it possible to export a some documents such as Invoices, Purchase Orders, Some reports as PDFs to be saved under shared drives through a plugin.
Mean, map a selective shared drive in the plugin and save it there.

public ServiceStack.Web.IHttpResult Get(ReportsPDFGETRequest request)
{
JiwaApplication.Manager manager = this.SessionAs<JiwaAuthUserSession>().Manager;
JiwaApplication.Report.Configuration.ReportCollection m_Reports = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaApplication.Report.Configuration.ReportCollection>(null);
m_Reports.Read();
// find report with request.ReportID
JiwaApplication.Report.Configuration.Report report = m_Reports[request.ReportID];
if (report == null)
throw new JiwaApplication.Exceptions.RecordNotFoundException("Report not found");
JiwaApplication.JiwaPrintReport.JiwaPrintReport printReportObject = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaApplication.JiwaPrintReport.JiwaPrintReport>(null);
printReportObject.Setup();
printReportObject.LoadReport(report);
if (request.ReportParameters != null)
{
foreach (ReportParameter reportParameter in request.ReportParameters)
{
foreach (JiwaApplication.JiwaPrintReport.JiwaReportRange jiwaReportRange in printReportObject.JiwaReportRangeCollection)
{
if (printReportObject.JiwaPrintFormulaCollection[jiwaReportRange.FormulaKey].Name.Replace("{", "").Replace("}", "").Replace("@", "").Trim().ToUpper() == reportParameter.Name.Replace("{", "").Replace("}", "").Replace("@", "").Trim().ToUpper())
{
jiwaReportRange.Value = reportParameter.Value;
break;
}
}
}
}
printReportObject.UpdateReport();
// export report to PDF
string tempFolderPath = System.IO.Path.GetTempPath();
string fileName = report.Title;
// Make filename safe
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
{
fileName = fileName.Replace(c.ToString(), "");
}
string fullFileName = System.IO.Path.Combine(tempFolderPath, fileName) + ".pdf";
printReportObject.CrystalReportObject.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fullFileName);
// Return the file
System.IO.FileInfo fileInfo = new System.IO.FileInfo(fullFileName);
return new HttpResult(fileInfo, asAttachment: request.AsAttachment);
}


Riyaz wrote:Hi Stuart
Thanks for the same, prefer to do this via plugin, is that not possible?






Return to Technical and or Programming
Users browsing this forum: No registered users and 5 guests