public void AddCountNum(string relatedTableName, string relatedIdentity, ECountType countType) { var sqlString = $"UPDATE siteserver_Count SET {SqlUtils.ToPlusSqlString("CountNum")} WHERE RelatedTableName = @RelatedTableName AND RelatedIdentity = @RelatedIdentity AND CountType = @CountType"; var insertParms = new IDataParameter[] { GetParameter(ParmRelatedTableName, DataType.VarChar, 255, relatedTableName), GetParameter(ParmRelatedIdentity, DataType.VarChar, 255, relatedIdentity), GetParameter(ParmCountType, DataType.VarChar, 50, ECountTypeUtils.GetValue(countType)), }; ExecuteNonQuery(sqlString, insertParms); }
public void Insert(string relatedTableName, string relatedIdentity, ECountType countType, int countNum) { const string sqlString = "INSERT INTO siteserver_Count (RelatedTableName, RelatedIdentity, CountType, CountNum) VALUES (@RelatedTableName, @RelatedIdentity, @CountType, @CountNum)"; var insertParms = new IDataParameter[] { GetParameter(ParmRelatedTableName, DataType.VarChar, 255, relatedTableName), GetParameter(ParmRelatedIdentity, DataType.VarChar, 255, relatedIdentity), GetParameter(ParmCountType, DataType.VarChar, 50, ECountTypeUtils.GetValue(countType)), GetParameter(ParmCountNum, DataType.Integer, countNum) }; ExecuteNonQuery(sqlString, insertParms); }
public object GetValue(string attributeName) { foreach (var name in AllAttributes) { if (!StringUtils.EqualsIgnoreCase(name, attributeName)) { continue; } var nameVlaue = GetType().GetProperty(name).GetValue(this, null); return(attributeName == "CountType" ? ECountTypeUtils.GetEnumType(nameVlaue.ToString()) : nameVlaue); } return(null); }
/// <summary> /// 获取站点的统计数据 /// </summary> /// <param name="relatedTableName"></param> /// <param name="siteId"></param> /// <param name="countType"></param> /// <returns></returns> public int GetCountNum(string relatedTableName, int siteId, ECountType countType) { var countNum = 0; string sqlString = $@"select sum(cou.CountNum) from siteserver_Count cou left join {relatedTableName} con on cou.RelatedIdentity = con.ID where cou.RelatedTableName = '{relatedTableName}' and con.SiteId = {siteId} and cou.CountType = '{ECountTypeUtils.GetValue(countType)}'"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read()) { countNum = GetInt(rdr, 0); } rdr.Close(); } return(countNum); }
public int GetCountNum(string relatedTableName, string relatedIdentity, ECountType countType) { var countNum = 0; var parms = new IDataParameter[] { GetParameter(ParmRelatedTableName, DataType.VarChar, 255, relatedTableName), GetParameter(ParmRelatedIdentity, DataType.VarChar, 255, relatedIdentity), GetParameter(ParmCountType, DataType.VarChar, 50, ECountTypeUtils.GetValue(countType)) }; using (var rdr = ExecuteReader(SqlSelectCountNum, parms)) { if (rdr.Read()) { countNum = GetInt(rdr, 0); } rdr.Close(); } return(countNum); }