Hello,
I am trying to create a function that generates an SSRS report that is defined as a report data definition and report style.
I’m currently having issues attempting to execute the TransformDynamicCriteria function. Unfortunately, this function is defined as taking a parameter of type object with the name ds, so I cannot tell what exactly it is expecting in regard to type. I can call TransformDynamicCriteria outside of the function via Postman and the REST API and it functions properly. I am using the same dataset that is created in my code below with this REST API and it is functioning properly.
Here are the different things I’ve tried:
1. Use Ice.DatasetAdapter.ConvertToGenericDataset and pass the tableset that is retrieved when calling GetNewDynamicCriteriaReportParam and pass that to the function
2. Serialize the generic dataset to JSON and pass that to the function
3. Create a non-generic dataset, DynamicCriteriaDataSet, and use Ice.DatasetAdapter.CopyTSTableToDataTable to copy both the DynamicCriteriaParam and ReportStyle tables to the new dataset, then pass that to the function
Here is the code from my function that I have been attempting to use. Currently, the parameters are hard coded for testing purposes, and the reportID is passed as a parameter to the function. When executing this function via Postman, an exception is thrown, which I am capturing.
Exception contents: “InvalidDataset (Parameter ‘ds’)”
Code:
try
{
this.CallService<Ice.Contracts.DynamicCriteriaSvcContract>(bo =>
{
Guid guid = Guid.NewGuid();
Ice.Tablesets.DynamicCriteriaTableset tsDynamicCriteria = bo.GetNewDynamicCriteriaReportParam(this.reportID);
tsDynamicCriteria.DynamicCriteriaParam[0].ArchiveCode = 1;
tsDynamicCriteria.DynamicCriteriaParam[0].AutoAction = "SSRSGENERATE";
tsDynamicCriteria.DynamicCriteriaParam[0].SSRSRenderFormat = "PDF";
tsDynamicCriteria.DynamicCriteriaParam[0].WorkstationID = "web_manager"; //callContextBpmData.Character01;
tsDynamicCriteria.DynamicCriteriaParam[0].TaskNote = guid.ToString();
tsDynamicCriteria.ReportStyle[0]["SSRSRenderFormat"] = "PDF";
Ice.IceColumn paramColumn1 = Ice.IceColumn.CreateExtensionColumn("dateFrom", typeof(System.DateTime));
tsDynamicCriteria.DynamicCriteriaParam.Columns.Add(paramColumn1);
Ice.IceColumn paramColumn2 = Ice.IceColumn.CreateExtensionColumn("dateTo", typeof(System.DateTime));
tsDynamicCriteria.DynamicCriteriaParam.Columns.Add(paramColumn2);
Ice.IceColumn paramColumn3 = Ice.IceColumn.CreateExtensionColumn("salesRepCode", typeof(System.String));
tsDynamicCriteria.DynamicCriteriaParam.Columns.Add(paramColumn3);
tsDynamicCriteria.DynamicCriteriaParam[0]["dateFrom"] = "07/01/2023";
tsDynamicCriteria.DynamicCriteriaParam[0]["dateTo"] = "08/05/2024";
tsDynamicCriteria.DynamicCriteriaParam[0]["salesRepCode"] = "SALESREP";
this.ds = (System.Data.DataSet)bo.TransformDynamicCriteria(Ice.DatasetAdapter.ConvertToGenericDataset(tsDynamicCriteria, "", null, true));
string defaultTaskAgentID = "";
this.CallService<Ice.Contracts.SysAgentSvcContract>(svc1 =>
{
svc1.GetDefaultTaskAgentID(out defaultTaskAgentID);
});
bo.SubmitToAgent(tsDynamicCriteria, "", 0, 0, "Erp.UIRpt.TestForm");
bool isReady = false;
while (!isReady)
{
var sysRptLstQuery = this.Db.SysRptLst.FirstOrDefault(t => t.RptNote == guid.ToString());
if (sysRptLstQuery != null)
{
isReady = true;
}
}
this.CallService<Ice.Contracts.ReportMonitorSvcContract>(svc2 =>
{
bool morePages = true;
Ice.Tablesets.ReportMonitorTableset tsReportMonitor = svc2.GetRows($"RptNote='{guid.ToString()}'", 1, 1, out morePages);
if (tsReportMonitor.SysRptLst.Count > 0)
{
Ice.BO.ReportMonitorDataSet dsReportMonitor = new Ice.BO.ReportMonitorDataSet();
DatasetAdapter.CopyTSTableToDataTable<Ice.Tablesets.SysRptLstRow, Ice.BO.ReportMonitorDataSet.SysRptLstDataTable>(tsReportMonitor.SysRptLst, dsReportMonitor.SysRptLst);
//System.IO.MemoryStream ms = new System.IO.MemoryStream(svc2.GetReportBytes(tsReportMonitor.SysRptLst[0].SysRowID));
//System.IO.StreamWriter sw = new System.IO.StreamWriter($"OUTPUTPATH");
//ms.WriteTo(sw.BaseStream);
//sw.Flush();
//sw.Close();
this.ds = dsReportMonitor;
}
});
});
}
catch(Exception ex)
{
this.outputStr = ex.Message;
}