コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
      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);
      }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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());
            }
        }
コード例 #6
0
ファイル: UnitInfoLogic.cs プロジェクト: kszysiu/hfm-net
        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());
        }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
ファイル: UnitInfoDatabase.cs プロジェクト: harlam357/hfm-net
 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));
    }
 }
コード例 #9
0
ファイル: UnitInfoModel.cs プロジェクト: pnoodles/hfm-net
        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());
        }
コード例 #10
0
 public static bool IsEnabled(this BonusCalculationType type)
 {
     return(type.Equals(BonusCalculationType.DownloadTime) ||
            type.Equals(BonusCalculationType.FrameTime));
 }
コード例 #11
0
ファイル: UnitInfoModel.cs プロジェクト: pnoodles/hfm-net
        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));
        }
コード例 #12
0
ファイル: UnitInfoModel.cs プロジェクト: pnoodles/hfm-net
        /// <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));
        }
コード例 #13
0
ファイル: UnitInfoLogic.cs プロジェクト: kszysiu/hfm-net
        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);
        }
コード例 #14
0
ファイル: UnitInfoDatabase.cs プロジェクト: harlam357/hfm-net
 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));
    }
 }
コード例 #15
0
        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));
            }
        }
コード例 #16
0
ファイル: UnitInfoDatabase.cs プロジェクト: harlam357/hfm-net
      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;
            }
         }
      }
コード例 #17
0
        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));
        }
コード例 #18
0
ファイル: UnitInfoDatabase.cs プロジェクト: harlam357/hfm-net
      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;
            }
         }
      }
コード例 #19
0
ファイル: UnitInfoLogic.cs プロジェクト: kszysiu/hfm-net
 /// <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);
 }