Thank Jose!
For anyone else looking for a solution we also had to do the following:
- Can’t reference oTrans from Tracker Customization so had to post if to a Menu as Dashboard-Assembly , then customize the menu item
- 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);
}
}