I have a Pre-Processing BPM for Labor.Update which is acting a bit odd. I have posted the full code below for reference. You will notice that there are 9 InfoMessage.Publish("#"); and 1 ‘if’ statement (nearer to the bottom, after InfoMessage.Publish(“8”)
InfoMessage.Publish("1"); // First thing that should happen when this fires is this box appearing
Erp.Tables.JobOper JobOper; // Need to be sure this is available to us
InfoMessage.Publish("2"); // Now show this box
tooMany = false; // default this to False, just in case it stuck around for some reason
//prevOpQtyComplete = 0;
//thisOpQtyComplete = 0;
//totalQtyComplete = 0;
var ttLDtl = ttLaborDtl.Where(x => x.RowMod != "").FirstOrDefault(); // Lets get this transaction info
InfoMessage.Publish("3"); // Now I should see this box
// This seems to work as expected, allowing me to use JobOper in the next few sections
JobOper = (from JobOper_Row in Db.JobOper
where JobOper_Row.Company == Session.CompanyID
&& JobOper_Row.JobNum == ttLDtl.JobNum
&& JobOper_Row.OprSeq <= ttLDtl.OprSeq
select JobOper_Row).FirstOrDefault();
InfoMessage.Publish("4"); // Followed by this one
// This correctly sets the prevOpQtyComplete to the Qty Complete in the previous op
prevOpQtyComplete = (from JobOper_Row in Db.JobOper where JobOper_Row.JobNum == ttLDtl.JobNum
&& JobOper_Row.OprSeq < ((from JobOper_Row0 in Db.JobOper where JobOper_Row0.JobNum == ttLDtl.JobNum
orderby JobOper_Row0.OprSeq descending select new {
JobOper_Row0.OprSeq}).Take(1).FirstOrDefault().OprSeq)
orderby JobOper_Row.OprSeq descending
select JobOper_Row.QtyCompleted).Take(1).Sum();
InfoMessage.Publish("5"); // ...and this one
// This correctly sets thisOpQtyComplete to the Qty Complete for this op (excluding the current transaction)
thisOpQtyComplete = (from JobOper_Row in Db.JobOper where JobOper_Row.JobNum == ttLDtl.JobNum
&& JobOper_Row.OprSeq == ttLDtl.OprSeq
orderby JobOper_Row.OprSeq descending
select JobOper_Row.QtyCompleted).Take(1).FirstOrDefault();
InfoMessage.Publish("6"); // You know what I am going to say
// Add the value of thisOpQtyComplete with ttLDtl.LaborQty to get the total completed for this op (including current transaction)
totalQtyComplete = thisOpQtyComplete + ttLDtl.LaborQty;
InfoMessage.Publish("7"); //Why am I bothering to enter these comments still?
InfoMessage.Publish(string.Format("Previous Operation Completed: {1}{0}This Op Completion: {2}{0}Total Completion: {3}", Environment.NewLine, prevOpQtyComplete, ttLDtl.LaborQty, totalQtyComplete));
InfoMessage.Publish("8"); // Seriously, nobody is going to read this but me!
// THIS SEEMS TO BE CAUSING AN ISSUE OF SOME SORT ISSUE
// Basically, if totalQtyComplete is more than what the previous operation
// has made available (prevOpQtyComplete), then set tooMany to true, else false.
// This is used in a conditional check in the next step of the BPM
if (totalQtyComplete > prevOpQtyComplete) { tooMany = true; } else { tooMany = false; }
InfoMessage.Publish("9"); // F-it...I'm this far...I may as well do this one too
InfoMessage.Publish(string.Format("You are able to close this job because there have been {0} completed parts in the previous operation, and you are completing less than that, with a total of {1}", prevOpQtyComplete.ToString(), ttLDtl.LaborQty));
Now if I put a value of 10 into LaborDtl.LaborQty when closing out the op, I will see all 9 message boxes appear, and the BPM continues on as it should. This is because the value of totalQtyComplete would not be greater than what is provided from the previous operation.
However, if I put in a value that would cause totalQtyComplete to be greater than the previous operation complete, none of those 9 message boxes appear, and the BPM powers through the rest of the steps.
Is there something with how BPM’s work that would stop the InfoMessage’s from appearing?
