public IList <HistoryEntry> Fetch(QueryParameters parameters, BonusCalculationType bonusCalculation) { var sw = Stopwatch.StartNew(); try { return(FetchInternal(parameters, bonusCalculation)); } finally { _logger.DebugFormat("Database Fetch ({0}) completed in {1}", parameters, sw.GetExecTime()); } }
private IList <HistoryEntry> FetchInternal(QueryParameters parameters, BonusCalculationType bonusCalculation) { Debug.Assert(TableExists(SqlTable.WuHistory)); var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql); select.Append(WhereBuilder.Execute(parameters)); GetProduction.BonusCalculation = bonusCalculation; using (var connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (var database = new PetaPoco.Database(connection)) { List <HistoryEntry> query = database.Fetch <HistoryEntry>(select); return(query); } } }
private void FetchInternal(int count, QueryParameters parameters, BonusCalculationType bonusCalculation) { var entries = _database.Fetch(parameters, bonusCalculation); //#if DEBUG // //Debug.WriteLine(parameters.Fields[0].Name); // foreach (var entry in entries) // { // Debug.WriteLine(entry.ID); // } //#endif Assert.AreEqual(count, entries.Count); }
private PetaPoco.Page <HistoryEntry> PageInternal(long page, long itemsPerPage, QueryParameters parameters, BonusCalculationType bonusCalculation) { Debug.Assert(TableExists(SqlTable.WuHistory)); var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql); select.Append(WhereBuilder.Execute(parameters)); GetProduction.BonusCalculation = bonusCalculation; using (var connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (var database = new PetaPoco.Database(connection)) { PetaPoco.Page <HistoryEntry> query = database.Page <HistoryEntry>(page, itemsPerPage, select); Debug.Assert(query != null); return(query); } } }
public PetaPoco.Page <HistoryEntry> Page(long page, long itemsPerPage, QueryParameters parameters, BonusCalculationType bonusCalculation) { var sw = Stopwatch.StartNew(); try { return(PageInternal(page, itemsPerPage, parameters, bonusCalculation)); } finally { _logger.DebugFormat("Database Page Fetch ({0}) completed in {1}", parameters, sw.GetExecTime()); } }
public void ShowPPDTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus) { // test the level if (!logger.IsDebugEnabled) return; if (CurrentProtein.IsUnknown()) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD."); return; } // Issue 125 if (calculateBonus.Equals(BonusCalculationType.DownloadTime)) { // Issue 183 if (status.Equals(SlotStatus.RunningAsync) || status.Equals(SlotStatus.RunningNoFrameTimes)) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time."); } else { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Download Time."); } } else if (calculateBonus.Equals(BonusCalculationType.FrameTime)) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time."); } else { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD."); } TimeSpan frameTime = GetFrameTime(calculationType); var values = CurrentProtein.GetProductionValues(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), calculateBonus.IsEnabled()); logger.Debug(values.ToMultiLineString()); }
/// <summary> /// Points per day (PPD) rating for this unit /// </summary> public double GetPPD(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus) { TimeSpan frameTime = GetFrameTime(calculationType); return(GetPPD(frameTime, GetUnitTimeByDownloadTime(frameTime), GetUnitTimeByFrameTime(frameTime), status, calculateBonus)); }
public PetaPoco.Page<HistoryEntry> Page(long page, long itemsPerPage, QueryParameters parameters, BonusCalculationType bonusCalculation) { DateTime start = Instrumentation.ExecStart; try { return PageInternal(page, itemsPerPage, parameters, bonusCalculation); } finally { _logger.DebugFormat("Database Page Fetch ({0}) completed in {1}", parameters, Instrumentation.GetExecTime(start)); } }
public void ShowPPDTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType bonusCalculationType) { // test the level if (!logger.IsDebugEnabled) { return; } if (CurrentProtein.IsUnknown) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD."); return; } // Issue 125 if (bonusCalculationType == BonusCalculationType.DownloadTime) { // Issue 183 if (status.Equals(SlotStatus.RunningAsync) || status.Equals(SlotStatus.RunningNoFrameTimes)) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time."); } else { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Download Time."); } } else if (bonusCalculationType == BonusCalculationType.FrameTime) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time."); } else { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD."); } TimeSpan frameTime = GetFrameTime(calculationType); var values = ProductionCalculator.GetProductionValues(frameTime, CurrentProtein, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime)); logger.DebugFormat(" - {0}", UnitInfoData.ToProjectString()); logger.Debug(values.ToMultiLineString()); }
public static bool IsEnabled(this BonusCalculationType type) { return(type.Equals(BonusCalculationType.DownloadTime) || type.Equals(BonusCalculationType.FrameTime)); }
private double GetPPD(TimeSpan frameTime, TimeSpan eftByDownloadTime, TimeSpan eftByFrameTime, SlotStatus status, BonusCalculationType calculateBonus) { if (CurrentProtein.IsUnknown) { return(0); } // Issue 125 if (calculateBonus.Equals(BonusCalculationType.DownloadTime)) { // Issue 183 if (status.Equals(SlotStatus.RunningAsync) || status.Equals(SlotStatus.RunningNoFrameTimes)) { return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByFrameTime)); } return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByDownloadTime)); } if (calculateBonus.Equals(BonusCalculationType.FrameTime)) { return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByFrameTime)); } return(ProductionCalculator.GetPPD(frameTime, CurrentProtein)); }
/// <summary> /// Work unit credit /// </summary> public double GetCredit(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus) { TimeSpan frameTime = GetFrameTime(calculationType); return(GetCredit(GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), status, calculateBonus)); }
private double GetPPD(TimeSpan frameTime, TimeSpan eftByDownloadTime, TimeSpan eftByFrameTime, SlotStatus status, BonusCalculationType calculateBonus) { if (CurrentProtein.IsUnknown()) { return 0; } // Issue 125 if (calculateBonus.Equals(BonusCalculationType.DownloadTime)) { // Issue 183 if (status.Equals(SlotStatus.RunningAsync) || status.Equals(SlotStatus.RunningNoFrameTimes)) { return CurrentProtein.GetPPD(frameTime, eftByFrameTime, true); } return CurrentProtein.GetPPD(frameTime, eftByDownloadTime, true); } if (calculateBonus.Equals(BonusCalculationType.FrameTime)) { return CurrentProtein.GetPPD(frameTime, eftByFrameTime, true); } return CurrentProtein.GetPPD(frameTime); }
public IList<HistoryEntry> Fetch(QueryParameters parameters, BonusCalculationType bonusCalculation) { DateTime start = Instrumentation.ExecStart; try { return FetchInternal(parameters, bonusCalculation); } finally { _logger.DebugFormat("Database Fetch ({0}) completed in {1}", parameters, Instrumentation.GetExecTime(start)); } }
private double GetPPD(TimeSpan frameTime, TimeSpan unitTimeByDownloadTime, TimeSpan unitTimeByFrameTime, SlotStatus status, BonusCalculationType calculateBonus) { if (CurrentProtein.IsUnknown()) { return(0.0); } switch (calculateBonus) { case BonusCalculationType.DownloadTime when status == SlotStatus.RunningNoFrameTimes: return(CurrentProtein.GetBonusPPD(frameTime, unitTimeByFrameTime)); case BonusCalculationType.DownloadTime: return(CurrentProtein.GetBonusPPD(frameTime, unitTimeByDownloadTime)); case BonusCalculationType.FrameTime: return(CurrentProtein.GetBonusPPD(frameTime, unitTimeByFrameTime)); default: return(CurrentProtein.GetPPD(frameTime)); } }
private IList<HistoryEntry> FetchInternal(QueryParameters parameters, BonusCalculationType bonusCalculation) { Debug.Assert(TableExists(SqlTable.WuHistory)); var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql); select.Append(WhereBuilder.Execute(parameters)); GetProduction.BonusCalculation = bonusCalculation; using (var connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (var database = new PetaPoco.Database(connection)) { List<HistoryEntry> query = database.Fetch<HistoryEntry>(select); return query; } } }
public void ShowProductionTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType bonusCalculationType) { // test the level if (!logger.IsDebugEnabled) { return; } if (CurrentProtein.IsUnknown()) { logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD."); return; } switch (bonusCalculationType) { case BonusCalculationType.DownloadTime: logger.DebugFormat(Constants.ClientNameFormat, slotName, status == SlotStatus.RunningNoFrameTimes ? "Calculate Bonus PPD by Frame Time." : "Calculate Bonus PPD by Download Time."); break; case BonusCalculationType.FrameTime: logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time."); break; default: logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD."); break; } TimeSpan frameTime = GetFrameTime(calculationType); var noBonusValues = CurrentProtein.GetProductionValues(frameTime, TimeSpan.Zero); TimeSpan unitTimeByDownloadTime = GetUnitTimeByDownloadTime(frameTime); var bonusByDownloadValues = CurrentProtein.GetProductionValues(frameTime, unitTimeByDownloadTime); TimeSpan unitTimeByFrameTime = GetUnitTimeByFrameTime(frameTime); var bonusByFrameValues = CurrentProtein.GetProductionValues(frameTime, unitTimeByFrameTime); logger.Debug(CreateProductionDebugOutput(UnitInfoData.ToShortProjectString(), frameTime, CurrentProtein, noBonusValues, unitTimeByDownloadTime, bonusByDownloadValues, unitTimeByFrameTime, bonusByFrameValues)); }
private PetaPoco.Page<HistoryEntry> PageInternal(long page, long itemsPerPage, QueryParameters parameters, BonusCalculationType bonusCalculation) { Debug.Assert(TableExists(SqlTable.WuHistory)); var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql); select.Append(WhereBuilder.Execute(parameters)); GetProduction.BonusCalculation = bonusCalculation; using (var connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (var database = new PetaPoco.Database(connection)) { PetaPoco.Page<HistoryEntry> query = database.Page<HistoryEntry>(page, itemsPerPage, select); Debug.Assert(query != null); return query; } } }
/// <summary> /// Points per day (PPD) rating for this unit /// </summary> public double GetPPD(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus) { TimeSpan frameTime = GetFrameTime(calculationType); return GetPPD(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), status, calculateBonus); }