|
No problem. I hope they can sort this issue out for you.
|
|
|
|
|
Hello,
I've been working on a program to renew Windows profiles on a remote location via Active Directory.
The program retrieves a user profile location(ProfilePath)
once the program verifies the email adres to be valid. The problem with the code provided below is that aside from the test e-mail account i used any other e-mail adres inputted returns the NullReferenceException.
my test account works perfectly and renames the profile to <profilename>.old. I can't think or see what i did wrong,
Any critisism or suggestions what i could try is welcome.
Thanks in advance.
Greetings,
Edit:
Found out the problem lies with loggin in with different credentials. I need to extend the right of the logged in over the entire application the loggin works but renaming a folder is not allowed on for the user running the application
private string GetProfilePath(string user)
{
DirectoryEntry dirEntry = CreateDirEntry();
DirectorySearcher dirSearcher = new DirectorySearcher();
dirSearcher.Filter = "mail=" + user;
dirSearcher.PropertiesToLoad.Add("profilePath");
SearchResult sResult = dirSearcher.FindOne();
if (sResult == null)
{
MessageBox.Show("Niks gevonden", "Niks gevonden", MessageBoxButtons.OK, MessageBoxIcon.Error);
SystemSounds.Beep.Play();
return null;
}
else
{
DirectoryEntry dirEntr = new DirectoryEntry(sResult.Path);
string profile = dirEntr.Properties["profilePath"].Value.ToString();
dirEntr.Close();
dirEntry.Close();
return profile;
}
}
modified 21-Nov-12 6:51am.
|
|
|
|
|
May I suggest you always write English, including comments.
I'm native Flemish speaking, but most on CP are not and if you're Belgian, you'd know that our French-speaking neighbors across the language border do not understand it either...
PS: Doesn't the Beep come AFTER you pressed OK on the Messagebox, in this case? Shouldn't it be before?
it's difficult to say what happens, but I suggest you add some logging and print out the different values, that might give you a clue.
|
|
|
|
|
doing so now.
and point taken about comments being in english.
My code is kinda messy at this point but the beep comes when the error box opens
Tested it beep comes when the error box opens but thanks for pointing it out
|
|
|
|
|
MacUseless wrote: and point taken about comments being in english.
You're welcome.
MacUseless wrote: Tested it beep comes when the error box opens but thanks for pointing it out
Against my expectations (messagebox blocks the thread, but if it works, it works )
|
|
|
|
|
Hi,
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.
<pre lang="xml">
<BACKGROUND>
<QUES_NUMBER>1</QUES_NUMBER>
<QUES_RESPONSE>Y</QUES_RESPONSE>
</BACKGROUND>
<BACKGROUND>
<QUES_NUMBER>2</QUES_NUMBER>
<QUES_RESPONSE>Y</QUES_RESPONSE>
</BACKGROUND>
<BACKGROUND>
<QUES_NUMBER>3</QUES_NUMBER>
<QUES_RESPONSE>Y</QUES_RESPONSE>
</BACKGROUND>
<BACKGROUND>
<QUES_NUMBER>4</QUES_NUMBER>
<QUES_RESPONSE>N</QUES_RESPONSE>
</BACKGROUND>
<BACKGROUND>
<QUES_NUMBER>5</QUES_NUMBER>
<QUES_RESPONSE>Y</QUES_RESPONSE>
</BACKGROUND>
<BACKGROUND>
<QUES_NUMBER>1A</QUES_NUMBER>
<QUES_RESPONSE>Y</QUES_RESPONSE>
</BACKGROUND>
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.
public static bool PROCESSRULE_RANGE(string expValue, ArrayList xmlValColl, out int valIndex)
{
string currentValue = string.Empty;
valIndex = -1;
string[] expValArr = expValue.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
var intersect = expValArr.Intersect(xmlValColl.ToArray());
if (intersect.Count() > 0)
{
valIndex = xmlValColl.IndexOf(intersect.First());
return true;
}
}
I am using XPATH to read the values in xml file.
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
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.
|
|
|
|
|
Hi,
Thanks for your reply..
Now the problem has been resolved...
Rahul
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Hi,
Do you know how to set or assign the distance (spaces) between checkbox and text when using TreeView (Visual Studio):
[] node1
[] node2
Thanks and regards
|
|
|
|
|
Web:
Use CSS to set space between check box and node text.
Window:
Append blank string with node text as prefix.
|
|
|
|
|
Thanks Jay Nardev,
I also used appending blank string (for Window), but when selecting a node, it include the blank string (I want it only includes text)
Kind regards,
|
|
|
|
|
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
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker2.RunWorkerAsync();
}
public void additem(int i)
{
listBox1.Items.Add(i);
}
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 10; i++)
{
additem(i);
Thread.Sleep(500);
}
}
|
|
|
|
|
Hi,
I can see similar thread Here[^]
Please let me know if it not works...
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
hi,
Thank you very much for your help .
I have done, i using "invoke and delegate"
Invoke(new MethodInvoker(delegate {
listBox1.Items.Add(value);
}));
|
|
|
|
|
Nice...
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
|
I am trying to click a button programmatically.
If I click the button with my mouse it works fine by going out to the internet and asking for info the website thens sends the info requested.
However I have this on a timer (DelegateTimer, found here)
When the timer sends the request to "ButtonUpdatesPerformClick()" the .PerformClick does not work below.
I cannot bypass the button by going to "NonButtonUpdates()", because when it goes out to the internet, the information never comes back.
Can anyone help me with this problem.
Thanks in advance.
Michael
delegate void SetUpdatesCallback();
public void ButtonUpdatesPerformClick()
{
if (this.buttonUpdates.InvokeRequired)
{
SetUpdatesCallback button = new SetUpdatesCallback(this.ButtonUpdatesPerformClick);
this.Invoke(button, new object[] { });
}
else
{
this.buttonUpdates.PerformClick();
}
}
private void buttonUpdates_Click(object sender, EventArgs e)
{
this.NonButtonUpdates();
}
private void NonButtonUpdates()
{
this.GoToWebsiteGetData();
}
modified 20-Nov-12 22:59pm.
|
|
|
|
|
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.
modified 21-Nov-12 12:50pm.
|
|
|
|
|
You can call your click Event in simple method whenever you required.There is no need of button click.
|
|
|
|
|
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?
Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Is there a way to return the full path name of the file containing the code?
suppose I have the following class in the file c:\myproject\CA.cs
public static class A
{
public static void Show()
{
string myFile = ....
Console.WriteLine(myFile);
}
}
modified 20-Nov-12 17:08pm.
|
|
|
|
|
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 ??
Maybe Ive mis-interpreted what you're asking
|
|
|
|
|
You can certainly get the fully qualified name.
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 best I can think of is the stack trace, but it's probably not worth the trouble.
Remember that a class can be partial or inherit members from base classes.
If you really want to, you could add an Attribute to the class, but you'd have to weigh the costs and benefits of added maintenance.
It still comes down to why you want the information.
|
|
|
|
|
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..
a workaround.. but it should work
|
|
|
|