Render Document using APIs in ASP.NET Application

Discussions related to Crystal Reports development.

Moderator: Lisa Ennis

Post Reply
Prakasha NB
Posts: 4
Joined: Thu Mar 09, 2017 3:09 am

Render Document using APIs in ASP.NET Application

Post by Prakasha NB »

We are rendering commitment and Invoice docs using APIs,but we are getting following exception.This is working fine in Console Application,but troubling in ASP.NET application.Did i miss any DLLs? , hard to understand what i missed,almost all the required DLLs added.

Here is the Exception Message ,Stack Trace and Inner Exception.

The type initializer for 'SoftPro.Select.Client.Fieldcodes.FieldResolver' threw an exception.


Could not load file or assembly 'file:///C:\Workspace\FD-P2\Fnf.NetSolutions.Website\SoftPro.OrderTracking.Client.dll' or one of its dependencies. The system cannot find the file specified.

at SoftPro.Select.Client.Fieldcodes.FieldResolver..ctor(IServiceProvider sp)
at SoftPro.Select.Client.Fieldcodes.FieldcodeResolver..ctor(IServiceProvider sp)
at SoftPro.Select.Client.Fieldcodes.FieldcodeProcessing.SoftPro.Select.Client.Fieldcodes.IFieldcodeProcessing.GetResolver()
at SoftPro.Documents.Markup.Analyzer.Initialize(IServiceProvider sp)
at SoftPro.Documents.Markup.Analyzer..ctor(IServiceProvider sp, IRenderingAdapter adapter)
at SoftPro.Documents.Rendering.TextControl.TXTextRendererImpl.SoftPro.Documents.Client.Rendering.IRendererImpl.Render(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IDocumentInfo document, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.Render(IDocumentInfo document, Object context, IPrompt`1 prompt)
at Module.SoftProClient.Business.LiveScheduleA.RenderDoc(IOrder iorder, IDocumentManager docMgr, IRenderer renderer, String docName) in C:\Workspace\FD-P2\Module.SoftPro\Business\LiveScheduleA.cs:line 264
at Module.SoftProClient.Business.LiveScheduleA.GetDocuments(String OrderNumber, List`1 documentsList) in C:\Workspace\FD-P2\Module.SoftPro\Business\LiveScheduleA.cs:line 241



Thanks in advance
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Render Document using APIs in ASP.NET Application

Post by BobRichards »

It appears you missed one or more required DLLs. See viewtopic.php?f=17&t=1093 for a discussion on how to determine what file(s) is missing by examining the exception information.

By the way, your problem is with the API and not the Crystal Report. In the future, you should look at the Integration Development / General forum. You will find helpful solutions to many API related issues.
Bob Richards, Senior Software Developer, SoftPro
Prakasha NB
Posts: 4
Joined: Thu Mar 09, 2017 3:09 am

Re: Render Document using APIs in ASP.NET Application

Post by Prakasha NB »

We Copied all DLLs into Bin Directory,after that getting following exception.If you have any samples for rendering docs in ASP.NET app would be much helpful.


Message: Type SoftPro.Select.Client.Fieldcodes.SelectFieldResolutionHandler does not implement IFieldResolutionHandler.
Stack Trace:
at SoftPro.Select.Client.Fieldcodes.FieldResolver.Create(Type type)
at SoftPro.Select.Client.Fieldcodes.FieldResolver.<CreateHandlers>b__12_0(Type type)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at SoftPro.Select.Client.Fieldcodes.FieldResolver.CreateHandlers()
at SoftPro.Select.Client.Fieldcodes.FieldResolver..ctor(IServiceProvider sp)
at SoftPro.Select.Client.Fieldcodes.FieldcodeResolver..ctor(IServiceProvider sp)
at SoftPro.Select.Client.Fieldcodes.FieldcodeProcessing.SoftPro.Select.Client.Fieldcodes.IFieldcodeProcessing.GetResolver()
at SoftPro.Documents.Markup.Analyzer.Initialize(IServiceProvider sp)
at SoftPro.Documents.Markup.Analyzer..ctor(IServiceProvider sp, IRenderingAdapter adapter)
at SoftPro.Documents.Rendering.TextControl.TXTextRendererImpl.SoftPro.Documents.Client.Rendering.IRendererImpl.Render(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IDocumentInfo document, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.Render(IDocumentInfo document, Object context, IPrompt`1 prompt)
at Module.SoftProClient.Business.LiveScheduleA.RenderDoc(IOrder iorder, IDocumentManager docMgr, IRenderer renderer, String docName) in d:\FNF Global\illinois_ticortitle_com_redesign_FNFI-P2\Module.SoftPro\Business\LiveScheduleA.cs:line 264
at Module.SoftProClient.Business.LiveScheduleA.GetDocuments(String OrderNumber, List`1 documentsList) in d:\FNF Global\illinois_ticortitle_com_redesign_FNFI-P2\Module.SoftPro\Business\LiveScheduleA.cs:line 241
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Render Document using APIs in ASP.NET Application

Post by BobRichards »

Does the Console version still work with the SAME API CODE as used in the ASP.NET code? Are you answering the Select render prompt request with the same values? I'm wondering if one of the render prompt responses is returning an invalid object.
Bob Richards, Senior Software Developer, SoftPro
manjunath.bhat
Posts: 7
Joined: Wed Mar 08, 2017 4:01 am

Re: Render Document using APIs in ASP.NET Application

Post by manjunath.bhat »

Thank you for your help on this Bob.

We have a solution where we created separate DLL for SoftPro related code. ASP.NET web project and Console application both use the same DLL. All SoftPro DLLs from "C:\Program Files (x86)\SoftPro\Select" are included as reference in both ASP.NET project and Console Project.

Here is the code we are trying with:

Code: Select all

IOrderStore os = oSelectServer.GetService<IOrderStore>();
            IOrderInfo search = os.Orders.Where(x => x.Number == OrderNumber).FirstOrDefault();
            IOrder order = os.OpenOrder(search, OrderEditMode.ReadOnly);

            IDocumentManager dm = oSelectServer.GetService<IDocumentManager>();
            IRendererFactory rendererFactory = oSelectServer.GetService<IRendererFactory>();
            IRenderer renderer = rendererFactory.Create();
            IDocumentInfo docInfo = dm.Documents
                .Where(t => t.Title == "ALTA Commitment (6-17-06)")
                .FirstOrDefault();
            try
            {
                RenderPrompts prompts = new RenderPrompts();
                IRendering rendering = renderer.Render(docInfo, order, prompts);
            }
            catch (Exception Ex)
            {
                
                throw Ex;
            }
Web Application returns error: "Type SoftPro.Select.Client.Fieldcodes.SelectFieldResolutionHandler does not implement IFieldResolutionHandler" at line:

Code: Select all

IRendering rendering = renderer.Render(docInfo, order, prompts);
Console returns without any error:
Console Response.png
Console Response.png (10.28 KiB) Viewed 7466 times
This document does not show any prompt when we print it from SoftPro Select. Even when we change the prompt parameter to null, we get the same exception

Code: Select all

IRendering rendering = renderer.Render(docInfo, order, null);
Our Environment:
Version: 4.2.41213.27 (4.2.3.6)
SERVER: http://JDCSWBSWB1A-T:8080

Thanks.
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Render Document using APIs in ASP.NET Application

Post by John Morris »

Are you sure that all of the DLLs you copied are from the same version release of Select?
John Morris
Sr. Software Architect
SoftPro
manjunath.bhat
Posts: 7
Joined: Wed Mar 08, 2017 4:01 am

Re: Render Document using APIs in ASP.NET Application

Post by manjunath.bhat »

Thank you guys for your help on this:

We are generating documents from console application now and able to get pdf out from SDK. Here is a new issue we are facing:

We are trying to print 3 documents:
  • Master Commitment (DOC_SSCORPD1411)
    Initial Fee Quote (DOC_SSCORPD5409)
    Master Statement, Legal (CDF) (DOC_SSCORPD5454)
First 2 documents, when generated from SDK does not match the ones generated from SPS. Please see attached (Left one from SPS and right one from SDK), most of the information missing in these. DOC_SSCORPD1411 & DOC_SSCORPD5409 have this problem but not DOC_SSCORPD5454.

We are working with API examples from here viewtopic.php?f=6&t=940&p=4184&hilit=Mi ... lues#p4006

Server: http://JTCSSPSAPP3D-T:8080/ILFUT
Version: 4.3.50811.25
Sample Order: CH17014862

Thank you in advance
Attachments
Commitment.PNG
Commitment.PNG (96.9 KiB) Viewed 7413 times
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Render Document using APIs in ASP.NET Application

Post by BobRichards »

I have not forgotten about you. It is taking some time to get a matching database and documents package to write code exercising the reports you referenced. At this point, I am assuming the correct context is not being passed, but I want to generate tested code. Hopefully the stars will align tomorrow.
Bob Richards, Senior Software Developer, SoftPro
manjunath.bhat
Posts: 7
Joined: Wed Mar 08, 2017 4:01 am

Re: Render Document using APIs in ASP.NET Application

Post by manjunath.bhat »

BobRichards wrote: Tue Nov 28, 2017 5:28 pm I have not forgotten about you. It is taking some time to get a matching database and documents package to write code exercising the reports you referenced. At this point, I am assuming the correct context is not being passed, but I want to generate tested code. Hopefully the stars will align tomorrow.
Hello Bob,

Please let me know if you have found something.

Thanks.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Render Document using APIs in ASP.NET Application

Post by BobRichards »

I do not have a setup that allows me to test a test a document with a complex document context like in DOC_SSCORPD1411. You will note that the rather ugly looking context for the document is:
{{Order.Title.Commitment[BeginsWith({{.RB_Code_FNF#}},"R") or BeginsWith({{.RB_Code_FNF#}},"C")]}}
requiring the commitment to begin with specific letters. The document I am using has the same basic requirement - except it allows any commitment to be passed to it
{{Order.Title.Commitment}}
The part you are potentially missing is that you must pass an order commitment to the renderer - not the entire order:

Code: Select all

// Get a single Commitment.
IOrderItem title = (IOrderItem)order.GetProperty("Title");
IList commitments = (IList)title.GetProperty("Commitments");
IOrderItem commitment = (IOrderItem)commitments[0];

// My document doesn't request additional prompts so pass null instead.
rendering = renderer.Render(docInfo, commitment, null);
Bob Richards, Senior Software Developer, SoftPro
Post Reply