internal void SaveResult(DateTime predict_date, SP_Predict_AnimalList_Result item, double prob_calving, double missing_gaps)
        {
            int bolus_id = item.bolus_id;

            Prediction pr = new Prediction();

            pr.bolus_id      = bolus_id;
            pr.analysis_date = predict_date;
            pr.prob_calving  = prob_calving;
            pr.prop_missing  = 1 - missing_gaps;
            pr.confidence    = missing_gaps;
            pr.date_stamp    = DateTime.UtcNow;
            try
            {
                using (DB_A4A060_csEntities context = new DB_A4A060_csEntities())
                {
                    context.Predictions.Add(pr);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #2
0
        private static string EmailMessageBuilder(SP_Predict_AnimalList_Result item, DateTime predict_date, double result, double missing_gaps)
        {
            string msg      = string.Empty;
            double lastprob = GetLastProb(item.bolus_id);

            if (lastprob > result || lastprob < 0)
            {
                //<Farm>. <Data /time>
                //Calving prediction for the next 24 hours for cow<animal_ID>.
                //Probability < Prob in %>.Missing data < missing_data in %>.

                msg = GetFarmNameByBolusID(item.bolus_id) + ". " + predict_date.ToString("MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture) + "\r\n" +
                      "Calving prediction for the next 24 hours for cow #" + item.animal_id.Value + "\r\n" +
                      "Probability " + string.Format("{0:0.##}%", result * 100) +
                      ". Missing data " + string.Format("{0:0.##}%", (1 - missing_gaps) * 100) + "\r\n\r\n";
            }
            else
            {
                //< Farm >. < Data / time >
                //INCREASED calving prediction for the next 24 hours for cow<animal_ID>.
                //Probability from < Prob in % last > to < Porb in % new>.
                //Missing data < missing_data in %>.
                msg = GetFarmNameByBolusID(item.bolus_id) + ". " + predict_date.ToString("MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture) + "\r\n" +
                      "INCREASED calving prediction for the next 24 hours for cow #" + item.animal_id.Value + "\r\n" +
                      "Probability from " + string.Format("{0:0.##}%", lastprob * 100) + " to " + string.Format("{0:0.##}%", result * 100) +
                      ". Missing data " + string.Format("{0:0.##}%", (1 - missing_gaps) * 100) + "\r\n\r\n";
            }
            return(msg);
        }