I want to simulate a print preview and then request an API.
This is the result of clicking Preview.
Now I’ve written code in function to request the API
var context=Ice.Services.ContextFactory.CreateContext<ErpContext>();
var erpContext=new Erp.Internal.Lib.CCredChk(context);
Ice.Contracts.BAQReportSvcContract bAQReportSvc=Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.BAQReportSvcContract>(erpContext.Db,true);
Ice.Tablesets.BAQReportTableset bAQReportTableset=new Ice.Tablesets.BAQReportTableset();
try
{
string pcReportID="BAQRptTest";
string maintProgram="Ice.UIRpt.BAQRptTest";
string PrintProgram="reports/CustomReports/BAQRptTest";
Ice.Tablesets.BAQReportParamRow bAQReportParamRow=new Ice.Tablesets.BAQReportParamRow();
Ice.Tablesets.ReportStyleRow reportStyleRow= new Ice.Tablesets.ReportStyleRow();
//Parameter
bAQReportParamRow.UserID=this.callContextClient.CurrentUserId;
bAQReportParamRow.Filter1="5404";
bAQReportParamRow.AutoAction="SSRSPREVIEW";
bAQReportParamRow.ReportStyleNum=1;
bAQReportParamRow.WorkstationID=this.callContextClient.CurrentUserId;
bAQReportParamRow.SSRSRenderFormat="PDF";
bAQReportParamRow.RowMod="A";
bAQReportParamRow.ReportID=pcReportID;
bAQReportParamRow.ReportCurrencyCode="CNY";
bAQReportParamRow.ReportCultureCode="zh-CN";
bAQReportParamRow.DateFormat= "m/d/yyyy";
bAQReportParamRow.NumericFormat=",.";
bAQReportTableset.BAQReportParam.Add(bAQReportParamRow);
//ReportStyle
//Search ReportStyle
var ReportStyeResult= from ReportStye in erpContext.Db.ReportStyle where ReportStye.ReportID==pcReportID select ReportStye;
if(ReportStyeResult.Count()>0)
{
reportStyleRow.Company=ReportStyeResult.FirstOrDefault().Company;
reportStyleRow.ReportID=ReportStyeResult.FirstOrDefault().ReportID;
reportStyleRow.StyleNum=ReportStyeResult.FirstOrDefault().StyleNum;
reportStyleRow.StyleDescription=ReportStyeResult.FirstOrDefault().StyleDescription;
reportStyleRow.RptTypeID=ReportStyeResult.FirstOrDefault().RptTypeID;
reportStyleRow.PrintProgram=ReportStyeResult.FirstOrDefault().PrintProgram;
reportStyleRow.PrintProgramOptions=ReportStyeResult.FirstOrDefault().PrintProgramOptions;
reportStyleRow.RptDefID=ReportStyeResult.FirstOrDefault().RptDefID;
reportStyleRow.CompanyList=ReportStyeResult.FirstOrDefault().CompanyList;
reportStyleRow.ServerNum=ReportStyeResult.FirstOrDefault().ServerNum;
reportStyleRow.OutputLocation=ReportStyeResult.FirstOrDefault().OutputLocation;
reportStyleRow.OutputEDI=ReportStyeResult.FirstOrDefault().OutputEDI;
reportStyleRow.SystemFlag=ReportStyeResult.FirstOrDefault().SystemFlag;
reportStyleRow.CGCCode=ReportStyeResult.FirstOrDefault().CGCCode;
reportStyleRow.SysRevID=0;
reportStyleRow.SysRowID=ReportStyeResult.FirstOrDefault().SysRowID;
reportStyleRow.RptCriteriaSetID=ReportStyeResult.FirstOrDefault().RptCriteriaSetID;
reportStyleRow.RptStructuredOutputDefID=ReportStyeResult.FirstOrDefault().RptStructuredOutputDefID;
reportStyleRow.StructuredOutputEnabled=ReportStyeResult.FirstOrDefault().StructuredOutputEnabled;
reportStyleRow.RequireSubmissionID=ReportStyeResult.FirstOrDefault().RequireSubmissionID;
reportStyleRow.AllowResetAfterSubmit=ReportStyeResult.FirstOrDefault().AllowResetAfterSubmit;
reportStyleRow.CertificateID=ReportStyeResult.FirstOrDefault().CertificateID;
reportStyleRow.LangNameID=ReportStyeResult.FirstOrDefault().LangNameID;
reportStyleRow.FormatCulture=ReportStyeResult.FirstOrDefault().FormatCulture;
reportStyleRow.StructuredOutputCertificateID=ReportStyeResult.FirstOrDefault().StructuredOutputCertificateID;
reportStyleRow.StructuredOutputAlgorithm=ReportStyeResult.FirstOrDefault().StructuredOutputAlgorithm;
reportStyleRow.StatusCode=ReportStyeResult.FirstOrDefault().StatusCode;
reportStyleRow.StatusDesc=ReportStyeResult.FirstOrDefault().StatusDesc;
bAQReportTableset.ReportStyle.Add(reportStyleRow);
}
throw new Ice.BLException(Newtonsoft.Json.JsonConvert.SerializeObject(bAQReportTableset));
bAQReportSvc.TransformAndSubmit(bAQReportTableset,"",0,0,maintProgram);
}
catch(Exception ex)
{
throw new Ice.BLException("Data: " + ex.Data + "Source: " + ex.Source + "Message: " + ex.Message+"StackTrace: "+ex.StackTrace);
}
finally
{
context.Dispose();
erpContext.Dispose();
}
An error Invalid dataset was reported while requesting a TransformAndSubmit
Then I printed out bAQReportTableset and put it in the Rest API for debugging and the request was successful
So I am very confused, is it the problem of my code, have you encountered similar problems, can you help me…