Using System.Diagnostics.PerformanceCounterCategory.GetInstanceNames - vb.net

When I use System.Diagnostics.PerformanceCounterCategory.GetInstanceNames call, I always get 0 instances returned the first time. If I actually query for a counter value first (using perfmon) and then call GetInstanceNames, it works fine. Can someone provide some insight? Do I need to get a counter value first (in code) and then use the GetInstanceNames?

I found the answer. I added a call to System.Diagnostics.PerformanceCounterCategory.ReadCategory before trying GetInstances. That seems to fixed the issue I was seeing.

Related

Pentaho/PDI: Increment a value automatically by one if a load-job (within a metajob) fails

in PDI I've got the following structure
0_Metajob
1_Load_1
1_Load_2
1_SimpleEvaluation
1_Mail
As of now
1_Load_1 and 1_Load_2 are independent of each other. The second one will run, irrespective of the success of the first one. That is okay, I want it that way!
Issue
I want to have a counter that is incremented by one every time one of the single loads fails, i.e. in my example the counter can take the values 0, 1 or 2.
What do I need it for? Customer will receive a mail at the end of the metajob. The aforementioned value determines the subject of the mail, i.e. 0=everything fine, 1=so-so, 2=load totally failed!
Why not mailing within every single the Load-Job? I do that but without attaching the log-file because it is usually non-finished. Therefore the log-file is mailed with the mail that is sent when the Metajob is finished.
Tried
"Set a variable". Thought I can simply increment it with adding a one in the value field, i.e. "${VariableName}+1". Of course, this step is implementened within a fail path of each Load-Job.
However, it didn't work.
Would anyone mind helping me? I would appreciate that!
Set Variable doesn't do calculations, you'll need a Javascript step for that.
Fortunately, variables can be also be set within the Javascript step. This bit of code should go into each of the steps you put in place of the Set Variable steps:
var i = parseInt(parent_job.getVariable("Counter"),0);
i = i + 1;
parent_job.setVariable("Counter",i);
true;
This bit of code gets the variable "Counter" from the parent job and converts it to int, since all Pentaho variables are strings. Then it increments it and sets the job variable again. The "true" at the end is to ensure that the javascript step reports success to the main job.
IMPORTANT: This works roughly as you would expect in a Job. It will NOT in a transformation!

The specified RegistryOptions value is invalid

What im trying to do is write a key to the registry but im stepping from one problem to another, first permissions problem, now this..
This is the line of code.
If PNGchk.Checked = True Then
My.Computer.Registry.Users.CreateSubKey(UserSID & "\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice", True, Security.AccessControl.RegistryRights.FullControl).SetValue("Progid", "SIV.png", Microsoft.Win32.RegistryValueKind.String)
End If
You must have Option Strict Off for that code to even compile, so you might want to fix that to start with. Option Strict On would have flagged issues with that code right away. You should read the documentation or at least pay attention to Intellisense for that method because your second and third arguments make no sense. No overload that I can see has a Boolean parameter and if you want to use a RegistryRights value you do so within a RegistrySecurity object as far as I can see.
RegistryKeyPermissionCheck.ReadWriteSubTree worked for me.
Using clsid64 = view64.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice", RegistryKeyPermissionCheck.ReadWriteSubTree)
clsid64.SetValue("StubPath", "SIV.png")
clsid64.Close()
End Using

character manipulation?

the idea is to take a word and sub out all specified letters for another letter.
Any help on how to make this kind of function work?
The last array_push is not being called because you're returning before. Change it to:
array_push($stepsinchain, $subed);
return $subed;
Since $subed is never stored in the $stepsinchain array, due to the return being before, you're not able to access previous alternations.
array_push is also slower and not recommended when entering one element in an array. Instead, use
$stepsinchain[] = $subed;
It is also much faster as documented at http://www.php.net/manual/en/function.array-push.php#Hcom83388

Stimulsoft code based variables won't show their value

I´m losing my mind here, I've tried every example I've found online and still can't get it to work, this is the way im creating the variable on the code that generates the report, I'm working on a .NET application:
report.Dictionary.Variables.Add(New Stimulsoft.Report.Dictionary.StiVariable("test",""))
report("test") = "ANYTHING"
While it does show me the created variables on the Stimuloft gui, it contains absolutely nothing, any ideas on what I'm doing wrong? Thanks!
You should use next code to set value of variable:
report.Dictionary.Variables("test").Value = "ANYTHING"
The code that you use will work after calling report.Compile() method only.

VBA Overflow Error 6 -- simply when terminating a class

I am trying to debug code that typically functions properly and has been in production for a while, but has some errors associated with particular case runs.
I have a class called "Guarantee", and a variable / object, "myDem", which is of that class. The class has an associated function called "NumberOfGuaranteeDays". The first image given below shows a Long variable called "numRows" being assigned to this function call on "myDem". When this assigment is made -- and, therefore, the "NumberOfGuaranteeDays" function is called -- I receive an Overflow error.
After the function call "NumberOfGuaranteeDays" is run, which is a fairly complex call with many sub-functions itself, then class attempts to terminate itself, and return the value (the number of days, which is an integer... in this case it's 32561). It is during this termination step and the assignment of "numRows" to the value 32561, when the error occurs.
Here I simply demonstrate that the very next step within the code, if I step through it, is where the error message is returned back to me.
Finally I wanted to provide "proof" that the value assigned to "numRows" is 32561, of type Integer, which can acceptably be assigned to a Long. Note in the far right in the watch part of the window, the value "res" is the value which is returned from the "NumberOfGuaranteeDays" call, which is then assigned to the variable "numRows".
As far as I can tell, there are only 2 possibilities for why a crash can be occurring:
There is an error in the attempt to terminate the class. I don't understand how this could lead to an "overflow" error, though.
There is an error in the assignment of the value calculated from "NumberOfGuaranteeDays" to the variable "numRows". This sort of assignment could potentially have an overflow, but not in this case. The return from "NumberOfGuaranteeDays", which is the "res" integer set at 32561, is assigned to "numRows", which is a Long.
So, since neither of these possibilities that I can imagine make sense, I figure there must be another possibility I cannot see. Thank you all in advance for the help!
I opted to put in cut & pasted images instead of writing as code because so much of what's critical to understanding the steps is seeing "proof" of where I am in the debugging stages. If actual code snippets would help, let me know.
Thank you!
Mike