Classic customization FileTransferSvcContract / GetService

We were storing a bunch of byte data in strings in our UDCodes table to recompile into images. At the time we didn’t want to store them directly on our server. UDCodes table is starting to cause issues with backups and restores for our test instance, and generally speed went down after our move to a managed instance of sql. So we decided we wanted to store them on the server instead of in the table.

The screen has some other functions that we don’t have bandwidth to move to a kinetic style at the moment - so I was going to add the File Transfer service the way I did in a BPM recently.

However - I can’t find a way to call CallService, and read a article saying I may need to bring the dll into the client’s folder?

Can’t do this directly since it’s abstract
Ice.Contracts.FileTransferSvcContract fileHandler = new Ice.Contracts.FileTransferSvcContract();

I don’t tend to use Lamda expressions so not sure if there’s a clever way I can write one to handle what I’m trying?

(going to make a configurable path for this too if I have time)
Later down the script I’m just trying to do:

Byte[] fileBytes = File.ReadAllBytes(@"T:\Documents\Prep_Images\" + path.Text.ToString());

fileTransfer.UploadFile(Epicor.ServiceModel.Utilities.SpecialFolder.CompanyData, @"Files\PrepCodes\" + code.Text.ToString() + "-" + num.ToString(), fileBytes);

Tldr; How did you all handle using FileTransfer in classic customizations? Is there an assembly I can bring in to use either CallService or some variant, or an expression to use FileTransferSvcContract directly?

I should note that I did try bringing in both the FileTransfer dll and looked for a Service dll but none of them seemed to bring in what I needed.

I use my function runner.

I could be convinced to write a demo.

I may have another slick way too, un momento.

1 Like

Looks like Server File Download uses Ice.Lib.FileTransfer.

Is this a new feature :heart_eyes: I don’t remember it telling me which to use before…
The type ‘Ice.Lib.IFileTransfer’ is defined in an assembly that is not referenced. You must add a reference to assembly 'Ice.Lib.IFileTransfer, Version=4.3.100.0

1 Like

I would bet you need Ice.Lib.FileTransfer.dll & Ice.Contracts.Lib.FileTransfer.dll

How to use them… no clue yet.

Looks like they take two paths rather than bytes in the Upload function. Still working on the declaration since it says doesn’t contain a constructor with 0 arguments.

1 Like

Don’t have time to poke.

Holler if you figure it out, or want a demo of functionrunner.

void UploadFile(SpecialFolder folder, string serverPath, byte[] data);

pass it a session

I already had the references you mentioned, I did have to also add the ILib version of it as well.

Constructor takes an Session from Ice.Core, need to cast the oTrans version of it.

Ice.Lib.FileTransfer fileHandler = new Ice.Lib.FileTransfer((Ice.Core.Session)oTrans.Session);

Then no bytes are needed:
String 1 = source path+file
String 2 = destination Special Folder
String 3 = destination relative path + file name

fileHandler.UploadFile(@"T:\Documents\Prep_Images\" + path.Text.ToString(), Epicor.ServiceModel.Utilities.SpecialFolder.CompanyData, @"Files\PrepCodes\" + code.Text.ToString() + "-" + num.ToString());

where?

I brought it in as a custom reference.

Ice.Lib.FileTransfer.dll & Ice.Contracts.Lib.FileTransfer.dll

When I tried to bring those in earlier and use the UploadFile it was telling me Ice.Lib. didn’t contain it and same with Ice.Contracts. That said, I don’t recall if I was trying to use the SvcContract, like in my BPM, or not.

Guessing yours works too?

I ended up doing Ice.Lib.FileTransfer xyz = new Ice.Lib.FileTransfer(); and it told me that I needed to bring in Ice.Lib.IFileTransfer so I brought it in as a custom reference.

The type ‘Ice.Lib.IFileTransfer’ is defined in an assembly that is not referenced. You must add a reference to assembly 'Ice.Lib.IFileTransfer, Version=4.3.100.0

After I brought it in, it let me create the object with Ice.Lib.FileTransfer. I kind of like this version more since it doesn’t take bytes so one less line of code haha

No

I have Ice.Lib.FileTransfer.dll & Ice.Contracts.Lib.FileTransfer.dll

and I still get

The type ‘Ice.Lib.IFileTransfer’ is defined in an assembly that is not referenced. You must add a reference to assembly 'Ice.Lib.IFileTransfer, Version=4.3.100.0

brought what in?

the Ice.Lib.IFileTransfer.dll as a custom assembly reference

image

what is the file name?

For me it’s exactly that - though it doesn’t show unless I do “All files”

1 Like

I did that 4 times… it finally showed up lol.

1 Like