本文整理汇总了C#中TimeInterval.ToDbTableString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeInterval.ToDbTableString方法的具体用法?C# TimeInterval.ToDbTableString怎么用?C# TimeInterval.ToDbTableString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeInterval
的用法示例。
在下文中一共展示了TimeInterval.ToDbTableString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UsersOnlineBySessionType
public List<PVTimeSeries> UsersOnlineBySessionType(string gameShort, TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate)
{
GameMonitoringConfig game = Games.Instance.GetMonitoredGames().Where(x => x.ShortTitle == gameShort).FirstOrDefault();
List<PVTimeSeries> timeSeriesData = new List<PVTimeSeries>();
DataTable queryResults = new DataTable();
startDate = startDate.RoundDown(interval);
endDate = endDate.RoundDown(interval);
string query = String.Format(
@"SELECT RecordTimestamp,
SessionTypeName_0, SUM(SessionTypeUsers_0) AS SessionTypeUsers_0,
SessionTypeName_1, SUM(SessionTypeUsers_1) AS SessionTypeUsers_1,
SessionTypeName_2, SUM(SessionTypeUsers_2) AS SessionTypeUsers_2,
SessionTypeName_3, SUM(SessionTypeUsers_3) AS SessionTypeUsers_3,
SessionTypeName_4, SUM(SessionTypeUsers_4) AS SessionTypeUsers_4,
SessionTypeName_5, SUM(SessionTypeUsers_5) AS SessionTypeUsers_5,
SessionTypeName_6, SUM(SessionTypeUsers_6) AS SessionTypeUsers_6,
SessionTypeName_7, SUM(SessionTypeUsers_7) AS SessionTypeUsers_7,
Other, SUM(SessionTypeUsers_Other) AS SessionTypeUsers_Other
FROM (
SELECT RecordTimestamp,
RegionName,
SessionTypeName_0, ROUND(AVG(SessionTypeUsers_0)) AS SessionTypeUsers_0,
SessionTypeName_1, ROUND(AVG(SessionTypeUsers_1)) AS SessionTypeUsers_1,
SessionTypeName_2, ROUND(AVG(SessionTypeUsers_2)) AS SessionTypeUsers_2,
SessionTypeName_3, ROUND(AVG(SessionTypeUsers_3)) AS SessionTypeUsers_3,
SessionTypeName_4, ROUND(AVG(SessionTypeUsers_4)) AS SessionTypeUsers_4,
SessionTypeName_5, ROUND(AVG(SessionTypeUsers_5)) AS SessionTypeUsers_5,
SessionTypeName_6, ROUND(AVG(SessionTypeUsers_6)) AS SessionTypeUsers_6,
SessionTypeName_7, ROUND(AVG(SessionTypeUsers_7)) AS SessionTypeUsers_7,
'Other', ROUND(AVG(SessionTypeUsers_Other)) AS SessionTypeUsers_Other
FROM {0}
WHERE GameId = '{1}'
AND RecordTimestamp BETWEEN '{2}' AND '{3}'
AND RegionName like '{4}'
GROUP BY RecordTimestamp,
RegionName,
SessionTypeName_0,
SessionTypeName_1,
SessionTypeName_2,
SessionTypeName_3,
SessionTypeName_4,
SessionTypeName_5,
SessionTypeName_6,
SessionTypeName_7,
'Other'
) AGGSESSIONS
GROUP BY RecordTimestamp,
SessionTypeName_0,
SessionTypeName_1,
SessionTypeName_2,
SessionTypeName_3,
SessionTypeName_4,
SessionTypeName_5,
SessionTypeName_6,
SessionTypeName_7,
Other
ORDER BY RecordTimestamp ASC;",
String.Format("GameUserActivity{0}", interval.ToDbTableString()),
game.Id,
startDate.ToString("yyyy-MM-dd HH:mm:ss"),
endDate.ToString("yyyy-MM-dd HH:mm:ss"),
region.GetDatabaseString());
try
{
// Get time series data
queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
if (queryResults.HasRows())
{
foreach (DataRow row in queryResults.Rows)
{
foreach (DataColumn col in queryResults.Columns)
{
if ((col.ColumnName.Contains("SessionTypeName") || col.ColumnName == "Other") && !String.IsNullOrEmpty(row[col.ColumnName].ToString()))
{
int count = Convert.ToInt32(row[col.Ordinal + 1].ToString());
PVTimeSeries series = timeSeriesData.FirstOrDefault(x => x.name == row[col.ColumnName].ToString());
if (series == default(PVTimeSeries))
{
series = new PVTimeSeries
{
name = row[col.ColumnName].ToString(),
data = new List<int>(),
pointStart = row.Field<DateTime>("RecordTimestamp").ToUnixTimestamp() * 1000, //JS unix timestamp is in milliseconds
pointInterval = (int)interval * 60 * 1000, //JS unix timestamp is in milliseconds
type = "area"
};
int zerosCount = ((int)(endDate - startDate).TotalMinutes / (int)interval) + 1;
for (int i = 0; i < zerosCount; i++)
{
series.data.Add(0);
}
timeSeriesData.Add(series);
//.........这里部分代码省略.........
示例2: GetUsersByRegion
public List<PVTimeSeries> GetUsersByRegion(TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate, GameMonitoringConfig game)
{
#region Validation
//if (!interval.IsSupportedInterval(TimeInterval.Minute, TimeInterval.Year))
//{
// throw new Exception(String.Format("Chart data only supports an interval between {0} and {1}", TimeInterval.Day, TimeInterval.Year));
//}
//if (startDate == DateTime.MinValue || endDate == DateTime.MinValue || (startDate >= endDate))
//{
// throw new Exception("StartDate and EndDate cannot be null, and StartDate must come before EndDate");
//}
//if (String.IsNullOrEmpty(game.Id))
//{
// throw new Exception("GameID cannot be empty or null");
//}
#endregion
List<PVTimeSeries> timeSeriesData = new List<PVTimeSeries>();
// Init dates
startDate = startDate.RoundDown(interval).ToUniversalTime();
endDate = endDate.RoundDown(interval).ToUniversalTime();
string query = String.Format(
@"SELECT RecordTimestamp,
RegionName,
GameSessionUsers
FROM {0}
WHERE GameId = '{1}'
AND RecordTimestamp BETWEEN '{2}' AND '{3}'
ORDER BY RecordTimestamp, RegionName ASC;",
String.Format("GameUserActivity{0}", interval.ToDbTableString()),
game.Id,
startDate.ToString("yyyy-MM-dd HH:mm:ss"),
endDate.ToString("yyyy-MM-dd HH:mm:ss"));
try
{
// Get time series data
DataTable queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
foreach (DataRow row in queryResults.Rows)
{
PVTimeSeries series = timeSeriesData.FirstOrDefault(x => x.name == row["RegionName"].ToString());
if (series == default(PVTimeSeries))
{
series = new PVTimeSeries
{
name = row["RegionName"].ToString(),
data = new List<int>(),
pointStart = queryResults.Rows[0].Field<DateTime>("RecordTimestamp").ToUnixTimestamp() * 1000, //JS unix timestamp is in milliseconds
pointInterval = (int)interval * 60 * 1000,
type = "area"
};
int zerosCount = ((int)(endDate - startDate).TotalMinutes / (int)interval) + 1;
for (int i = 0; i < zerosCount; i++)
{
series.data.Add(0);
}
timeSeriesData.Add(series);
}
DateTime timeStamp = row.Field<DateTime>("RecordTimestamp");
int index = (int)(timeStamp - startDate).TotalMinutes / (int)interval;
series.data[index] = Convert.ToInt32(row["GameSessionUsers"].ToString());
}
}
catch (Exception ex)
{
Logger.Instance.Exception(ex.Message, ex.StackTrace);
}
return timeSeriesData;
}
示例3: GetConcurrentUsersSessionType
public TimeSeriesDataNew GetConcurrentUsersSessionType(TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate, GameMonitoringConfig game)
{
#region Validation
if (!interval.IsSupportedInterval(TimeInterval.Minute, TimeInterval.Year))
{
throw new Exception(String.Format("Chart data only supports an interval between {0} and {1}", TimeInterval.Day, TimeInterval.Year));
}
//if (region != 0) {
// throw new Exception("write check for valid region");
//}
if (startDate == DateTime.MinValue || endDate == DateTime.MinValue || (startDate >= endDate))
{
throw new Exception("StartDate and EndDate cannot be null, and StartDate must come before EndDate");
}
if (String.IsNullOrEmpty(game.Id))
{
throw new Exception("GameID cannot be empty or null");
}
#endregion
TimeSeriesDataNew timeSeriesData = new TimeSeriesDataNew();
DataTable queryResults = new DataTable();
startDate = startDate.RoundDown(interval);
endDate = endDate.RoundDown(interval);
string query = String.Format(
@"SELECT RecordTimestamp,
SessionTypeName_0, SUM(SessionTypeUsers_0) AS SessionTypeUsers_0,
SessionTypeName_1, SUM(SessionTypeUsers_1) AS SessionTypeUsers_1,
SessionTypeName_2, SUM(SessionTypeUsers_2) AS SessionTypeUsers_2,
SessionTypeName_3, SUM(SessionTypeUsers_3) AS SessionTypeUsers_3,
SessionTypeName_4, SUM(SessionTypeUsers_4) AS SessionTypeUsers_4,
SessionTypeName_5, SUM(SessionTypeUsers_5) AS SessionTypeUsers_5,
SessionTypeName_6, SUM(SessionTypeUsers_6) AS SessionTypeUsers_6,
SessionTypeName_7, SUM(SessionTypeUsers_7) AS SessionTypeUsers_7,
Other, SUM(SessionTypeUsers_Other) AS SessionTypeUsers_Other
FROM (
SELECT RecordTimestamp,
RegionName,
SessionTypeName_0, ROUND(AVG(SessionTypeUsers_0)) AS SessionTypeUsers_0,
SessionTypeName_1, ROUND(AVG(SessionTypeUsers_1)) AS SessionTypeUsers_1,
SessionTypeName_2, ROUND(AVG(SessionTypeUsers_2)) AS SessionTypeUsers_2,
SessionTypeName_3, ROUND(AVG(SessionTypeUsers_3)) AS SessionTypeUsers_3,
SessionTypeName_4, ROUND(AVG(SessionTypeUsers_4)) AS SessionTypeUsers_4,
SessionTypeName_5, ROUND(AVG(SessionTypeUsers_5)) AS SessionTypeUsers_5,
SessionTypeName_6, ROUND(AVG(SessionTypeUsers_6)) AS SessionTypeUsers_6,
SessionTypeName_7, ROUND(AVG(SessionTypeUsers_7)) AS SessionTypeUsers_7,
'Other', ROUND(AVG(SessionTypeUsers_Other)) AS SessionTypeUsers_Other
FROM {0}
WHERE GameId = '{1}'
AND RecordTimestamp BETWEEN '{2}' AND '{3}'
AND RegionName like '{4}'
GROUP BY RecordTimestamp,
RegionName,
SessionTypeName_0,
SessionTypeName_1,
SessionTypeName_2,
SessionTypeName_3,
SessionTypeName_4,
SessionTypeName_5,
SessionTypeName_6,
SessionTypeName_7,
'Other'
) AGGSESSIONS
GROUP BY RecordTimestamp,
SessionTypeName_0,
SessionTypeName_1,
SessionTypeName_2,
SessionTypeName_3,
SessionTypeName_4,
SessionTypeName_5,
SessionTypeName_6,
SessionTypeName_7,
Other
ORDER BY RecordTimestamp ASC;",
String.Format("GameUserActivity{0}", interval.ToDbTableString()),
game.Id,
startDate.ToString("yyyy-MM-dd HH:mm:ss"),
endDate.ToString("yyyy-MM-dd HH:mm:ss"),
region.GetDatabaseString());
try
{
// Get time series data
queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
timeSeriesData = Charts.Instance.GetTimeSeriesNewData(queryResults, interval, startDate, endDate, "RecordTimestamp");
}
catch (Exception ex)
{
Logger.Instance.Exception(ex.Message, ex.StackTrace);
}
return timeSeriesData;
}
示例4: GetCurrentOnline
public List<PVTimeSeries> GetCurrentOnline(TimeInterval interval, DateTime start, DateTime end, GameMonitoringConfig game)
{
#region Validation
if (!interval.IsSupportedInterval(TimeInterval.Minute, TimeInterval.Year))
{
throw new Exception(String.Format("Chart data only supports an interval between {0} and {1}", TimeInterval.Day, TimeInterval.Year));
}
if (start == DateTime.MinValue || end == DateTime.MinValue || (start >= end))
{
throw new Exception("StartDate and EndDate cannot be null, and StartDate must come before EndDate");
}
start = start.RoundDown(interval).ToUniversalTime();
end = end.RoundDown(interval).ToUniversalTime();
#endregion
string query = String.Format(
@"SELECT RecordTimestamp,
Title,
sum(GameSessionUsers) as GameSessionUsers
FROM (
SELECT RecordTimestamp,
GMC.Title,
GUA.RegionName,
round(avg(GameSessionUsers)) as GameSessionUsers
FROM {0} GUA
INNER JOIN GameMonitoringConfig GMC
ON GUA.GameId = GMC.GameId
WHERE RecordTimestamp BETWEEN '{1}' AND '{2}'
AND GMC.GameId = '{3}'
GROUP BY RecordTimestamp, GMC.Title, GUA.RegionName
) USERS
GROUP BY RecordTimestamp, Title
ORDER BY RecordTimestamp ASC, Title ASC;",
String.Format("GameUserActivity{0}", interval.ToDbTableString()),
start.ToString("yyyy-MM-dd HH:mm:ss"),
end.ToString("yyyy-MM-dd HH:mm:ss"),
game.Id);
List<PVTimeSeries> SeriesList = new List<PVTimeSeries>();
try
{
// Get time series data
DataTable queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
foreach (DataRow row in queryResults.Rows)
{
PVTimeSeries series = SeriesList.FirstOrDefault(x => x.name == row["Title"].ToString());
if (series == default(PVTimeSeries))
{
series = new PVTimeSeries();
series.name = row["Title"].ToString();
series.data = new List<int>();
series.pointStart = queryResults.Rows[0].Field<DateTime>("RecordTimestamp").ToUnixTimestamp() * 1000; //JS unix timestamp is in milliseconds
series.pointInterval = (int)interval * 60 * 1000; //JS unix timestamp is in milliseconds
series.type = "area";
int zerosCount = ((int)(end - start).TotalMinutes / (int)interval) + 1;
for (int i = 0; i < zerosCount; i++)
{
series.data.Add(0);
}
SeriesList.Add(series);
}
DateTime timeStamp = row.Field<DateTime>("RecordTimestamp");
int index = (int)(timeStamp - start).TotalMinutes / (int)interval;
series.data[index] = Convert.ToInt32(row["GameSessionUsers"].ToString());
}
}
catch (Exception ex)
{
Logger.Instance.Exception(ex.Message, ex.StackTrace);
}
return SeriesList;
}