Having a Service use another service  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Having a Service use another service

Postby SBarnes » Wed Jul 25, 2018 4:05 pm

HI Mike,

I need to develop a service to produce a debtor statement where I want to hand in a Debtor ID , I know the report ID inside the plugin and obviously the parameter name for the report, are there any issues that would be caused to the API by having the new service do

Code: Select all
ReportsServices rs = new ReportsServices();


Fill up the necessary report ReportsPDFGETRequest and call

Code: Select all
ServiceStack.Web.IHttpResult Get(ReportsPDFGETRequest request)


and return that?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Having a Service use another service  Topic is solved

Postby SBarnes » Wed Jul 25, 2018 5:30 pm

Ok to answer my own question yes it can be done, code below but there are two things

1. You should use base.ResolveService to instantiate the service class see https://stackoverflow.com/questions/12811182/servicestack-how-to-call-my-service-from-code as to why.
2. You need to instantiate ReportParameters yourself as there is no constructor on ReportsPDFGETRequest doing it.


Code: Select all
         JiwaApplication.Manager manager = this.SessionAs<JiwaAuthUserSession>().Manager;
         ReportsServices rs = base.ResolveService<ReportsServices>();
         ReportsPDFGETRequest pdfreq = new ReportsPDFGETRequest();
         pdfreq.ReportID = RESTAPIPlugin.StatementReportID;
         pdfreq.ReportParameters = new List<ReportParameter>();
         pdfreq.AsAttachment = true;
         pdfreq.ReportParameters.Add(new ReportParameter(){Name = "Pass_SP_StartingDebtorAccountNo", Value = request.DebtorID});
         pdfreq.ReportParameters.Add(new ReportParameter(){Name = "Pass_SP_EndingDebtorAccountNo", Value = request.DebtorID});
         pdfreq.ReportParameters.Add(new ReportParameter(){Name = "Pass_SP_AsAtDate", Value = DateTime.Now.ToString()});
         return  rs.Get(pdfreq);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 3 guests

cron