Can I get the steps inside workflow only? - filenet-process-engine

I am trying to get all the steps inside a particular workflow ONLY in FileNet Process Engine. But no luck getting it. I am not sure if what I am trying to achieve is available in the API because I looked for days but cannot see it.
Here is my code
String workflowName = "Sample workflow 1";
String[] workClassNames = myPESession.fetchWorkClassNames(true);
for (int i = 0; i < workClassNames.length; i++) {
System.out.println(workClassNames[i]);
}
// Launch Workflow VWStepElement
VWStepElement stepElement = myPESession.createWorkflow(workflowName);
System.out.println(stepElement.getWorkflowName());
System.out.println(stepElement.getSubject());
System.out.println(stepElement.getComment());
System.out.println(stepElement.getStepDescription());
System.out.println("Parameters");
String[] a = stepElement.getParameterNames();
for (int i = 0; i < a.length; i++)
{
if (a[i] != null)
{
Object _parameterValue = stepElement.getParameterValue(a[i]);
System.out.println("\t" + a[i] + "=" + _parameterValue);
}
}

It is static part that is the same for any instance of particular workflow. Thus you should obtain it from the workflow definition, not the running workflow instance.
You should start with VWWorkflowDefinition, iterate through each map obtained using getMaps() and then obtain the steps from VWMapDefinition using getSteps().

Try this
VWWorkflowDefinition defn = peSession.fetchWorkflowDefinition(workSpaceId, workflowIdentifier, convert);
VWMapDefinition vwMapDefinition = defn.getMap(workflowname);
VWMapNode[] mapNode = vwMapDefinition.getSteps()//Gets all of the steps contained in this map.
then iterate the mapNode.

Related

Game Maker Studio: DoSet :: Invalid comparison type

___________________________________________
############################################################################################
FATAL ERROR in
action number 4
of Create Event
for object eng_Global:
DoSet :: Invalid comparison type
at gml_Script_Data_Load (line 1) - ///Data_Load()
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_Data_Load (line 1)
called from - gml_Object_eng_Global_CreateEvent_4 (line 60) - Data_Load();
I get this error on a comment, not an actual if statement, I can't bypass this without commenting out Data_Load(), which is what loads the users' data.
I recently updated to version 1.4.1567, maybe that is a bug in this version.
I should state that "Connected" and "Guest" variables are both integers (boolean) and do not get set to string at any point in the code.
Here is the Data_Load() script:
///Data_Load()
if (Connected && !Guest) {
ini_open(User_Name+"_NSD_Temp.ini");
// Base Statistics
Level = ini_read_real("Statistics","Level",Level);
Exp_Total = ini_read_real("Statistics","Experience_Total",Exp_Total);
Exp = ini_read_real("Statistics","Experience",Exp);
Exp_Left = ini_read_real("Statistics","Experience_Left",Exp_Left);
Exp_Max = ceil(Level*5);
Gold = ini_read_real("Statistics","Gold",Gold);
Gold_Total = ini_read_real("Statistics","Gold_Total",Gold_Total);
Karma = ini_read_real("Statistics","Karma",Karma);
Karma_Total = ini_read_real("Statistics","Karma_Total",Karma_Total);
Highscore = ini_read_real("Statistics","Highscore",Highscore);
Weapons_Inv_Length = ini_read_real("Statistics","Weapons_Inv_Length",Weapons_Inv_Length);
Stones_Inv_Length = ini_read_real("Statistics","Stones_Inv_Length",Stones_Inv_Length);
Stone_Slots_Owned = ini_read_real("Statistics","Stones_Slots_Owned",Stones_Slots_Owned);
// Game
Ninja_Name = ini_read_string("Game","Ninja_Name",Ninja_Name);
Ninja_Level = ini_read_real("Game","Ninja_Level",Ninja_Level);
Ninja_Health = ini_read_real("Game","Ninja_Health",Ninja_Health);
Ninja_Health_Max = ini_read_real("Game","Ninja_Health_Max",Ninja_Health_Max);
Ninja_Health_Regen_Upgrade = ini_read_real("Game","Ninja_Health_Regen_Upgrade",Ninja_Health_Regen_Upgrade);
Ninja_Health_Regen = Ninja_Health_Base*(Ninja_Health_Regen_Upgrade)/room_speed;
Ninja_Weapon = ini_read_real("Game","Ninja_Weapon",Ninja_Weapon);
Ninja_Colour = ini_read_real("Game","Ninja_Colour",Ninja_Colour);
Ninja_Power = ini_read_real("Game","Ninja_Power",Ninja_Power);
Ninja_Max_Speed = ini_read_real("Game","Ninja_Max_Speed",Ninja_Max_Speed);
Ninja_Attack_Speed = ini_read_real("Game","Ninja_Attack_Speed",Ninja_Attack_Speed);
// Weapons Inventory
for (i=0; i<Weapons_Inv_Length; i++) {
Weapons_Inv[i,0] = i;
Weapons_Inv[i,1] = ini_read_real("Weapons Inventory","Inv_Slot_"+string(i),0);
Weapons[Weapons_Inv[i,1],5] = ini_read_real("Weapons Inventory","Inv_Slot_"+string(i)+"_Owned",Weapons[Weapons_Inv[i,1],5]);
}
// Stones Inventory
for (i=0; i<Stones_Inv_Length; i++) {
Stones_Inv[i,0] = i;
Stones_Inv[i,1] = ini_read_real("Stones Inventory","Inv_Slot_"+string(i),0);
Stones[Stones_Inv[i,1],5] = ini_read_real("Stones Inventory","Inv_Slot_"+string(i)+"_Owned",Stones[Stones_Inv[i,1],5]);
}
// Equipped Stones
for (i=0; i<Stone_Slots_Owned; i++) {
Stone_Slots[i,0] = i;
Stone_Slots[i,1] = ini_read_real("Stones Equipped","Slot_"+string(i),Stone_Slots[i,1]);
}
// Costume Colours
for (i=0; i<array_height_2d(Colours); i++) {
Colours[i,5] = ini_read_real("Costume Colours",Colours[i,1],Colours[i,5]);
}
// Stats
Stat_Clouds_Clicked = ini_read_real("Stats","Clouds_Clicked",Stat_Clouds_Clicked);
Stat_Stars_Clicked = ini_read_real("Stats","Stars_Clicked",Stat_Stars_Clicked);
// Options
SoundFX = ini_read_real("Options","SoundFX",SoundFX);
// Version
Save_Version = ini_read_string("Version","Current",Save_Version);
// Resets
ForceResets = ini_read_string("External","Force_Resets",Force_Resets);
ini_close();
if (ForceResets != Force_Resets) {
Data_Erase();
}
Data_Submit();
} // If Connected & Not Guest
GM's compiler is always weird about those line errors. It often doesn't count blank lines as actual lines.
If you adjust for that issue, the real line of code that is throwing the error is this:
if (ForceResets != Force_Resets) {
Maybe it doesn't like that you're basically asking "If something is not equal to itself", which hardly makes sense. That statement will always evaluate to false, so you should probably remove it.
Seeing as you don't declare var on any of these variables, then you're manipulating the variables on the instance that called this script. If there's somehow a ForceResets script variable, and a ForceResets variable on the calling instance, then this whole thing might be a naming issue. I'm also making this assuming because you called:
ForceResets = ini_read_string("External","Force_Resets",Force_Resets);
Where that third parameter isn't declared anywhere in this script.
All in all, I'd say that you need to clean this script up a little.
Pro Tip: Use for(var i = 0; ... instead of for(i = 0 99% of the time. Otherwise you're leaving this instance with an i variable that it will never use.

Adobe AIR Interface Name Format

Using this code:
results = NetworkInfo.networkInfo.findInterfaces();
for (var i:int =0; i<results.length; i++) {
ethName = ethName + results[i].name
}
I get this result:
{E9742B69-3B80-471A-AF41-B38753474834}
I thought I'd get either the hardware information for the interface or the name. What is this? Anyone have a similar result?
Thanks!

Flex 3: Using array item value as an objects name

If I have a list of items in an array that represent the names of modules:
var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");
and I want to go through each one of these and call a function within each instance of each module, how would I go about doing so. So far, I have the following:
private function changeStartViewDate(numDays:Number):void
{
startViewDate = rightDate(startViewDate.getMonth(), startViewDate.getDate() + numDays, startViewDate.getFullYear());
getDateInfo();
determineCalendarWeek();
var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");
for (var i:int = 0; i < wholeProject.length; i++)
{
wholeProject[i].moveProject(Number((1-2) * numDays));
}
for (i = 0; i < phaseNames.length; i++)
{
for (var j:int = 0; j < [phaseNames[i]].length; j++)
{
[phaseNames[i]].movePhase(Number((-1) * numDays));
}
}
}
But when I try to save it, I get the following error:
1084: Syntax Error: expecting identifier before dot.
It's telling me the error is on the following line:
[phaseNames[i]].movePhase(Number((-1) * numDays));
I tried doing something like the following, but it didn't work:
[phaseNames[i].movePhase(Number((-1) * numDays))];
The above attempt of trying to figure this out gave me the following error
1064: Invalid metadata.
Any help would be appreciated.
I am going to assume that:
Each value of your phaseNames array references an actual instance of some other class [and not the name of the class]
The instance defined in the phaseNames array is a child of the current class.
You should be able to do something like this:
var childName = phaseNames[0];
var myChild : myObjectType = this[childName];
// then call function
myChild.doStuff();
This approach is not dissimilar to what you have; I'm just doing it in more lines. I'm also adding the this keyword to access the child.
I bet if you tried this, directly, it would work:
this[phaseNames[i]].movePhase(Number((-1) * numDays));
I have to wonder why you haven't created an array of all the instances instead of an array of all the variables names that point to the instances.

checkboxlist selection issue

There are 5 goals and 5 employees. Each goal can be assigned to any number of these 5 employees. So I have 5 CheckBoxLists for each of the goals, each CheckBoxList having the names of these 5 employees as items.
I want to retrieve from the database which employees have been assigned which goals. I have the following piece of code:
List<CheckBoxList> checkboxlists = new List<CheckBoxList>();
checkboxlists.Add(CheckBoxList1);
checkboxlists.Add(CheckBoxList2);
checkboxlists.Add(CheckBoxList3);
checkboxlists.Add(CheckBoxList4);
checkboxlists.Add(CheckBoxList5);
for (int z = 1; z <= checkboxlists.Count; z++)
{
SqlCommand check = new SqlCommand("SELECT ISGoal1, ISGoal2,ISGoal3, ISGoal4,ISGoal5 FROM PRM2011_EMPLOYEE_GOAL WHERE EmployeeID = '" + employeeid[z - 1] + "'", con);
SqlDataReader y = check.ExecuteReader();
y.Read();
for (int j = 1; j <= 5; j++)
{
if (null != y && y.HasRows)
{
string yes_or_no = y["ISGoal" + j].ToString().Trim();
if (yes_or_no == "Yes")
{
checkboxlists[j-1].Items[z-1].Selected = true;
}
//else checkboxlists[j - 1].Items[z - 1].Selected = false;
}
}
y.Close();
}
My problem is that even if I select one goal for an employee, all the checkboxes corresponding to that particular employee get selected. Why is this happening?
Correspondingly, if I comment out the else portion in the code posted, and if any of the goals are not selected, then all the checkboxes corresponding to that employee goes unselected. Please help.
A few thoughts:
Have your for loops go from 0 to less than checkboxlists.Count and from 0 to less than 5. That way you can avoid having to deal with all the subtractions everywhere.
On the line checkboxlists[j-1].Items[z-1].Selected = true, shouldn't it be checkboxlists[z-1].Items[j-1].Selected = true since I am assuming you are using z to iterate over your CheckBoxLists.
Its late here, so my brain may be a bit fuzzy, but it seems that #2 could be your issue. Give those thoughts a shot and I will follow up with you if you are still having issues.
You have many issues in your code I'll tell you the main problem and then I'll list the other flaws of your code.
What's causing this is:
the existence of the method y.Read(); out side of the for loop.
since the function of Read(); is to read the next row in the database. so basically your code reads the first value, Let's assume the value will be "Yes" so it will cause the ListBox to check the employee and instead of calling the y.Read(); again so it moves to the next row it DOES NOT! .. so the value is kept "Yes" and hense all the CheckBoxes in the List will be checked.
The Solution:
It's as simple as just moving the y.Read(); from out side the loop into it.
Like this:
List<CheckBoxList> checkboxlists = new List<CheckBoxList>();
checkboxlists.Add(CheckBoxList1);
checkboxlists.Add(CheckBoxList2);
checkboxlists.Add(CheckBoxList3);
checkboxlists.Add(CheckBoxList4);
checkboxlists.Add(CheckBoxList5);
for (int z = 1; z <= checkboxlists.Count; z++)
{
SqlCommand check = new SqlCommand("SELECT ISGoal1, ISGoal2,ISGoal3, ISGoal4,ISGoal5 FROM PRM2011_EMPLOYEE_GOAL WHERE EmployeeID = '" + employeeid[z - 1] + "'", con);
SqlDataReader y = check.ExecuteReader();
for (int j = 1; j <= 5; j++)
{
y.Read();
if (null != y && y.HasRows)
{
string yes_or_no = y["ISGoal" + j].ToString().Trim();
if (yes_or_no == "Yes")
{
checkboxlists[j-1].Items[z-1].Selected = true;
}
//else checkboxlists[j - 1].Items[z - 1].Selected = false;
}
}
y.Close();
}
Extra Notes on your code
First of all
You need to edit your SqlCommand to use SqlParameters
SqlCommand check = new SqlCommand("SELECT ISGoal1, ISGoal2,ISGoal3, ISGoal4,ISGoal5 FROM PRM2011_EMPLOYEE_GOAL WHERE EmployeeID = #EmpID", con);
check.Parameters.AddWithValue("#ImpID", employeeid[z - 1]);
Second
If you are trying to build a real application then this is a very bad practice. Even if you are not building this application for real I don't think this is the way to practice.
for (int j = 1; j <= 5; j++)
your Loop should look like this:
for (int j = 1; j <= checkboxlists.Count; j++)
Third
Using a string to represent a Yes/No value is a also a bad practice .. You should use for all your ISGoal columns database, the DataType BIT. and consequently you'll change the local variable's DateType in your C# code from string to bool.
Fourth
checkboxlists[j-1].Items[z-1].Selected = true;
You should switch as Ryan said, because z denotes to the CheckBoxLists and j denotes to the items of a given CheckBoxList
so it could be like this:
checkboxlists[z-1].Items[j-1].Selected = true;
N.B: I wasn't paying attention at first I thougth [z-1] is some kind of LINQ expression :D!! .. It's my fault but I mean I used to do this when I first started programming and I still couldn't recognize it .. It's not the best practice I think! .. my advice respect the used Zero-Based numbering.
Finally
You don't have to check everytime if y.Read(); is null or not. So I think this piece of code would make more sense and also hard coding the condition of the loop is a very bad practice, so we'll use a while loop and add local variable of type int, then we'll increment it within our loop code so you could use it to access the CheckBoxList items
int j = 1;
while (y.Read())
{
string yes_or_no = y["ISGoal" + j].ToString().Trim();
if (yes_or_no == "Yes")
{
checkboxlists[j-1].Items[z-1].Selected = true;
//use our counter "j" here
}
//else checkboxlists[j - 1].Items[z - 1].Selected = false;
//use our counter "j" here
j++;
}
..Good Luck ;)

ASP.NET StreamWriter - new line after x commas

I've got a JS array which is writing to a text file on the server using StreamWriter. This is the line that does it:
sw.WriteLine(Request.Form["seatsArray"]);
At the moment one line is being written out with the entire contents of the array on it. I want a new line to be written after every 5 commas. Example array:
BN,ST,A1,303,601,BN,ST,A2,303,621,BN,WC,A3,303,641,
Should output:
BN,ST,A1,303,601,
BN,ST,A2,303,621,
BN,WC,A3,303,641,
I know I could use a string replace but I only know how to make this output a new line after every comma, and not after a specified amount of commas.
How can I get this to happen?
Thanks!
Well, here's the simplest answer I can think of:
string[] bits = Request.Form["seatsArray"].Split(',');
for (int i = 0; i < bits.Length; i++)
{
sw.Write(bits[i]);
sw.Write(",");
if (i % 5 == 4)
{
sw.WriteLine();
}
}
It's not terribly elegant, but it'll get the job done, I believe.
You may want this afterwards to finish off the current line, if necessary:
if (bits[i].Length % 5 != 0)
{
sw.WriteLine();
}
I'm sure there are cleverer ways... but this is simple.
One question: are the values always three characters long? Because if so, you're basically just breaking the string up every 20 characters...
Something like:
var input = "BN,ST,A1,303,601,BN,ST,A2,303,621,BN,WC,A3,303,641,";
var splitted = input.Split(',');
var cols = 5;
var rows = splitted.Length / cols;
var arr = new string[rows, cols];
for (int row = 0; row < rows; row++)
for (int col = 0; col < cols; col++)
arr[row, col] = splitted[row * cols + col];
I will try find a more elegant solution. Properly with some functional-style over it.
Update: Just find out it is not actually what you needs. With this you get a 2D array with 3 rows and 5 columns.
This however will give you 3 lines. They do not have a ending ','. Do you want that? Do you always want to print it out? Or do you want to have access to the different lines?:
var splitted = input.Split(new [] { ','}, StringSplitOptions.RemoveEmptyEntries);
var lines = from item in splitted.Select((part, i) => new { part, i })
group item by item.i / 5 into g
select string.Join(",", g.Select(a => a.part));
Or by this rather large code. But I have often needed a "Chunk" method so it may be reusable. I do not know whether there is a build-in "Chunk" method - couldn't find it.
public static class LinqExtensions
{
public static IEnumerable<IList<T>> Chunks<T>(this IEnumerable<T> xs, int size)
{
int i = 0;
var curr = new List<T>();
foreach (var x in xs)
{
curr.Add(x);
if (++i % size == 0)
{
yield return curr;
curr = new List<T>();
}
}
}
}
Usage:
var lines = input.Split(',').Chunks(5).Select(list => string.Join(",", list));

Resources