/// <summary> /// 判断名称的唯一性 /// </summary> /// <param name="GroupName"></param> /// <param name="GroupID"></param> /// <returns></returns> public static bool CodeExist(string Code, string ID) { //insert时, ID == "" //update时, ID == 必须为 原来的ID //Excel find 时, 对应表单操作 ID == "" bool bExist = false; bExist = KPI_RealTagDal.CodeExist(Code, ID) || KPI_InputTagDal.CodeExist(Code, ID) || CurveTagDal.CodeExist(Code, ID) || ECTagDal.CodeExist(Code, ID) || KPI_SATagDal.CodeExist(Code, ID); return(bExist); }
/// <summary> /// 拷贝实体数据 /// </summary> /// <returns></returns> public static bool CopyCurveTag(string CurveID) { CurveTagEntity et = CurveTagDal.GetEntity(CurveID); //NewID string newid = Guid.NewGuid().ToString(); et.CurveID = newid; et.CurveCode = et.CurveCode + "_copy"; if (ALLDal.CodeExist(et.CurveCode, "")) { return(false); } et.CurveName = et.CurveName; et.CurveCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); et.CurveModifyTime = et.CurveCreateTime; CurveTagDal.Insert(et); return(true); }
/// <summary> /// 得到区间值,实体形式 /// </summary> /// <returns></returns> public static bool CheckEntityForXline(ECTagEntity ltone) { try { List <KPI_XLineEntity> ltxls = new List <KPI_XLineEntity>(); string ecid = ltone.ECID; string eccode = ltone.ECCode; int xlinetype = ltone.ECXLineType; int xlinegettype = ltone.ECXLineGetType; string xlinexyz = ltone.ECXLineXYZ; string ecscoreexp = ltone.ECScoreExp; DataTable dtXLine = new DataTable(); double dout = 0.0; //XYZ Tag不加'',因为有默认机组负荷的情况下,为空。 int anum = 0; if (ecscoreexp.Contains("@a8")) { anum += 1; } if (ecscoreexp.Contains("@a7")) { anum += 1; } if (ecscoreexp.Contains("@a6")) { anum += 1; } if (ecscoreexp.Contains("@a5")) { anum += 1; } if (ecscoreexp.Contains("@a4")) { anum += 1; } if (ecscoreexp.Contains("@a3")) { anum += 1; } if (ecscoreexp.Contains("@a2")) { anum += 1; } if (ecscoreexp.Contains("@a1")) { anum += 1; } bool bResult = GetXLineXYZ(xlinetype, xlinexyz, out dtXLine, out dout); if (xlinetype == 0) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a1"; entity.XLineGet = xlinegettype; entity.XLineXBase = ""; entity.XLineYBase = ""; entity.XLineX = 0; entity.XLineY = 0; entity.XLineValue = dout; if (anum > 1) { return(false); } ltxls.Add(entity); } else if (xlinetype == 1) { string xrealtag = ltone.ECXLineXRealTag; //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag); //xrealtag = "'" + xrealtag + "'"; for (int i = 1; i < dtXLine.Rows.Count; i++) { for (int j = 1; j < dtXLine.Columns.Count; j++) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a" + i.ToString(); entity.XLineGet = xlinegettype; entity.XLineXBase = xrealtag; entity.XLineYBase = ""; entity.XLineX = double.Parse(dtXLine.Rows[0][j].ToString()); entity.XLineY = 0; entity.XLineValue = double.Parse(dtXLine.Rows[i][j].ToString()); ltxls.Add(entity); } } if (anum > (dtXLine.Rows.Count - 1)) { return(false); } } else if (xlinetype == 2) { //可以是默认的机组负荷点,所以为空。 string xrealtag = ltone.ECXLineXRealTag; //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag); //xrealtag = "'" + xrealtag + "'"; string yrealtag = ltone.ECXLineYRealTag; //yrealtag = KPI_RealTagDal.GetRealCode(yrealtag); //yrealtag = "'" + yrealtag + "'"; for (int i = 1; i < dtXLine.Rows.Count; i++) { for (int j = 1; j < dtXLine.Columns.Count; j++) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a1"; entity.XLineGet = xlinegettype; entity.XLineXBase = xrealtag; entity.XLineYBase = yrealtag; entity.XLineX = double.Parse(dtXLine.Rows[0][j].ToString()); entity.XLineY = double.Parse(dtXLine.Rows[i][0].ToString()); entity.XLineValue = double.Parse(dtXLine.Rows[i][j].ToString()); ltxls.Add(entity); } } if (anum > 1) { return(false); } } ////////////////////////////////////////////////// //==3忽略 else if (xlinetype == 4) { //在CurveDal中直接生成 XLineEntity string curvegroup = ltone.ECCurveGroup; List <KPI_XLineEntity> ltcurve = new List <KPI_XLineEntity>(); ltcurve = CurveTagDal.GetAllXLineEntity(ecid, eccode, curvegroup, anum); if (ltcurve == null) { return(false); } ltxls.AddRange(ltcurve); } return(true); } catch (Exception) { return(false); } }
/// <summary> /// 得到区间值,实体形式 /// </summary> /// <returns></returns> public static List <KPI_XLineEntity> GetAllXLineEntity() { List <KPI_XLineEntity> ltxls = new List <KPI_XLineEntity>(); string sql = @"SELECT ECID, ECCode, ECXLineType, ECXLineGetType, ECXLineXRealTag, ECXLineYRealTag, ECXLineZRealTag, ECXLineXYZ, ECCurveGroup FROM KPI_ECTag WHERE ECIsValid=1 ORDER BY ECCode "; using (DataTable dt = DBAccess.GetRelation().ExecuteDataset(sql).Tables[0]) { foreach (DataRow dr in dt.Rows) { string ecid = dr["ECID"].ToString(); string eccode = dr["ECCode"].ToString(); int xlinetype = int.Parse(dr["ECXLineType"].ToString()); int xlinegettype = int.Parse(dr["ECXLineGetType"].ToString()); string xlinexyz = dr["ECXLineXYZ"].ToString(); DataTable dtXLine = new DataTable(); double dout = 0.0; //XYZ Tag不加'',因为有默认机组负荷的情况下,为空。 bool bResult = GetXLineXYZ(xlinetype, xlinexyz, out dtXLine, out dout); if (xlinetype == 0) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a1"; entity.XLineGet = xlinegettype; entity.XLineXBase = ""; entity.XLineYBase = ""; entity.XLineX = 0; entity.XLineY = 0; entity.XLineValue = dout; ltxls.Add(entity); } if (xlinetype == 1) { string xrealtag = dr["ECXLineXRealTag"].ToString(); //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag); //xrealtag = "'" + xrealtag + "'"; for (int i = 1; i < dtXLine.Rows.Count; i++) { for (int j = 1; j < dtXLine.Columns.Count; j++) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a" + i.ToString(); entity.XLineGet = xlinegettype; entity.XLineXBase = xrealtag; entity.XLineYBase = ""; entity.XLineX = double.Parse(dtXLine.Rows[0][j].ToString()); entity.XLineY = 0; entity.XLineValue = double.Parse(dtXLine.Rows[i][j].ToString()); ltxls.Add(entity); } } } if (xlinetype == 2) { //可以是默认的机组负荷点,所以为空。 string xrealtag = dr["ECXLineXRealTag"].ToString(); //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag); //xrealtag = "'" + xrealtag + "'"; string yrealtag = dr["ECXLineYRealTag"].ToString(); //yrealtag = KPI_RealTagDal.GetRealCode(yrealtag); //yrealtag = "'" + yrealtag + "'"; for (int i = 1; i < dtXLine.Rows.Count; i++) { for (int j = 1; j < dtXLine.Columns.Count; j++) { KPI_XLineEntity entity = new KPI_XLineEntity(); entity.XLineID = Guid.NewGuid().ToString(); entity.ECID = ecid; entity.ECCode = eccode; entity.ECCurveGroup = ""; entity.XLineMonth = ""; entity.XLineCoef = "a1"; entity.XLineGet = xlinegettype; entity.XLineXBase = xrealtag; entity.XLineYBase = yrealtag; entity.XLineX = double.Parse(dtXLine.Rows[0][j].ToString()); entity.XLineY = double.Parse(dtXLine.Rows[i][0].ToString()); entity.XLineValue = double.Parse(dtXLine.Rows[i][j].ToString()); ltxls.Add(entity); } } } ////////////////////////////////////////////////// //==3忽略 if (xlinetype == 4) { //在CurveDal中直接生成 XLineEntity string curvegroup = dr["ECCurveGroup"].ToString(); List <KPI_XLineEntity> ltcurve = new List <KPI_XLineEntity>(); //因为这里不用判断是否正确,故传0进入,判断条件始终不成立即可。 //numbers ltcurve = CurveTagDal.GetAllXLineEntity(ecid, eccode, curvegroup, 0); ltxls.AddRange(ltcurve); } } } return(ltxls); }