Click here to Skip to main content
15,903,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Copy text to clipboard Pin
Luc Pattyn24-Jul-09 4:07
sitebuilderLuc Pattyn24-Jul-09 4:07 
GeneralRe: Copy text to clipboard Pin
jaro1624-Jul-09 6:03
jaro1624-Jul-09 6:03 
Questiongetting timeout expired error Pin
venu65624-Jul-09 1:49
venu65624-Jul-09 1:49 
RantRe: getting timeout expired error Pin
musefan24-Jul-09 2:08
musefan24-Jul-09 2:08 
AnswerRe: getting timeout expired error Pin
MumbleB24-Jul-09 2:46
MumbleB24-Jul-09 2:46 
AnswerRe: getting timeout expired error Pin
Dave Kreskowiak24-Jul-09 4:08
mveDave Kreskowiak24-Jul-09 4:08 
Answer1 lac = 100,000 : Re: getting timeout expired error Pin
BillWoodruff24-Jul-09 5:19
professionalBillWoodruff24-Jul-09 5:19 
QuestionInresponsive program during an Active Directory search. Pin
Hardus Lombaard24-Jul-09 1:42
Hardus Lombaard24-Jul-09 1:42 
Below is some code that validates entries in a datagridview against entries in Active Directory and changes the color of the datagridview cells accordingly. A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive and the form doesn't refresh any longer until after the process is finished, thereby causing the progressbar to loose its functionality. How can I overcome this glitch? I would also like to implement a cancel button so that the user can cancel the validation process at any moment, but if a button is pressed I experience the problem mentioned above. Any help would be appreciated. Thanx.

private void btnCheck_Click(object sender, EventArgs e)
{
                  using (DirectoryEntry de = new DirectoryEntry(adPath, adUsername, adPassword)) //))                 
                  {
                        de.Username = Environment.UserName;
                        de.AuthenticationType = AuthenticationTypes.Secure;
                        //these are the attributes that will show              
                        string[] attribs = new string[] { "displayName", "mail", "userAccountControl" };
                        for (int x = 0; x < dgvManager.Rows.Count - 1; x++)
                        {
                              ValidateDetails(4, 5, 6, x, de, attribs); //Second in charge
                              ValidateDetails(7, 8, 9, x, de, attribs); //Branch Manager
                              ValidateDetails(10, 11, 12, x, de, attribs); //Regional Manager
                              ValidateDetails(13, 14, 15, x, de, attribs); //General Manager
                              ValidateDetails(16, 17, 18, x, de, attribs); //Managing Director

                              progressBar.Value = Convert.ToInt32(Convert.ToDecimal(x) / dgvManager.Rows.Count * 100);
                              lblPercent.Text = Convert.ToInt32((Convert.ToDecimal(x) / dgvManager.Rows.Count * 100)).ToString() + "%";
                              this.Refresh();
                        }//for
                  }//using
}


private void ValidateDetails(int cell1, int cell2, int cell3, int row, DirectoryEntry de, string[] attribs)
            {
                  DirectorySearcher ds = null;
                  string y = "", u = "", z = "", sFilter = "";
                  //use the username as search key
                  if (dgvManager.Rows[row].Cells[cell3].Value.ToString() != "")
                  {
                        sFilter = String.Format(
                              "(&(objectCategory=person)(sAMAccountName={0}))",
                              dgvManager.Rows[row].Cells[cell3].Value.ToString().Split(new char[] { '\\' })[1]
                              );
                        ds = new DirectorySearcher(de, sFilter, attribs);
                        using (SearchResultCollection src = ds.FindAll())
                        {
                              SearchResult sr = null;
                              if (src.Count > 0)
                              {
                                    sr = src[0];
                                    dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.LightGreen;
                                    dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.LightGreen;
                                    dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.LightGreen;
                                    if (sr.Properties["mail"].Count != 0)
                                    {

                                          z = sr.Properties["mail"][0].ToString();
                                          if (z.ToLower() != dgvManager.Rows[row].Cells[cell2].Value.ToString().ToLower()) //email address
                                                dgvManager.Rows[row].Cells[cell2].Value = z;
                                    }
                                    else
                                          dgvManager.Rows[row].Cells[cell2].Value = "";
                                    if (sr.Properties["displayname"].Count != 0)
                                    {
                                          y = sr.Properties["displayName"][0].ToString();
                                          if (y.ToLower() != dgvManager.Rows[row].Cells[cell1].Value.ToString().ToLower()) //display name
                                                dgvManager.Rows[row].Cells[cell1].Value = y;
                                    }
                                    else
                                          dgvManager.Rows[row].Cells[cell1].Value = "";
                                    if (sr.Properties["userAccountControl"].Count != 0)
                                    {
                                          u = sr.Properties["userAccountControl"][0].ToString();
                                          if (u == "514" | u == "66050") // account disabled
                                                dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Orange;
                                    }
                                    else
                                          dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Orange;
                              }
                              else
                              {
                                    dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Red;
                                    dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.Red;
                                    dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.Red;
                              }
                        }
                  }
                  else
                  {
                        dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Red;
                        dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.Red;
                        dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.Red;
                  }
            }
AnswerRe: Inresponsive program during an Active Directory search. Pin
musefan24-Jul-09 2:02
musefan24-Jul-09 2:02 
AnswerRe: Inresponsive program during an Active Directory search. Pin
Abhijit Jana24-Jul-09 2:09
professionalAbhijit Jana24-Jul-09 2:09 
Questionconversion a jpg image in to 16 bit Pin
shekhar25839524-Jul-09 1:12
shekhar25839524-Jul-09 1:12 
QuestionDirectUIHWND Pin
Satish Pai24-Jul-09 0:17
Satish Pai24-Jul-09 0:17 
AnswerRe: DirectUIHWND Pin
stancrm24-Jul-09 0:32
stancrm24-Jul-09 0:32 
QuestionHow to use bytes in bytes buffer? Pin
Member 474292223-Jul-09 23:33
Member 474292223-Jul-09 23:33 
AnswerRe: How to use bytes in bytes buffer? Pin
DaveyM6923-Jul-09 23:39
professionalDaveyM6923-Jul-09 23:39 
GeneralRe: How to use bytes in bytes buffer? Pin
Member 474292223-Jul-09 23:41
Member 474292223-Jul-09 23:41 
AnswerRe: How to use bytes in bytes buffer? Pin
Muhammad Mazhar23-Jul-09 23:45
Muhammad Mazhar23-Jul-09 23:45 
GeneralRe: How to use bytes in bytes buffer? Pin
Member 474292223-Jul-09 23:52
Member 474292223-Jul-09 23:52 
GeneralRe: How to use bytes in bytes buffer? Pin
harold aptroot24-Jul-09 4:06
harold aptroot24-Jul-09 4:06 
GeneralRe: How to use bytes in bytes buffer? Pin
musefan24-Jul-09 0:03
musefan24-Jul-09 0:03 
GeneralRe: How to use bytes in bytes buffer? Pin
Member 474292224-Jul-09 1:14
Member 474292224-Jul-09 1:14 
AnswerRe: How to use bytes in bytes buffer? Pin
0x3c024-Jul-09 0:39
0x3c024-Jul-09 0:39 
AnswerRe: How to use bytes in bytes buffer? Pin
Luc Pattyn24-Jul-09 0:49
sitebuilderLuc Pattyn24-Jul-09 0:49 
QuestionHow to make a Component like MSN status label? Pin
Don.Y23-Jul-09 23:19
Don.Y23-Jul-09 23:19 
AnswerRe: How to make a Component like MSN status label? Pin
DaveyM6923-Jul-09 23:21
professionalDaveyM6923-Jul-09 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.