private static string configString(string content, string channelkey) { MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(content); if (mif.SectionExists(servname) && mif.KeyExists(servname, channelkey)) { return(mif.ReadString(servname, channelkey, String.Empty)); } return(String.Empty); }
public static void StartFetch(string[] args) { string ApplicationStartupPath = (args.Length >= 1) ? args[0] : String.Empty; string ConfigContent = (args.Length >= 2) ? args[1] : String.Empty; Station = (args.Length >= 3) ? int.Parse(args[2]) : 0; // MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(ConfigContent); string section = "FetchServices"; if (mif.SectionExists(section) && mif.KeyExists(section, servname) && mif.ReadBool(section, servname, false) && mif.SectionExists(servname)) { string[] keys = mif.ReadSectionKeys(servname); foreach (string key in keys) { int channel; if (key.StartsWith("Channel") && int.TryParse(key.Substring(7), out channel)) { string desc = "Канал " + channel + " сервера опроса"; Data.SendToSystemLog(Station, "Опрос KR500", desc + " загружен"); string ClientID = Data.ClientLogin(String.Empty, "F", Station, desc + " KR500"); BackgroundWorker worker = new BackgroundWorker(); workers.Add(new Tuple <string, BackgroundWorker>( ClientID, worker)); worker.DoWork += worker_DoWork; worker.ProgressChanged += worker_ProgressChanged; worker.WorkerSupportsCancellation = true; //worker.WorkerReportsProgress = true; worker.RunWorkerAsync(new Tuple <string, string, string, int, string>( ClientID, ApplicationStartupPath, ConfigContent, channel, key)); } } } }