internal static void SetDefaultDocumentGroup(string documentType) { CustomPropertiesSection myCustomPropertiesSection = configuration.GetSection("customProperties") as CustomPropertiesSection; myCustomPropertiesSection.DocumentGroups.Default = documentType; //configuration.SaveAs(@"D:/cfg_ddg.xml", ConfigurationSaveMode.Full); try { configuration.Save(ConfigurationSaveMode.Modified); //configuration.SaveAs(Assembly.GetExecutingAssembly().Location + @"/cfg_ddg.xml", ConfigurationSaveMode.Modified); } catch (Exception ex) { MessageBox.Show("Not able to save."); MessageBox.Show(ex.Message); } }
internal static void SetDefaultBaseUrl(string baseUrlName) { CustomPropertiesSection myCustomPropertiesSection = configuration.GetSection("customProperties") as CustomPropertiesSection; myCustomPropertiesSection.Urls.Default = baseUrlName; //configuration.SaveAs(@"D:/cfg_dbu.xml", ConfigurationSaveMode.Full); try { configuration.Save(ConfigurationSaveMode.Modified); //configuration.SaveAs(Assembly.GetExecutingAssembly().Location + @"/cfg_dbu.xml", ConfigurationSaveMode.Modified); } catch (Exception ex) { MessageBox.Show("Not able to save."); MessageBox.Show(ex.Message); } }
internal static Dictionary <string, string> GetDocumentGroupList() { Dictionary <string, string> result = new Dictionary <string, string>(); try { // Get the MyUrls section. CustomPropertiesSection myCustomPropertiesSection = configuration.GetSection("customProperties") as CustomPropertiesSection; //CustomPropertiesSection myCustomPropertiesSection = ConfigurationManager. as CustomPropertiesSection; if (myCustomPropertiesSection == null) { logger.Log("Failed to load UrlsSection."); } else { foreach (DocumentGroupConfigElement documentGroupConfigElement in myCustomPropertiesSection.DocumentGroups) { result.Add(documentGroupConfigElement.Name, documentGroupConfigElement.Value); } } } catch (Exception ex) { MessageBox.Show("Error reading configuration file. Reason: " + ex.Message, "IDM Tools", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Log(ex.Message); } finally { if (result.Count == 0) { result.Add("NO_DOCUMENT_GROUPS_FOUND", "No Document Groups found"); } } return(result); }