protected virtual void ReadConfiguration() { try { Random rnd = new Random(); MemIniFile iniFile = new MemIniFile(settingFileName, true); iniFile.Load(); Left = iniFile.ReadInteger("Settings", "Left", rnd.Next(0, PrimaryScreen.Bounds.Width - 96)); Top = iniFile.ReadInteger("Settings", "Top", rnd.Next(0, (int)((PrimaryScreen.Bounds.Height - 96) / 2))); OnLoadSettings(new IniFileAccessArgs(iniFile)); iniFile.Dispose(); } catch { } }
public void LoadReport(string reportname, string reportsconfig) { if (reportname.Length > 0) { ReportName = reportname; byte[] image = Data.GetReportData(reportname); if (image != null) { MemIniFile mif = new MemIniFile(String.Empty); mif.FromString(reportsconfig); this.PrintAuto = mif.ReadBool(reportname, "PrintAuto", false); this.PrintTime = mif.ReadDate(reportname, "PrintTime", DateTime.Parse("08:05:00")); this.PrintPeriod = mif.ReadInteger(reportname, "PrintPeriod", 0); //------------------------------------------ SelList.Clear(); PlotList.Clear(); GC.Collect(); string content = Encoding.Unicode.GetString(image); PrinterSettings ps = printDocument.PrinterSettings; string[] lines = content.Split(new string[] { "\r\n" }, StringSplitOptions.None); ImportLines(ref ps, lines); printDocument.PrinterSettings = ps; Update(); } } }
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; } } }
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(); } } }