示例#1
0
        public void Calculate()
        {
            Protein value = _proteinService.Get(SelectedProject);

            if (value == null)
            {
                return;
            }
            Protein protein = CopyProtein(value);

            if (PreferredDeadlineChecked)
            {
                protein.PreferredDays = PreferredDeadline;
            }
            if (FinalDeadlineChecked)
            {
                protein.MaximumDays = FinalDeadline;
            }
            if (KFactorChecked)
            {
                protein.KFactor = KFactor;
            }

            TimeSpan frameTime        = TimeSpan.FromMinutes(TpfMinutes).Add(TimeSpan.FromSeconds(TpfSeconds));
            TimeSpan totalTimeByFrame = TimeSpan.FromSeconds(frameTime.TotalSeconds * protein.Frames);
            TimeSpan totalTimeByUser  = totalTimeByFrame;

            if (TotalWuTimeEnabled)
            {
                totalTimeByUser = TimeSpan.FromMinutes(TotalWuTimeMinutes).Add(TimeSpan.FromSeconds(TotalWuTimeSeconds));
                // user time is less than total time by frame, not permitted
                if (totalTimeByUser < totalTimeByFrame)
                {
                    totalTimeByUser = totalTimeByFrame;
                }
            }

            var decimalPlaces = _prefs.Get <int>(Preference.DecimalPlaces);
            var noBonusValues = protein.GetProductionValues(frameTime, TimeSpan.Zero);
            var bonusByUserSpecifiedTimeValues = protein.GetProductionValues(frameTime, totalTimeByUser);
            var bonusByFrameTimeValues         = protein.GetProductionValues(frameTime, totalTimeByFrame);

            CoreName          = protein.Core;
            SlotType          = protein.Core.ToSlotType().ToString();
            NumberOfAtoms     = protein.NumberOfAtoms;
            CompletionTime    = Math.Round((TotalWuTimeEnabled ? totalTimeByUser.TotalDays : totalTimeByFrame.TotalDays), decimalPlaces);
            PreferredDeadline = protein.PreferredDays;
            FinalDeadline     = protein.MaximumDays;
            KFactor           = protein.KFactor;
            BonusMultiplier   = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.Multiplier : bonusByFrameTimeValues.Multiplier), decimalPlaces);
            BaseCredit        = noBonusValues.Credit;
            TotalCredit       = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.Credit : bonusByFrameTimeValues.Credit), decimalPlaces);
            BasePpd           = noBonusValues.PPD;
            TotalPpd          = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.PPD : bonusByFrameTimeValues.PPD), decimalPlaces);
        }