Hi All, I can’t seem to figure out how to get this to work assuming I even can. I have a UD_Field that gets updated by BPM with custom code to list open operations by OpCode. There is no sort and when looking at it it’s just random. I want the list to display the operation code but in the proper open operation sequence. 10, 20, 30 40 and so on. But to dispaly as Laser, Weld, Machine, OutSide Sub.
This is what I have…
foreach (var iJobOper in
(from rJobOper in ttJobOper
select rJobOper)
) {
var xJobOper = iJobOper;
foreach (var iJobAsmbl in
(from rJobAsmbl in Db.JobAsmbl
where string.Compare(rJobAsmbl.Company, xJobOper.Company, true) == 0
&& string.Compare(rJobAsmbl.JobNum, xJobOper.JobNum, true) == 0
&& rJobAsmbl.AssemblySeq == xJobOper.AssemblySeq
select rJobAsmbl)
) {
var dbJobAsmbl = iJobAsmbl;
var xOpCode_List = "";
foreach (var idbJobOper in
(from rdbJobOper in Db.JobOper
where string.Compare(rdbJobOper.Company, dbJobAsmbl.Company, true) == 0
&& string.Compare(rdbJobOper.JobNum, dbJobAsmbl.JobNum, true) == 0
&& rdbJobOper.AssemblySeq == dbJobAsmbl.AssemblySeq
&& rdbJobOper.JobComplete == false
&& rdbJobOper.OpComplete == false
orderby xJobOper.AssemblySeq, rdbJobOper.OprSeq
select rdbJobOper)
) {
var dbJobOper = idbJobOper;
if (xOpCode_List == "")
xOpCode_List = dbJobOper.OpCode;
else
xOpCode_List = xOpCode_List + ", " + dbJobOper.OpCode;
}
dbJobAsmbl.OpenOp_c = xOpCode_List;
}
}
EDIT: I wrapped your code in grave accents to highlight it correctly, so I can read it… Details are in the reply dialog before you type.
I can’t seem to figure out where to get the orderby placed. I’ve tried a few places and it doesn’t take it. Not sure what C# linq is. I’m not a programmer, self-taught.
You want it ordered by OprSeq, but listing only the OpCode? It looks like you’re already sorting by OprSeq in your rdbJobOper query. It’s not coming through in that order?
When an operation get’s completed or any change made to JobOper table, it writes the list of open operations to OpenOp_C field. This field is then used on dashboards for production to reivew jobs and they can see what operations by OpCode are still open. It shows the open Ops, just not putting them in any order when you view on dashboard they are random. Listing op 10, 20 and so on doesn’t help determine if it’s getting machined next or need to go for outside sub for example.
For my jobs it seems to get the correct ordering, but they are fairly simple. I took your routine and made as few changes as possible (rowmod was changed, so it did not run twice) and one I made closer to how I would write it and both produced the same list.
Can you add the write lines or use the below to see if your data somehow does not get ordered.
Since this is on a DD and is going to get hit a lot, I would bring all of the JobOpers records and only the fields needed from the Db once and then iterate that to make the list.
I added the comment at the top because I can’t stand seeing code in the action pane.
The start and end show when the routine begins and ends. The list shows me in the severlog what is happening in the code.
/* calc open ops */
Ice.Diagnostics.Log.WriteEntry("Start Orig Calc");
foreach (var iJobOper in
(from rJobOper in ttJobOper where !rJobOper.Unchanged()
select rJobOper)
) {
var xJobOper = iJobOper;
foreach (var iJobAsmbl in
(from rJobAsmbl in Db.JobAsmbl
where string.Compare(rJobAsmbl.Company, xJobOper.Company, true) == 0
&& string.Compare(rJobAsmbl.JobNum, xJobOper.JobNum, true) == 0
&& rJobAsmbl.AssemblySeq == xJobOper.AssemblySeq
select rJobAsmbl)
) {
var dbJobAsmbl = iJobAsmbl;
var xOpCode_List = "";
foreach (var idbJobOper in
(from rdbJobOper in Db.JobOper
where string.Compare(rdbJobOper.Company, dbJobAsmbl.Company, true) == 0
&& string.Compare(rdbJobOper.JobNum, dbJobAsmbl.JobNum, true) == 0
&& rdbJobOper.AssemblySeq == dbJobAsmbl.AssemblySeq
&& rdbJobOper.JobComplete == false
&& rdbJobOper.OpComplete == false
orderby xJobOper.AssemblySeq, rdbJobOper.OprSeq
select rdbJobOper)
) {
var dbJobOper = idbJobOper;
if (xOpCode_List == "")
xOpCode_List = dbJobOper.OpCode;
else
xOpCode_List = xOpCode_List + ", " + dbJobOper.OpCode;
Ice.Diagnostics.Log.WriteEntry($"OList {idbJobOper.OprSeq}-{idbJobOper.OpCode} {idbJobOper.QtyCompleted:0}");
}
dbJobAsmbl.Character02 = xOpCode_List;
Ice.Diagnostics.Log.WriteEntry($"OList {xOpCode_List}");
}
}
Ice.Diagnostics.Log.WriteEntry("Exit Orig Calc");