Esempio n. 1
0
 public bool insertLongMDevLimit(MDevLimitMessageOutClass newClass, string type, string year, string month, string day, string hour)
 {
     try
     {
         bool      isok = false;
         DataTable dt   = isHaveData(year, month, day, hour, type, "psl_mdevlimit");
         if (dt != null && dt.Rows.Count > 0)
         {
             isok = a_dal.updateLongMDevLimit(Convert.ToInt32(dt.Rows[0]["id"].ToString()), newClass, type, year, month, day, hour);
         }
         else
         {
             isok = a_dal.insertLongMDevLimit(newClass, type, year, month, day, hour);
         }
         return(isok);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
        public static Results Calcu(DataSet inputs, CalcuInfo calcuinfo)
        {
            bool   _errorFlag   = false;
            string _errorInfo   = "";
            bool   _warningFlag = false;
            string _warningInfo = "";
            bool   _fatalFlag   = false;
            string _fatalInfo   = "";

            int i;

            //0输出初始化:该算法如果没有有效输入值(inputs为null)或者输入值得有效值为null,给出的计算结果。值为0,计算标志位为StatusConst.InputIsNull
            List <PValue>[] results = new List <PValue> [122];   //最大值(快速);最小值(快速);极差(快速);算术和(快速);算术平均值(快速)
            for (i = 0; i < results.Length; i++)
            {
                results[i] = new List <PValue>();
                results[i].Add(new PValue(0, calcuinfo.fstarttime, calcuinfo.fendtime, (long)StatusConst.InputIsNull));
            }

            try
            { //读取参数
                double   LimitHH, LimitH, LimitRP, LimitOO, LimitRN, LimitL, LimitLL;
                string   mode;
                string[] paras = calcuinfo.fparas.Split(';');

                LimitHH = int.Parse(paras[0]);
                LimitH  = int.Parse(paras[1]);
                LimitRP = double.Parse(paras[2]);
                LimitOO = double.Parse(paras[3]);
                LimitRN = double.Parse(paras[4]);
                LimitL  = double.Parse(paras[5]);
                LimitLL = double.Parse(paras[6]);

                string year  = calcuinfo.fstarttime.Year.ToString();
                string month = calcuinfo.fstarttime.Month.ToString();
                string day   = calcuinfo.fstarttime.Day.ToString();
                string hour  = "0";
                //tagId
                string tagid = calcuinfo.fsourtagids[0].ToString();
                //获取短周期数据
                DataSet ds = BLL.AlgorithmBLL.getShortData("psl_mdevlimit", tagid, year, month, day);
                //0.1、输入处理:过滤后结果。
                //——如果去除了截止时刻点,过滤后长度小于1(计算要求至少有一个有效数据),则直接返回null
                //——如果没取除截止时刻点,过滤后长度小于2(计算要求至少有一个有效数据和一个截止时刻值)
                if (ds.Tables[0] == null || ds.Tables[0].Rows.Count < 1)
                {
                    _warningFlag = true;
                    _warningInfo = "对应时间段内的源数据状态位全部异常。";
                    return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo));
                }


                #region 长周期计算
                List <MDevLimitMessageOutClass> effective = new DatatableToEntity <MDevLimitMessageOutClass>().FillModel(ds.Tables[0]);
                MDevLimitMessageOutClass        res       = MDevLimitCaculate.longMDevLimit(effective, LimitHH, LimitH, LimitRP, LimitOO, LimitRN, LimitL, LimitLL);

                //计算结果存入数据库
                bool isok = BLL.AlgorithmBLL.insertLongMDevLimit(res, tagid, year, month, day, hour);
                if (isok)
                {
                    return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo));
                }
                else
                {
                    _fatalFlag = true;
                    _fatalInfo = "MDevLimit长周期数据录入数据库是失败";
                    return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo));
                }
                #endregion
            }
            catch (Exception ex)
            {
                //计算中出任何错误,则需要记录log
                //LogHelper.Write(LogType.Error, "计算模块错误!");
                //记录计算模块的名称、当前标签、起始时间、结束时间
                //string moduleInfo = string.Format("——计算模块的名称是:{0},当前计算源标签是:{1},计算起始时间是:{2},计算结束时间是:{3}。", calcuInfo.fmodulename, calcuInfo.sourcetagname, calcuinfo.fstarttime.ToString(), calcuinfo.fendtime.ToString());
                //LogHelper.Write(LogType.Error, moduleInfo);
                //计算引擎报错具体信息
                //string errInfo = string.Format("——具体报错信息:{0}。", ex.ToString());
                //LogHelper.Write(LogType.Error, errInfo);
                //返回null供计算引擎处理
                _fatalFlag = true;
                _fatalInfo = ex.ToString();
                return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo));
            }
        }