protected override void OnDelete(SyncStatus status) { try { if (MsgBoxUtil.Confirm(this.SnapIn, Properties.Resources.DeleteFieldMessage) == true) { // get SSO application fields SSOAppFieldCollection appFields = SSOManager.GetApplicationFields(this.ScopeNode.DisplayName); // delete selected ones foreach (ResultNode resultNode in this.SelectedNodes) { appFields.Remove(resultNode.DisplayName); this.ResultNodes.Remove(resultNode); } // save fields SSOManager.UpdateApplicationFields(this.ScopeNode.DisplayName, appFields, true); // refresh view this.RefreshFields(); } } catch (Exception ex) { MsgBoxUtil.Show(this.SnapIn, ex); } }
private void PropertyPage_Save(object sender, ResultEventArgs <bool> e) { if (this.IsValid() == false) { MsgBoxUtil.Show(this.ParentSheet, "Some information is missing or incorrect. Please review and correct the information entered on the page."); e.Result = false; } else { if (this.IsDirty() == true) { // get the new field information entered on the page this.Update(this.appField); // get the SSO application fields SSOAppFieldCollection appFields = SSOManager.GetApplicationFields(this.appName); // flag to indicate whether the application must be recreated bool recreate = false; // check if the field is new or was renamed if (string.IsNullOrEmpty(this.originalFieldName) == true || this.propertyControl.FieldName.Equals(this.originalFieldName, StringComparison.InvariantCultureIgnoreCase) == false) { // the field is new or was renamed, ensure the new field name does not exist if (appFields.Contains(this.propertyControl.FieldName) == true) { MsgBoxUtil.Show(this.ParentSheet, string.Format("The field name {0} already exists.", this.propertyControl.FieldName)); e.Result = false; return; } // need to recreate the application recreate = true; // remove the field before writing it using the new name (it will cause to add it) if (appFields.Contains(this.propertyControl.FieldName) == true) { appFields.Remove(this.propertyControl.FieldName); } } // write the field value (if the field was renamed, a new one will be added) appFields.Write(this.propertyControl.FieldName, this.propertyControl.FieldValue); // update the sso application SSOManager.UpdateApplicationFields(this.appName, appFields, recreate); // update the result node ResultNode resultNode = (ResultNode)this.ParentSheet.SelectionObject; this.OnSaved(new EventArgs <SSOAppField>(this.appField)); } e.Result = true; } }