Exemplo n.º 1
0
        public static List <BookInfo> GetAllBooks()
        {
            List <BookInfo> infos    = new List <BookInfo>();
            var             sections = IniUtils.ReadSections(ConfigFile);

            foreach (var section in sections)
            {
                if (section != CURRENTKEY && section != CONFIGKEY)
                {
                    BookInfo info;
                    if (GetBookInfo(section, out info))
                    {
                        infos.Add(info);
                    }
                }
            }
            return(infos);
        }
Exemplo n.º 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            /// 系统参数读取
            ///
            // 计时器频率
            String intervalStr = iniUtils.IniReadValue(Config.SystemIniPath, "system", "interval");
            // 请求超时时间
            String timeoutStr = iniUtils.IniReadValue(Config.SystemIniPath, "system", "timeout");
            int    interval   = 0;
            int    timeout    = 0;

            if (null == intervalStr || "".Equals(intervalStr))
            {
                interval = Decimal.ToInt32(TimerInterval_Input.Minimum);
            }
            else
            {
                interval = int.Parse(intervalStr);
            }
            if (null == timeoutStr || "".Equals(timeoutStr))
            {
                timeout = Decimal.ToInt32(Timeout_Input.Minimum);
            }
            else
            {
                timeout = int.Parse(timeoutStr);
            }
            TimerInterval_Input.Value = interval;
            Timeout_Input.Value       = timeout;
            Config.interval           = interval;
            Config.timeout            = timeout;
            // 监控邮件配置
            String emailServer = iniUtils.IniReadValue(Config.SystemIniPath, "email", "server");
            String emailPort   = iniUtils.IniReadValue(Config.SystemIniPath, "email", "port");
            String fromEmail   = iniUtils.IniReadValue(Config.SystemIniPath, "email", "fromEmail");
            String username    = iniUtils.IniReadValue(Config.SystemIniPath, "email", "username");
            String password    = iniUtils.IniReadValue(Config.SystemIniPath, "email", "password");

            Config.emailServer = emailServer;
            Config.emailPort   = emailPort;
            Config.fromEmail   = fromEmail;
            Config.username    = username;
            Config.password    = password;
            // 日志
            String logFileName = iniUtils.IniReadValue(Config.SystemIniPath, "log", "filename");
            String logSwitch   = iniUtils.IniReadValue(Config.SystemIniPath, "log", "switch");

            Config.logFileName = logFileName;
            if (logSwitch != null && "on".Equals(logSwitch))
            {
                Config.logSwitch = true;
            }
            // 主窗体赋值,以便其它地方调用
            Config.mainForm = this;
            // 动态创建按钮控件
            List <String> sectionList = iniUtils.ReadSections(Config.MonitorIniPath);

            for (int i = 0; i < sectionList.Count; i++)
            {
                String section = sectionList[i];
                // 创建按钮
                addButton(section);
            }
            // 给时间控件绑定事件
            timer.Elapsed  += new System.Timers.ElapsedEventHandler(timer_total_Tick);
            timer.AutoReset = true;

            // 按钮可用初始化
            Monitor_Button.Enabled = true;
            Stop_Button.Enabled    = false;
        }