Example #1
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="type">Type of the reimbursing agency. Values: Federal, State, Local, Other</param>
 ///<param name="name">The name of the reimbursing agency. This element is to be used when the Type is set as Other.</param>
 ///<param name="rates">A Rates</param>
 ///
 public Agency( AgencyTypeCode type, string name, Rates rates )
     : base(FoodDTD.AGENCY)
 {
     this.SetType( type );
     this.Name = name;
     this.Rates = rates;
 }
Example #2
0
        public CurrencyService(ICurrencyApi api)
        {
            _api = api;
            var task = GetLatest();

            Task.WaitAll(task);
            _latestRates = task.Result;
            _rates       = _latestRates;
        }
Example #3
0
        public ActionResult DeleteReviewToRedoIt(int BookId)
        {
            var   currentUserId = User.Identity.GetUserId();
            Rates rates         = db.Rates.Where(a => a.BookID == BookId).FirstOrDefault(a => a.UserID == currentUserId);

            db.Rates.Remove(rates);
            db.SaveChanges();
            return(RedirectToAction("Details", new { Id = BookId }));
        }
Example #4
0
    private DataTable GetRatesByType()
    {
        Rates rate = new Rates();

        rate.RateType = Int32.Parse(drpRateTypesList.SelectedValue);
        DataTable table = rate.SelectByRateType();

        return(table);
    }
Example #5
0
        public void Should_return_rates_saved_in_database()
        {
            var      rates        = new Rates();
            Currency usdCurrency  = new Currency(usdCurrencyName);
            var      usdEurRate   = rates.GetRateOf(usdCurrency);
            Rate     expectedRate = new Rate(usdRateValue);

            Check.That(usdEurRate).IsEqualTo(expectedRate);
        }
Example #6
0
    private void DeleteRate(int rateId)
    {
        Rates rate = new Rates();

        rate.Rate_ID = rateId;
        rate.SelectOne();
        rate.Delete();
        BindGridView();
    }
Example #7
0
        //1-5
        public void RateTraining(int rate)
        {
            if (rate < 1 || rate > 5)
            {
                throw new Exception("Invalid rating. Rating should be between 1 and 5");
            }

            Rates.Add(rate);
        }
Example #8
0
        public ActionResult GetRateInfo(int listingId, int rateId)
        {
            AuditRecord   newAudit = new AuditRecord();
            SqlDataReader rdr      = null;

            newAudit.user  = "******";
            newAudit.title = "GetRateInfo";
            Rates thisRate = new Rates();

            // newAudit.description = "Listing Id: " + listingId + " | Image Name: " + imgName;

            try
            {
                using (
                    SqlConnection conn =
                        new SqlConnection(
                            System.Configuration.ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString)
                    )
                {
                    conn.Open();
                    SqlCommand sqlComm = new SqlCommand("GetRateInfo", conn);
                    sqlComm.CommandType = CommandType.StoredProcedure;

                    sqlComm.Parameters.AddWithValue("@listingId", listingId);
                    sqlComm.Parameters.AddWithValue("@rateId", rateId);

                    rdr = sqlComm.ExecuteReader();

                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            thisRate = new Rates();

                            //myListingAmenity.amenityType = rdr["type"].ToString();
                            thisRate.rateType   = rdr["rateType"].ToString();
                            thisRate.rateAmount = Convert.ToDouble(rdr["rateAmount"]);
                            thisRate.startDate  = rdr["startDate"].ToString();
                            thisRate.endDate    = rdr["endDate"].ToString();
                            thisRate.minStay    = rdr["minStay"].ToString();
                            thisRate.cancelDays = rdr["cancelDays"].ToString();
                        }
                    }

                    return(Json(thisRate));
                }
            }
            catch (Exception ex)
            {
                string exception = ex.ToString();
                newAudit.title       = "**Failure** - " + newAudit.title;
                newAudit.description = " Exception: " + exception;
                //AddLogRecord(newAudit);
                return(Json(new { sequenceNumber = exception }));
            }
        }
Example #9
0
    protected void drpRateTypesList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Rates rate = new Rates();

        rate.RateType = Int32.Parse(drpRateTypesList.SelectedValue);
        DataTable table = rate.SelectByRateType();

        grid.DataSource = table;
        grid.DataBind();
    }
Example #10
0
 public ActionResult Edit([Bind(Include = "Id,PageName,EffectiveDate")] Rates rates)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rates).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rates));
 }
Example #11
0
    private void BindRates()
    {
        DataTable table = new Rates().SelectAll();

        drpRates.DataSource     = table;
        drpRates.DataTextField  = table.Columns["RateDescription_EN"].ToString();
        drpRates.DataValueField = table.Columns["Rate_ID"].ToString();
        drpRates.DataBind();
        drpRates.Items.Insert(0, new ListItem("Select a Rate...", "-1"));
    }
Example #12
0
        public static Rates GetRate()
        {
            Rates rate = new Rates();

            rate.From = "USD";
            rate.To   = "EUR";
            rate.Rate = (decimal)0.53;

            return(rate);
        }
        public static RatesDTO ToDTO(this Rates rate)
        {
            RatesDTO rateDto = new RatesDTO();

            rateDto.From = rate.From;
            rateDto.To   = rate.To;
            rateDto.Rate = rate.Rate;

            return(rateDto);
        }
Example #14
0
        public async Task <decimal> Convert(string baseCurrency, string targetCurrency, decimal amount, DateTime?date)
        {
            var result = await Rates.GetRate(baseCurrency, targetCurrency, date);

            if (result != null)
            {
                return(result.Rates[targetCurrency] * amount);
            }
            return(0);
        }
        public Dictionary <double, string> CreateRatesDictionary(Rates rates)
        {
            var values = rates.GetType().GetProperties().Select(x => x.Name).ToList();
            var keys   = rates.GetType().GetProperties().Select(x => Convert.ToDouble(x.GetValue(rates))).ToList();

            var ratesDictionary = keys.Zip(values, (k, v) => new { Key = k, Value = v })
                                  .ToDictionary(x => x.Key, x => x.Value);

            return(ratesDictionary);
        }
Example #16
0
        public bool Put([FromBody] Rates dg)
        {
            RatesDAO dgO = new RatesDAO();

            if (!dgO.insertDanhGia(dg))
            {
                return(dgO.updateDanhGia(dg));
            }
            return(true);
        }
Example #17
0
        public decimal GetUPSRate(Rates objRates, CurrentUserInfo uinfo, Delivery delivery, string strShippingOptionName)
        {
            decimal decRate = 0;

            try
            {
                // Cache the data for 10 minutes with a key
                using (CachedSection <Rates> cs = new CachedSection <Rates>(ref objRates, 60, true, null, "UPS-" + uinfo.UserID + "-" + delivery.DeliveryAddress.AddressZip + "-" + ValidationHelper.GetString(delivery.Weight, "")))
                {
                    if (cs.LoadData)
                    {
                        //Get real-time shipping rates from UPS using dotNETShip
                        Ship objShip = new Ship();
                        objShip.UPSLogin      = strUPSLogin;
                        objShip.UPSTestMode   = SettingsKeyInfoProvider.GetBoolValue("MultiCarrierTestMode");
                        objShip.OrigZipPostal = SettingsKeyInfoProvider.GetValue("SourceZip", "90001");
                        string[]    strCountryState = SettingsKeyInfoProvider.GetValue("SourceCountryState", "US").Split(';');
                        CountryInfo ci = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetString(strCountryState[0], "USA"));
                        objShip.OrigCountry = ci.CountryTwoLetterCode;
                        StateInfo si = StateInfoProvider.GetStateInfo(ValidationHelper.GetString(strCountryState[1], "California"));
                        objShip.OrigStateProvince = si.StateCode;

                        objShip.DestZipPostal     = delivery.DeliveryAddress.AddressZip;
                        objShip.DestCountry       = delivery.DeliveryAddress.GetCountryTwoLetterCode();
                        objShip.DestStateProvince = delivery.DeliveryAddress.GetStateCode();

                        objShip.Weight = (float)delivery.Weight;

                        objShip.Rate("UPS");

                        cs.Data = objShip.Rates;
                    }

                    objRates = cs.Data;
                }

                foreach (Rate rate in objRates)
                {
                    if (rate.Name.ToLower() == strShippingOptionName.ToLower())
                    {
                        decRate = ValidationHelper.GetDecimal(rate.Charge, 0);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                //Log the error
                EventLogProvider.LogException("MultiCarrier - GetUPSRate", "EXCEPTION", ex);
                //Set some base rate for the shipping
                decRate = 10;
            }

            return(decRate);
        }
Example #18
0
        public string AddRate(string code, string Name, string Rate, string Language)
        {
            if (Session[Util.ProjectConfig.ADMINUSER] == null)
            {
                return("");
            }

            Model.Rate rate = new Model.Rate();
            if (Language == "cn")
            {
                rate.Name_cn = Name;
            }
            if (Language == "tw")
            {
                rate.Name_tw = Name;
            }
            if (Language == "en")
            {
                rate.Name_en = Name;
            }
            if (Language == "th")
            {
                rate.Name_th = Name;
            }
            if (Language == "vn")
            {
                rate.Name_vn = Name;
            }

            rate.Rate1    = Convert.ToDecimal(Rate);
            rate.Lasttime = DateTime.Now;
            Model.Manager m = Session[ProjectConfig.ADMINUSER] as Model.Manager;
            rate.Operator = m.ManagerId;
            rate.Code     = code;
            string strHostName = Dns.GetHostName();

            System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
            rate.Ip = addressList[0].ToString();
            bool reval = BLL.RateManager.AddRate(rate);

            if (reval)
            {
                Rates rates = new Rates();
                rates.Name     = Name;
                rates.Rate     = Convert.ToDecimal(Rate);
                rates.Lasttime = DateTime.Now;
                rates.Operator = m.ManagerId;
                rates.Ip       = addressList[0].ToString();
                return(DAL.ObjectToJson.ObjectsToJson <Rates>(rates));
            }
            else
            {
                return("none");
            }
        }
Example #19
0
        //Possible upgrade or improvement: Use Automapper or reflection with anonimous types and flags
        public static RatesDTO Rate_To_RateDTO(Rates entity)
        {
            RatesDTO mappedEntity = new RatesDTO
            {
                From = entity.From,
                To   = entity.To,
                Rate = entity.Rate
            };

            return(mappedEntity);
        }
        static (decimal, Rates) GetRate(string ccyPair, Rates cache)
        {
            if (cache.ContainsKey(ccyPair))
            {
                return(cache[ccyPair], cache);
            }

            var rate = FxApi.GetRate(ccyPair);

            return(rate, cache.Add(ccyPair, rate));
        }
Example #21
0
        /// <summary>
        ///  Dump out the ratings
        /// </summary>
        public void DumpRatings()
        {
            var myEnumerator = Rates.GetEnumerator();

            while (myEnumerator.MoveNext())
            {
                var ratings = (NibbleTeamRating)myEnumerator.Value;
                Utility.Announce(string.Format("Season {0}:- ", myEnumerator.Key));
                Utility.Announce(string.Format("\t[{0}]\t[{1}]", ratings.Offence, ratings.Defence));
            }
        }
Example #22
0
        public double GetRate(string currency)
        {
            var property = Rates.Property(currency.ToUpper());

            if (property == null)
            {
                throw new Exception($"Not found {currency}");
            }

            return((double)property.Value);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,From,To,Rate")] Rates rates)
        {
            if (ModelState.IsValid)
            {
                this.ratesRepository.Update(rates);
                await this.ratesRepository.Save();

                return(RedirectToAction("Index"));
            }
            return(View(rates));
        }
Example #24
0
        public ActionResult Create([Bind(Include = "Id,PageName,EffectiveDate")] Rates rates)
        {
            if (ModelState.IsValid)
            {
                db.Rates.Add(rates);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rates));
        }
Example #25
0
 public static string ToXML(
     this Rates r)
 => new[]
 {
     string.Empty,
     "x-slow",
     "slow",
     "medium",
     "fast",
     "x-fast",
 }[(int)r];
Example #26
0
        public static Rates RateDTO_To_Rate(RatesDTO entity)
        {
            Rates mappedEntity = new Rates
            {
                From = entity.From,
                To   = entity.To,
                Rate = entity.Rate
            };

            return(mappedEntity);
        }
Example #27
0
        internal static void MapToRates(RatesDto dto, Rates domain = null)
        {
            if (domain == null)
            {
                domain = new Rates();
            }

            domain.From = dto.From;
            domain.Rate = dto.Rate;
            domain.To   = dto.To;
        }
Example #28
0
        public Rates ToEntity(IfyContext context, Entity entity)
        {
            Rates rate = new Rates(context);

            rate.Identifier = this.Identifier;
            rate.Unit       = this.Unit;
            rate.Cost       = this.Cost;
            rate.Service    = entity;

            return(rate);
        }
Example #29
0
 //
 // Default constructor - Internal prevents public creation
 // of instances. Returned by Telescope.AxisRates.
 //
 internal TrackingRates(params DriveRates[] Rates)
 {
     //
     // This array must hold ONE or more DriveRates values, indicating
     // the tracking rates supported by your telescope. The one value
     // (tracking rate) that MUST be supported is driveSidereal!
     //
     this.trackingRates    = new DriveRates[Rates.Length + 1];
     this.trackingRates[0] = DriveRates.driveSidereal;
     Rates.CopyTo(this.trackingRates, 1);
 }
        public string GetRate([FromUri] DateTime dtEntry, [FromUri] DateTime dtExit, [FromBody] Rates oRateCard)
        {
            CPRateRQ oInput = new CPRateRQ()
            {
                EntryDT = dtEntry, ExitDT = dtExit
            };

            string sRate = GetCalculatedRate(oInput, oRateCard);

            return(sRate);
        }
Example #31
0
        public Index(Rates rate)
        {
            var db = new SPContext();

            BookName = db.Books.Where(a => (a.BookID == rate.BookID)).FirstOrDefault().BookName;
            UserName = db.Users.Where(a => (a.Id == rate.UserID)).FirstOrDefault().UserName;
            Created  = rate.Created;
            Modified = rate.Modified;
            Value    = rate.RateValue;
            Id       = rate.RateID;
        }
Example #32
0
		public Rates GetRates(Guid slideId, string courseId)
		{
			var rates = new Rates();
			var allRates = db.SlideRates.Where(x => x.SlideId == slideId).ToList();
			foreach (var rate in allRates)
			{
				if (rate.Rate == SlideRates.Good)
					rates.AddGood();
				if (rate.Rate == SlideRates.NotUnderstand)
					rates.AddNotUnderstand();
				if (rate.Rate == SlideRates.NotWatched)
					rates.AddNotWatched();
				if (rate.Rate == SlideRates.Trivial)
					rates.AddTrivial();
			}
			return rates;
		}
Example #33
0
        public decimal GetUSPSRate(Rates objRates, CurrentUserInfo uinfo, Delivery delivery, string strShippingOptionName)
        {
            decimal decRate = 0;

            try
            {
                // Cache the data for 10 minutes with a key
                using (CachedSection<Rates> cs = new CachedSection<Rates>(ref objRates, 60, true, null, "USPS-" + uinfo.UserID + "-" + delivery.DeliveryAddress.AddressZip + "-" + ValidationHelper.GetString(delivery.Weight, "")))
                {
                    if (cs.LoadData)
                    {

                        //Get real-time shipping rates from USPS using dotNETShip
                        Ship objShip = new Ship();
                        objShip.USPSLogin = strUSPSLogin;
                        objShip.OrigZipPostal = SettingsKeyInfoProvider.GetValue("SourceZip", "90001");
                        string[] strCountryState = SettingsKeyInfoProvider.GetValue("SourceCountryState", "US").Split(';');
                        CountryInfo ci = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetString(strCountryState[0], "USA"));
                        objShip.OrigCountry = ci.CountryTwoLetterCode;
                        StateInfo si = StateInfoProvider.GetStateInfo(ValidationHelper.GetString(strCountryState[1], "California"));
                        objShip.OrigStateProvince = si.StateCode;

                        objShip.DestZipPostal = delivery.DeliveryAddress.AddressZip;
                        objShip.DestCountry = delivery.DeliveryAddress.GetCountryTwoLetterCode();
                        objShip.DestStateProvince = delivery.DeliveryAddress.GetStateCode();

                        objShip.Length = 12;
                        objShip.Width = 12;
                        objShip.Height = 12;

                        objShip.Weight = (float)delivery.Weight;

                        objShip.Rate("USPS");

                        cs.Data = objShip.Rates;
                    }

                    objRates = cs.Data;
                }

                foreach (Rate rate in objRates)
                {
                    if (rate.Name.ToLower() == strShippingOptionName.ToLower())
                    {
                        decRate = ValidationHelper.GetDecimal(rate.Charge, 0);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                //Log the error
                EventLogProvider.LogException("MultiCarrier - GetUSPSRate", "EXCEPTION", ex);
                //Set some base rate for the shipping
                decRate = 10;
            }

            return decRate;
        }
Example #34
0
        public decimal GetPrice(Delivery delivery, string currencyCode)
        {
            decimal decRate = 0;
            try
            {
                ShipmentCarrier scCarrier = new ShipmentCarrier();
                string strShippingOptionName = "";
                switch (delivery.ShippingOption.ShippingOptionName)
                {
                    case "Multi-FedExPriorityOvernight":
                        strShippingOptionName = "Priority Overnight";
                        scCarrier = ShipmentCarrier.FedEx;
                        break;
                    case "Multi-FedExStandardOvernight":
                        strShippingOptionName = "Standard Overnight";
                        scCarrier = ShipmentCarrier.FedEx;
                        break;
                    case "Multi-UPSNextDayAirSaver":
                        strShippingOptionName = "UPS  Next Day Air Saver®";
                        scCarrier = ShipmentCarrier.UPS;
                        break;
                    case "Multi-UPSNextDayAir":
                        strShippingOptionName = "UPS Next Day Air®";
                        scCarrier = ShipmentCarrier.UPS;
                        break;
                    case "Multi-USPSFirstClassMail":
                        strShippingOptionName = "First-Class Mail";
                        scCarrier = ShipmentCarrier.USPS;
                        break;
                    case "Multi-USPSPriorityMail2-Day":
                        strShippingOptionName = "Priority Mail 2-Day";
                        scCarrier = ShipmentCarrier.USPS;
                        break;
                    case "Multi-USPSPriorityMailExpress1-Day":
                        strShippingOptionName = "Priority Mail Express 1-Day";
                        scCarrier = ShipmentCarrier.USPS;
                        break;
                }

                Rates objRates = new Rates();

                CurrentUserInfo uinfo = MembershipContext.AuthenticatedUser;

                switch (scCarrier)
                {
                    case ShipmentCarrier.FedEx:
                        decRate = GetFedExRate(objRates, uinfo, delivery, strShippingOptionName);
                        break;
                    case ShipmentCarrier.UPS:
                        decRate = GetUPSRate(objRates, uinfo, delivery, strShippingOptionName);
                        break;
                    case ShipmentCarrier.USPS:
                        decRate = GetUSPSRate(objRates, uinfo, delivery, strShippingOptionName);
                        break;
                    default:
                        decRate = 10; //Set a default shipping rate in case there is an issue.
                        break;
                }
            }
            catch (Exception ex)
            {
                //Log the error
                EventLogProvider.LogException("MultiCarrier - GetPrice", "EXCEPTION", ex);
                //Set some base rate for the shipping
                decRate = 10;
            }
            return decRate;
        }
            /// <summary>
            /// Set a currency rate.
            /// </summary>
            /// <param name="currency">The currency to add.</param>
            /// <param name="bid">The 'bid' rate.</param>
            /// <param name="ask">The 'ask' rate.</param>
            public Rates SetRate( string currency, string bid, string ask )
            {
                var newRates = new Rates( bid, ask );

                CurrencyRates.Add( currency, newRates );

                return newRates;
            }
Example #36
0
        static void CalculateVerificationResults(this Measurement meas, Multiplicity mkey, MultiplicityCountingRes results)
        {
            Tuple normal_mass = new Tuple(-1, 0), backup_mass = new Tuple(-1, 0);
            try
            {
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.CalibrationCurve))
                {
                    // get the current results_cal_curve_rec and cal_curve params

                    //dev note: the rates as computed by the first and second phases are not yet on ccres, because they exist soley on the counting results MultiplicityCountingRes instance

                    INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec)
                        meas.INCCAnalysisResults.LookupMethodResults(mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.CalibrationCurve, true);
                    INCCAnalysisParams.cal_curve_rec cal_curve = (INCCAnalysisParams.cal_curve_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.CalibrationCurve);
                    INCCAnalysisParams.CalCurveResult status = INCCAnalysisParams.CalCurveResult.Unknown;
                    if (cal_curve == null)
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10199, "No " + AnalysisMethod.KnownA.FullName() + " method parameters found");
                        return;
                    }
                    if (cal_curve.CalCurveType != INCCAnalysisParams.CalCurveType.HM)
                    {
                        Tuple pu240e = new Tuple();
                        Tuple doubles;
                        if (cal_curve.cev.useSingles)  // the 2009 MTS hack
                            doubles = new Tuple(results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected).Singles);
                        else
                            doubles = new Tuple(results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected).Doubles);
                        status = INCCAnalysis.CalculateCalibrationCurveOnly(cal_curve.cev, out pu240e, results.rates, doubles, RatesAdjustments.DeadtimeCorrected); // rates (triples) not used
                        ccres.pu240e_mass = pu240e;
                    }
                    else
                    {
                        // get the item id from the acquire record or the ItemId on the measurement itself
                        // if there is no item id use the empty default item id
                        // dev note: at some point the acquire record item id becomes a full ItemId record on the measurmeent
                        //if not NC.App.DB.ItemIdSet.Contains AcquireState.item_id then
                        //    get the default empty one
                        //end

                        // from HEAVY_M.cpp
                        INCCAnalysis.calc_heavy_metal(
                                cal_curve.heavy_metal_corr_factor,
                                cal_curve.heavy_metal_reference,
                                results.rates.DTCRates.Singles,
                                results.rates.DTCRates.Doubles,
                                ref ccres.heavy_metal_content,
                                ref ccres.heavy_metal_correction,
                                ref ccres.heavy_metal_corr_singles,
                                ref ccres.heavy_metal_corr_doubles, meas);

                        status = INCCAnalysis.CalculateCalibrationCurveOnly(cal_curve.cev,
                                        out ccres.pu240e_mass,
                                        results.rates, ccres.heavy_metal_corr_doubles,
                                        RatesAdjustments.DeadtimeCorrected);

                        ccres.pu240e_mass.v *= meas.MeasurementId.Item.length;
                        ccres.pu240e_mass.err *= meas.MeasurementId.Item.length;
                    }

                    if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        string msg = String.Format("Passive calibration curve failed mass limits of {0} and {1}", cal_curve.cev.lower_mass_limit, cal_curve.cev.upper_mass_limit);
                        meas.AddErrorMessage(msg, 10196, mkey);
                    }
                    else if (status != INCCAnalysisParams.CalCurveResult.Success)
                    {
                        meas.AddErrorMessage("Passive calibration curve analysis error", 10197, mkey);
                    }
                    if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        ccres.dcl_pu_mass = meas.AcquireState.mass; // another requirement for the acquire state
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 10133, "calc_mass/calc_u235_mass are called next");
                        if (cal_curve.CalCurveType != INCCAnalysisParams.CalCurveType.U)
                        {
                            INCCAnalysis.calc_mass(ccres.pu240e_mass,
                                ref ccres.pu_mass, ref ccres.dcl_pu_mass, ref ccres.dcl_pu240e_mass, ref ccres.dcl_minus_asy_pu_mass, ref ccres.dcl_minus_asy_pu_mass_pct, ref ccres.pass,
                                meas);
                        }
                        else
                        {
                            INCCAnalysis.calc_u235_mass(cal_curve.percent_u235, ccres.pu240e_mass,
                               ref ccres.pu_mass, ref ccres.dcl_pu_mass, ref ccres.dcl_minus_asy_pu_mass, ref ccres.dcl_minus_asy_pu_mass_pct, ref ccres.pass,
                                meas);
                        }

                        if (!ccres.pass)
                        {
                            meas.AddWarningMessage("Passive calibration curve: failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Passive calibration curve: passed stratum rejection limits", 10200, mkey);
                        }

                        if (ccres.pu240e_mass.v > ccres.methodParams.cev.upper_mass_limit)
                        {
                            meas.AddWarningMessage("Passive calibration curve: upper Pu240e mass limit exceeded.", 10210, mkey);
                        }
                        if (ccres.pu240e_mass.v < ccres.methodParams.cev.lower_mass_limit)
                        {
                            meas.AddWarningMessage("Passive calibration curve: lower Pu240e mass limit exceeded.", 10211, mkey);
                        }
                    }
                    // normal and backup retention
                    if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.CalibrationCurve)
                    {
                        normal_mass.CopyFrom(ccres.pu240e_mass);
                    }
                    if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.CalibrationCurve)
                    {
                        backup_mass.CopyFrom(ccres.pu240e_mass);
                    }

                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.KnownA))
                {
                    INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec)
                    meas.INCCAnalysisResults.LookupMethodResults(mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownA, true);
                    INCCAnalysisParams.known_alpha_rec ka_params = (INCCAnalysisParams.known_alpha_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.KnownA);
                    if (ka_params == null)
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10199, "No Known alpha method parameters found");
                        return;
                    }
                    bool success = false;
                    kares.dcl_pu_mass = meas.AcquireState.mass;  // dev note: another use of acq, a requirement, here
                    // copy the input calibration params to the copy on the results rec, to be saved with the KA results
                    kares.methodParams = new INCCAnalysisParams.known_alpha_rec(ka_params);

                    if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.Conventional)
                    {
                        INCCMethodResults.results_known_alpha_rec karesdup = INCCAnalysis.CalculateKnownAlpha(mkey, results.rates, meas, RatesAdjustments.DeadtimeCorrected); // rates (triples) not used
                        if (karesdup != null) // we have the new mass results, and they are preserved in the results map
                        {
                            success = true;
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha results for pu240E {0} +- {1}", karesdup.pu240e_mass.v, karesdup.pu240e_mass.err);
                        }
                    }
                    else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.HeavyMetalCorrection)
                    {
                        INCCAnalysis.calc_heavy_metal(
                                ka_params.heavy_metal_corr_factor,
                                ka_params.heavy_metal_reference,
                                results.rates.DTCRates.Singles,
                                results.rates.DTCRates.Doubles,
                                ref kares.heavy_metal_content,
                                ref kares.heavy_metal_correction,
                                ref kares.corr_singles,
                                ref kares.corr_doubles, meas);

                        Rates HMSDRates = new Rates();
                        HMSDRates.DeadtimeCorrectedRates.Singles.CopyFrom(kares.corr_singles);
                        HMSDRates.DeadtimeCorrectedRates.Doubles.CopyFrom(kares.corr_doubles);

                        INCCMethodResults.results_known_alpha_rec karesdup = INCCAnalysis.CalculateKnownAlpha(mkey, HMSDRates, meas, RatesAdjustments.DeadtimeCorrected);
                        if (karesdup != null) // we have the new mass results, and they are preserved in the results map
                        {
                            success = true;
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha HM results for pu240E {0} +- {1}", karesdup.pu240e_mass.v, karesdup.pu240e_mass.err);
                        }
                        kares.pu240e_mass.v *= meas.MeasurementId.Item.length;
                        kares.pu240e_mass.err *= meas.MeasurementId.Item.length;
                    }
                    else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.MoistureCorrAppliedToDryAlpha)
                    {
                        success =
                         INCCAnalysis.calc_known_alpha_moisture_corr(
                                    results.rates.DTCRates.Singles,
                                    results.rates.DTCRates.Doubles,
                                    results.Scaler1, results.Scaler2,
                                    ref kares.corr_singles, /* ring ratio */
                                    ref kares.corr_factor,
                                    ref kares.dry_alpha_or_mult_dbls, /* dry alpha */
                                    ref kares.mult_corr_doubles,
                                    ref kares.mult,
                                    ref kares.alphaK,
                                    ref kares.pu240e_mass, ka_params, meas, mkey);
                        if (success)
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha MoistureCorrAppliedToDryAlpha results for pu240E {0} +- {1}", kares.pu240e_mass.v, kares.pu240e_mass.err);

                    }
                    else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.MoistureCorrAppliedToMultCorrDoubles)
                    {
                        success =
                            INCCAnalysis.calc_known_alpha_moisture_corr_mult_doubles(
                                    results.rates.DTCRates.Singles,
                                    results.rates.DTCRates.Doubles,
                                    results.Scaler1, results.Scaler2,
                                    ref kares.corr_singles, /* ring ratio */
                                    ref kares.corr_factor,
                                    ref kares.dry_alpha_or_mult_dbls, /* moist mult_corr_doubles */
                                    ref kares.mult_corr_doubles,
                                    ref kares.mult,
                                    ref kares.alphaK,
                                    ref kares.pu240e_mass, ka_params, meas, mkey);
                        if (success)
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha MoistureCorrAppliedToMultCorrDoubles results for pu240E {0} +- {1}", kares.pu240e_mass.v, kares.pu240e_mass.err);

                    }

                    if (success)
                    {
                        INCCAnalysis.calc_mass(kares.pu240e_mass,
                            ref kares.pu_mass, ref kares.dcl_pu_mass, ref kares.dcl_pu240e_mass, ref kares.dcl_minus_asy_pu_mass, ref kares.dcl_minus_asy_pu_mass_pct, ref kares.pass,
                            meas);
                    }
                    else
                    {
                        meas.AddErrorMessage("Known alpha analysis error", 10199, mkey);
                    }
                    if (!kares.pass)
                    {
                        meas.AddWarningMessage("Known alpha: failed stratum rejection limits", 10198, mkey);
                    }
                    else
                    {
                        meas.AddWarningMessage("Known alpha: passed stratum rejection limits", 10200, mkey);
                    }
                    if (kares.pu240e_mass.v > kares.methodParams.cev.upper_mass_limit)
                    {
                        meas.AddWarningMessage("Known alpha: upper Pu240e mass limit exceeded.", 10210, mkey);
                    }
                    if (kares.pu240e_mass.v < kares.methodParams.cev.lower_mass_limit)
                    {
                        meas.AddWarningMessage("Known alpha: lower Pu240e mass limit exceeded.", 10211, mkey);
                    }
                    // normal and backup retention
                    if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.KnownA)
                    {
                        normal_mass.CopyFrom(kares.pu240e_mass);
                    }
                    if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.KnownA)
                    {
                        backup_mass.CopyFrom(kares.pu240e_mass);
                    }
                }

                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Multiplicity))
                {
                    double error = 0.0;
                    INCCAnalysisParams.multiplicity_rec mul_param = (INCCAnalysisParams.multiplicity_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.Multiplicity);
                    if (mul_param == null)
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No Multiplicity method parameters found");
                        return;
                    }
                    INCCMethodResults.results_multiplicity_rec mmres = (INCCMethodResults.results_multiplicity_rec)meas.INCCAnalysisResults.LookupMethodResults(
                                                              mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Multiplicity, true);
                    // weird rates (triples) used, but they are wrong (see note line 568 avg_sums.cs)
                    INCCMethodResults.results_multiplicity_rec mmresdup = INCCAnalysis.CalculateMultiplicity(mkey, results.covariance_matrix, results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected), meas, RatesAdjustments.DeadtimeCorrected);
                    if (mmresdup != null) // we have the new mass results, and they are preserved in the results map
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Multiplicity results for pu240E {0} +- {1}", mmres.pu240e_mass.v, mmres.pu240e_mass.err);
                        if (meas.AcquireState.acquire_type == AcquireConvergence.Pu240EffPrecision)
                        {
                            if (mmres.pu240e_mass.v != 0.0)
                            {
                                error = mmres.pu240e_mass.err /
                                    mmres.pu240e_mass.v * 100.0;
                                if (error > meas.AcquireState.meas_precision)
                                {
                                    meas.AddWarningMessage(String.Format("Multiplicity: Pu240e error = {0}%", error), 10198, mkey);
                                }
                            }
                        }
                        mmres.dcl_pu_mass = meas.AcquireState.mass;  // another use of acq, a requirement, here

                        INCCAnalysis.calc_mass(mmres.pu240e_mass,
                            ref mmres.pu_mass, ref mmres.dcl_pu_mass, ref mmres.dcl_pu240e_mass, ref mmres.dcl_minus_asy_pu_mass, ref mmres.dcl_minus_asy_pu_mass_pct, ref mmres.pass,
                            meas);

                        if (!mmres.pass)
                        {
                            meas.AddWarningMessage("Multiplicity: failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Multiplicity: passed stratum rejection limits", 10200, mkey);
                        }

                        if (mul_param.solve_efficiency == INCCAnalysisParams.MultChoice.CONVENTIONAL_MULT_WEIGHTED) // todo: implement Weighted
                        {
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 36010, "CONVENTIONAL_MULT_WEIGHTED Multiplicity measurement results");
                        }
                        else if (mul_param.solve_efficiency == INCCAnalysisParams.MultChoice.MULT_DUAL_ENERGY_MODEL) // todo: implement DE
                        {
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 36010, "MULT_DUAL_ENERGY_MODEL Multiplicity measurement results");
                        }
                        // normal and backup retention
                        if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.Multiplicity)
                        {
                            normal_mass.CopyFrom(mmres.pu240e_mass);
                        }
                        if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.Multiplicity)
                        {
                            backup_mass.CopyFrom(mmres.pu240e_mass);
                        }
                    }
                    else
                    {
                        meas.AddErrorMessage("Multiplicity analysis error", 10198, mkey);
                    }

                    // copy the input calib to the results rec
                    mmres.methodParams = new INCCAnalysisParams.multiplicity_rec(mul_param);

                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.KnownM))
                {
                    INCCMethodResults.results_known_m_rec kmres = INCCAnalysis.CalculateKnownM(mkey, results, meas, RatesAdjustments.DeadtimeCorrected);

                    // calc mass
                    if (kmres != null) // you have calculated well my child
                    {
                        INCCAnalysis.calc_mass(kmres.pu240e_mass,
                                            ref kmres.pu_mass, ref kmres.dcl_pu_mass, ref kmres.dcl_pu240e_mass,
                                            ref kmres.dcl_minus_asy_pu_mass, ref kmres.dcl_minus_asy_pu_mass_pct, ref kmres.pass, meas);

                        if (!kmres.pass)
                        {
                            meas.AddWarningMessage("Known M: failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Known M: passed stratum rejection limits", 10200, mkey);
                        }

                        if (kmres.pu240e_mass.v > kmres.methodParams.upper_mass_limit)
                        {
                            meas.AddWarningMessage("Known M: upper Pu240e mass limit exceeded.", 10210, mkey);
                        }
                        if (kmres.pu240e_mass.v < kmres.methodParams.lower_mass_limit)
                        {
                            meas.AddWarningMessage("Known M: lower Pu240e mass limit exceeded.", 10211, mkey);
                        }
                        // normal and backup retention
                        if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.KnownM)
                        {
                            normal_mass.CopyFrom(kmres.pu240e_mass);
                        }
                        if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.KnownM)
                        {
                            backup_mass.CopyFrom(kmres.pu240e_mass);
                        }
                    }
                    else
                    {
                        meas.AddErrorMessage("Known M: analysis error", 10198, mkey);
                    }

                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Active))
                {
                    INCCAnalysisParams.active_rec act_param = (INCCAnalysisParams.active_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.Active);
                    if (act_param == null)
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No Active method parameters found");
                        return;
                    }
                    INCCMethodResults.results_active_rec actres = (INCCMethodResults.results_active_rec)meas.INCCAnalysisResults.LookupMethodResults(
                                                              mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Active, true);
                    /* calculate active doubles rate corrected for source yield factor */
                    //line 331 if calc_asy.cpp
                    Measurement.SourceYieldFactoredRates syfr = new Measurement.SourceYieldFactoredRates(results, meas);
                    // line 1267 of calc_asy.cpp
                    //Martyn says we need stuff here to deal with Cf active measurements HN 7.23.2015
                    actres.k0.v = syfr.source_yield_factor;
                    actres.k = new Tuple(syfr.total_corr_fact);
                    actres.k1 = new Tuple(meas.Norm.currNormalizationConstant);
                    // This stays the same for Cf. HN 7.23.2015
                    INCCAnalysisParams.CalCurveResult status = INCCAnalysis.CalculateCalibrationCurveOnly(act_param.cev,
                                    out actres.u235_mass, results.rates, syfr.corrected_doubles,
                                    RatesAdjustments.DeadtimeCorrected);

                    if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        string msg = String.Format("Active calibration curve failed mass limits of {0} and {1}", act_param.cev.lower_mass_limit, act_param.cev.upper_mass_limit);
                        meas.AddErrorMessage(msg, 10196, mkey);
                    }
                    else if (status != INCCAnalysisParams.CalCurveResult.Success)
                    {
                        meas.AddErrorMessage("Active calibration curve analysis error", 10197, mkey);
                    }
                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Active results for U235 {0} +- {1}", actres.u235_mass.v, actres.u235_mass.err);
                    if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        actres.dcl_u235_mass = meas.AcquireState.mass;
                        INCCAnalysis.calc_decl_minus_assay_u235(actres.u235_mass, actres.dcl_u235_mass, ref actres.dcl_minus_asy_u235_mass, ref actres.dcl_minus_asy_u235_mass_pct, ref actres.pass, meas);
                        if (!actres.pass)
                        {
                            meas.AddWarningMessage("Active calibration curve: failed stratum rejection limits", 10198, mkey);
                        }
                        else if (!meas.Stratum.Unset)
                        {
                            meas.AddWarningMessage("Active calibration curve: passed stratum rejection limits", 10200, mkey);
                        }

                        if (actres.u235_mass.v > actres.methodParams.cev.upper_mass_limit)
                        {
                            meas.AddWarningMessage("Active calibration curve: upper U235 mass limit exceeded.", 10210, mkey);
                        }
                        if (actres.u235_mass.v < actres.methodParams.cev.lower_mass_limit)
                        {
                            meas.AddWarningMessage("Active calibration curve: lower U235 mass limit exceeded.", 10211, mkey);
                        }
                    }
                    // normal and backup retention not performed for active

                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.ActiveMultiplicity))
                {
                    // sets results class' mult v,err values at end of calculation
                    INCCMethodResults.results_active_mult_rec res = INCCAnalysis.CalculateActiveMultiplicity(mkey, results, meas, RatesAdjustments.DeadtimeCorrected);
                    if (res == null)
                    {
                        meas.AddErrorMessage("Active multiplicity analysis error", 10152, mkey);
                    }
                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.TruncatedMultiplicity))
                {
                    INCCMethodResults.results_truncated_mult_rec res = INCCAnalysis.CalculateTruncatedMult(mkey, results, meas, RatesAdjustments.DeadtimeCorrected);
                    // normal and backup retention
                    if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.TruncatedMultiplicity)
                    {
                        if (res.methodParams.known_eff)
                            normal_mass.CopyFrom(res.k.pu240e_mass);
                        else
                            normal_mass.CopyFrom(res.s.pu240e_mass);
                    }
                    if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.TruncatedMultiplicity)
                    {
                        if (res.methodParams.known_eff)
                            backup_mass.CopyFrom(res.k.pu240e_mass);
                        else
                            backup_mass.CopyFrom(res.s.pu240e_mass);
                    }
                }

                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Collar))
                {
                    meas.AddWarningMessage("Collar mass results", 10153, mkey); // NEXT: Collar is incomplete, new design from IAEA is pending, this is a big task
                    INCCAnalysis.CalculateCollar(mkey, results, meas, RatesAdjustments.DeadtimeCorrected);
                }

                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.ActivePassive))
                {
                    INCCAnalysisParams.active_passive_rec act_param = (INCCAnalysisParams.active_passive_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.ActivePassive);
                    if (act_param == null)
                    {
                        meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No active/passive method parameters found");
                        return;
                    }
                    INCCMethodResults.results_active_passive_rec actres = (INCCMethodResults.results_active_passive_rec)meas.INCCAnalysisResults.LookupMethodResults(
                                                              mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.ActivePassive, true);

                    INCCAnalysis.CalculateActivePassive(mkey, results, meas, RatesAdjustments.DeadtimeCorrected);

                    //line 1134 if calc_asy.cpp
                    // calculate delta doubles and error from passive and active doubles
                    Measurement.SourceYieldFactoredRates syfr = new Measurement.SourceYieldFactoredRates(results, meas);
                    actres.k0.v = syfr.source_yield_factor;
                    actres.k = new Tuple(syfr.total_corr_fact);
                    actres.k1 = new Tuple(meas.Norm.currNormalizationConstant);

                    actres.delta_doubles.v = syfr.corrected_doubles.v - results.DeadtimeCorrectedDoublesRate.v;
                    actres.delta_doubles.err = Math.Sqrt((syfr.corrected_doubles.v * results.DeadtimeCorrectedDoublesRate.err) + (syfr.corrected_doubles.v * results.DeadtimeCorrectedDoublesRate.err));

                    INCCAnalysisParams.CalCurveResult status = INCCAnalysis.CalculateCalibrationCurveOnly(act_param.cev,
                                                 out actres.u235_mass, results.rates, actres.delta_doubles,
                                                 RatesAdjustments.DeadtimeCorrected);

                    if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        string msg = String.Format("Active/passive calibration curve failed mass limits of {0} and {1}", act_param.cev.lower_mass_limit, act_param.cev.upper_mass_limit);
                        meas.AddErrorMessage(msg, 10196, mkey);
                    }
                    else if (status != INCCAnalysisParams.CalCurveResult.Success)
                    {
                        meas.AddErrorMessage("Active/passive calibration curve analysis error", 10197, mkey);
                    }
                    if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        actres.dcl_u235_mass = meas.AcquireState.mass;
                        INCCAnalysis.calc_decl_minus_assay_u235(actres.u235_mass, actres.dcl_u235_mass, ref actres.dcl_minus_asy_u235_mass, ref actres.dcl_minus_asy_u235_mass_pct, ref actres.pass, meas);
                        if (!actres.pass)
                        {
                            meas.AddWarningMessage("Active/passive: failed stratum rejection limits", 10198, mkey);
                        }
                        else if (!meas.Stratum.Unset)
                        {
                            meas.AddWarningMessage("Active/passive: passed stratum rejection limits", 10200, mkey);
                        }

                        if (actres.u235_mass.v > actres.methodParams.cev.upper_mass_limit)
                        {
                            meas.AddWarningMessage("Active/passive: upper U235 mass limit exceeded.", 10210, mkey);
                        }
                        if (actres.u235_mass.v < actres.methodParams.cev.lower_mass_limit)
                        {
                            meas.AddWarningMessage("Active/passive: lower U235 mass limit exceeded.", 10211, mkey);
                        }
                    }
                }

                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource))
                {
                    INCCAnalysisParams.CalCurveResult status;
                    INCCMethodResults.results_add_a_source_rec res = null;
                    // gotta do a sanity check for the AAS cycles, they may not be there due to unfinished processing in the overall code
                    if (meas.CFCycles != null)
                    {
                        res = INCCAnalysis.CalculateAddASource(mkey, results, meas, RatesAdjustments.DeadtimeCorrected, out status);
                    }
                    else
                    {
                        meas.AddErrorMessage("Add-a-source calibration curve cycles not present error", 10197, mkey);
                        status = INCCAnalysisParams.CalCurveResult.EpicFailLOL;
                    }
                    if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        string msg = String.Format("Add-a-source calibration curve failed mass limits of {0} and {1}", res.methodParams.cev.lower_mass_limit, res.methodParams.cev.upper_mass_limit);
                        meas.AddErrorMessage(msg, 10196, mkey);
                    }
                    else if (status != INCCAnalysisParams.CalCurveResult.Success)
                    {
                        meas.AddErrorMessage("Add-a-source calibration curve analysis error", 10197, mkey);
                    }
                    if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        res.dcl_pu_mass = meas.AcquireState.mass;
                        INCCAnalysis.calc_mass(res.pu240e_mass,
                                ref res.pu_mass, ref res.dcl_pu_mass, ref res.dcl_pu240e_mass,
                                ref res.dcl_minus_asy_pu_mass, ref res.dcl_minus_asy_pu_mass_pct, ref res.pass, meas);
                        if (!res.pass)
                        {
                            meas.AddWarningMessage("Add-a-source calibration curve: failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Add-a-source calibration curve: passed stratum rejection limits", 10200, mkey);
                        }

                        if (res.pu240e_mass.v > res.methodParams.cev.upper_mass_limit)
                        {
                            meas.AddWarningMessage("Add-a-source calibration curve: upper Pu240e mass limit exceeded.", 10210, mkey);
                        }
                        if (res.pu240e_mass.v < res.methodParams.cev.lower_mass_limit)
                        {
                            meas.AddWarningMessage("Add-a-source calibration curve: lower Pu240e mass limit exceeded.", 10211, mkey);
                        }
                        // normal and backup retention
                        if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.AddASource)
                        {
                            normal_mass.CopyFrom(res.pu240e_mass);
                        }
                        if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.AddASource)
                        {
                            backup_mass.CopyFrom(res.pu240e_mass);
                        }
                    }
                }
                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.CuriumRatio))
                {
                    INCCAnalysisParams.CalCurveResult status;
                    INCCMethodResults.results_curium_ratio_rec res = INCCAnalysis.CalculateCuriumRatio(mkey, results, meas, RatesAdjustments.DeadtimeCorrected, out status);
                    if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        string msg = String.Format("Curium ratio calibration curve failed mass limits of {0} and {1}", res.methodParams.cev.lower_mass_limit, res.methodParams.cev.upper_mass_limit);
                        meas.AddErrorMessage(msg, 10196, mkey);
                    }
                    else if (status != INCCAnalysisParams.CalCurveResult.Success)
                    {
                        meas.AddErrorMessage("Curium ratio calibration curve analysis error", 10197, mkey);
                    }

                    if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit)
                    {
                        INCCAnalysisParams.cm_pu_ratio_rec cm_pu_ratio = NC.App.DB.Cm_Pu_RatioParameters.Get(); // load from DB, just like test params,
                        // dev note: better not to ref DB here, because this is a one-off state retrieval and no other DB access occurs during mass calc processing, but that is how it works this morning

                        //calc  curium mass
                        INCCAnalysis.calc_curium_mass(res, cm_pu_ratio, meas);
                        res.u.dcl_mass = cm_pu_ratio.cm_dcl_u_mass;
                        res.u235.dcl_mass = cm_pu_ratio.cm_dcl_u235_mass;
                        if (!res.pu.pass)
                        {
                            meas.AddWarningMessage("Curium ratio: Pu failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Curium ratio: Pu passed stratum rejection limits", 10200, mkey);
                        }
                        if (!res.u.pass)
                        {
                            meas.AddWarningMessage("Curium ratio: U failed stratum rejection limits", 10198, mkey);
                        }
                        else
                        {
                            meas.AddWarningMessage("Curium ratio: U passed stratum rejection limits", 10200, mkey);
                        }
                        // normal and backup retention
                        if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.CuriumRatio)
                        {
                            normal_mass.CopyFrom(res.pu.pu240e_mass);
                        }
                        if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.CuriumRatio)
                        {
                            backup_mass.CopyFrom(res.pu.pu240e_mass);
                        }
                    }

                }

                // annotate the final results method marker on the INCC results instance.
                INCCMethodResults imr = null;
                if (normal_mass.v != -1.0)
                {
                    bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr);
                    if (got)
                        imr.primaryMethod = meas.INCCAnalysisState.Methods.Normal;
                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10100, "Verification primary method {0} with mass {1} is from the normal method", imr.primaryMethod.ToString(), normal_mass.v);
                }
                else if (backup_mass.v != -1.0)
                {
                    bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr);
                    if (got)
                        imr.primaryMethod = meas.INCCAnalysisState.Methods.Backup;
                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10101, "Verification primary method {0} with mass {1} is from the backup method", imr.primaryMethod.ToString(), backup_mass.v);
                }
                if ((normal_mass.v != -1.0) && (backup_mass.v != -1.0))
                {
                    if (meas.INCCAnalysisState.Methods.Backup.IsNone())
                    {
                        double delta = Math.Abs(normal_mass.v - backup_mass.v);
                        double delta_error = Math.Sqrt(normal_mass.err * normal_mass.err +
                             backup_mass.err * backup_mass.err);

                        bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr);

                        if (delta <= (delta_error * meas.Tests.normalBackupAssayTestLimit))
                        {
                            if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Normal;
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10102, "Verification primary method {0} with masses {1} and {2} is from the normal method", imr.primaryMethod.ToString(), normal_mass.v, backup_mass.v);
                        }
                        else
                        {
                            if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Backup;
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10103, "Verification primary method {0} with masses {1} and {2} is from the backup method", imr.primaryMethod.ToString(), normal_mass.v, backup_mass.v);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                meas.Logger.TraceException(e);
            }
        }
 private void AddOrEditCustomer_Load(object sender, EventArgs e)
 {
     _rates = new Rates { Name = "rates", Dock = DockStyle.Fill, Visible = true };
     groupStudioAnalysisBands.Controls.Add(_rates);
     if (_customer != null)
         _rates.State = _customer.Rates;
     rbTemplateSimpleWordAnalysis.Checked = true;
 }