Esempio n. 1
0
        public static int CheckedExecNonModal(Action fn)
        {
            int ret = -1;

            try
            {
                fn();

                ret = 1;
            }

            catch (ArgumentNullException e)
            {
                MMCDlgHelper.ShowError(e.Message);

                ret = -1;
            }

            catch (Exception exp)
            {
                MMCDlgHelper.ShowError(exp.Message);

                ret = -1;
            }

            return(ret);
        }
Esempio n. 2
0
        private async Task OnOkClick()
        {
            try
            {
                btnOK.Enabled = false;
                if (IsValid())
                {
                    if (Server == null)
                    {
                        Server = new ServerDto();
                    }
                    Server.Server   = txtDirectoryServer.Text;
                    Server.Upn      = txtBindUPN.Text;
                    Server.Password = txtPassword.Text;
                    var parts = Server.Upn.Split('@');
                    Server.UserName   = parts[0];
                    Server.DomainName = parts[1];
                    var task = new Task(Connect);
                    task.Start();
                    if (task == await Task.WhenAny(task, Task.Delay(Constants.TopologyTimeout * Constants.MilliSecsMultiplier)))
                    {
                        await task;
                    }

                    if (ManagementDto != null)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MiscUtilsService.ShowError(Constants.LoginError, "Error", MessageBoxButtons.OK);
                        btnOK.Enabled = true;
                    }
                }
                else
                {
                    btnOK.Enabled = true;
                }
            }
            catch (AggregateException exc)
            {
                var custom = new CustomExceptionExtractor().GetCustomMessage(exc);
                PscHighAvailabilityAppEnvironment.Instance.Logger.LogException(exc, custom);
                if (exc.InnerExceptions.Count > 0)
                {
                    var msg = exc.InnerExceptions.Select(x => x.Message).Aggregate((x, y) => x + " , " + y);
                    MMCDlgHelper.ShowError(msg);
                }
            }
            catch (Exception exp)
            {
                var custom = new CustomExceptionExtractor().GetCustomMessage(exp);
                PscHighAvailabilityAppEnvironment.Instance.Logger.LogException(exp, custom);
                MiscUtilsService.ShowError(exp);
            }
        }
Esempio n. 3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            var max = (int)nudMaxKeySize.Value;
            var min = (int)nudMinKeySize.Value;

            if (max < min)
            {
                MMCDlgHelper.ShowError("MAX Key size cannot be less than MIN key size");
            }
            else
            {
                _dto = new SignatureAlgorithmDto {
                    MaxKeySize = max, MinKeySize = min, Priority = (int)nudPriority.Value
                };
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 4
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     shouldClose = false;
     if (ValidateControls())
     {
         ViewToDataContext();
         var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(_serverDto, _tenantName);
         ActionHelper.Execute(delegate
         {
             try
             {
                 var service       = ScopeNodeExtensions.GetServiceGateway(_serverDto.ServerName);
                 _userDto          = service.User.Create(_serverDto, _tenantName, _userDto, auth.Token);
                 shouldClose       = true;
                 this.DialogResult = DialogResult.OK;
                 Close();
             }
             catch (WebException exp)
             {
                 if (exp.Response is HttpWebResponse)
                 {
                     var response = exp.Response as HttpWebResponse;
                     if (response != null && response.StatusCode == HttpStatusCode.BadRequest && response.ContentType == "application/json")
                     {
                         var resp  = new StreamReader(response.GetResponseStream()).ReadToEnd();
                         var error = JsonConvert.Deserialize <AuthErrorDto>(resp);
                         if (error.Cause == "Constraint violation")
                         {
                             MMCDlgHelper.ShowError("Password does not match the password policy set on the tenant. Check tenant configuration for password policy or contact administrator");
                         }
                         else
                         {
                             MMCDlgHelper.ShowError(error.Details + " Cause - " + error.Cause);
                         }
                     }
                     else
                     {
                         throw exp;
                     }
                 }
             }
         }, auth);
     }
 }
        public async Task DoLogin()
        {
            try
            {
                if (!ServerDTO.IsLoggedIn)
                {
                    if (!string.IsNullOrEmpty(ServerDTO.UserName))
                    {
                        String[] user = ServerDTO.UserName.Split('@');
                        ServerDTO.UserName = user[0];
                    }
                    var frmLogin = new LoginForm(ServerDTO.Server, ServerDTO.UserName, ServerDTO.DomainName);
                    if (this.SnapIn.Console.ShowDialog(frmLogin) == DialogResult.OK)
                    {
                        ServerDTO.Server     = frmLogin.Server;
                        ServerDTO.UserName   = frmLogin.UserName;
                        ServerDTO.Password   = frmLogin.Password;
                        ServerDTO.DomainName = frmLogin.DomainName;
                        await ServerDTO.LogintoServer(ServerDTO.UserName, ServerDTO.Password, ServerDTO.DomainName);

                        this.DisplayName = ServerDTO.Server;
                        if (ServerDTO.IsLoggedIn)
                        {
                            PopulateChildren();
                            this.ActionsPaneItems.Clear();
                            this.ActionsPaneItems.Add(new Microsoft.ManagementConsole.Action("Logout", "Logout", -1, ACTION_LOGOUT));
                            this.ActionsPaneItems.Add(new Microsoft.ManagementConsole.Action("Check connectivity",
                                                                                             "Check connectivity", -1, ACTION_CHECK_CONNECTIVITY));
                            this.ActionsPaneItems.Add(new Microsoft.ManagementConsole.Action("Get Store version",
                                                                                             "Get Store version", -1, ACTION_GET_STORE_VERSION));
                        }
                        else
                        {
                            MMCDlgHelper.ShowError(MMCUIConstants.UNABLE_TO_LOGIN);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MMCDlgHelper.ShowException(e);
            }
        }
Esempio n. 6
0
        private void CompareButton_Click(object sender, EventArgs e)

        {
            try

            {
                if (this.MetaDataButton.Checked == true)

                {
                    ViewAttributeTypeDiffButton.Visible = true;

                    ViewObjectClassDiffButton.Visible = false;

                    ViewAttributeTypeDiffButton.Text = VMDirSchemaConstants.DIFF_METADATA;

                    schemaDiff = ServerNode.ServerDTO.Connection.SchemaConnection.GetAllSchemaMetadataDiffs();

                    NodesList.DataSource = attrTypediff.Keys.ToList();
                }

                else if (this.SchemaButton.Checked == true)

                {
                    ViewAttributeTypeDiffButton.Visible = true;

                    ViewObjectClassDiffButton.Visible = true;

                    ViewAttributeTypeDiffButton.Text = VMDirSchemaConstants.DIFF_ATTRIBUTETYPE;

                    attrTypediff = ServerNode.ServerDTO.Connection.SchemaConnection.GetAllSchemaDefinitionDiffs();

                    NodesList.DataSource = attrTypediff.Keys.ToList();
                }
            }

            catch (Exception ex)

            {
                MMCDlgHelper.ShowError(ex.Message);
            }
        }
Esempio n. 7
0
 private void btnAddSignatureAlgorithm_Click(object sender, EventArgs e)
 {
     ActionHelper.Execute(delegate
     {
         var form = new AddNewSignatureAlgorithm();
         if (form.ShowDialog() == DialogResult.OK)
         {
             var service = (SignatureAlgorithmDto)form.DataContext;
             if (service.MaxKeySize < service.MinKeySize)
             {
                 MMCDlgHelper.ShowError("MAX Key size cannot be less than MIN key size");
                 DialogResult = DialogResult.Cancel;
                 return;
             }
             var lstItem = new ListViewItem(new[] { service.MaxKeySize.ToString(), service.MinKeySize.ToString(), service.Priority.ToString() })
             {
                 Tag = service
             };
             lstSignatureAlgorithms.Items.Add(lstItem);
         }
     }, null);
 }
Esempio n. 8
0
 public static void ShowError(string error)
 {
     MMCDlgHelper.ShowError(error);
 }