public static void btnPrint_OnClickStep(IRNReportDetails form, EventArgs args) { // TODO: Complete business rule implementation IAttachment attachment = null; string pluginid = string.Empty; Sage.Entity.Interfaces.IRNReport parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IRNReport; if (ReportsHelper.GetPluginId("RNReport:Irnreport", out pluginid)) { WebReportingClass reporting = new WebReportingClass(); Sage.Platform.Data.IDataService datasvc = MySlx.Data.CurrentConnection; Sage.Entity.Interfaces.IUser user = MySlx.Security.CurrentSalesLogixUser; string tempPath = Rules.GetTempAttachmentPath(); string ConnectionString = datasvc.GetConnectionString(); string report = reporting.GenerateReport(ConnectionString, datasvc.Server, DatabaseServer.dsMSSQL, tempPath, false, false, "RNREPORT.RNREPORTID", "", pluginid, "", "", "", "SELECT RNREPORT.RNREPORTID FROM RNREPORT", string.Format("(RNREPORT.RNREPORTID = '{0}')", parentEntity.Id), user.Id.ToString(), user.UserName.ToString()); ReportDocument doc = new ReportDocument(); report = string.Format("{0}run\\{1}", tempPath, report); doc.Load(report); string filename = string.Format("{0}\\{1}_v{2}.pdf", Rules.GetAttachmentPath(), parentEntity.ReferenceNumber.Replace(" ", "_"), 1); doc.ExportToDisk(ExportFormatType.PortableDocFormat, filename); doc.Close(); attachment = Sage.Platform.EntityFactory.Create <IAttachment>(); attachment.Description = string.Format("{0} v{1}", parentEntity.ReferenceNumber, 1); attachment.InsertFileAttachment(filename); attachment.RNREPORTID = Convert.ToString(parentEntity.Id); attachment.Save(); System.IO.File.Delete(report); } }
public static void btnPrint_OnClickStep( IRNReportDetails form, EventArgs args) { // TODO: Complete business rule implementation IAttachment attachment = null; string pluginid = string.Empty; Sage.Entity.Interfaces.IRNReport parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IRNReport; if (ReportsHelper.GetPluginId("RNReport:Irnreport", out pluginid)) { WebReportingClass reporting = new WebReportingClass(); Sage.Platform.Data.IDataService datasvc = MySlx.Data.CurrentConnection; Sage.Entity.Interfaces.IUser user = MySlx.Security.CurrentSalesLogixUser; string tempPath = Rules.GetTempAttachmentPath(); string ConnectionString = datasvc.GetConnectionString(); string report = reporting.GenerateReport(ConnectionString,datasvc.Server,DatabaseServer.dsMSSQL,tempPath,false,false,"RNREPORT.RNREPORTID", "", pluginid, "", "", "", "SELECT RNREPORT.RNREPORTID FROM RNREPORT", string.Format("(RNREPORT.RNREPORTID = '{0}')", parentEntity.Id), user.Id.ToString(), user.UserName.ToString()); ReportDocument doc = new ReportDocument(); report = string.Format("{0}run\\{1}", tempPath, report); doc.Load(report); string filename = string.Format("{0}\\{1}_v{2}.pdf", Rules.GetAttachmentPath(), parentEntity.ReferenceNumber.Replace(" ", "_"), 1); doc.ExportToDisk(ExportFormatType.PortableDocFormat,filename); doc.Close(); attachment = Sage.Platform.EntityFactory.Create<IAttachment>(); attachment.Description = string.Format("{0} v{1}", parentEntity.ReferenceNumber, 1); attachment.InsertFileAttachment(filename); attachment.RNREPORTID =Convert.ToString(parentEntity.Id); attachment.Save(); System.IO.File.Delete(report); } }