public int GetCount(int publishmentSystemId, int year, int month, ECountType countType) { var count = 0; string sqlString = $"SELECT Count FROM wx_Count WHERE PublishmentSystemID = {publishmentSystemId} AND CountYear = {year} AND CountMonth = {month} AND CountType = '{ECountTypeUtils.GetValue(countType)}'"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read() && !rdr.IsDBNull(0)) { count = rdr.GetInt32(0); } rdr.Close(); } return(count); }
public int GetCount(int publishmentSystemID, ECountType countType) { var count = 0; var now = DateTime.Now; string sqlString = $"SELECT Count FROM wx_Count WHERE PublishmentSystemID = {publishmentSystemID} AND CountYear = {now.Year} AND CountMonth = {now.Month} AND CountDay = {now.Day} AND CountType = '{ECountTypeUtils.GetValue(countType)}'"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read() && !rdr.IsDBNull(0)) { count = rdr.GetInt32(0); } rdr.Close(); } return(count); }
public void AddCount(int publishmentSystemId, ECountType countType) { var count = GetCount(publishmentSystemId, countType); var now = DateTime.Now; if (count == 0) { string sqlString = $"INSERT INTO wx_Count (PublishmentSystemID, CountYear, CountMonth, CountDay, CountType, Count) VALUES ({publishmentSystemId}, {now.Year}, {now.Month}, {now.Day}, '{ECountTypeUtils.GetValue(countType)}', 1)"; ExecuteNonQuery(sqlString); } else { string sqlString = $"UPDATE wx_Count SET Count = Count + 1 WHERE PublishmentSystemID = {publishmentSystemId} AND CountYear = {now.Year} AND CountMonth = {now.Month} AND CountDay = {now.Day} AND CountType = '{ECountTypeUtils.GetValue(countType)}'"; ExecuteNonQuery(sqlString); } }
public Dictionary <int, int> GetDayCount(int publishmentSystemId, int year, int month, ECountType countType) { var dictionary = new Dictionary <int, int>(); string sqlString = $"SELECT CountDay, Count FROM wx_Count WHERE PublishmentSystemID = {publishmentSystemId} AND CountYear = {year} AND CountMonth = {month} AND CountType = '{ECountTypeUtils.GetValue(countType)}'"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read() && !rdr.IsDBNull(0)) { var day = rdr.GetInt32(0); var count = rdr.GetInt32(1); dictionary[day] = count; } rdr.Close(); } return(dictionary); }