private void LoadIniFileData() { Description = iniFile.ReadString("Settings", "Description", string.Empty); Description = Description.Replace(@"\n", Environment.NewLine); logoFile = FileOperations.StripFileName(iniFile.ReadString("Settings", "Logo", string.Empty)); TranslationId = iniFile.ReadString("Settings", "TranslationId", string.Empty); if (!string.IsNullOrEmpty(TranslationId)) { Caption = SR.Keys.GetString(TranslationId); } else { Caption = string.Empty; } if (string.IsNullOrEmpty(Caption)) { if (TextHelper.SameText(GlobalConfig.HomeCircleName, FileName)) { Caption = SR.DefaultRingName; } else { Caption = Path.GetFileNameWithoutExtension(FileName); } } }
public HistoryEntry(string fileName) { this.iniFile = new MemIniFile(FileOperations.StripFileName(fileName)); iniFile.Load(); TranslationId = iniFile.ReadString("Settings", "TranslationId", string.Empty); if (!string.IsNullOrEmpty(TranslationId)) { caption = SR.Keys.GetString(TranslationId); } else { caption = string.Empty; } if (string.IsNullOrEmpty(caption)) { if (TextHelper.SameText(GlobalConfig.HomeCircleName, fileName)) { caption = SR.DefaultRingName; } else { caption = Path.GetFileNameWithoutExtension(fileName); } } description = iniFile.ReadString("Settings", "Description", string.Empty); logoFile = iniFile.ReadString("Settings", "Logo", string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="ToyAboutBox"/> class. /// </summary> public ToyAboutBox(string configFileName) { MemIniFile iniFile = new MemIniFile(configFileName); iniFile.Load(); window = new AboutWindow(); window.TopMostWindow = true; window.KeyDown += new System.Windows.Forms.KeyEventHandler(window_KeyDown); window.MouseClick += new System.Windows.Forms.MouseEventHandler(window_MouseClick); window.BigIcon = Path.Combine(Path.GetDirectoryName(configFileName), iniFile.ReadString("Toy", "Icon")); window.Copyright = iniFile.ReadString("Toy", "Copyright"); window.Author = "Author: " + iniFile.ReadString("Toy", "Author"); window.Version = "Version: " + iniFile.ReadString("Toy", "Version"); window.Description = iniFile.ReadString("Toy", "Description"); window.AboutText = iniFile.ReadString("Toy", "AboutText"); iniFile.Dispose(); }
public override void ReadConfiguration(MemIniFile ini) { if (!IsVirtual) { string stringValue; //we need target name before reading the base config try { stringValue = ini.ReadString(this.StoneID, "Target", null); if (!string.IsNullOrEmpty(stringValue)) { TargetName = stringValue; } } catch (Exception ex) { throw new StoneSettingsException("Read stone settings error", ex); } base.ReadConfiguration(ini); try { stringValue = ini.ReadString(this.StoneID, "Parameters", null); if (!string.IsNullOrEmpty(stringValue)) { TargetParameters = stringValue; } stringValue = ini.ReadString(this.StoneID, "Argument", null); if (!string.IsNullOrEmpty(stringValue)) { ArgumentDescription = stringValue; } } catch (Exception ex) { throw new StoneSettingsException("Read stone settings error", ex); } } }
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 virtual void ReadConfiguration(MemIniFile ini) { if (!IsVirtual) { try { string stringValue; RunCount = ini.ReadInteger(this.stoneID, "RunCount", 0); Rating = ini.ReadInteger(this.stoneID, "Rating", 0); RunLevel = ini.ReadInteger(this.stoneID, "RunLevel", 0); stringValue = ini.ReadString(this.stoneID, "TranslationId", null); if (!string.IsNullOrEmpty(stringValue)) { TranslationId = stringValue; } TargetDescription = ini.ReadString(this.StoneID, "Description", null); } catch (Exception ex) { throw new StoneSettingsException("Read stone settings error", ex); } } }
private void AutoPrintReports(DateTime now) { MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(Properties.Settings.Default.ReportsConfig); // выбор автозапускаемых отчётов на текущее время в список list List <string> list = new List <string>(); foreach (string section in mif.ReadSections()) { bool auto = mif.ReadBool(section, "PrintAuto", false); if (auto) { string name = mif.ReadString(section, "ReportName", section); DateTime time = mif.ReadDate(section, "PrintTime", DateTime.Parse("08:05:00")); int period = mif.ReadInteger(section, "PrintPeriod", 0); if (period == 0) // ежедневно { if (time.Hour == now.Hour && time.Minute == now.Minute) { list.Add(name); } } else if (period == 1) // ежемесячно 1 числа { if (now.Day == 1 && time.Hour == now.Hour && time.Minute == now.Minute) { list.Add(name); } } } } // отправка на печать отчётов, печатаемых в настоящий момент foreach (string name in list) { using (PrintDocument printDoc = new PrintDocument()) { printDoc.PrintPage += printDoc_PrintPage; printReport = new PrintReport(printDoc); printReport.LoadReport(name, Properties.Settings.Default.ReportsConfig); printDoc.Print(); printDoc.PrintPage -= printDoc_PrintPage; } } }
public override void ReadConfiguration(MemIniFile ini) { if (!IsVirtual) { string stringValue; base.ReadConfiguration(ini); try { stringValue = ini.ReadString(this.StoneID, "CustomIcon", null); if (!string.IsNullOrEmpty(stringValue)) { CustomIcon = FileOperations.StripFileName(stringValue); } } catch (Exception ex) { throw new StoneSettingsException("Read stone settings error", ex); } } }
private static void worker_DoWork(object sender, DoWorkEventArgs e) { Tuple <int, string, string, exitApp, string, int> args = (Tuple <int, string, string, exitApp, string, int>)e.Argument; int channel = args.Item1; string info = args.Item2; MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(args.Item3); exitApp DoExitApp = args.Item4; string ClientID = args.Item5; int timeout = args.Item6; string section = "Application"; int station = mif.ReadInteger(section, "Station", 1); string ApplicationStartupPath = mif.ReadString(section, "StartupPath", "."); bool Registered = mif.ReadBool(section, "Registered", false); bool Bonus = mif.ReadBool(section, "Bonus", false); Data.RestoreSQLsettingsFromString(args.Item3); BackgroundWorker worker = (BackgroundWorker)sender; DateTime TurnOnTime = DateTime.Now; IDictionary <string, IPointPlugin> plugins = PointPlugin.LoadPlugin(ApplicationStartupPath + "\\Points.Modbus.dll"); // Инициализация, создание баз, если их раньше не было Settings.CreateDataAndFetchBases(); string desc = "Канал " + channel + " сервера опроса"; // Заполнение списка для опроса LoadFirst(worker, ClientID, channel, plugins); bool _exit = false; bool _continue = true; while (_continue) { if (!Data.ImLive(ClientID, "F", Station, desc + " Modbus")) { ClientID = Data.ClientLogin(ClientID, "F", station, desc + " Modbus"); } string[] command = Data.GetClientCommand(ClientID); //if (command[0].Equals("RELOAD")) //{ //} if (!Registered) { if (DateTime.Now.AddHours(-2.5) > TurnOnTime) { Bonus = false; } } if (Registered || Bonus) { try { FetchBase(worker, ClientID, channel, info, timeout, plugins); Thread.Sleep(50); } catch (Exception ex) { Data.SendToSystemLog(0, "Опрос Modbus", ex.Message); } } else if (!_exit) { _exit = true; Data.SendToSystemLog(Station, "Опрос Modbus", "Прекращена работа неавторизованного сервера опроса"); DoExitApp(); } } }
private static void worker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; Tuple <string, exitApp> args = (Tuple <string, exitApp>)e.Argument; MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(args.Item1); string section = "Application"; int station = mif.ReadInteger(section, "Station", 1); string ApplicationStartupPath = mif.ReadString(section, "StartupPath", "."); bool Registered = mif.ReadBool(section, "Registered", false); bool Bonus = mif.ReadBool(section, "Bonus", false); exitApp DoExitApp = args.Item2; Data.RestoreSQLsettingsFromString(args.Item1); DateTime TurnOnTime = DateTime.Now; // Загрузка плагина виртуальных точек IDictionary <string, IPointPlugin> plugins = PointPlugin.LoadPlugin(ApplicationStartupPath + "\\Points.Virtuals.dll"); // Инициализация, создание баз, если их раньше не было Settings.CreateDataAndFetchBases(); // Загрузка виртуальных точек из базы данных Data.LoadBase(plugins); string desc = "Сервер опроса виртуальных значений"; Data.SendToSystemLog(station, "Опрос виртуальных", "Сервер опроса загружен"); ClientID = Data.ClientLogin(ClientID, "F", Station, desc); // Заполнение списка для опроса LoadFirst(worker); bool _exit = false; bool _continue = true; while (_continue) { _continue = !worker.CancellationPending; if (!Data.ImLive(ClientID, "F", Station, desc)) { ClientID = Data.ClientLogin(ClientID, "F", Station, desc); } string[] command = Data.GetClientCommand(ClientID); //if (command[0].Equals("RELOAD")) //{ //} if (!Registered) { if (DateTime.Now.AddHours(-2.5) > TurnOnTime) { Bonus = false; } } if (Registered || Bonus) { try { FetchBase(worker, plugins); Thread.Sleep(50); } catch (Exception ex) { Data.SendToSystemLog(0, "Опрос виртуальных", ex.Message); } } else if (!_exit) { _exit = true; Data.SendToSystemLog(station, "Опрос виртуальных", "Прекращена работа неавторизованного сервера опроса"); DoExitApp(); } } }