Example #1
0
        private List <SystemParameterEntity> GetDataSource()
        {
            KPI_SystemDal DataAccess = new KPI_SystemDal();
            List <SystemParameterEntity> List = new List <SystemParameterEntity>();
            SystemParameterEntity        SystemParameter, Param;
            List <KPI_UnitEntity>        UnitList = KPI_UnitDal.GetAllEntity();

            foreach (KPI_UnitEntity Unit in UnitList)
            {
                SystemParameter = DataAccess.GetSystemParameter(Unit.UnitID);
                if (SystemParameter == null)
                {
                    SystemParameter         = new SystemParameterEntity();
                    SystemParameter.SysName = Unit.UnitID;
                    SystemParameter.SysDesc = Unit.UnitName + "奖金金额";
                }
                SystemParameter.SysCode = Unit.UnitCode;
                Param = DataAccess.GetSystemParameter(Unit.UnitCode);
                if (Param != null)
                {
                    SystemParameter.SysValue2 = Param.SysValue;
                }
                //SystemParameter.SysValue2 = DataAccess.GetSystemParameter(Unit.UnitCode).SysValue;
                List.Add(SystemParameter);
            }
            return(List);
        }
Example #2
0
        private void ClientInitial()
        {
            DateTime Current = DateTime.Now;

            //txtBeginTime.Attributes.Add("onclick", "'new WdatePicker(this,'%Y年%M月%D日',false,'whyGreen')'");
            //txtEndTime.Attributes.Add("onclick", "new WdatePicker(this,'%Y年%M月%D日',false,'whyGreen')");
            txtBeginTime.Text = Current.ToString("yyyy-MM-dd");
            txtEndTime.Text   = Current.ToString("yyyy-MM-dd");

            //List<KPI_UnitEntity> UnitList = KPI_UnitDal.GetAllEntity();
            //UnitList.Insert(0, new KPI_UnitEntity { UnitID = "", UnitName = "【所有机组】" });
            //drpUnits.DataSource = UnitList;
            //drpUnits.DataTextField = "UnitName";
            //drpUnits.DataValueField = "UnitID";
            //drpUnits.DataBind();
            //DataTable Plants = KPI_PlantDal.GetDataTable();
            //drpPlants.DataSource = Plants;
            //drpPlants.DataValueField = "PlantID";
            //drpPlants.DataTextField = "PlantName";
            //drpPlants.DataBind();
            //if (Plants.Rows.Count > 0) {
            //    String PlantID = Plants.Rows[0]["PlantID"] + "";

            //}
            string plantCode = Request.Params["Plantcode"];

            drpUnits.DataSource     = KPI_UnitDal.GetUnitListByPlantCode(plantCode);
            drpUnits.DataTextField  = "UnitName";
            drpUnits.DataValueField = "UnitID";
            drpUnits.DataBind();
            BindSAKPI();
            //string plantid = KPI_PlantDal.GetPlantIDByCode(plantCode);
            //BindUnits(plantid);
        }
        /// <summary>
        /// 获取班次与值次
        /// </summary>
        /// <param name="UnitID">机组编码</param>
        /// <param name="Shift">当前值</param>
        /// <param name="Period">当前班</param>
        private void GetShiftAndPeriod(String UnitID, out String Shift, out String Period, DateTime CalcTime)
        {
            String strStartTime = "";
            String strEndTime   = "";

            Shift  = "";
            Period = "";
            KPI_UnitEntity Entity = KPI_UnitDal.GetEntity(UnitID);

            if (Entity == null)
            {
                return;
            }
            try
            {
                String strWorkID        = Entity.WorkID;
                String strCurrentMinute = CalcTime.ToString("yyyy-MM-dd HH:mm:00");
                KPI_WorkDal.GetShiftAndPeriod(strWorkID, strCurrentMinute,
                                              ref Shift, ref Period, ref strStartTime, ref strEndTime);
            }
            catch (Exception ex)
            {
                m_Logger.Error(ex.Message, ex);
            }
        }
Example #4
0
        private void ClientInitial()
        {
            List <KPI_UnitEntity> UnitList = KPI_UnitDal.GetAllEntity();

            //drpUnits.Items.Add(new ListItem("全厂", "00"));
            drpSUnits.Items.Add(new ListItem("【所有机组】", ""));
            foreach (KPI_UnitEntity Unit in UnitList)
            {
                drpSUnits.Items.Add(new ListItem(Unit.UnitName, Unit.UnitID));
                drpUnits.Items.Add(new ListItem(Unit.UnitName, Unit.UnitID));
            }

            DataTable Shifts = KPI_ShiftDal.GetShifts();

            drpSShifts.Items.Add(new ListItem("【所有值次】", ""));
            foreach (DataRow dr in Shifts.Rows)
            {
                drpShifts.Items.Add(new ListItem(dr["Name"] + "值", dr["Name"] + ""));
                drpSShifts.Items.Add(new ListItem(dr["Name"] + "值", dr["Name"] + ""));
            }
            Shifts.Dispose();

            DataTable PositionTable = KPI_PositionDal.GetDataTable();

            foreach (DataRow dr in PositionTable.Rows)
            {
                drpPositions.Items.Add(new ListItem(dr["PositionName"] + "", dr["PositionID"] + ""));
            }
            PositionTable.Dispose();
        }
Example #5
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        void BindValues()
        {
            string UnitID = ViewState["unitid"].ToString();

            KPI_UnitEntity mEntity = KPI_UnitDal.GetEntity(UnitID);

            ddl_PlantID.Value     = mEntity.PlantID;
            txt_UnitCode.Value    = mEntity.UnitCode;
            txt_UnitName.Value    = mEntity.UnitName;
            txt_UnitDesc.Value    = mEntity.UnitDesc;
            txt_UnitIndex.Value   = mEntity.UnitIndex.ToString();
            txt_UnitPrefix.Value  = mEntity.UnitPrefix;
            ddl_UnitIsValid.Value = mEntity.UnitIsValid.ToString();

            txt_UnitMW.Value    = mEntity.UnitMW.ToString();
            txt_UnitMWTag.Value = mEntity.UnitMWTag;

            txt_UnitCondition.Value  = mEntity.UnitCondition;
            ddl_UnitIsKPI.Value      = mEntity.UnitIsKPI.ToString();
            ddl_UnitIsSnapshot.Value = mEntity.UnitIsSnapshot.ToString();
            ddl_UnitIsSort.Value     = mEntity.UnitIsSort.ToString();
            ddl_UnitIsSecurity.Value = mEntity.UnitIsSecurity.ToString();
            ddl_UnitIsPower.Value    = mEntity.UnitIsPower.ToString();

            if (mEntity.WorkID == null || mEntity.WorkID == "")
            {
                ddl_UnitWorkID.Value = "NULL";
            }
            else
            {
                ddl_UnitWorkID.Value = mEntity.WorkID;
            }

            txt_UnitNote.Value = mEntity.UnitNote;
        }
Example #6
0
        public void Execute(IJobExecutionContext context)
        {
            MonitorDurationDal    DataAccess = new MonitorDurationDal();
            List <KPI_UnitEntity> UnitList   = KPI_UnitDal.GetAllEntity();

            foreach (KPI_UnitEntity Unit in UnitList)
            {
                if (String.IsNullOrEmpty(Unit.WorkID))
                {
                    return;
                }
                if (UnitIsRunning(Unit.UnitID))
                {
                    m_Loger.InfoFormat("开始计算{0}操盘时间", Unit.UnitName);
                    MonitorDurationEntity MonitorDuration = new MonitorDurationEntity();
                    DateTime Now              = DateTime.Now;
                    String   strStartTime     = "";
                    String   strEndTime       = "";
                    String   Shift            = "";
                    String   Period           = "";
                    String   strCurrentMinute = Now.ToString("yyyy-MM-dd HH:mm:00");
                    KPI_WorkDal.GetShiftAndPeriod(Unit.WorkID, strCurrentMinute,
                                                  ref Shift, ref Period, ref strStartTime, ref strEndTime);
                    DateTime ShiftStartTime = Convert.ToDateTime(strStartTime);
                    DateTime ShiftEndTime   = Convert.ToDateTime(strEndTime);
                    MonitorDuration.UnitID    = Unit.UnitID;
                    MonitorDuration.Shift     = Shift;
                    MonitorDuration.CheckDate = Now.Date;
                    MonitorDuration.Duration  = GetDuration(ShiftStartTime, ShiftEndTime);
                    m_Loger.InfoFormat("{0}值值班开始时间{1}值班结束时间{2}当天操盘时长是{3}小时", Shift, ShiftStartTime, ShiftEndTime, MonitorDuration.Duration);
                    DataAccess.SaveMonitorDuration(MonitorDuration);
                    m_Loger.InfoFormat("{0}操盘时间计算结束", Unit.UnitName);
                }
            }
        }
Example #7
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <returns></returns>
        bool Update()
        {
            string unitid = ViewState["unitid"].ToString();

            KPI_UnitEntity mEntity = new KPI_UnitEntity();

            mEntity.UnitID        = unitid;
            mEntity.PlantID       = ddl_PlantID.Value;
            mEntity.UnitCode      = txt_UnitCode.Value.Trim();
            mEntity.UnitName      = txt_UnitName.Value.Trim();
            mEntity.UnitDesc      = txt_UnitDesc.Value.Trim();
            mEntity.UnitIndex     = int.Parse(txt_UnitIndex.Value.Trim());
            mEntity.UnitIsValid   = int.Parse(ddl_UnitIsValid.Value);
            mEntity.UnitPrefix    = txt_UnitPrefix.Value;
            mEntity.UnitMW        = decimal.Parse(txt_UnitMW.Value);
            mEntity.UnitMWTag     = txt_UnitMWTag.Value;
            mEntity.UnitCondition = txt_UnitCondition.Value;//.Replace("'", "''");

            mEntity.UnitIsKPI      = int.Parse(ddl_UnitIsKPI.Value);
            mEntity.UnitIsSnapshot = int.Parse(ddl_UnitIsSnapshot.Value);
            mEntity.UnitIsSort     = int.Parse(ddl_UnitIsSort.Value);
            mEntity.UnitIsSecurity = int.Parse(ddl_UnitIsSecurity.Value);
            mEntity.UnitIsPower    = int.Parse(ddl_UnitIsPower.Value);

            mEntity.WorkID = ddl_UnitWorkID.Value;

            mEntity.UnitNote = txt_UnitNote.Value.Trim();

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

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

            return(KPI_UnitDal.Update(mEntity));
        }
 protected void drpPlants_SelectedIndexChanged(object sender, EventArgs e)
 {
     drpUnits.DataSource     = KPI_UnitDal.GetUnits(drpPlants.SelectedValue);
     drpUnits.DataValueField = "ID";
     drpUnits.DataTextField  = "Name";
     drpUnits.DataBind();
 }
Example #9
0
        public override void DataBind()
        {
            string SpecialField = Request.Params["ecweb"];
            string queryTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
            String PlantCode    = Request.Params["plantcode"];
            String UnitCode     = Request.Params["unitcode"];
            String PlantID      = KPI_PlantDal.GetPlantIDByCode(PlantCode);
            String UnitID       = KPI_UnitDal.GetUnitIDByCode(UnitCode);

            gvReal.DataSource = KPI_RealValueDal.GetRealValue(PlantID, "");
            base.DataBind();

            nowtime.Text  = "计算时间:" + queryTime;
            nowshift.Text = "轮班值次:";
            if (!String.IsNullOrWhiteSpace(UnitID))
            {
                string workid     = KPI_UnitDal.GetWorkIDByID(UnitID);
                string ShiftName  = "";
                string PeriodName = "";
                string StartTime  = "";
                string EndTime    = "";
                bool   bGood      = KPI_WorkDal.GetShiftAndPeriod(workid, queryTime, ref ShiftName,
                                                                  ref PeriodName, ref StartTime, ref EndTime);
                nowshift.Text = "轮班值次:" + ShiftName;
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //指标信息
                if (Request.QueryString["webcode"] != null)
                {
                    WebCode = Request.QueryString["webcode"].ToString();

                    lblInfor.Text = "报表名称: " + KPI_WebDal.GetWebDesc(WebCode);
                }
                else
                {
                    WebCode = "";
                }


                ////机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                foreach (DataRow dr in dt.Rows)
                {
                    ddlUnit.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //
                txt_ST.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                txt_ET.Value = DateTime.Now.ToString("yyyy-MM-dd");

                BindValue();
            }
        }
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!IsPostBack)
     {
         String strStartTime            = "";
         String strEndTime              = "";
         String CurrentShift            = "";
         String Period                  = "";
         List <KPI_UnitEntity> UnitList = KPI_UnitDal.GetAllEntity();
         if (UnitList.Count > 0)
         {
             String         UnitID = UnitList.First().UnitID;
             KPI_UnitEntity Entity = KPI_UnitDal.GetEntity(UnitID);
             if (Entity != null)
             {
                 String strWorkID        = Entity.WorkID;
                 String strCurrentMinute = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
                 KPI_WorkDal.GetShiftAndPeriod(strWorkID, strCurrentMinute,
                                               ref CurrentShift, ref Period, ref strStartTime, ref strEndTime);
             }
             lblShift.Text  = CurrentShift;
             Shift          = CurrentShift;
             ShiftStartTime = Convert.ToDateTime(strStartTime);
             ShiftEndTime   = Convert.ToDateTime(strEndTime);
         }
         DataBind();
     }
 }
        void SetECCodeAndName()
        {
            string unitcode = KPI_UnitDal.GetUnitCode(ddl_UnitID.SelectedValue);
            string kpicode  = KpiDal.GetKpiCode(ddl_KpiID.SelectedValue);

            txt_ECCode.Value = unitcode + "_" + kpicode + "_";
            txt_ECName.Value = ddl_UnitID.SelectedItem.Text + ddl_KpiID.SelectedItem.Text;
        }
Example #13
0
        private String GetWorkID()
        {
            String Result = "";
            List <KPI_UnitEntity> UnitList = KPI_UnitDal.GetAllEntity();

            if (UnitList.Count > 0)
            {
                Result = UnitList.First().WorkID;
            }
            return(Result);
        }
Example #14
0
        protected void rblRMType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rblRMType.SelectedValue == "0")
            {
                cbxRMKPIID.Visible = false;
                ddlRMKPIID.Visible = true;
                ddlRMKPIID.Items.Clear();

                DataTable dt = KPI_UnitDal.GetUnits("");
                foreach (DataRow dr in dt.Rows)
                {
                    ddlRMKPIID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }
            }
            else if (rblRMType.SelectedValue == "1")
            {
                cbxRMKPIID.Visible = false;
                ddlRMKPIID.Visible = true;
                ddlRMKPIID.Items.Clear();

                DataTable dt = KPI_SeqDal.GetSeqs();
                foreach (DataRow dr in dt.Rows)
                {
                    ddlRMKPIID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }
            }
            else if (rblRMType.SelectedValue == "2")
            {
                cbxRMKPIID.Visible = false;
                ddlRMKPIID.Visible = true;
                ddlRMKPIID.Items.Clear();

                DataTable dt = KpiDal.GetKpis();
                foreach (DataRow dr in dt.Rows)
                {
                    ddlRMKPIID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }
            }
            else if (rblRMType.SelectedValue == "3")
            {
                cbxRMKPIID.Visible = true;
                cbxRMKPIID.Items.Clear();

                ddlRMKPIID.Visible = false;
                ddlRMKPIID.Items.Clear();

                DataTable dt = ECTagDal.GetECs();
                foreach (DataRow dr in dt.Rows)
                {
                    cbxRMKPIID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }
            }
        }
        private void BindUnits(String PlantID)
        {
            var UnitList = KPI_UnitDal.GetUnits(PlantID);

            drpUnits.DataSource     = UnitList;
            drpUnits.DataTextField  = "Name";
            drpUnits.DataValueField = "ID";
            drpUnits.DataBind();
            //drpUnits.DataSource = UnitList;
            //drpUnits.DataValueField = "ID";
            //drpUnits.DataTextField = "Name";
            //drpUnits.DataBind();
        }
Example #16
0
        public override void DataBind()
        {
            //Repeater1.DataSource = "";
            DateTime StartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime EndDate   = Convert.ToDateTime(txtEndDate.Text);
            String   UnitCode  = Request.Params["UnitCode"];
            String   UnitID    = KPI_UnitDal.GetUnitIDByCode(UnitCode);

            using (ECHistoryDataAccess DataAccess = new ECHistoryDataAccess()) {
                KPIRepeater.DataSource = DataAccess.GetKPIRank(UnitID, StartDate, EndDate);
            }
            base.DataBind();
        }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnDelete.Attributes.Add("onclick", "return confirm('确认删除吗?');");

                //机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                ddl_UnitID.Items.Add(new ListItem("所有机组集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_UnitID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //设备信息
                dt = KPI_SeqDal.GetSeqs();
                ddl_SeqID.Items.Add(new ListItem("所有设备集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_SeqID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //指标信息
                dt = KpiDal.GetKpis();
                ddl_KpiID.Items.Add(new ListItem("所有指标集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_KpiID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //周期集信息
                //dt = KPI_CycleDal.GetCycles();
                //ddl_CycleID.Items.Add(new ListItem("所有周期", "ALL"));
                //foreach (DataRow dr in dt.Rows)
                //{
                //    ddl_CycleID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                //}

                //实时指标信息
                dt = ECTagDal.GetECs();
                ddl_ECID.Items.Add(new ListItem("所有指标", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_ECID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                BindEC();
            }
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                ddlUnitID.Items.Add(new ListItem("所有机组集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddlUnitID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                BindReal();
            }
        }
Example #19
0
        protected void gvUnit_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string keyid = e.CommandArgument.ToString();

            if (e.CommandName == "dataDelete")
            {
                if (KPI_UnitDal.DeleteUnit(keyid))
                {
                    MessageBox.popupClientMessage(this.Page, "删除成功!", "call();");
                }
                else
                {
                    MessageBox.popupClientMessage(this.Page, "删除错误!", "call();");
                }
            }
        }
 public void ClientInitial()
 {
     DateTime StartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
     DateTime EndDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
     if (StartDate == EndDate) {
         StartDate = StartDate.AddMonths(-1);
     }
     txtStartDate.Text = StartDate.ToString("yyyy-MM-dd");
     txtEndDate.Text = EndDate.ToString("yyyy-MM-dd");
     using(KPI_UnitDal DataAccess = new  KPI_UnitDal()){
         List<KPI_UnitEntity> UnitList = DataAccess.GetUnitIDs("");
         foreach (KPI_UnitEntity Entity in UnitList) {
             if (Entity.UnitID !="0000")	drpUnits.Items.Add(new ListItem(Entity.UnitName,Entity.UnitID));
         }
     }
 }
Example #21
0
 private void Initialize()
 {
     using (KPI_UnitDal DataAccess = new KPI_UnitDal()) {
         m_UnitList = DataAccess.GetUnitIDs(string.Empty);
     }
     m_Parser.CustomFunction += new FunctionHandler(Parser_CustomFunction);
     m_Parser.OnError        += new ErrorHandler(Parser_OnError);
     m_Parser.AddCustomFunction("SACOUNT", 1);            //超限次数统计
     m_Parser.AddCustomFunction("SACOUNTBYTYPE", 2);      //根据超限类型统计超限次数
     m_Parser.AddCustomFunction("SALONGCOUNT", 2);        //超限次数统计(连续超限时长超过指定时长为超限1次)
     m_Parser.AddCustomFunction("SALONGCOUNTBYTYPE", 3);  //根据超限类型统计超限次数(连续超限时长超过指定时长为超限1次)
     m_Parser.AddCustomFunction("SADURATION", 1);
     m_Parser.AddCustomFunction("SADURATIONBYTYPE", 2);
     m_Parser.AddCustomFunction("SALONGDURATION", 2);
     m_Parser.AddCustomFunction("SALONGDURATIONBYTYPE", 3);
 }
Example #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                ddl_UnitID.Items.Add(new ListItem("所有机组集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_UnitID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //设备信息
                dt = KPI_SeqDal.GetSeqs();
                ddl_SeqID.Items.Add(new ListItem("所有设备集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_SeqID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //指标信息
                dt = KpiDal.GetKpis();
                ddl_KpiID.Items.Add(new ListItem("所有指标集", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_KpiID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                //周期集信息
                //dt = KPI_CycleDal.GetCycles();
                //ddl_CycleID.Items.Add(new ListItem("所有周期", "ALL"));
                //foreach (DataRow dr in dt.Rows)
                //{
                //    ddl_CycleID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                //}

                //安全指标信息
                dt = KPI_SATagDal.GetSAs();
                ddl_SAID.Items.Add(new ListItem("所有安全指标", "ALL"));
                foreach (DataRow dr in dt.Rows)
                {
                    ddl_SAID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                BindSA();
            }
        }
Example #23
0
        private void ClientInitial()
        {
            DataTable Plants = KPI_PlantDal.GetDataTable();

            drpPlants.DataSource     = Plants;
            drpPlants.DataValueField = "PlantID";
            drpPlants.DataTextField  = "PlantName";
            drpPlants.DataBind();
            if (Plants.Rows.Count > 0)
            {
                String PlantID = Plants.Rows[0]["PlantID"] + "";
                drpUnits.DataSource     = KPI_UnitDal.GetUnits(PlantID);
                drpUnits.DataValueField = "ID";
                drpUnits.DataTextField  = "Name";
                drpUnits.DataBind();
            }
        }
Example #24
0
        //////////////////////////////////////////////////////////////////////////////
        #region Define Functions

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool KPIInitialVar()
        {
            try {
                //是否取服务器时间
                bTimeMode = KPI_SystemDal.GetKPITimeMode() == 1 ? true : false;
                //偏置时间
                nOffset = KPI_SystemDal.GetKPIOffset();
                //初始所有List<>
                ltUnits = KPI_UnitDal.GetValidEntity();
                ltSeqs  = KPI_SeqDal.GetValidEntity();
                ltKpis  = KpiDal.GetValidEntity();

                //实时、手录、曲线指标
                ltReals  = KPI_RealTagDal.GetAllEntity();
                ltInputs = KPI_InputTagDal.GetAllEntity();
                ltCurves = CurveTagDal.GetAllEntity();
                //计算周期
                List <CycleEntity> ltCYs = CycleDal.GetAllEntity();
                dicCYs = new Dictionary <string, CycleEntity>();
                foreach (CycleEntity cye in ltCYs)
                {
                    dicCYs[cye.CycleID] = cye;
                }

                //经济指标
                ltECs    = ECTagDal.GetValidEntity();
                ltXLines = ECTagDal.GetAllXLineEntity();
                ltScores = ECTagDal.GetAllScoreEntity();
                /////////////////////////////////////////////////////////////////
                //安全指标
                dicUnitStatus = new Dictionary <string, bool>();
                dicUnitPEs    = new Dictionary <string, double>();
                dicTags       = new Dictionary <string, double>();
                dicRealTag    = new Dictionary <string, RealTag>();
            }
            catch (Exception ex) {
                LogUtil.LogMessage(ex.ToString());

                return(false);
            }

            return(true);
        }
Example #25
0
        /// <summary>
        /// 交接时关闭上一班报警
        /// </summary>
        /// <param name="faultConfiguration"></param>
        private void StopLastShiftAlarm(OverLimitConfigEntity faultConfiguration)
        {
            KPI_UnitEntity Entity = KPI_UnitDal.GetEntity(faultConfiguration.UnitID);

            if (Entity == null)
            {
                return;
            }
            String strWorkID        = Entity.WorkID;
            String strStartTime     = "";
            String strEndTime       = "";
            String Shift            = "";
            String Period           = "";
            String strCurrentMinute = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");

            KPI_WorkDal.GetShiftAndPeriod(strWorkID, strCurrentMinute,
                                          ref Shift, ref Period, ref strStartTime, ref strEndTime);
            DateTime ShiftStartTime = Convert.ToDateTime(strStartTime);
            DateTime CurrentTime    = DateTime.Now;
            TimeSpan Span           = CurrentTime - ShiftStartTime;
            double   TotalMinutes   = Span.TotalMinutes;

            if (TotalMinutes <= 10)
            {
                try {
                    using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) {
                        KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
                        for (int i = 1; i < 4; i++)
                        {
                            entity.TagID          = faultConfiguration.TagName;
                            entity.AlarmStartTime = ShiftStartTime;
                            entity.AlarmType      = i;
                            DataAccess.UpdateOverLimitRecord(entity);
                        }
                    }
                }
                catch (Exception ex) {
                    m_Logger.InfoFormat("StopLastShiftAlarm安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
                                        ex.Message, ex.StackTrace);
                    m_Logger.Error(ex);
                }
            }
        }
Example #26
0
        /// <summary>
        /// 获取班次与值次
        /// </summary>
        /// <param name="UnitID">机组编码</param>
        /// <param name="Shift">当前值</param>
        /// <param name="Period">当前班</param>
        private void GetShiftAndPeriod(String UnitID, out String Shift, out String Period)
        {
            String strStartTime = "";
            String strEndTime   = "";

            Shift  = "";
            Period = "";
            KPI_UnitEntity Entity = KPI_UnitDal.GetEntity(UnitID);

            if (Entity == null)
            {
                return;
            }
            String strWorkID        = Entity.WorkID;
            String strCurrentMinute = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");

            KPI_WorkDal.GetShiftAndPeriod(strWorkID, strCurrentMinute,
                                          ref Shift, ref Period, ref strStartTime, ref strEndTime);
        }
Example #27
0
        private CurrentWorkInfo GetWorkInfo(String unitID, DateTime CalcDateTime)
        {
            CurrentWorkInfo Result = new CurrentWorkInfo();
            KPI_UnitEntity  Entity = KPI_UnitDal.GetEntity(unitID);

            Result.WorkID = Entity.WorkID;
            String strStartTime     = "";
            String strEndTime       = "";
            String Shift            = "";
            String Period           = "";
            String strCurrentMinute = CalcDateTime.ToString("yyyy-MM-dd HH:mm:00");

            KPI_WorkDal.GetShiftAndPeriod(Result.WorkID, strCurrentMinute,
                                          ref Shift, ref Period, ref strStartTime, ref strEndTime);
            Result.Shift     = Shift;
            Result.Period    = Period;
            Result.StartTime = Convert.ToDateTime(strStartTime);
            Result.EndTime   = Convert.ToDateTime(strEndTime);
            return(Result);
        }
Example #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //全部指标
                rblRDType.SelectedValue = "0";

                //初始化
                //机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                foreach (DataRow dr in dt.Rows)
                {
                    cbxRDID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                txt_ST.Value = DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd HH:mm:00");
                txt_ET.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
                
                BindRD();
            }
        }
Example #29
0
        public void ClientInitial()
        {
            DateTime StartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime EndDate   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            if (StartDate == EndDate)
            {
                StartDate = StartDate.AddMonths(-1);
            }
            txtStartDate.Text = StartDate.ToString("yyyy-MM-dd");
            txtEndDate.Text   = EndDate.ToString("yyyy-MM-dd");
            using (KPI_UnitDal DataAccess = new  KPI_UnitDal()){
                List <KPI_UnitEntity> UnitList = DataAccess.GetUnitIDs("");
                foreach (KPI_UnitEntity Entity in UnitList)
                {
                    if (Entity.UnitID != "0000")
                    {
                        drpUnits.Items.Add(new ListItem(Entity.UnitName, Entity.UnitID));
                    }
                }
            }
        }
Example #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnExcute.Attributes.Add("onclick", "return confirm('确认执行吗?');");

                //全部指标
                rblRMType.SelectedValue = "0";

                //机组信息
                DataTable dt = KPI_UnitDal.GetUnits("");
                foreach (DataRow dr in dt.Rows)
                {
                    ddlRMKPIID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
                }

                txt_ST.Value = DateTime.Now.AddMonths(-1).AddDays(-10).ToString("yyyy-MM-dd HH:mm:00");
                txt_ET.Value = DateTime.Now.AddMonths(-1).AddDays(-5).ToString("yyyy-MM-dd HH:mm:00");

                BindRM();
            }
        }
Example #31
0
        /// <summary>
        /// 显示机组信息
        /// </summary>
        void BindUnit()
        {
            //机组信息
            txt_UnitName.Text = txt_UnitName.Text.Trim();
            txt_UnitDesc.Text = txt_UnitDesc.Text.Trim();

            string sql = "";

            if (txt_UnitName.Text != "")
            {
                sql += " and UnitName like '%" + txt_UnitName.Text + "%'";
            }

            if (txt_UnitDesc.Text != "")
            {
                sql += " and UnitDesc like '%" + txt_UnitDesc.Text + "%'";
            }

            DataTable dtUnit = KPI_UnitDal.GetSearchList(sql);

            gvUnit.DataSource = dtUnit;
            gvUnit.DataBind();
        }
Example #32
0
        /// <summary>
        /// Race_Archive的操作
        /// </summary>
        /// <returns></returns>
        public static bool HistoryCalc(DateTime dtSTime, DateTime dtETime)
        {
            bool bGood = false;
            //bool bIDL = false;

            //DataTable dtUnit = KPI_UnitDal.GetUnitIDs("");
            List<KPI_UnitEntity> UnitList;
            using (KPI_UnitDal DataAccess = new KPI_UnitDal()) {
                UnitList = DataAccess.GetUnitIDs("");
            }

            //if (dtUnit == null || dtUnit.Rows.Count <= 0) {
            //    return true;
            //}
            //else {
            //    for (int k = 0; k < dtUnit.Rows.Count; k++) {
            foreach (KPI_UnitEntity Unit in UnitList) {
                //string UnitID = dtUnit.Rows[k]["UnitID"].ToString();
                //string UnitName = KPI_UnitDal.GetUnitName(UnitID);

                string HStartTime = dtSTime.ToString("yyyy-MM-dd HH:mm:ss");
                string HEndTime = dtETime.ToString("yyyy-MM-dd HH:mm:ss");
                if (string.IsNullOrEmpty(Unit.UnitID)) {
                    continue;
                }

                //DataTable tags = Race_TagDal.GetTags(Unit.UnitID);
                //if (tags == null || tags.Rows.Count <= 0) {
                //    return true;
                //}
                List<Race_TagEntity> RaceTagList;
                using (Race_TagDal DataAccess = new Race_TagDal()) {
                    RaceTagList = DataAccess.GetTagList(Unit.UnitID);
                }
                if (RaceTagList.Count <= 0) return true;

                //delete
                string sql = @"delete Race_Archive where UnitID='{0}'  and  (TagStartTime>'{1}' and TagStartTime<'{2}') ";

                sql = string.Format(sql, Unit.UnitID, HStartTime, HEndTime);

                DBAccess.GetRelation().ExecuteNonQuery(sql);

                //insert
                string WorkID = KPI_UnitDal.GetWorkIDByID(Unit.UnitID);

                bool bCalc = true;
                while (bCalc) {
                    string ShiftName = "";
                    string PeriodName = "";
                    string StartTime = "";
                    string EndTime = "";

                    bGood = KPI_WorkDal.GetShiftAndPeriod(WorkID, HStartTime, ref ShiftName, ref PeriodName, ref StartTime, ref EndTime);

                    if (!bGood) {
                        return false;
                    }

                    if (DateTime.Parse(EndTime) > DateTime.Parse(HEndTime)) {
                        //While 循环结束
                        bCalc = false;

                        continue;
                    }

                    DateTime dts = DateTime.Parse(StartTime);
                    DateTime dte = DateTime.Parse(EndTime);

                    //string PeriodID = KPI_PeriodDal.GetPeriodID(PeriodName);
                    //string ShiftID = KPI_ShiftDal.GetShiftID(ShiftName);

                    //历史计算
                    foreach (Race_TagEntity RaceTag in RaceTagList) {
                        //string TagID = tags.Rows[i]["TagID"].ToString();
                        decimal TagValue = decimal.MinValue;
                        RTInterface RTDB = DBAccess.GetRealTime();
                        //Race_TagEntity tentity = Race_TagDal.GetEntity(RaceTag.TagID);

                        if (RaceTag.TagCalcExpType == 0) {
                            TagValue = Convert.ToDecimal(RTDB.TagCalculatedData(RaceTag.TagCalcExp, dts, dte, RaceTag.TagFilterExp, GetRaceTagCalcType(RaceTag.TagCalcType)));
                            //Random rdm = new Random();
                            //TagValue = rdm.NextDouble() * 100;

                            if (TagValue == decimal.MinValue) {
                                LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");

                                continue;
                            }

                            TagValue = TagValue * RaceTag.TagFactor + RaceTag.TagOffset;

                        }
                        else if (RaceTag.TagCalcExpType == 1) {
                            TagValue = Convert.ToDecimal(RTDB.ExpCalculatedData(RaceTag.TagCalcExp, dts, dte, RaceTag.TagFilterExp, GetRaceTagCalcType(RaceTag.TagCalcType)));
                            //Random rdm = new Random();
                            //TagValue = rdm.NextDouble() * 100;

                            if (TagValue == decimal.MinValue) {
                                LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");

                                continue;
                            }

                            TagValue = TagValue * RaceTag.TagFactor + RaceTag.TagOffset;
                        }
                        else if (RaceTag.TagCalcExpType == 2) {
                            Random rdm = new Random();
                            TagValue = Convert.ToDecimal(rdm.NextDouble() * 100);
                            if (TagValue == decimal.MinValue) {
                                LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");
                                continue;
                            }
                            TagValue = TagValue * RaceTag.TagFactor + RaceTag.TagOffset;
                        }
                        //insert Archive
                        //insert
                        Race_ArchiveEntity sae = new Race_ArchiveEntity();
                        sae.TagID = RaceTag.TagID;
                        sae.UnitID = Unit.UnitID;
                        sae.TagType = RaceTag.TagType;
                        sae.TagShift = ShiftName;
                        sae.TagPeriod = PeriodName;
                        sae.TagStartTime = StartTime;
                        sae.TagEndTime = EndTime;
                        sae.TagValue = Convert.ToDouble(TagValue);
                        Race_ArchiveDal.Insert(sae);
                    }
                    HStartTime = EndTime;
                }
            }
            return true;
        }
Example #33
0
        public bool SnapshotCalc()
        {
            bool bGood = false;
            bool bIDL = false;
            //DataTable dtUnit = KPI_UnitDal.GetUnitIDs("");
            //if (dtUnit == null || dtUnit.Rows.Count <= 0) {
            //    return true;
            //}
            //else {
            List<KPI_UnitEntity> UnitList;
            using (KPI_UnitDal DataAccess = new KPI_UnitDal()) {
                UnitList = DataAccess.GetUnitIDs("");
            }

            foreach (KPI_UnitEntity Unit in UnitList) {
                //string UnitID = Unit.UnitID;
                //string UnitName = KPI_UnitDal.GetUnitName(UnitID);
                if (string.IsNullOrEmpty(Unit.UnitID)) {
                    continue;
                }
                //DataTable tags = Race_TagDal.GetTags(Unit.UnitID);
                List<Race_TagEntity> RaceTagList;
                using (Race_TagDal DataAccess = new Race_TagDal()) {
                    RaceTagList = DataAccess.GetTagList(Unit.UnitID);
                }
                //if (tags == null || tags.Rows.Count <= 0) {
                //    return true;
                //}
                if (RaceTagList.Count <= 0) return true;
                string WorkID = Unit.WorkID;
                string CurrentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string ShiftName = "";
                string PeriodName = "";
                string StartTime = "";
                string EndTime = "";
                bGood = KPI_WorkDal.GetShiftAndPeriod(WorkID, CurrentTime, ref ShiftName, ref PeriodName, ref StartTime, ref EndTime);
                if (!bGood) {
                    return false;
                }
                DateTime dts = DateTime.Parse(StartTime);
                DateTime dte = DateTime.Parse(EndTime);
                //从当前值的开始时间到当前时间的统计
                DateTime dtc = DateTime.Parse(CurrentTime);
                //////////////////////////////////////////////////////////////////////////////////
                //是否需要补算上一班的数据
                //并将数据写入到Archive中
                TimeSpan tspan = dtc - dts;
                if (tspan.TotalMinutes < 10) {
                    //刚好在交班时间内,需要将历史统计一下
                    bIDL = true;
                }
                if (bIDL) {
                    string HStartTime = dts.AddMinutes(-2 * tspan.TotalMinutes).ToString("yyyy-MM-dd HH:mm:ss");
                    string HEndTime = dtc.ToString("yyyy-MM-dd HH:mm:ss");

                    LastShiftCalc(Unit.UnitID, HStartTime, HEndTime);
                }
                ////////////////////////////////////////////////////////////////////////
                //判断时间是否太小
                TimeSpan tscs = dtc - dts;
                if (tscs.TotalMinutes < 5) {
                    //间隔太小,不计算
                    continue;
                }
                ////////////////////////////////////////////////////////////////////////
                //string PeriodID = KPI_PeriodDal.GetPeriodID(PeriodName);
                //string ShiftID = KPI_ShiftDal.GetShiftID(ShiftName);

                RTInterface RTDB = DBAccess.GetRealTime();
                //实时计算
                foreach (Race_TagEntity RaceTag  in RaceTagList) {
                    //string TagID = tags.Rows[i]["TagID"].ToString();
                    decimal TagValue = decimal.MinValue;
                    //Race_TagEntity tentity = Race_TagDal.GetEntity(TagID);
                    if (RaceTag.TagCalcExpType == 0) {
                        TagValue = Convert.ToDecimal(RTDB.TagCalculatedData(RaceTag.TagCalcExp, dts, dtc, RaceTag.TagFilterExp, GetRaceTagCalcType(RaceTag.TagCalcType)));
                        //Random rdm = new Random();
                        //TagValue = rdm.NextDouble() * 100;
                        if (TagValue == decimal.MinValue) {
                            LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");
                            continue;
                        }
                        TagValue = Convert.ToDecimal(TagValue) * RaceTag.TagFactor + RaceTag.TagOffset;
                    }
                    else if (RaceTag.TagCalcExpType == 1) {
                        TagValue = Convert.ToDecimal(RTDB.ExpCalculatedData(RaceTag.TagCalcExp, dts, dtc, RaceTag.TagFilterExp, GetRaceTagCalcType(RaceTag.TagCalcType)));
                        //Random rdm = new Random();
                        //TagValue = rdm.NextDouble() * 100;

                        if (TagValue == decimal.MinValue) {
                            LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");
                            continue;
                        }
                        TagValue = TagValue * RaceTag.TagFactor + RaceTag.TagOffset;
                    }
                    else if (RaceTag.TagCalcExpType == 2) {
                        Random rdm = new Random();
                        TagValue = Convert.ToDecimal(rdm.NextDouble() * 100);
                        if (TagValue == decimal.MinValue) {
                            LogUtil.LogMessage(RaceTag.TagDesc + "数据出现错误!");
                            continue;
                        }
                        TagValue = TagValue * RaceTag.TagFactor + RaceTag.TagOffset;
                    }

                    //update and insert
                    if (GetSnapshotExits(RaceTag.TagID, ShiftName)) {
                        //update
                        //Race_SnapshotEntity sse = new Race_SnapshotEntity();

                        ////sse.TagID = TagID;
                        ////sse.UnitID = UnitID;
                        ////sse.TagType = tentity.TagType;

                        //sse.TagShift = ShiftID;
                        //sse.TagPeriod = PeriodID;
                        //sse.TagStartTime = StartTime;
                        //sse.TagEndTime = EndTime;
                        //sse.TagValue = TagValue;
                        string sql = @"update Race_Snapshot
                                        set TagPeriod='{0}', TagStartTime='{1}',
                                                TagEndTime='{2}', TagValue={3}
                                    where TagID='{4}' and TagShift='{5}'";

                        sql = string.Format(sql, PeriodName, StartTime, EndTime, TagValue.ToString(), RaceTag.TagID, ShiftName);
                        DBAccess.GetRelation().ExecuteNonQuery(sql);
                    }
                    else {
                        //insert
                        Race_SnapshotEntity sse = new Race_SnapshotEntity();
                        sse.TagID = RaceTag.TagID;
                        sse.UnitID = Unit.UnitID;
                        sse.TagType = RaceTag.TagType;
                        sse.TagShift = ShiftName;
                        sse.TagPeriod = PeriodName;
                        sse.TagStartTime = StartTime;
                        sse.TagEndTime = EndTime;
                        sse.TagValue = Convert.ToDouble(TagValue);
                        Race_SnapshotDal.Insert(sse);
                    }

                    //update and insert
                    if (GetArchiveExits(RaceTag.TagID, ShiftName, StartTime)) {
                        //update
                        //Race_ArchiveEntity sse = new Race_ArchiveEntity();

                        ////sse.TagID = TagID;
                        ////sse.UnitID = UnitID;
                        ////sse.TagType = tentity.TagType;

                        //sse.TagShift = ShiftID;
                        //sse.TagPeriod = PeriodID;
                        //sse.TagStartTime = StartTime;
                        //sse.TagEndTime = EndTime;
                        //sse.TagValue = TagValue;
                        string sql = @"update Race_Archive
                                        set TagPeriod='{0}', TagEndTime='{1}', TagValue={2}
                                    where TagID='{3}' and TagShift='{4}' and TagStartTime='{5}'";
                        sql = string.Format(sql, PeriodName, EndTime, TagValue.ToString(), RaceTag.TagID, ShiftName, StartTime);
                        DBAccess.GetRelation().ExecuteNonQuery(sql);

                    }
                    else {
                        //insert
                        Race_ArchiveEntity sse = new Race_ArchiveEntity();

                        sse.TagID = RaceTag.TagID;
                        sse.UnitID = Unit.UnitID;
                        sse.TagType = RaceTag.TagType;
                        sse.TagShift = ShiftName;
                        sse.TagPeriod = PeriodName;
                        sse.TagStartTime = StartTime;
                        sse.TagEndTime = EndTime;
                        sse.TagValue = Convert.ToDouble(TagValue);
                        Race_ArchiveDal.Insert(sse);
                    }
                }
            }
            return true;
        }
Example #34
0
 private void Initialize()
 {
     using (KPI_UnitDal DataAccess = new KPI_UnitDal()) {
         m_UnitList = DataAccess.GetUnitIDs(string.Empty);
     }
     m_Parser.CustomFunction += new FunctionHandler(Parser_CustomFunction);
     m_Parser.OnError += new ErrorHandler(Parser_OnError);
     m_Parser.AddCustomFunction("SACOUNT", 1);//超限次数统计
     m_Parser.AddCustomFunction("SACOUNTBYTYPE", 2);//根据超限类型统计超限次数
     m_Parser.AddCustomFunction("SALONGCOUNT", 2);//超限次数统计(连续超限时长超过指定时长为超限1次)
     m_Parser.AddCustomFunction("SALONGCOUNTBYTYPE", 3);//根据超限类型统计超限次数(连续超限时长超过指定时长为超限1次)
     m_Parser.AddCustomFunction("SADURATION", 1);
     m_Parser.AddCustomFunction("SADURATIONBYTYPE", 2);
     m_Parser.AddCustomFunction("SALONGDURATION", 2);
     m_Parser.AddCustomFunction("SALONGDURATIONBYTYPE", 3);
 }