当前位置: 首页 > 开发 > 正文

X++ 查找产品的图片

//Hu.Luo 2013-08-23
//Suport: Database/Local folder/SMB folder
public Bitmap getProductImageData(InventTable _inventTable)
{
 #WinAPI
 
 FileIOPermission permission;
 EcoResProductImage ecoResProductImage;
 DocuRef docuRef;
 DocuType docuType;
 DocuValue docuValue;
 container containerNull = connull();
 container con;
 BinData binData;

 URL url;
 URL urlTmp;
 FilePath pathTmp;
 
 //Hu.Luo 2013-12-11 BG
 str endSlash(str _str)
 {
 return (strscan(_str, '\\',strlen(_str),-1)) ? _str : _str + '\\';
 }
 ;
 //Hu.Luo 2013-12-11 END
 
 while select ecoResProductImage
 order by ecoResProductImage.DefaultImage desc, ecoResProductImage.Usage
 join docuRef
 where docuRef.RecId == ecoResProductImage.RefRecId
 && docuRef.RefRecId == _inventTable.RecId
 && docuRef.RefTableId == _inventTable.TableId
 && docuRef.RefCompanyId == _inventTable.dataAreaId
 join TypeId from docuType
 where (docuType.TypeGroup == DocuTypeGroup::File
 || docuType.TypeGroup== DocuTypeGroup::Image
 || docuType.TypeGroup== DocuTypeGroup::URL)
 && docuType.TypeId == docuRef.TypeId
 {
 docuValue = docuRef.docuValue();
 if (docuValue.File)
 {
 DocuFileWatchDog::create();
 url = DocuActionFile::saveTempFile(docuRef);
 }
 else
 {
 url = docuRef.completeFilename();
 con = WinAPI::findFirstFile(url);
 if (!conpeek(con, 2) && conpeek(con, 1) == -1)
 continue; // find next
 
 //Hu.Luo 2013-12-11 BG
 //Copy to IE cache folder via windows API
 pathTmp = endSlash(WinAPI::getFolderPath(#CSIDL_INTERNET_CACHE));
 urlTmp = docuRef.completeFilename(pathTmp);
 
 try
 {
 WinAPI::copyFile(url,urlTmp,true);
 }
 catch(Exception::Error)
 {
 return containerNull;
 }
 
 url = urlTmp;
 //Hu.Luo 2013-12-11 END
 }
 permission = new FileIOPermission(url,"r");
 permission.assert();
 binData = new BinData();
 binData.loadFile(url);

 return binData.getData();
 }

 return containerNull;
}

本文固定链接: http://www.erpgolive.com/archives/291 | 我心依旧

该日志由 虎哥 于2016年12月06日发表在 开发 分类下,
原创文章转载请注明: X++ 查找产品的图片 | 我心依旧

报歉!评论已关闭.