Updating Code for 10.2.200 from 10.1.400

Main questions is this correct for the update between versions. If not, can you point us in the right direction for how we should invoke this call in C#.

10.1.400 call
using(var callService = WCFServiceSupport.CreateImpl<UD05Impl>(session, UD05Impl.UriPath))

10.2.200 call that will compile. The above call would not compile in the customization maintenance verification.
using(var callService = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.UD05Impl>(session, Ice.Proxy.BO.UD05Impl.UriPath))

This new code is using the Ice.Proxy. Is this correct?

Thanks!
Josh

What is the compilation error?

UD05Impl is not available in the namespace. I can change it back to get the exact error statement if I need too.

Ice.Proxy.BO is the namespace.

Did you reference the contract?

We had a few errors like that as well.

I just converted the code to use the adapter vs the WCF.

Think I could have fixed it by adding a using as well.

I agree with @knash, i think an adapter is a much better solution. It will require some code changes, not too bad tho

@Chris_Conn and @knash
Thanks for the replies guys, however I have one additional question. I am passing your details back to our on staff developers, but they are asking me how to actually change the code to use an adapter instead of the WCF. Can you please provide a short code snippet/explanation? I am sure they will be able to interrupt it quicker than I can. If you have any additional questions please let me know. Thanks for all the help!

Depends on the original code.

I followed a youtube video by @josecgomez which uses an adapter to call a BAQ with a parameter.

There’s an issue we found going from 10.1 to 10.2. The verify option on Customization Maintenance will strip out the ‘using Ice.Proxy.BO;’ from the start of any customization that normally belongs in the ‘Erp’ namespace.
It does the same thing to ‘using Erp.Proxy.BO;’ if it belongs to an ‘Ice’ application.

Easiest fix is adding the using directive back to the top of the customizations, but it will error out again the next time you do a verify. Just putting ‘Ice.Proxy.BO.’ in front of the object is going to be an easy way to fix it permanently without having to change all your code.

Not going to weigh in on the whole adapter vs business object debate but we went that route because it meant much fewer changes to our code.

1 Like

The biggest change from BO to adapter has to do with the dataset.

In a BO, you provide and maintain the dataset, in an adapter, that dataset is provided and managed by the adapter.

An example (proabably not syntactically correct)
//BO 
var partDS = new PartDataSet();
partBO.Update(partDS); //passing the DS

//adapter
partAdapter.Update(); //no need to pass as DS
//results are in partAdapter.PartData (this name changes based on adapter)

Here is the updated code that our developers created this morning after getting the replies back.

using(var ud05Adapter = new UD05Adapter(this.oTrans))
{
if(ud05Adapter.GetByID(“PackSlip”,"","","",""))
{
var dataSet = ud05Adapter.GetCurrentDataSet(DataSetMode.RowsDataSet) as UD05DataSet;
var packSlipString = dataSet.UD05[0][“Character01”].ToString();

                                                        int packSlipValue;
                                                        if(int.TryParse(packSlipString, out packSlipValue))
                                                        {
                                                                    packSlipString = (++packSlipValue).ToString("00000");

                                                                    dataSet.UD05[0]["Character01"] = packSlipString;
                                                                    
                                                                    ud05Adapter.Update();

                                                                    return packSlipString;
                                                        }
                                            }
                                }

This probably isnt updating for them because they need to change the row mod on the desired record to update to U

dataSet.UD05[0]["Character01"] = packSlipString;
dataSet.UD05[0]["RowMod"] = "U";
ud05Adapter.Update();

also instead of getting the ds with GetCurrentDataSet, they can simply modify the ds direct in the adapter.
ud05Adapter.UD05Data.UD05.Rows[0] etc

EDIT: The NullReferenceException was due to not calling .BOConnect() prior to GetByID().

Thanks for everyone’s help.

Chris,
Thanks for the suggestions.

I’m now confused because I’m getting a NullReferenceException at ud05Adapter.GetByID method. I don’t know what would be null in this context.

Exception Details

Error Detail
Message: Object reference not set to an instance of an object.
Program: Ice.Adapters.UD05.dll
Method: OnGetByID

Client Stack Trace
at Ice.Adapters.UD05Adapter.OnGetByID(Object[] parameters)
at Ice.Lib.Framework.EpiBaseAdapter.GetByID(Object[] parameters)
at Script.GetNextPackSlipID()

Code

using(var ud05Adapter = new UD05Adapter(this.oTrans))
{
    if(ud05Adapter.GetByID("PackSlip","","","",""))
    {
        var packSlipRow = ud05Adapter.UD05Data.UD05.Rows[0];
        var packSlipString = packSlipRow["Character01"].ToString();

        int packSlipValue;
        if(int.TryParse(packSlipString, out packSlipValue))
        {
            packSlipString = (++packSlipValue).ToString("00000");

            packSlipRow["Character01"] = packSlipString;
            packSlipRow["RowMod"] = "U";                        

            ud05Adapter.Update();

            return packSlipString;
        }
    }
}

First call for adapter should be BOConnect();

using(var ud05Adapter = new UD05Adapter(this.oTrans))
{
ud05Adapter.BOConnect();
    if(ud05Adapter.GetByID("PackSlip","","","",""))
    {

Edit - I didnt see your edit lol. Glad you got it worked out.