Beispiel #1
0
        private bool UpdateSSOApplication(string newName, string oldName)
        {
            //write to SSOPropBag to figure out how many rows we have
            ArrayList maskArray = new ArrayList();

            try
            {
                HybridDictionary props = new HybridDictionary();

                foreach (DataGridViewRow row in dgvSearch.Rows)
                {
                    int keyIndex   = 0;
                    int valueIndex = 1;

                    if (row.Cells[keyIndex].Value != null)
                    {
                        // insert values on grid from property bag, replace special characters like \r \t
                        object objPropValue = row.Cells[valueIndex].Value.ToString().Replace("\t", "").Replace("\r", "");
                        object objPropKey   = row.Cells[keyIndex].Value.ToString().Replace("\t", "").Replace("\r", "");
                        props.Add(objPropKey, objPropValue);
                        maskArray.Add(0);
                    }
                }

                //if (newApp)
                //{
                SSOConfigManager.DeleteApplication(oldName);
                //}

                SSOPropBag propertiesBag = new SSOPropBag(props);

                //create and enable application
                SSOConfigManager.CreateConfigStoreApplication(newName, "", ContactInfo,
                                                              AuserAcct, AdminAcct, propertiesBag, maskArray);

                //set default configuration field values
                SSOConfigManager.SetConfigProperties(newName, propertiesBag);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("Erro, verifique se existe alguma key repetida\n" + ex.ToString(),
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured.  Details: " + ex.ToString(),
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Rename nodes/keys (level 2) from treeview
        /// </summary>
        /// <param name="node">Node already renamed</param>
        /// <param name="oldNode">Old node name</param>
        /// <param name="parentSelectedNode">Parent of node renamed</param>
        public static bool RenameKeyValueFromSSOApp(TreeNode node, string oldNode, string parentSelectedNode)
        {
            ArrayList maskArray = new ArrayList();
            string    appUserAcct = string.Empty, appAdminAcct = string.Empty,
                      contactInfo = string.Empty, description = string.Empty;

            try
            {
                HybridDictionary props = SSOConfigManager.GetConfigProperties(parentSelectedNode, out description,
                                                                              out contactInfo, out appUserAcct, out appAdminAcct);
                HybridDictionary propsTemp = new HybridDictionary();

                //save nodes to rename
                foreach (DictionaryEntry item in props)
                {
                    if (item.Key.ToString().Contains(oldNode))
                    {
                        propsTemp.Add(item.Key.ToString().Replace(oldNode, node.Text.ToString()), item.Value.ToString());
                    }
                    maskArray.Add(0);
                }

                Utils.RemoveKeyValueFromSSOApp(oldNode, parentSelectedNode);

                props = SSOConfigManager.GetConfigProperties(parentSelectedNode, out description,
                                                             out contactInfo, out appUserAcct, out appAdminAcct);

                foreach (DictionaryEntry item in propsTemp)
                {
                    props.Add(item.Key.ToString(), item.Value.ToString());
                }

                SSOConfigManager.DeleteApplication(parentSelectedNode);
                SSOPropBag propertiesBag = new SSOPropBag(props);
                Utils.CreateAndEnableAppInSSO(parentSelectedNode, string.Empty, contactInfo,
                                              appUserAcct, appAdminAcct, propertiesBag, maskArray);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format("Cannot rename key(s) '{0}' to '{1}' \n\n{2}", oldNode, node.Text.ToString(), ex.Message.ToString()),
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
        /// <summary>
        /// Remove nodes/keys (level 2) from treeview
        /// </summary>
        /// <param name="KeyValueToBeRemoved">Node/key to remove</param>
        /// <param name="parentNode">Parent of node/key to remove</param>
        public static bool RemoveKeyValueFromSSOApp(string KeyValueToBeRemoved, string parentNode)
        {
            string appUserAcct = string.Empty, appAdminAcct = string.Empty,
                   contactInfo = string.Empty, description = string.Empty;
            List <String> keysToRemove = new List <string>();
            ArrayList     maskArray    = new ArrayList();

            try
            {
                //Gets the configuration information from the configuration store about parentNode
                HybridDictionary props = SSOConfigManager.GetConfigProperties(parentNode, out description,
                                                                              out contactInfo, out appUserAcct, out appAdminAcct);

                //search in 'props' if exists some key/prefix that contains 'KeyValueToBeRemoved'
                //if exists, store it in a list
                foreach (var item in props.Keys)
                {
                    if (item.ToString().Contains(KeyValueToBeRemoved))
                    {
                        keysToRemove.Add(item.ToString());
                        //in this foreach i cannot remove the key directly from 'props'
                    }
                    maskArray.Add(0);
                }

                //remove keys from 'props':
                foreach (string key in keysToRemove)
                {
                    props.Remove(key);
                    maskArray.Remove(0);
                }

                SSOConfigManager.DeleteApplication(parentNode);
                SSOPropBag propertiesBag = new SSOPropBag(props);
                CreateAndEnableAppInSSO(parentNode, string.Empty, contactInfo, appUserAcct, appAdminAcct, propertiesBag, maskArray);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot delete key(s) '{0}'\n\n{1}", KeyValueToBeRemoved, ex.Message.ToString()),
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Beispiel #4
0
        private void ctmTreeDelete_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(string.Format("Are you sure you wish to delete '{0}'?", tvApps.SelectedNode.Text),
                                "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                try
                {
                    SSOConfigManager.DeleteApplication(tvApps.SelectedNode.Text);

                    //confirmation
                    MessageBox.Show("Application deleted.", "Information", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Occured.  Details: " + ex.ToString(), "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                Utils._gridChanged  = false;
                tvApps.SelectedNode = tvApps.Nodes[0];
                Utils.Search(tvApps, txbSearch.Text, dgvSearch);
            }
        }