I want to validate the xml file against certain set of rules in database.I have done most of the this but got stuck in below part. Any pointers will be appreciated.
Following is the sample xml file.
As displayed there are multiple instances of <BACKGROUND><QUES_NUMBER><QUES_RESPONSE></BACKGROUND> tag. Now I have to validate below rule.
Rule 1- If QUES_NUMBER in (1,01,001) Then QUES_RESPONSE should be in (Y,N) Rule 2- If QUES_RESPONSE Equals (Y) Then one instance of QUES_NUMBER 1A,01A,1B,01B should exist. Rule 3- If QUES_NUMBER in (1A,01A) Then QUES_RESPONSE (X,Y,Z,Y/Z) Rule 3.1- If QUES_NUMBER in (1B,01B) Then QUES_RESPONSE (X,Y,Z,Y/Z)
This is the complete Rule. If we are processing rule number 1 and result is true then we have to validate THEN condition (QUES_RESPONSE). If THEN condition is true then I have to process Rule 2 (as there are multiple instance of same tag) I have to check the QUES_RESPONSE (Y) of the same tag for which I have validated Rule 1 condition. For that purpose I am passing then index of index of the QUES_NUMBER and it works f9. PROBLEM occurred in the THEN condition of Rule 2..Where are I am passing the value in xml file and match value (value in database Y,N) and index of the question number to look at. But the as per then condition 1A..tag should exist and the code will try to locate the tag on that index which he will never find. Any pointer where I need to change in logic/any other way will be appreciated. Below is the function which is validating the value in xml file against db value.
What occurs to me is the possibility of having the rules be XPath expressions. For example, rule 1 could be expressed as something like:
//BACKGROUND/QUES_NUMBER[.='1' or .='01' or .='001']/parent::BACKGROUND/QUES_RESPONSE[.='Y' or .='N']
These expressions could then be stored in the database, probably with something to indicate which order to apply them and a value (e.g. 0 or 1) that would indicate a successful test. Maybe have a branching scheme -- so you can choose the next rules based on the result of the current one. For instance, the above expression should return one node -- if 0 fail, if 1 goto rule 2, else fail.
However, it will be very tricky to define the rules exactly right.
this's the error when I run the program "Cross-thread operation not valid: Control 'listBox1' accessed from a thread other than the thread it was created on." please help me this's my code, it's simple
You should not access the UI elements in the DoWork handler. Then how do I access the UI elements? The below article helps you in understanding that.. Look how the progress bar and vowel count meter is accessed.
Your code makes zero sense. Have your click handler call a private method with no arguments DoStuff() for example. You don't want to click the button programatically, now do you? Do you actually want the button to press itself visually as if by magic? Probably not. You just want the code behind it to execute. So your timer or whatever would also just call the DoStuff() method directly.
I created a custom combo box class, which inherits from the built-in System.Windows.Forms.ComboBox class. I changed the AutoCompleteMode property to be AutoCompleteMode.SuggestAppend, which is working just fine. However, I would now like to capture the up & down arrows, only when the auto complete dialog is NOT open, to allow a client to cycle through all of the drop down options without opening the dropdown (in my custom control, the Items property is an empty collection, and my dropdown is done using a ToolStripDropDown).
Currently, I have overridden the ProcessCmdKey method, since the KeyDown, KeyUp, and KeyPress events are not being fired once the auto complete dialog has been opened (even if it is closed at a later time). The problem is that I can't figure out how to tell if the auto complete dialog is open. If it is open, I want to use the default behavior implemented in the base class. If not, I want the drop down to cycle through the available options.
I have looked through the Windows messages using Spy++, but can't figure out which one is causing the auto complete dialog to open & close. Some of the suspicious ones are (WM_USER + 7441), LB_FINDSTRING, LVM_GETNEXTITEM, and LVM_SETITEMCOUNT when it opens, and LVM_SETITEMSTATE when it closes.
Should I watch for these messages within the WndProc override, and maintain a boolean between the LVM_SETITEMCOUNT and LVM_SETITEMSTATE? Should I query all open classes of type ComboLBox (the type that is being displayed in the auto complete; the problem is that the parent is the desktop for this type)? Is there some better way to query whether the auto complete dialog is open?
The only possible reason I could see for you doing so, is if you're working on some sort of dynamic plugin system and you're going to compile/interpret/load the file at runtime - in which case you need a system to register where you're going to look for the code/plugin/etc
Once your code is compiled into an exe or a dll, you can find the path to the executable module or where it was loaded from, but not to a single piece of code - What would be the point, hmm, if a compiled module couldnt be shipped to a seperate machine/location, but that compiled module still had to retain a reference to the source code ?? yuck ??
There might be some method in the Assembly which loaded the class which might provide a path name but I doubt it would be a fully qualified one. (I don't feel like looking at the docs at the current time.)
Your version control system might have 'variables' (or macros, etc - the name is always different) that allows it to insert the path into the source code when you check it in. If so you could create string with that. Of course you would need to do it on every class.
The reason it that the class has a method that should be able to copy its source file whatever it is.
An alternative solution i found: 1) create each file containing one only class so that the file is the class name 2) implementing a method (in a base class that will be overrides), which get the text class name, and build a name of file (classname +".cs"). Then starting from root directory of project, it will search for the file name in the sub directories..