Process Manager Instance Search Return Invalid Object
Posted: Fri Sep 24, 2021 11:11 am
Good Morning.
I'm Attempting to create a program that cancels and restarts all process instances that are stuck.
The current built in system is malfunctioning.
In dev I can access the instances and cancel / restart them with the following code:
However in prod, I run into memory issues because of the size of our system.
I tried taking the orders search method which works just fine:
And applied it to instances (They are both IQuerable)
But this returned an error:
If I change the value from "IProcessInstanceInfo" to "Var" it returns an un-useable object
( Also needed to remove the .First() as well)
Finally, I came across a post using a seach object which I also attempted, but without avail.
In the above example I can not "search" the instances as the example in the following example:
https://devforum.softprocorp.com/viewto ... ject#p4627
In summary, the same functionally for the same Iquerable Orders was not applicable on Process Instances.
Is there another way I can search / filter?
Or am I able to iterate over a certain number of instances when querying for all items?
(processManager.Instances)
I'm Attempting to create a program that cancels and restarts all process instances that are stuck.
The current built in system is malfunctioning.
In dev I can access the instances and cancel / restart them with the following code:
Code: Select all
foreach (IProcessInstanceInfo instance in processMgr.Instances)
{ // Cancel // Restart}
I tried taking the orders search method which works just fine:
Code: Select all
IOrderStore os = ss.GetService<IOrderStore>();
IOrderInfo search = os.Orders.Where(t => t.Number == orderNumber).First();
Code: Select all
IProcessManager processMgr = ss.GetService<IProcessManager>();
IProcessInstanceInfo idleInstances = processMgr.Instances.Where(t => t.Status.ToString() == "Idle").First();
Code: Select all
System.InvalidOperationException:[b] Operation is not valid due to the current state of the object.[/b]
at SoftPro.ClientModel.Linq.ExpressionTreeHelpers.GetMemberExpressionFromBinaryExpression(BinaryExpression be)
at SoftPro.ClientModel.Linq.CriteriaBuilder`2.WhereTranslator.VisitBinary(BinaryExpression b)
at SoftPro.ClientModel.Linq.ExpressionVisitor.Visit(Expression exp)
at SoftPro.ClientModel.Linq.CriteriaBuilder`2.WhereTranslator.Translate(CriteriaBuilder`2 builder, Expression expression)
at SoftPro.ClientModel.Linq.CriteriaBuilder`2.TranslateWhereExpression(Expression whereExpression)
at SoftPro.ClientModel.Linq.CriteriaBuilder`2.HandleWhereExpression(Expression expression)
at SoftPro.ClientModel.Linq.CriteriaBuilder`2.Build(Expression& expression)
at SoftPro.ClientModel.Linq.CriteriaQueryProvider`2.Execute(Expression expression, Boolean enumerable)
at SoftPro.ClientModel.Linq.CriteriaQueryProvider`2.Execute[TResult](Expression expression)
at SoftPro.ClientModel.Linq.CriteriaQuery`2.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Automation_Queue_Manager.IdleProcesses.GetIdleProcesses(SelectServer ss) in C:\_C# Projects\Automation Queue Manager\Automation Queue Manager\IdleProcesses.cs:line 26
( Also needed to remove the .First() as well)
Code: Select all
var idleInstances = processMgr.Instances.Where(t => t.Status.ToString() == "Idle");
Console.WriteLine(idleInstances);
// Returns:
//SoftPro.ClientModel.Linq.CriteriaQuery`2[SoftPro.Select.Client.Automation.IProcessInstanceInfo,SoftPro.Select.Client.Automation.AutomationCriteria]
Finally, I came across a post using a seach object which I also attempted, but without avail.
Code: Select all
var searchObjt = processMgr.NewProcessInstanceSearch(t => t.Status.ToString() == "Canceled");
var idleProcesses = processMgr.Instances.Search(searchObjt).ToList();
https://devforum.softprocorp.com/viewto ... ject#p4627
In summary, the same functionally for the same Iquerable Orders was not applicable on Process Instances.
Is there another way I can search / filter?
Or am I able to iterate over a certain number of instances when querying for all items?
(processManager.Instances)