Custom BPM For Revision and Approve under Engineering Workbench

Good night E10 world,

I need to write a code to check if the operation its Final Operation and its Stock Part and Auto Receive its not check then raise an message “Please this its stock part, please check Auto Receive”. This need to be happen when we do a Action – Valida Bill or Approve
I write this custom code but its not something right there because not work and I know Ion the right business object for Validate Bill Erp.EngWorkBench.ValidateBill

Here its the code:

foreach(var eco in (from ecorow in ttECORev
where (string.Equals(ecorow.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase))
select ecorow ))
{
foreach(var pp in ( from pprow in Db.PartPlant
where (eco.Company == pprow.Company)&& (pprow.PartNum == eco.PartNum) && (pprow.Plant == eco.Plant)
select pprow ))
{
foreach(var eo in ( from eoprrow in ttECOOpr
where (eco.Company == eoprrow.Company) && (eco.GroupID == eoprrow.GroupID) && (eco.RevisionNum == eoprrow.RevisionNum) && (eco.PartNum == eoprrow.PartNum)
select eoprrow ))
{
if (pp.NonStock == false && eo.AutoReceive == false && eo.FinalOpr == true)

InfoMessage.Publish("This part is a Stock Part Number and the final operation needs to be set for AutoReceive to stock, please fix the configuration and try approving again",Ice.Common.BusinessObjectMessageType.Error,Ice.Bpm.InfoMessageDisplayMode.Individual);
}}}