How to call DocStarDownload Attachment

Hi Jose!

Sort of unrelated question:
I am having trouble calling the DocStarDownloadFile method.
Could you please show me how you defined the attachmentBO object?
Thank you in advance!

Best,
Moe

Where are you calling it from?

Attempting to call it from a dashboard customization.
We initially did not have DocStar so I was able to just open the path, now it is not so easy.

Tracker customization that is

You don’t have docstar?

We just bought it.
We were initially saving documents through the default Epicor file transfer functionality so the customization above worked just fine.

We are now in the process of implementing DocStar.
I did a trace to open a document saved in DocStar to see if there is an adapter method I could use and found this:

The issue I am having now is I cannot find an attchment adapter I could reference

You need to get the XFileRefNum first.

Bring in the Ice.Contracts.BO.Attachment DLL

using Ice.Proxy.BO;
.....

Ice.Proxy.BO.AttachmentImpl attachmentBO = attachmentBO = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.AttachmentImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.AttachmentSvcContract>.UriPath);
var fileData = attachmentBO.DocStarDownloadFile(xFileRefNum,ref metaData);
string fileName = Path.GetTempFileName().Replace(".tmp",".pdf");
File.WriteAllBytes(fileName, fileData);
2 Likes

Thank Jose!

For anyone else looking for a solution we also had to do the following:

  1. Can’t reference oTrans from Tracker Customization so had to post if to a Menu as Dashboard-Assembly , then customize the menu item
  2. Include Ice.Contracts.BO and Ice.Core.Session
    3.Parse file extension

Final Code Snip:

    private void btnOpen_Click(object sender, System.EventArgs args)
    	{
    		// ** Place Event Handling Code Here ** txtRef
    		if(!string.IsNullOrEmpty(txtRef.Text)){
    		int reff= Convert.ToInt32(txtRef.Text);
    		string txt = ((EpiTextBox)csm.GetNativeControlReference("655779fb-e72c-4b6c-af6c-9993468f016b")).Text;
    		string ext="."+txt.Split('.')[txt.Split('.').Length-1];

    		try{
    		
    			Process.Start(txt);
    		
    		}catch{
    		
    			Dictionary<String,String> metaData = new Dictionary<String,String>();
    			Ice.Proxy.BO.AttachmentImpl attachmentBO  = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.AttachmentImpl>
    			((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.AttachmentSvcContract>.UriPath);
    			var fileData = attachmentBO.DocStarDownloadFile(reff,ref metaData);
    			string fileName = System.IO.Path.GetTempFileName().Replace(".tmp",ext);
    			System.IO.File.WriteAllBytes(fileName, fileData);
    			Process.Start(fileName);
    		}
    	}
4 Likes