protected void btnApply_Click(object sender, EventArgs e)
        {
            if (gvTable.Rows.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < gvTable.Rows.Count; i++)
            {
                ECTagEntity csE = new ECTagEntity();
                csE.ECID = gvTable.Rows[i]["ECID"].ToString();
                csE.ECIndex = i + 1;

                ECTagDal.Update(csE);
            }

            MessageBox.popupClientMessage(this.Page, "排序成功!", "call();");
        }
        protected bool ImportFromExcelToDelete(DataSet ds)
        {
            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int nAll = dt.Rows.Count;
                int nDelete = 0;
                int nEmpty = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string ECCode = dr["ECCode"].ToString().Trim();

                        //判断是否存在
                        if (!ECTagDal.CodeExist(ECCode, ""))
                        {
                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            nEmpty += 1;
                            continue;
                        }
                        else
                        {
                            //main tag
                            ECTagEntity mEntity = new ECTagEntity();
                            mEntity.ECID = ECTagDal.GetECIDByCode(ECCode);

                            ECTagDal.Delete(mEntity);
                            nDelete += 1;
                        }
                    }
                }

                string strInfor = "标签点总数为:{0}个, 删除成功:{1}个,空标签点: {2}个。";
                strInfor = string.Format(strInfor, nAll, nDelete, nEmpty);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return true;

            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, ee.Message, "call();");

                return false;
            }

        }
        protected bool ImportFromExcelToModify(DataSet ds)
        {
            string strError = "";
            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int nAll = dt.Rows.Count;
                int nModify = 0;
                int nNoExist = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string ECCode = dr["ECCode"].ToString().Trim();
                        strError = ECCode;

                        //判断是否存在
                        if (!ECTagDal.CodeExist(ECCode, ""))
                        {
                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            nNoExist += 1;
                            continue;
                        }

                        //main tag
                        string keyid = ECTagDal.GetECIDByCode(ECCode);


                        ECTagEntity mEntity = new ECTagEntity();

                        mEntity.ECID = keyid;
                        string UnitName = dr["UnitName"].ToString().Trim();
                        mEntity.UnitID = KPI_UnitDal.GetUnitID(UnitName);
                        string SeqName = dr["SeqName"].ToString().Trim();
                        mEntity.SeqID = KPI_SeqDal.GetSeqID(SeqName);
                        string KpiName = dr["KpiName"].ToString().Trim();
                        mEntity.KpiID = KpiDal.GetKpiID(KpiName);
                        string EngunitName = dr["EngunitName"].ToString().Trim();
                        mEntity.EngunitID = EngunitDal.GetEngunitID(EngunitName);
                        string CycleName = dr["CycleName"].ToString().Trim();
                        mEntity.CycleID = CycleDal.GetCycleID(CycleName);

                        mEntity.ECCode = dr["ECCode"].ToString().Trim();
                        mEntity.ECName = dr["ECName"].ToString().Trim();
                        mEntity.ECDesc = dr["ECDesc"].ToString().Trim();
                        mEntity.ECIndex = int.Parse(dr["ECIndex"].ToString().Trim());
                        mEntity.ECWeb = dr["ECWeb"].ToString().Trim();
                        mEntity.ECIsValid = int.Parse(dr["ECIsValid"].ToString().Trim());

                        mEntity.ECIsCalc = int.Parse(dr["ECIsCalc"].ToString().Trim());
                        mEntity.ECIsAsses = int.Parse(dr["ECIsAsses"].ToString().Trim());
                        mEntity.ECIsZero = int.Parse(dr["ECIsZero"].ToString().Trim());
                        mEntity.ECIsDisplay = int.Parse(dr["ECIsDisplay"].ToString().Trim());
                        mEntity.ECIsTotal = int.Parse(dr["ECIsTotal"].ToString().Trim());
                        mEntity.ECDesign = dr["ECDesign"].ToString().Trim();

                        mEntity.ECOptimal = dr["ECOptimal"].ToString().Trim();
                        if (dr["ECMaxValue"].ToString().Trim() != "")
                        {
							mEntity.ECMaxValue = decimal.Parse(dr["ECMaxValue"].ToString().Trim());
                        }
                        if (dr["ECMinValue"].ToString().Trim() != "")
                        {
							mEntity.ECMinValue = decimal.Parse(dr["ECMinValue"].ToString().Trim());
                        }
						mEntity.ECWeight = decimal.Parse(dr["ECWeight"].ToString().Trim());
                        mEntity.ECCalcClass = int.Parse(dr["ECCalcClass"].ToString().Trim());
                        mEntity.ECFilterExp = dr["ECFilterExp"].ToString().Trim();

                        mEntity.ECCalcExp = dr["ECCalcExp"].ToString().Trim();
                        mEntity.ECCalcDesc = dr["ECCalcDesc"].ToString().Trim();
                        mEntity.ECIsSnapshot = int.Parse(dr["ECIsSnapshot"].ToString().Trim());
                        mEntity.ECXLineType = int.Parse(dr["ECXLineType"].ToString().Trim());
                        mEntity.ECXLineGetType = int.Parse(dr["ECXLineGetType"].ToString().Trim());
                        mEntity.ECXLineXRealTag = dr["ECXLineXRealTag"].ToString().Trim();

                        mEntity.ECXLineYRealTag = dr["ECXLineYRealTag"].ToString().Trim();
                        mEntity.ECXLineZRealTag = dr["ECXLineZRealTag"].ToString().Trim();
                        mEntity.ECXLineXYZ = dr["ECXLineXYZ"].ToString().Trim();
                        mEntity.ECScoreExp = dr["ECScoreExp"].ToString().Trim();
                        mEntity.ECCurveGroup = dr["ECCurveGroup"].ToString().Trim();
                        mEntity.ECIsSort = int.Parse(dr["ECIsSort"].ToString().Trim());
                        mEntity.ECType = int.Parse(dr["ECType"].ToString().Trim());

                        mEntity.ECSort = int.Parse(dr["ECSort"].ToString().Trim());
                        mEntity.ECScore = dr["ECScore"].ToString().Trim();
                        mEntity.ECExExp = dr["ECExExp"].ToString().Trim();
                        mEntity.ECExScore = dr["ECExScore"].ToString().Trim();
                        mEntity.ECNote = dr["ECNote"].ToString().Trim();

                        mEntity.ECCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                        mEntity.ECModifyTime = mEntity.ECCreateTime;


                        ECTagDal.Update(mEntity);

                        nModify += 1;
                    }


                }

                string strInfor = "标签点总数为:{0}个, 修改成功:{1}个,不存在标签点: {2}个。";
                strInfor = string.Format(strInfor, nAll, nModify, nNoExist);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return true;

            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, strError + ": " + ee.Message, "call();");

                return false;
            }
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        void BindValues()
        {
            string ECID = ViewState["ecid"].ToString();

            if (ECID == "")
            {
                btnAddScore.Enabled = false;

                return;
            }

            mEntity = ECTagDal.GetEntity(ECID);

            if (mEntity == null)
            {
                return;
            }

            lbl_ECCode.Text = "指标代码:" + mEntity.ECCode;
            lbl_ECName.Text = "指标名称:" + mEntity.ECName;

            cbx_ECIsSnapshot.Checked = mEntity.ECIsSnapshot == 1 ? true : false;

            BindScore(true);
        }
        protected void cbx_ECIsSnapshot_CheckedChanged(object sender, EventArgs e)
        {
            string ecid = ViewState["ecid"].ToString();

            if (ecid == "")
            {
                btnAddScore.Enabled = false;

                return;
            }
            else
            {
                btnAddScore.Enabled = true;
            }

            ECTagEntity ect = new ECTagEntity();
            ect.ECID = ecid;
            ect.ECIsSnapshot = cbx_ECIsSnapshot.Checked ? 1 : 0;

            ECTagDal.Update(ect);
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <returns></returns>
        bool Update()
        {
            string ecid = ViewState["ecid"].ToString();

            ECTagEntity mEntity = new ECTagEntity();

            mEntity.ECID = ecid;
            mEntity.ECCalcExp = tbx_ECCalcExp.Text;//.Replace("'", "''");
            mEntity.ECCalcDesc = tbx_ECCalcDesc.Text;

            mEntity.ECModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

            return ECTagDal.Update(mEntity);
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <returns></returns>
        bool Update()
        {
            string ecid = ViewState["ecid"].ToString();

            ECTagEntity mEntity = new ECTagEntity();

            mEntity.ECID = ecid;
            mEntity.ECIsSort = cbx_ECIsSort.Checked ? 1 : 0;
            mEntity.ECType = int.Parse(ddl_ECType.SelectedValue);
            mEntity.ECSort= int.Parse(ddl_ECSort.Value);

            mEntity.ECScore = txt_ECScore.Value;
            mEntity.ECExExp = txt_ECExExp.Value;
            mEntity.ECExScore = txt_ECExScore.Value;

            mEntity.ECModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

            return ECTagDal.Update(mEntity);
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        bool Insert(string ecid)
        {
            ECTagEntity mEntity = new ECTagEntity();

            mEntity.ECID = ecid;
            //mEntity.UnitID = ddl_UnitID.SelectedValue;
            //mEntity.SeqID = ddl_SeqID.Value.Trim();
            //mEntity.KpiID = ddl_KpiID.SelectedValue;
            //mEntity.EngunitID = ddl_EngunitID.Value.Trim();
            //mEntity.CycleID = ddl_CycleID.Value.Trim();

            //mEntity.ECIsValid = int.Parse(ddl_ECIsValid.Value);
            //mEntity.ECIsCalc = int.Parse(ddl_ECIsCalc.Value);
            //mEntity.ECIsDisplay = int.Parse(ddl_ECIsDisplay.Value);
            //mEntity.ECIsTotal = int.Parse(ddl_ECIsTotal.Value);

            //mEntity.ECCode = txt_ECCode.Value.Trim();
            //mEntity.ECName = txt_ECName.Value.Trim();
            //mEntity.ECDesc = txt_ECDesc.Value.Trim();
            //mEntity.ECIndex = int.Parse(txt_ECIndex.Value.Trim());
            //mEntity.ECWeb = ddl_ECWeb.Value;

            ////
            //mEntity.ECDesign = txt_ECDesign.Value;
            //mEntity.ECOptimal = txt_ECOptimal.Value;
            //mEntity.ECMaxValue = int.Parse(txt_ECMaxValue.Value.Trim());
            //mEntity.ECMinValue = int.Parse(txt_ECMinValue.Value.Trim());
            //mEntity.ECWeight = int.Parse(txt_ECWeight.Value.Trim());

            //mEntity.ECNote = txt_ECNote.Value.Trim();
            //mEntity.ECCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            //mEntity.ECModifyTime = mEntity.ECCreateTime;

            return ECTagDal.Insert(mEntity);
        }
        /// <summary>
        /// KPI_Snapshot And KPI_Archive的操作
        /// xmin 周期的指标计算
        /// </summary>
        /// <returns></returns>
        public bool KPICalcForTM(bool bsnap, bool bRunning, ECTagEntity ecte, DateTime dtValid,
										string strCurrentShift, string strCurrentPeriod,
                                        out ECSSValueEntity kpiEV)
        {
            //bsnap== false时,更新 EC_SSArchive即可。
            if (bRunning == false) {
                kpiEV = null;
                return false;
            }
            string strCM = dtValid.ToString("yyyy-MM-dd HH:mm:00");
            bool bRight = true;
            double dResult = 0.0;
            String strResult = "";
            String strOptExp = "";
            double dScore = 0.0;
            int nAlarm = 0;
            if ((String.IsNullOrWhiteSpace(ecte.ECCalcExp)) && (!String.IsNullOrWhiteSpace(ecte.ECScoreExp))) {
                String strresult = "";
                String  strexpression="";
                double result = 0;
                Dictionary<String, double> dcexp = new Dictionary<string, double>();
                m_ExpressionParse.ExpCalculate(ecte.ECScoreExp, dcexp, out result, out strresult, out strexpression);
                kpiEV = new ECSSValueEntity();
                kpiEV.SSID = PageControl.GetGuid();
                kpiEV.UnitID = ecte.UnitID;
                kpiEV.SeqID = ecte.SeqID;
                kpiEV.KpiID = ecte.KpiID;
                kpiEV.ECID = ecte.ECID;
                kpiEV.ECName = ecte.ECName;
                kpiEV.ECTime = strCM;
                kpiEV.ECValue = 0;
                kpiEV.ECScore = result;
                kpiEV.ECOptExp = "";
                kpiEV.ECExpression = strexpression;
                kpiEV.ECQulity = 0;
                kpiEV.ECPeriod = strCurrentPeriod;
                kpiEV.ECShift = strCurrentShift;
                return true;
            }
            try {

                #region 指标计算

                ////////////////////////////////////////////////////////////////////////////////
                //指标计算
                //获得计算表达式
                string expression = ecte.ECCalcExp.ToUpper().Trim();
                string strexpression = "";

                if (expression == null || expression == "") {
                    LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "计算公式为空!");
                    kpiEV = null;
                    return true;
                }

                //解析计算表达式:获得标签及指标
                Dictionary<String, double> dic1 = new Dictionary<String, double>();
                if (m_ExpressionParse.ExpEvaluate(expression, ref dic1) != 0) {
                    LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标解析错误,确保实时标签存在,计算指标提前计算:" + ecte.ECCalcExp);
                    bRight = false;
                    dic1 = null;
                }
                else {
                    //执行计算表达式: 计算变量赋值与执行
                    for (int i = 0; i < dic1.Count; i++) {
                        String strkey = dic1.ElementAt(i).Key.ToUpper().Trim();
                        dic1[strkey] = m_KPIVar.dicTags[strkey];
                    }
                    //strexpression只在此使用,保证存储到数据库中
                    if (m_ExpressionParse.ExpCalculate(expression, dic1, out dResult, out strResult, out strexpression) != 0) {
                        LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标计算错误:" + ecte.ECCalcExp);
                        dResult = 0.0;
                        bRight = false;
                    }
                    dic1.Clear();

                    //是否负值归零
                    if (ecte.ECIsZero == 1 && dResult < 0) {
                        dResult = 0;
                    }
                    ////////////////////////////////////////////////////////////////////////////////
                    //指标赋值
                    //该指标添加到dicTags集合,其他指标使用时
                    String strCode = "'" + ecte.ECCode.ToUpper().Trim() + "'";
                    m_KPIVar.dicTags[strCode] = bRight ? dResult : 0.0;
                }
                //Console.WriteLine("指标计算结束");
                #endregion

                #region 得分计算

                if (bRight && bRunning) {
                    /////////////////////////////////////////////////////////////////////////////////////
                    //经济指标目标值计算
                    if (ecte.ECIsSnapshot == 1) {
                        //机组负荷,曲线默认基准值。
                        double dUnitPE = m_KPIVar.dicUnitPEs[ecte.UnitID];

                        #region 系数计算

                        //////////////////////////////////////////////
                        //@ref
                        m_KPIVar.dicTags["@REF"] = dResult;

                        //获得所有的得分计算公式
                        var scoreresult = from kpi in m_KPIVar.ltScores
                                          where (kpi.ECID == ecte.ECID && kpi.ScoreIsValid == 1)
                                          select kpi;

                        /////////////////////////////////////////////
                        //@a1, @a2, @a3, @a4, @a5, @a6, @a7, @a8
                        if (scoreresult.Count() > 0 && ecte.ECXLineType >= 0) {
                            //限定该指标的 相关曲线
                            var xlresult = (from kpi in m_KPIVar.ltXLines
                                            where kpi.ECID == ecte.ECID
                                            orderby kpi.XLineCoef
                                            select kpi).ToList();

                            if (xlresult.Count() > 0) {
                                var coefresult = (from kpi in xlresult
                                                  orderby kpi.XLineCoef
                                                  select kpi.XLineCoef).Distinct().ToList();

                                //只有一维(1)类型的区间可以有@a1,@a2,@a3,@a4, @a5添加, 定值及二维(0,2)类型的只能有1个@a1
                                //int num = ecte.ECXLineType == 1 ? coefresult.Count : 1;
                                int num = coefresult.Count;

                                //获得基准值
                                double dXBase = dUnitPE;
                                string xtag = "'" + xlresult[0].XLineXBase.ToUpper().Trim() + "'";
                                if (ecte.ECXLineXRealTag != "" && m_KPIVar.dicTags.ContainsKey(xtag)) {
                                    dXBase = double.Parse(m_KPIVar.dicTags[xtag].ToString());
                                }

                                double dYBase = dUnitPE;
                                string ytag = "'" + xlresult[0].XLineYBase.ToUpper().Trim() + "'";
                                if (ecte.ECXLineYRealTag != "" && m_KPIVar.dicTags.ContainsKey(ytag)) {
                                    dYBase = double.Parse(m_KPIVar.dicTags[ytag].ToString());
                                }

                                //计算组别
                                string sGroup = ecte.ECCurveGroup;

                                //计算月份
                                int nMonth = dtValid.Month;

                                //计算系数
                                double[] dAA = KPI_XLineDal.GetXLineCoefs(xlresult, num, ecte.ECXLineType, ecte.ECXLineGetType, dXBase, dYBase, sGroup, nMonth);

                                if (num >= 1) {
                                    m_KPIVar.dicTags["@A1"] = dAA[0];
                                }
                                if (num >= 2) {
                                    m_KPIVar.dicTags["@A2"] = dAA[1];
                                }
                                if (num >= 3) {
                                    m_KPIVar.dicTags["@A3"] = dAA[2];
                                }
                                if (num >= 4) {
                                    m_KPIVar.dicTags["@A4"] = dAA[3];
                                }
                                if (num >= 5) {
                                    m_KPIVar.dicTags["@A5"] = dAA[4];
                                }
                                if (num >= 6) {
                                    m_KPIVar.dicTags["@A6"] = dAA[5];
                                }
                                if (num >= 7) {
                                    m_KPIVar.dicTags["@A7"] = dAA[6];
                                }
                                if (num >= 8) {
                                    m_KPIVar.dicTags["@A8"] = dAA[7];
                                }
                            }
                        }

                        //Console.WriteLine("得分计算结束");

                        #endregion

                        #region 区间计算

                        //Console.WriteLine("得分区间计算结束");

                        foreach (KPI_ScoreEntity kse in scoreresult) {

                            #region 得分区间计算
                            //////////////////////////////////////////////////////
                            //获取得分表达式
                            expression = kse.ScoreCalcExp.ToUpper();
                            if (expression == null || expression == "") {
                                continue;
                            }

                            //解析得分表达式:获得标签及指标
                            Dictionary<String, double> dic2 = new Dictionary<String, double>();
                            if (m_ExpressionParse.ExpEvaluate(expression, ref dic2) != 0) {
                                LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标的得分区间解析错误:" + kse.ScoreCalcExp);
                                dic2 = null;
                                continue;
                            }

                            //执行计算表达式: 计算变量赋值与执行
                            for (int i = 0; i < dic2.Count; i++) {
                                String strkey = dic2.ElementAt(i).Key;
                                dic2[strkey] = m_KPIVar.dicTags[strkey];
                            }

                            bool bResult = false;
                            if (m_ExpressionParse.ExpBool(expression, dic2, out bResult, out strResult) != 0) {
                                LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标的得分区间计算错误:" + kse.ScoreCalcExp);
                                continue;
                            }
                            dic2.Clear();
                            dic2 = null;
                            //判断是否满足
                            if (!bResult) {
                                continue;
                            }

                            //判断是否报警
                            if (kse.ScoreAlarm == 1) {
                                nAlarm = 1;
                            }
                            //Console.WriteLine("分区间计算结束");
                            #endregion

                            #region 得分计算

                            ///////////////////////////////////////////////
                            //得分计算
                            expression = kse.ScoreGainExp.ToUpper();

                            if (expression == null || expression == "") {
                                continue;
                            }

                            //标签及指标解析
                            Dictionary<String, double> dic3 = new Dictionary<String, double>();
                            if (m_ExpressionParse.ExpEvaluate(expression, ref dic3) != 0) {
                                LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标的得分公式解析错误:" + kse.ScoreCalcExp);
                                continue;
                            }

                            //计算变量赋值
                            for (int i = 0; i < dic3.Count; i++) {
                                String strkey = dic3.ElementAt(i).Key;
                                dic3[strkey] = m_KPIVar.dicTags[strkey];
                            }

                            //标签及指标计算
                            string strscore = "";
                            if (m_ExpressionParse.ExpCalculate(expression, dic3, out dScore, out strResult, out strscore) != 0) {
                                LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "得分的得分公式计算错误:" + kse.ScoreGainExp);
                                dScore = 0.0;
                                dic3.Clear();
                                dic3 = null;
                                continue;
                            }
                            dic3.Clear();
                            dic3 = null;
                            if (dScore != double.MinValue) {
                                dScore = dScore * Convert.ToDouble(ecte.ECWeight / ecte.ECDenom);
                            }
                            //如果计算了得分后就不用再计算后面的得分了。
                            break;
                            #endregion
                        }
                        //Console.WriteLine("得分计算结束");
                        #endregion

                        #region  最优区间计算

                        foreach (KPI_ScoreEntity kse in scoreresult) {

                            //只需要有效的最优区间
                            if (kse.ScoreIsValid == 1 && kse.ScoreOptimal == 1) {
                                //////////////////////////////////////////////////////
                                //获取得分表达式
                                strOptExp = kse.ScoreCalcExp.ToUpper();
                                if (strOptExp != null && strOptExp != "") {
                                    //解析得分表达式:获得标签及指标
                                    Dictionary<String, double> dic4 = new Dictionary<String, double>();
                                    if (m_ExpressionParse.ExpEvaluate(strOptExp, ref dic4) != 0) {
                                        LogUtil.LogMessage(ecte.ECCode + ecte.ECName + "指标的最优区间解析错误:" + kse.ScoreCalcExp);
                                        break;
                                    }
                                    //执行计算表达式: 计算变量赋值与执行
                                    for (int i = 0; i < dic4.Count; i++) {
                                        String strkey = dic4.ElementAt(i).Key;
                                        dic4[strkey] = m_KPIVar.dicTags[strkey];
                                    }

                                    //生成最优区间表达式
                                    foreach (KeyValuePair<string, double> kvp in dic4) {
                                        if (kvp.Key == "@REF") {
                                            strOptExp = strOptExp.Replace(kvp.Key, "x");
                                        }
                                        else {
                                            strOptExp = strOptExp.Replace(kvp.Key, kvp.Value.ToString("0.00"));
                                        }
                                    }
                                    dic4.Clear();
                                    dic4 = null;
                                }
                                //搜索到最优区间后就结束。
                                break;
                            }
                        }

                        //Console.WriteLine("最优区间计算结束");
                        #endregion
                    }
                    else {
                        strOptExp = "非考核状态;";
                        dScore = 0;
                        nAlarm = 0;
                    }
                }

                if (!bRunning) {
                    if (ecte.ECIsSnapshot == 1) {
                        strOptExp = "非考核状态;";
                        dScore = Convert.ToDouble(ecte.ECWeight);
                        nAlarm = 0;
                    }
                    else {
                        strOptExp = "非考核状态;";
                        dScore = 0; //ecte.ECWeight;
                        nAlarm = 0;
                    }
                }
                else if (!bRight) {
                    strOptExp = "计算失败;";
                    dScore = 0;
                    nAlarm = 1;
                }

                #endregion

                #region 数据库

                ECSSValueEntity ssse = new ECSSValueEntity();
                ssse.SSID = PageControl.GetGuid();
                ssse.UnitID = ecte.UnitID;
                ssse.SeqID = ecte.SeqID;
                ssse.KpiID = ecte.KpiID;
                ssse.ECID = ecte.ECID;
                ssse.ECName = ecte.ECName;
                ssse.ECTime = strCM;
                ssse.ECValue = dResult == double.MinValue ? 0 : dResult;
                ssse.ECScore = dScore == double.MinValue ? 0 : dScore;
                ssse.ECOptExp = strOptExp;
                ssse.ECExpression = strexpression;
                ssse.ECQulity = nAlarm == int.MinValue ? 0 : nAlarm;
                ssse.ECPeriod = strCurrentPeriod;
                ssse.ECShift = strCurrentShift;
                ssse.ECIsRemove = 0;
                if ((!String.IsNullOrWhiteSpace(ecte.ECCode)) && (ecte.ECCode.ToUpper() == "GHND_SNDH")) {
                    ssse.ECScore = -1*ssse.ECValue;
                }

                ///////////////////////////////////////////////////////////////
                //out
                kpiEV = ssse;

                //if (bsnap)
                //{
                //    //写入Snapshot DB
                //    KPI_ECSSSnapshotEntity ssse = new KPI_ECSSSnapshotEntity();
                //    ssse.SSID = PageControl.GetGuid();
                //    ssse.UnitID = ecte.UnitID;
                //    ssse.SeqID = ecte.SeqID;
                //    ssse.KpiID = ecte.KpiID;
                //    ssse.ECID = ecte.ECID;
                //    ssse.ECName = ecte.ECName;
                //    ssse.ECTime = strCM;
                //    ssse.ECValue = dResult;
                //    ssse.ECScore = dScore;
                //    ssse.ECOptExp = strOptExp;
                //    ssse.ECExpression = strexpression;
                //    ssse.ECQulity = nAlarm;
                //    ssse.ECPeriod = strCurrentPeriod;
                //    ssse.ECShift = strCurrentShift;
                //    ssse.ECIsRemove = 0;

                //    KPI_ECSSSnapshotDal.DeleteTag(ssse.ECID);

                //    KPI_ECSSSnapshotDal.Insert(ssse);
                //}
                //else
                //{
                //    //写入Archive DB
                //    KPI_ECSSArchiveEntity ssse = new KPI_ECSSArchiveEntity();
                //    ssse.SSID = PageControl.GetGuid();
                //    ssse.UnitID = ecte.UnitID;
                //    ssse.SeqID = ecte.SeqID;
                //    ssse.KpiID = ecte.KpiID;
                //    ssse.ECID = ecte.ECID;
                //    ssse.ECName = ecte.ECName;
                //    ssse.ECTime = strCM;
                //    ssse.ECValue = dResult;
                //    ssse.ECScore = dScore;
                //    ssse.ECOptExp = strOptExp;
                //    ssse.ECExpression = strexpression;
                //    ssse.ECQulity = nAlarm;
                //    ssse.ECPeriod = strCurrentPeriod;
                //    ssse.ECShift = strCurrentShift;
                //    ssse.ECIsRemove = 0;

                //    KPI_ECSSArchiveDal.DeleteTag(ssse.ECID, strCM);

                //    KPI_ECSSArchiveDal.Insert(ssse);
                //}

                #endregion

                return true;

            }
            catch (Exception ex) {
                LogUtil.LogMessage("CalcTM:" + ecte.ECCode + ecte.ECName + ex.Message +
                    System.Environment.NewLine + ex.StackTrace);
                kpiEV = null;
                return false;
            }
        }
Beispiel #10
0
        /// <summary>
        /// KPI_Snapshot And KPI_Archive的操作
        /// </summary>
        /// <returns></returns>
        public bool KPICalcForTD(bool bsnap, ECTagEntity ecte, CycleEntity cye, DateTime dtValid,
										string strCurrentShift, string strCurrentPeriod,
                                        out ECSSValueEntity kpiEV)
        {
            //bsnap== false时,更新 EC_SSArchive即可。
            kpiEV = null;
            return true;
        }