public RlmStats GetStatistics() { RlmStats retVal = null; using (RlmDbEntities db = new RlmDbEntities(DatabaseName)) { retVal = RlmUtils.GetRNetworkStatistics(db, CurrentNetworkID); } return(retVal); }
public RlmStats GetStatistics() { RlmStats retVal = null; //using (RlmDbEntities db = new RlmDbEntities(DatabaseName)) //{ // retVal = RlmUtils.GetRNetworkStatistics(db, CurrentNetworkID); //} retVal = rlmDbDataLegacy.GetStatistics(CurrentNetworkID); return(retVal); }
public override RlmStats GetStatistics(long networkId) { RlmStats retVal = null; string sql = $@" declare @lastSessionId bigint, @lastSessionScore float, @lastSessionTime int; select top 1 @lastSessionId = [ID], @lastSessionScore = [SessionScore], @lastSessionTime = coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,convert(float,DateTimeStop)-Convert(float,DateTimeStart))),0) from [{nameof(_Session)}] where [Rnetwork_ID] = @p0 and [Hidden] = 0 and [SessionScore] <> @p1 order by [ID] desc; select coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,avg(convert(float,DateTimeStop)-Convert(float,DateTimeStart)))),0) as [AvgTimePerSessionInSeconds], coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,sum(convert(float,DateTimeStop)-Convert(float,DateTimeStart)))),0) as [TotalSessionTimeInSeconds], count([ID]) as [TotalSessions], coalesce(max([SessionScore]),0) as [MaxSessionScore], coalesce(avg([SessionScore]),0) as [AvgSessionScore], coalesce(@lastSessionId,0) as [LastSessionId], coalesce(@lastSessionScore,0) as [LastSessionScore], coalesce(@lastSessionTime,0) as [LastSessionTimeInSeconds] from [{nameof(_Session)}] where [Rnetwork_ID] = @p0 and [Hidden] = 0 and [SessionScore] <> @p1"; using (var conn = GetOpenDBConnection(ConnectionStringWithDatabaseName)) { retVal = conn.Query <RlmStats>(sql, new { p0 = networkId, p1 = int.MinValue }).FirstOrDefault(); if (retVal != null) { retVal.NumSessionsSinceLastBestScore = GetNumSessionSinceBestScore(networkId); } } return(retVal); }
public static RlmStats GetRNetworkStatistics(RlmDbEntities db, long rnetworkId) { RlmStats retVal = null; string sql = $@" declare @lastSessionId bigint, @lastSessionScore float, @lastSessionTime int; select top 1 @lastSessionId = [ID], @lastSessionScore = [SessionScore], @lastSessionTime = coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,convert(float,DateTimeStop)-Convert(float,DateTimeStart))),0) from [Sessions] where [Rnetwork_ID] = @p0 and [Hidden] = 0 and [SessionScore] <> @p1 order by [ID] desc; select coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,avg(convert(float,DateTimeStop)-Convert(float,DateTimeStart)))),0) as [AvgTimePerSessionInSeconds], coalesce(datediff(second,'1900-01-01 00:00:00.0000000', convert(datetime,sum(convert(float,DateTimeStop)-Convert(float,DateTimeStart)))),0) as [TotalSessionTimeInSeconds], count([ID]) as [TotalSessions], coalesce(max([SessionScore]),0) as [MaxSessionScore], coalesce(avg([SessionScore]),0) as [AvgSessionScore], coalesce(@lastSessionId,0) as [LastSessionId], coalesce(@lastSessionScore,0) as [LastSessionScore], coalesce(@lastSessionTime,0) as [LastSessionTimeInSeconds] from [Sessions] where [Rnetwork_ID] = @p0 and [Hidden] = 0 and [SessionScore] <> @p1"; retVal = db.Database.SqlQuery <RlmStats>(sql, rnetworkId, int.MinValue).FirstOrDefault(); if (retVal != null) { retVal.NumSessionsSinceLastBestScore = GetNumSessionSinceBestScore(db, rnetworkId); } return(retVal); }