internal static void DoAdmin() { SwitchablePolicyConfigFacade globalExtensionConfigFacade = EM_AppContext.Instance.GetSwitchablePolicyConfigFacade(); SwitchablePolicyConfig globalExtensionConfig = globalExtensionConfigFacade.GetSwitchablePolicyConfig(); try { List <ExtensionOrGroup> extensions = new List <ExtensionOrGroup>(); foreach (var sp in globalExtensionConfig.SwitchablePolicy) { extensions.Add(new ExtensionOrGroup(sp)); } AdminExtensionsOrGroupsForm adminDialog = new AdminExtensionsOrGroupsForm("Administrate Global Extensions", extensions, true); if (adminDialog.ShowDialog() == DialogResult.Cancel) { return; } foreach (ExtensionOrGroup add in adminDialog.added) { globalExtensionConfig.SwitchablePolicy.AddSwitchablePolicyRow(Guid.NewGuid().ToString(), add.name, add.shortName, add.look.ToXml()); } foreach (ExtensionOrGroup change in adminDialog.changed) { SwitchablePolicyConfig.SwitchablePolicyRow changeRow = (from ext in globalExtensionConfig.SwitchablePolicy where ext.ID == change.id select ext).First(); changeRow.LongName = change.name; changeRow.NamePattern = change.shortName; changeRow.Look = change.look.ToXml(); } List <SwitchablePolicyConfig.SwitchablePolicyRow> delRow = (from ext in globalExtensionConfig.SwitchablePolicy select ext).ToList(); for (int i = delRow.Count - 1; i >= 0; --i) { if (adminDialog.deletedIds.Contains(delRow[i].ID)) { delRow[i].Delete(); } } globalExtensionConfigFacade.AcceptChanges(); globalExtensionConfigFacade.WriteXML(); foreach (EM_UI_MainForm mainForm in EM_AppContext.Instance.GetOpenCountriesMainForms()) { mainForm.treeList.Refresh(); // update look if necessary } } catch (Exception exception) { globalExtensionConfigFacade.RejectChanges(); UserInfoHandler.ShowException(exception); } }
internal SwitchablePolicyConfigApplyAdministrator(MergeAdministrator mergeAdministrator, SwitchablePolicyConfigMergeForm mergeForm, SwitchablePolicyConfigFacade vcFacLocal, SwitchablePolicyConfigFacade vcFacRemote) { _mergeAdministrator = mergeAdministrator; _vcFacLocal = vcFacLocal; _vcLocal = _vcFacLocal.GetSwitchablePolicyConfig(); _vcFacRemote = vcFacRemote; _vcRemote = _vcFacRemote.GetSwitchablePolicyConfig(); _mergeForm = mergeForm; _mcSwitchablePolicyConfig = _mergeForm.GetMergeControlByName(EMPath.EM2_FILE_EXTENSIONS); }
void ApplyRemovals(MergeControl mergeControl, DataTable localDataTable, string idColumnName, bool local) { foreach (string ID in GetRelevantIDs(mergeControl, local, false)) { string whereClause = idColumnName + " = '" + ID + "'"; DataRow dataRow = localDataTable.Select(whereClause).First(); dataRow.Delete(); } _vcFacLocal.GetSwitchablePolicyConfig().AcceptChanges(); }
internal static SwitchablePolicyConfig.SwitchablePolicyRow GetGlobalExtension(SwitchablePolicyConfigFacade switchablePolicyConfigFacade, string extensionID) { return((from e in switchablePolicyConfigFacade.GetSwitchablePolicyConfig().SwitchablePolicy where e.ID == extensionID select e).FirstOrDefault()); }