Get Item Image in WHS Mobile APP base on Unit
I have a requirement in which user want to see the item images based on unit wise
for that what i did i customize this form and add unit id(DSTUOM field name in table) their as discussed in Screenshot
than whad i did
create extention of this classEcoResProductImage
which code is
[ExtensionOf(tableStr(EcoResProductImage))]
final class EcoResProductImage_DSTWMSIntegration_Extension
{
protected static ImageReference getImageFrom2Records(Common _firstRecord, Common _secondRecord, EcoResProductImageSize _ecoResProductImageSize)// = EcoResProductImageSize::Normal)
{
ImageReference ImageReferenceLocal,ImageReferenceTmp;
InventTable InventTableLocal;
DSTWMSItemImageTmp DSTWMSItemImageTmpLocal,DSTWMSItemImageTmpLocalV2;
ImageReferenceLocal = next getImageFrom2Records(_firstRecord,_secondRecord,_ecoResProductImageSize);
if(tableNum(InventTable) == _firstRecord.TableId )
{
select firstonly InventTableLocal
where InventTableLocal.RecId == _firstRecord.RecId;
DSTWMSItemImageTmpLocal = DSTWMSItemImageTmp::find(InventTableLocal.ItemId,curUserId());
if(DSTWMSItemImageTmpLocal)
{
ImageReferenceTmp = EcoResProductImage::getImageFrom2RecordsV2_DST(_firstRecord, _secondRecord,DSTWMSItemImageTmpLocal,_ecoResProductImageSize);
if(ImageReferenceTmp != EcoResProductImage::getDummyImage_DST())
{
ImageReferenceLocal = ImageReferenceTmp;
}
//delete_from DSTWMSItemImageTmpLocalV2
// where DSTWMSItemImageTmpLocalV2.RecId == DSTWMSItemImageTmpLocal.RecId;
}
}
return ImageReferenceLocal;
}
Public static ImageReference getImageFrom2RecordsV2_DST(Common _firstRecord, Common _secondRecord, DSTWMSItemImageTmp _DSTWMSItemImageTmp, EcoResProductImageSize _ecoResProductImageSize = EcoResProductImageSize::Normal)
{
TableId firstTableId = DocuRef::GetRootTableID(_firstRecord.TableId);
TableId secondTableId = DocuRef::GetRootTableID(_secondRecord.TableId);
DocuRef docuRef;
DocuValue docuValue;
EcoResProductImage ecoResProductImage;
DocuRef docuRefRow;
EcoResProductImage ecoResProductImageRow;
while select ecoResProductImage
where ecoResProductImage.DSTUOM == _DSTWMSItemImageTmp.UOM
join docuRef
where
docuRef.RecId == ecoResProductImage.RefRecId
&& ((docuRef.RefTableId == firstTableId
&& docuRef.RefRecId == _firstRecord.RecId
&& docuRef.RefCompanyId == _firstRecord.DataAreaId)
||
(docuRef.RefTableId == secondTableId
&& docuRef.RefRecId == _secondRecord.RecId
&& docuRef.RefCompanyId == _secondRecord.DataAreaId)
)
exists join docuValue
where
docuValue.RecId == docuRef.ValueRecId
{
docuRefRow.data(docuRef);
ecoResProductImageRow.data(ecoResProductImage);
if (docuRef.RefTableId == firstTableId)
{
// We loop until we hit the first table (in case the first table is selected as the second row).
// If we do not hit the first table, then second table row is used.
// This logic could also be replaced by ordering
// (depending on the order of firstTableId and secondTableId we would order our query,
// but it would result in copying the query code or building it dynamically, which is not worth it).
break;
}
}
if (ecoResProductImageRow)
{
return EcoResProductImage::getImageUrlReference_DST(docuRefRow, ecoResProductImageRow, _ecoResProductImageSize);
}
return EcoResProductImage::getDummyImage_DST();
}
Public static ImageReference getImageUrlReference_DST(DocuRef _docuRef, ecoResProductImage _ecoResProductImage, EcoResProductImageSize _ecoResProductImageSize)
{
switch (_ecoResProductImageSize)
{
case EcoResProductImageSize::Normal:
str displayUrl = DocumentManagement::getAttachmentPublicUrl(_docuRef);
return ImageReference::constructForUrl(displayUrl);
case EcoResProductImageSize::Thumbnail:
if (conLen(_ecoResProductImage.MediumSize) > 0)
{
Image mediumImage = new Image();
mediumImage.setData(_ecoResProductImage.MediumSize);
return ImageReference::constructForImage(mediumImage);
}
return EcoResProductImage::getDummyImage_DST();
}
throw error(error::wrongUseOfFunction(funcName()));
}
public static ImageReference getDummyImage_DST()
{
ImageReference imageRef = ImageReference::constructForAotResource(resourceStr(CatNoImageAvailable48x48));
return imageRef;
}
}
than customize this class WHSMobileAppServiceXMLTranslator
as
i create entry in separate table when user click enter item id i pich the item id and their unit store it in the table and delele that data in next request when user again enter the item id
as
i create entry in separate table when user click enter item id i pich the item id and their unit store it in the table and delele that data in next request when user again enter the item id
[ExtensionOf(classStr(WHSMobileAppServiceXMLTranslator))]
final class WHSMobileAppServiceXMLTranslator_DSTWMSIntegration_Extension
{
#WHSRF
#WHSWorkExecuteControlElements
public XML createXML(container _con)
{
XML result;
UnitOfMeasureSymbol dstItemUnitId,dstItemUnitIdselected;
str ItemIdLoc;
DSTWMSItemImageTmp DSTWMSItemImageTmp,DSTWMSItemImageTmpLocalV2;
WHSRFPassthrough locPass = WHSRFPassthrough::create(conPeek(_con, 2));
dstItemUnitIdselected = this.getControlDataFromContainer_DST(_con,#UOM,#selected);
dstItemUnitId = this.getControlDataFromContainer_DST(_con,#UOM);
ItemIdLoc = this.getControlDataFromContainer_DST(_con,#ItemId);
DSTWMSItemImageTmp.ItemId = ItemIdLoc;
if(dstItemUnitIdselected)
{
DSTWMSItemImageTmp.UOM = dstItemUnitIdselected;
}
else
{
dstItemUnitId = conPeek(list2Con(strSplit(dstItemUnitId,'||')),1);
DSTWMSItemImageTmp.UOM = dstItemUnitId;
}
if(DSTWMSItemImageTmp.ItemId && DSTWMSItemImageTmp.UOM)
{
DSTWMSItemImageTmp.UserId = locPass.lookupStr(#UserId);
delete_from DSTWMSItemImageTmpLocalV2
where DSTWMSItemImageTmpLocalV2.UserId == DSTWMSItemImageTmp.UserId
//&& DSTWMSItemImageTmpLocalV2.UOM == DSTWMSItemImageTmp.UOM
&& DSTWMSItemImageTmpLocalV2.ItemId == DSTWMSItemImageTmp.ItemId;
DSTWMSItemImageTmp.insert();
//SysGlobalCache::construct().flush();
//SysFlushAOD::main(new Args());
}
result = next createXML(_con);
return result;
}
Public str getControlDataFromContainer_DST(container _displayCon, str _controlName,int _Postion = #Data)
{
int controlIndex = this.indexOfBuildControlFromContainer_DST(_displayCon, _controlName);
container control;
str ret = '';
if (controlIndex > 0)
{
control = conPeek(_displayCon, controlIndex);
ret = conPeek(control, _Postion);
}
return ret;
}
public int indexOfBuildControlFromContainer_DST(container _displayCon, str _controlName)
{
int ret;
int counter;
container control;
str value;
for (counter = 1; counter <= conLen(_displayCon); counter++)
{
control = conPeek(_displayCon, counter);
value = strFmt("%1", conPeek(control, #name));
if (value == _controlName)
{
ret = counter;
break;
}
}
return ret;
}
}
this is main work we need to customize this class
WHSMobileAppAttachedImageDetails
In this method what i did i add the unit in the return string
this is main work we need to customize this class
WHSMobileAppAttachedImageDetails
In this method what i did i add the unit in the return string
before customizing this method xml control value of image is
after that control value is
_ImageInfo | : | RTAL|Product|ItemId:DPID0000026 |
_ImageInfo | : | RTAL|Product|ItemId:DPID0000026|PCs |
[ExtensionOf(classStr(WHSMobileAppAttachedImageDetails))]
final class WHSMobileAppAttachedImageDetails_DSTWMSIntegration_Extension
{
public str serialize()
{
str ImageSerialize = next serialize();
str ImageIdentifier = this.parmImageIdentifier();
str modifiedString;
// Remove "ItemId:" prefix original dtring like "ItemId:DPID0000026"
modifiedString = strReplace(ImageIdentifier, "ItemId:", "");
DSTWMSItemImageTmp DSTWMSItemImageTmpLocal = DSTWMSItemImageTmp::find(modifiedString,curUserId());
char Separator = '|';
if(DSTWMSItemImageTmpLocal)
{
ImageSerialize += Separator + DSTWMSItemImageTmpLocal.UOM ;
}
return ImageSerialize;
}
}
Comments
Post a Comment