private void btCreate_Click(object sender, RoutedEventArgs e) { if (this.tbApplicationName.Text != string.Empty) { //Try-Catch is uplifted to handle - Duplicate Key value pair try { SSOPropBag ssoPropBag = new SSOPropBag(); ArrayList maskArray = new ArrayList(); foreach (DataGridViewRow row in (IEnumerable)this.dgvKeyValue.Rows) { if (row.Cells["clKeyName"].Value != null && row.Cells["clKeyName"].Value.ToString() != string.Empty) { object ptrVar = row.Cells["clValue"].Value; ssoPropBag.Write(row.Cells["clKeyName"].Value.ToString(), ref ptrVar); if (row.Cells["clIsMask"].FormattedValue.ToString().ToLower() == "yes") { maskArray.Add((object)268435456); } else { maskArray.Add((object)0); } } } SSOConfigManager.CreateConfigStoreApplication(this.tbApplicationName.Text, this.tbApplicationDescription.Text, this.tbSSOAffliateAdminGrp.Text, this.tbSSOAdminGrp.Text, ssoPropBag, maskArray); SSOConfigManager.SetConfigProperties(this.tbApplicationName.Text, ssoPropBag); int num = (int)System.Windows.Forms.MessageBox.Show("Application Successfully Created", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured. Details: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } else { int num1 = (int)System.Windows.Forms.MessageBox.Show("Application name is required.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btModify_Click(object sender, RoutedEventArgs e) { SSOPropBag ssoPropBag = new SSOPropBag(); ArrayList maskArray = new ArrayList(); //Try-Catch is added to handle - Duplicate Key value pair try { foreach (DataGridViewRow row in (IEnumerable)this.dgvKeyValue.Rows) { if (row.Cells["clKeyName"].Value != null && row.Cells["clKeyName"].Value.ToString() != string.Empty) { string propName = row.Cells["clKeyName"].Value.ToString(); object ptrVar = (object)row.Cells["clValue"].Value.ToString(); ssoPropBag.Write(propName, ref ptrVar); if (row.Cells["clIsMask"].FormattedValue.ToString().ToLower() == "yes") { maskArray.Add((object)268435456); } else { maskArray.Add((object)0); } } } } catch (Exception ex) { int num = (int)System.Windows.Forms.MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } string str1 = ""; string str2 = ""; bool flag1 = false; string empty1 = string.Empty; string empty2 = string.Empty; string empty3 = string.Empty; string description; string contactInfo; string appUserAcct; string appAdminAcct; HybridDictionary configProperties = SSOConfigManager.GetConfigProperties(this.tbApplicationName.Text, out description, out contactInfo, out appUserAcct, out appAdminAcct); string str3 = string.Empty; if (description != this.tbApplicationDescription.Text) { str3 = "Application description, "; } else if (appUserAcct != this.tbSSOAffliateAdminGrp.Text) { str3 += "SSO User Group, "; } else if (appAdminAcct != this.tbSSOAdminGrp.Text) { str3 += "SSO Admin Group"; } if (str3 != string.Empty) { str1 = System.Windows.Forms.MessageBox.Show("Are you sure wish to modify: " + str3, "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE"; } if (str1 != "DONTCHANGE") { foreach (DictionaryEntry property in ssoPropBag.properties) { bool flag2 = false; bool flag3 = false; foreach (DictionaryEntry dictionaryEntry in configProperties) { if (dictionaryEntry.Key.ToString() == property.Key.ToString()) { flag2 = true; if (dictionaryEntry.Value.ToString() == property.Value.ToString()) { flag3 = true; } } } empty1 += !flag2?property.Key.ToString() + ", " : ""; empty3 += !flag3?property.Key.ToString() + ", " : ""; } foreach (DictionaryEntry dictionaryEntry in configProperties) { bool flag2 = false; flag1 = false; foreach (DictionaryEntry property in ssoPropBag.properties) { if (dictionaryEntry.Key.ToString() == property.Key.ToString()) { flag2 = true; } } empty2 += !flag2?dictionaryEntry.Key.ToString() + ", " : ""; } string str4 = empty2.TrimEnd(',', ' '); string str5 = empty1.TrimEnd(',', ' '); string str6 = empty3.TrimEnd(',', ' '); if (str5 != string.Empty && str4 != string.Empty) { str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Add field/s' (" + str5 + ") and Delete field/s' (" + str4 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE"; } else if (str5 != string.Empty) { str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Add field/s' (" + str5 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE"; } else if (str4 != string.Empty) { str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Delete field/s' (" + str4 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE"; } else if (str6 != string.Empty) { str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Update field/s' (" + str6 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE"; } try { if ((str2 == "CHANGE" || str1 == "CHANGE") && str2 != "DONTCHANGE") { SSOConfigManager.DeleteApplication(this.tbApplicationName.Text); SSOConfigManager.CreateConfigStoreApplication(this.tbApplicationName.Text, this.tbApplicationDescription.Text, this.tbSSOAffliateAdminGrp.Text, this.tbSSOAdminGrp.Text, ssoPropBag, maskArray); SSOConfigManager.SetConfigProperties(this.tbApplicationName.Text, ssoPropBag); if (str6 != string.Empty && str1 == "") { int num1 = (int)System.Windows.Forms.MessageBox.Show("Only field values are updated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (str6 != string.Empty && str1 == "CHANGE") { int num2 = (int)System.Windows.Forms.MessageBox.Show("User details and Only field values are updated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { int num3 = (int)System.Windows.Forms.MessageBox.Show("Application successfully modified.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { int num = (int)System.Windows.Forms.MessageBox.Show("No field values are updated.", "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { int num = (int)System.Windows.Forms.MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } else { int num4 = (int)System.Windows.Forms.MessageBox.Show("No field values are updated.", "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }