/// <summary> /// 页面信息检查 /// </summary> /// <param name="msg"></param> /// <returns></returns> bool CheckVal(out string msg) { bool flag = false; msg = ""; string sID = ViewState["said"].ToString(); txt_SACode.Value = txt_SACode.Value.Trim(); txt_SAName.Value = txt_SAName.Value.Trim(); ///////////////////////////////////////////////////////////////////// // if (txt_SACode.Value.Equals("")) { msg += "代码不能为空!\r\n"; flag = true; return(flag); } else { if (!Regex.IsMatch(txt_SACode.Value, @"^\w+$")) { msg += "代码只能由数字、字母和下划线组成!\r\n"; flag = true; return(flag); } if (string.IsNullOrWhiteSpace(sID)) { if (KPI_SATagDal.CodeExist(txt_SACode.Value, sID) || ALLDal.CodeExist(txt_SACode.Value, "")) { msg += "命名已存在,请检查!\r\n"; flag = true; return(flag); } } else { if (KPI_SATagDal.CodeExist(txt_SACode.Value, sID) || ALLDal.CodeExist(txt_SACode.Value, sID)) { msg += "命名已存在,请检查!\r\n"; flag = true; return(flag); } } } if (txt_SAName.Value.Equals("")) { msg += "名称不能为空!\r\n"; flag = true; return(flag); } return(flag); }
public override void DataBind() { using (KPI_SATagDal SATagDal = new KPI_SATagDal()) { SARepeater.DataSource = SATagDal.GetSATagList(drpUnits.SelectedValue); } base.DataBind(); }
/// <summary> /// 插入数据 /// </summary> /// <returns></returns> bool Insert(string said) { KPI_SATagEntity mEntity = new KPI_SATagEntity(); mEntity.SAID = said; 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.SAIsValid = int.Parse(ddl_SAIsValid.Value); mEntity.SAIsCalc = int.Parse(ddl_SAIsCalc.Value); mEntity.SAIsDisplay = int.Parse(ddl_SAIsDisplay.Value); mEntity.SAIsTotal = int.Parse(ddl_SAIsTotal.Value); mEntity.SACode = txt_SACode.Value.Trim(); mEntity.SAName = txt_SAName.Value.Trim(); mEntity.SADesc = txt_SADesc.Value.Trim(); mEntity.SAIndex = int.Parse(txt_SAIndex.Value.Trim()); mEntity.SAWeb = ddl_SAWeb.Value; //mEntity.SAFilterExp = tbx_SAFilterExp.Text; mEntity.SACalcExp = tbx_SACalcExp.Text; // mEntity.SANote = txt_SANote.Value.Trim(); mEntity.SACreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); mEntity.SAModifyTime = mEntity.SACreateTime; mEntity.SACountExpression = txtCountExpression.Text.Trim(); mEntity.SADurationExpression = txtDurationExpression.Text.Trim(); return(KPI_SATagDal.Insert(mEntity)); }
public override void DataBind() { using (KPI_SATagDal SATagDal = new KPI_SATagDal()) { SARepeater.DataSource = SATagDal.GetSATagList(drpUnits.SelectedValue); } base.DataBind(); }
void BindGrid() { gvTable = KPI_SATagDal.GetSearchListForSort(); gvTag.DataSource = gvTable; gvTag.DataBind(); }
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(); } }
/// <summary> /// //设备信息 /// </summary> void BindSA() { //查询条件 string UnitID = ""; string SeqID = ""; string KpiID = ""; string SAID = ""; //机组信息 if (ddl_UnitID.Value != "ALL") { UnitID = ddl_UnitID.Value; } //设备信息 if (ddl_SeqID.Value != "ALL") { SeqID = ddl_SeqID.Value; } //指标信息 if (ddl_KpiID.Value != "ALL") { KpiID = ddl_KpiID.Value; } //周期集信息 //if (ddl_CycleID.Value != "ALL") //{ // CycleID = ddl_CycleID.Value; //} //安全指标信息 if (ddl_SAID.Value != "ALL") { SAID = ddl_SAID.Value; } //设备信息 DataTable dtTags = KPI_SATagDal.GetSearchList(UnitID, SeqID, KpiID, SAID); gvSA.DataSource = dtTags; gvSA.DataBind(); }
protected void btnApply_Click(object sender, EventArgs e) { if (gvTable.Rows.Count <= 0) { return; } for (int i = 0; i < gvTable.Rows.Count; i++) { KPI_SATagEntity csE = new KPI_SATagEntity(); csE.SAID = gvTable.Rows[i]["SAID"].ToString(); csE.SAIndex = i + 1; KPI_SATagDal.Update(csE); } MessageBox.popupClientMessage(this.Page, "排序成功!", "call();"); }
private void CalculateSAScore(DateTime StartTime, DateTime EndTime) { KPI_SATagValueEntity SATagValue; List <KPI_SATagEntity> SATagList; this.BeginTime = StartTime; //开始时间 this.EndTime = EndTime; m_Log.Info("开始计算安全得分"); m_Log.InfoFormat("开始时间:{0} 结束时间:{1}", BeginTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime.ToString("yyyy-MM-dd HH:mm:ss")); using (KPI_SATagDal DataAccess = new KPI_SATagDal()) { foreach (KPI_UnitEntity Unit in m_UnitList) { if (UnitIsRunning(Unit.UnitID) == false) { continue; //机组停运不计算得分 } CurrentWorkInfo WorkInfo = GetWorkInfo(Unit.UnitID, BeginTime); //获取当前值次、班次相关信息 SATagValue = new KPI_SATagValueEntity(); SATagValue.Shift = WorkInfo.Shift; SATagValue.Period = WorkInfo.Period; SATagValue.CalcDateTime = EndTime; SATagList = DataAccess.GetSATagList(Unit.UnitID); foreach (KPI_SATagEntity SATag in SATagList) { SATagValue.SAID = SATag.SAID; SATagValue.SAScore = Convert.ToDecimal(m_Parser.Evaluate(SATag.SACalcExp)); //计算安全得分 //Console.WriteLine(SATag.SACountExpression); SATagValue.TotalCount = Convert.ToInt32(m_Parser.Evaluate(SATag.SACountExpression)); //计算超限次数 SATagValue.TotalDuration = Convert.ToDecimal(m_Parser.Evaluate(SATag.SADurationExpression)); //计算超限时长 if (SATagValue.TotalCount > 0) { m_DataAccess.SaveKPI_SATagValue(SATagValue); } } SATagList.Clear(); } } //Console.WriteLine("安全得分计算结束"); m_Log.Info("安全得分计算结束"); }
protected void gvSA_RowCommand(object sender, GridViewCommandEventArgs e) { string keyid = e.CommandArgument.ToString(); if (e.CommandName == "dataDelete") { if (KPI_SATagDal.DeleteTag(keyid)) { MessageBox.popupClientMessage(this.Page, "删除成功!", "call();"); BindSA(); } else { MessageBox.popupClientMessage(this.Page, "删除错误!", "call();"); } } else if (e.CommandName == "dataView") { Response.Redirect("KPI_SubSATagConfig.aspx?said=" + keyid); } else if (e.CommandName == "dataCopy") { //Response.Redirect("KPI_SubSATagConfig1.aspx?ecid=" + keyid); //string newid = PageControl.GetGuid(); if (KPI_SATagDal.CopySATag(keyid)) { MessageBox.popupClientMessage(this.Page, "复制成功,请修改相关配置!", "call();"); BindSA(); } else { MessageBox.popupClientMessage(this.Page, "复制错误!", "call();"); } } }
/// <summary> /// 绑定数据 /// </summary> void BindValues() { string SAID = ViewState["said"].ToString(); if (SAID == "") { return; } KPI_SATagEntity mEntity = KPI_SATagDal.GetEntity(SAID); ddl_UnitID.SelectedValue = mEntity.UnitID; ddl_SeqID.Value = mEntity.SeqID; ddl_KpiID.SelectedValue = mEntity.KpiID; ddl_EngunitID.Value = mEntity.EngunitID; ddl_CycleID.Value = mEntity.CycleID; ddl_SAIsValid.Value = mEntity.SAIsValid.ToString(); ddl_SAIsCalc.Value = mEntity.SAIsCalc.ToString(); ddl_SAIsDisplay.Value = mEntity.SAIsDisplay.ToString(); ddl_SAIsTotal.Value = mEntity.SAIsTotal.ToString(); ddl_SAWeb.Value = mEntity.SAWeb; txt_SACode.Value = mEntity.SACode; txt_SAName.Value = mEntity.SAName; txt_SADesc.Value = mEntity.SADesc; txt_SAIndex.Value = mEntity.SAIndex.ToString(); //tbx_SAFilterExp.Text = mEntity.SAFilterExp; tbx_SACalcExp.Text = mEntity.SACalcExp; txt_SANote.Value = mEntity.SANote; txtCountExpression.Text = mEntity.SACountExpression; txtDurationExpression.Text = mEntity.SADurationExpression; //BindSecurity(); }
private void BindSAKPI() { List <KPI_SATagEntity> DataSource; using (KPI_SATagDal SATagDal = new KPI_SATagDal()) { if (String.IsNullOrEmpty(drpUnits.SelectedValue)) { DataSource = SATagDal.GetSATags(); } else { DataSource = SATagDal.GetSATagList(drpUnits.SelectedValue); } KPI_SATagEntity item = new KPI_SATagEntity { SAID = "", SAName = "【所有指标】" }; DataSource.Insert(0, item); drpKPI.DataSource = DataSource; drpKPI.DataTextField = "SAName"; drpKPI.DataValueField = "SAID"; drpKPI.DataBind(); } }
private void CalculateSAScore(DateTime StartTime, DateTime EndTime) { KPI_SATagValueEntity SATagValue; List<KPI_SATagEntity> SATagList; this.BeginTime = StartTime; //开始时间 this.EndTime = EndTime; m_Log.Info("开始计算安全得分"); m_Log.InfoFormat("开始时间:{0} 结束时间:{1}", BeginTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime.ToString("yyyy-MM-dd HH:mm:ss")); using (KPI_SATagDal DataAccess = new KPI_SATagDal()) { foreach (KPI_UnitEntity Unit in m_UnitList) { if (UnitIsRunning(Unit.UnitID) == false) continue;//机组停运不计算得分 CurrentWorkInfo WorkInfo = GetWorkInfo(Unit.UnitID, BeginTime);//获取当前值次、班次相关信息 SATagValue = new KPI_SATagValueEntity(); SATagValue.Shift = WorkInfo.Shift; SATagValue.Period = WorkInfo.Period; SATagValue.CalcDateTime = EndTime; SATagList = DataAccess.GetSATagList(Unit.UnitID); foreach (KPI_SATagEntity SATag in SATagList) { SATagValue.SAID = SATag.SAID; SATagValue.SAScore = Convert.ToDecimal(m_Parser.Evaluate(SATag.SACalcExp));//计算安全得分 //Console.WriteLine(SATag.SACountExpression); SATagValue.TotalCount = Convert.ToInt32(m_Parser.Evaluate(SATag.SACountExpression));//计算超限次数 SATagValue.TotalDuration = Convert.ToDecimal(m_Parser.Evaluate(SATag.SADurationExpression));//计算超限时长 if (SATagValue.TotalCount > 0) m_DataAccess.SaveKPI_SATagValue(SATagValue); } SATagList.Clear(); } } //Console.WriteLine("安全得分计算结束"); m_Log.Info("安全得分计算结束"); }
private void BindSAKPI() { List<KPI_SATagEntity> DataSource; using (KPI_SATagDal SATagDal = new KPI_SATagDal()) { if (String.IsNullOrEmpty(drpUnits.SelectedValue)) { DataSource = SATagDal.GetSATags(); } else { DataSource = SATagDal.GetSATagList(drpUnits.SelectedValue); } KPI_SATagEntity item = new KPI_SATagEntity { SAID = "", SAName = "【所有指标】" }; DataSource.Insert(0, item); drpKPI.DataSource = DataSource; drpKPI.DataTextField = "SAName"; drpKPI.DataValueField = "SAID"; drpKPI.DataBind(); } }