Example #1
0
        private void QuerySusClientID(object obj)
        {
            ASyncClientParameters parameters = (ASyncClientParameters)obj;

            try
            {
                object[] args = new object[3];

                ADComputer computer = (ADComputer)dtGrdVResult.Rows[parameters.RowIndex].Cells["ComputerName"].Value;
                args[0] = string.Empty;
                args[1] = parameters.RowIndex;
                args[2] = "SusClientID";
                if (!_closing && !_aborting && !chkBxDontPing.Checked && !computer.Ping((int)nupPingTimeout.Value))
                {
                    args[0] = resMan.GetString("Unreachable");
                }
                else
                {
                    if (!_closing && !_aborting && !_wrongCrendentialsWatcher.IsAbortRequested)
                    {
                        lock (_QuerySusClientIDLocker)
                        {
                            try
                            {
                                if (!_wrongCrendentialsWatcher.IsAbortRequested && !_aborting && !_closing)
                                {
                                    computer.QuerySusClientID(parameters.Login, parameters.Password);
                                    args[0] = computer.SusClientID;
                                }
                                else
                                {
                                    args[0] = resMan.GetString("Aborted");
                                }
                            }
                            catch (UnauthorizedAccessException)
                            {
                                _wrongCrendentialsWatcher.IsWrongCredentials = true;

                                if (!_wrongCrendentialsWatcher.ContinueWithFailedCredentials)
                                {
                                    if (MessageBox.Show(resMan.GetString("CredentialFailed"), resMan.GetString("FailedToConnect"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                                    {
                                        Logger.Write("interrupt on failed credentials.");
                                        _wrongCrendentialsWatcher.IsAbortRequested = true;
                                        args[0] = resMan.GetString("Aborted");
                                    }
                                    else
                                    {
                                        Logger.Write("Continue with bad credentials.");
                                        _wrongCrendentialsWatcher.ContinueWithFailedCredentials = true;
                                        args[0] = resMan.GetString("FailedToConnect");
                                    }
                                }
                                else
                                {
                                    args[0] = resMan.GetString("FailedToConnect");
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.Write(ex.Message);
                                args[0] = resMan.GetString("FailedToSendCommand");
                            }
                        }
                    }
                    else
                    {
                        args[0] = resMan.GetString("Aborted");
                    }
                }
                UpdateRow(args);
            }
            catch (Exception) { }
            finally { parameters.CountEvent.Signal(); }
        }