public static Dictionary <int, string> LoadAPIKeys(string p) { Dictionary <int, string> apikeys = new Dictionary <int, string>(); Dictionary <string, string> dic; int key = -1; string msg = string.Empty; try { dic = IniItemCollection.ReadIni(p); foreach (string k in dic.Keys) { if (int.TryParse(k, out key)) { if (!string.IsNullOrEmpty(dic[k])) { apikeys[key] = dic[k]; } } else { msg += (msg != string.Empty ? "\r\n" : string.Empty) + "Error reading an int " + k; } } } catch (Exception ex) { MessageBox.Show("Error reading file " + p + "\r\n" + ex.Message, Properties.Settings.Default.tm, MessageBoxButtons.OK); } if (msg != string.Empty) { MessageBox.Show(msg, Properties.Settings.Default.tm, MessageBoxButtons.OK); } return(apikeys); }
public static bool LoadIni() { string qsrc = string.Empty; Dictionary <string, string> itms = IniItemCollection.ReadIni(Properties.Settings.Default.ini); if (itms == null) { throw new InvalidOperationException("Check ini file " + Properties.Settings.Default.ini); } if (itms.Count == 0) { throw new InvalidOperationException("Check ini file " + Properties.Settings.Default.ini); } foreach (string k in itms.Keys) { switch (k) { case "CrawlerDefault": Properties.Settings.Default.crawler = itms[k]; break; case "QuoteSource": qsrc = itms[k]; break; case "FilteringScheduledAt": Properties.Settings.Default.fltr_schedule = itms[k]; break; case "FilteringPassiveCollection": Properties.Settings.Default.fltr_passive = bool.Parse(itms[k]); break; case "TaskRemoteFeedType": Properties.Settings.Default.task_feed_type = int.Parse(itms[k]); break; case "FilterResultWrapper": Properties.Settings.Default.fltr_wrap = itms[k]; break; } } if (qsrc != QuandlAPI._PROVIDER /* && more */) { qsrc = string.Empty; } if (qsrc == string.Empty && Properties.Settings.Default.qsource == string.Empty) { Properties.Settings.Default.qsource = QuandlAPI._PROVIDER; } if (Properties.Settings.Default.qsource == QuandlAPI._PROVIDER) { if (!CreateDefaultDbConfig()) { MessageBox.Show("Error creating default DB config.", Properties.Settings.Default.tm, MessageBoxButtons.OK); return(false); } } else { throw new NotImplementedException(); } return(true); }