Ejemplo n.º 1
0
        /// <summary>
        /// 保存配置文件
        /// </summary>
        void SaveConfig()
        {
            if (cmboxPeriod.SelectedItem != null)
            {
                AkConfig.PeriodNum = int.Parse(cmboxPeriod.Text.ToString());
            }
            if (cmboxTime.SelectedItem != null)
            {
                AkConfig.UpdateNum = int.Parse(cmboxTime.Text.ToString());
            }

            AkSettingModel model = new AkSettingModel();

            model.PeriodNum = AkConfig.PeriodNum;
            model.UpdateNum = AkConfig.UpdateNum;
            string json = JsonConvert.SerializeObject(model);

            FileHelper.Instance.Write(json);

            //保存后从新更新阀值
            AkThreshold akThreshold = new AkThreshold();

            akThreshold.SaveThreshold(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            MessageBox.Show("保存成功!");
            this.Close();
        }
Ejemplo n.º 2
0
        //UDP发送分线提醒方法
        //MainWindow.mainWindow.SendMess();
        /// <summary>
        /// 开始计算
        /// </summary>
        public void Start()
        {
            AkThreshold akThreshold = new AkThreshold();

            ///上一次任务执行的时间
            string lastTaskTime = string.Empty;

            while (true)
            {
                //清除日志
                clearLog();

                //@1.读取系统配置信息
                AkConfig.ReadParam();

                //AkConfig.SysParam = new AkSystemParamModel();
                //AkConfig.SysParam.TaskTime = 300;

                //@2.间隔时间,单位 ms
                int waitetime = AkTask.WatiTime(lastTaskTime);
                Thread.Sleep(waitetime);

                lastTaskTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                LogHelper.Info("开始任务时间 = ", lastTaskTime);

                //@3.线程跑阀值
                akThreshold.Excute(lastTaskTime);

                //@4是否分线提醒
                bool bl = new AkRemind().Remind();

                if (bl)
                {
                    MainWindow.mainWindow.SendMess("分线提醒");
                    LogHelper.Info("分线提醒: ", DateTime.Now.ToLongTimeString());
                }
                else
                {
                    MainWindow.mainWindow.SendMess("不分线提醒");
                    LogHelper.Info("不分线提醒: ", DateTime.Now.ToLongTimeString());
                }
                LogHelper.Info(string.Empty, string.Empty);
            }
        }