/// <summary> /// Provides the closing html tags for object /// </summary> /// <returns></returns> public override string ModelSummaryInnerClosingTags(bool formatForParentControl) { string html = ""; if (formatForParentControl) { html += "</td>"; for (int i = 0; i < 12; i++) { if (MonthlyValues == null) { html += "<td><span class=\"errorlink\">?</span></td>"; } else if (i > MonthlyValues.Count() - 1) { html += "<td><span class=\"errorlink\">?</span></td>"; } else { html += "<td><span class=\"setvalue\">" + ((this.MonthlyValues.Length - 1 >= i) ? this.MonthlyValues[i].ToString() : "") + "</span></td>"; } } html += "</tr>"; } else { html += "\n</div>"; } return(html); }
/// <summary> /// Validate model /// </summary> /// <param name="validationContext"></param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var results = new List <ValidationResult>(); switch ((this.Parent as RuminantActivityFeed).FeedStyle) { case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: if (MonthlyValues.Max() > 1) { string[] memberNames = new string[] { "Monthly values" }; results.Add(new ValidationResult("Invalid monthly value provided [v" + MonthlyValues.Max().ToString() + "] for [" + this.Name + "] Feed Group for [" + this.Parent.Name + "] given the style of feeding selected requires a proportion.", memberNames)); } break; default: break; } if (MonthlyValues.Count() > 0) { if (MonthlyValues.Max() == 0) { Summary.WriteWarning(this, $"No feed values were defined for any month in [{this.Name}]. No feeding will be performed for [a={this.Parent.Name}]"); } } return(results); }
/// <summary> /// Provide the monthly labour availability /// </summary> /// <param name="month">Month for labour</param> /// <returns></returns> public override double GetAvailability(int month) { if (month <= 12 && month > 0 && month <= MonthlyValues.Count()) { return(MonthlyValues[month - 1]); } else { return(0); } }
/// <summary> /// Validate model /// </summary> /// <param name="validationContext"></param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var results = new List <ValidationResult>(); if (MonthlyValues.Count() > 0) { if (MonthlyValues.Max() == 0) { Summary.WriteWarning(this, $"No feed values were defined for any month in [{this.Name}]. No feeding will be performed for [a={this.Parent.Name}]"); } } return(results); }
/// <summary> /// Validate model /// </summary> /// <param name="validationContext"></param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var results = new List <ValidationResult>(); switch ((this.Parent as RuminantActivityFeed).FeedStyle) { case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: if (MonthlyValues.Max() > 1) { string[] memberNames = new string[] { "Monthly values" }; results.Add(new ValidationResult("Invalid monthly value provided [v" + MonthlyValues.Max().ToString() + "] for [" + this.Name + "] Feed Group for [" + this.Parent.Name + "] given the style of feeding selected requires a proportion.", memberNames)); } break; default: break; } return(results); }
/// <summary> /// Provides the description of the model settings for summary (GetFullSummary) /// </summary> /// <param name="formatForParentControl">Use full verbose description</param> /// <returns></returns> public override string ModelSummary(bool formatForParentControl) { using (StringWriter htmlWriter = new StringWriter()) { if (!formatForParentControl) { if (MonthlyValues == null) { return("\r\n<div class=\"activityentry\">No availability provided</div>"); } double min = MonthlyValues.Min(); double max = MonthlyValues.Max(); htmlWriter.Write("\r\n<div class=\"activityentry\">Monthly availability "); if (min != max) { htmlWriter.Write("ranges from "); } else { htmlWriter.Write("is "); } if (min <= 0) { htmlWriter.Write("<span class=\"errorlink\">" + min.ToString() + "</span>"); } else { htmlWriter.Write("<span class=\"setvalue\">" + min.ToString() + "</span>"); } if (min != max) { htmlWriter.Write("to <span class=\"setvalue\">" + max.ToString() + "</span>"); } htmlWriter.Write(" days each month</div>"); } return(htmlWriter.ToString()); } }
/// <summary> /// Provides the description of the model settings for summary (GetFullSummary) /// </summary> /// <param name="formatForParentControl">Use full verbose description</param> /// <returns></returns> public override string ModelSummary(bool formatForParentControl) { using (StringWriter htmlWriter = new StringWriter()) { // get amount var grps = MonthlyValues.GroupBy(a => a).OrderBy(a => a.Key); RuminantFeedActivityTypes ft = (this.Parent as RuminantActivityFeed).FeedStyle; htmlWriter.Write("\r\n<div class=\"activityentry\">"); if (grps.Count() > 1) { htmlWriter.Write("From "); } htmlWriter.Write("<span class=\"setvalue\">"); switch (ft) { case RuminantFeedActivityTypes.SpecifiedDailyAmount: htmlWriter.Write(grps.FirstOrDefault().Key.ToString() + "kg"); break; case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: case RuminantFeedActivityTypes.ProportionOfFeedAvailable: if (grps.LastOrDefault().Key != 1) { htmlWriter.Write((Convert.ToDecimal(grps.FirstOrDefault().Key, CultureInfo.InvariantCulture)).ToString("0.##%")); } break; default: break; } htmlWriter.Write("</span>"); if (grps.Count() > 1) { htmlWriter.Write(" to "); htmlWriter.Write("<span class=\"setvalue\">"); switch (ft) { case RuminantFeedActivityTypes.SpecifiedDailyAmount: htmlWriter.Write(grps.LastOrDefault().Key.ToString() + "kg"); break; case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: case RuminantFeedActivityTypes.ProportionOfFeedAvailable: htmlWriter.Write((Convert.ToDecimal(grps.LastOrDefault().Key, CultureInfo.InvariantCulture)).ToString("0.##%")); break; default: break; } htmlWriter.Write("</span>"); } string starter = " of "; if (grps.Count() == 1 && grps.LastOrDefault().Key == 1) { starter = "The "; } bool overfeed = false; htmlWriter.Write("<span class=\"setvalue\">"); switch (ft) { case RuminantFeedActivityTypes.ProportionOfFeedAvailable: htmlWriter.Write(" feed available"); overfeed = true; break; case RuminantFeedActivityTypes.SpecifiedDailyAmountPerIndividual: htmlWriter.Write(" per individual per day"); overfeed = true; break; case RuminantFeedActivityTypes.SpecifiedDailyAmount: htmlWriter.Write(" per day"); overfeed = true; break; case RuminantFeedActivityTypes.ProportionOfWeight: htmlWriter.Write(starter + "live weight"); overfeed = true; break; case RuminantFeedActivityTypes.ProportionOfPotentialIntake: htmlWriter.Write(starter + "potential intake"); break; case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: htmlWriter.Write(starter + "remaining intake"); break; default: break; } htmlWriter.Write("</span> is fed each month to the individuals that match the following conditions:"); htmlWriter.Write("</div>"); if (overfeed) { htmlWriter.Write("\r\n<div class=\"activityentry\">"); htmlWriter.Write("Individual's intake will be limited to Potential intake x the modifer for max overfeeding, with excess food still utilised but wasted"); htmlWriter.Write("</div>"); } return(htmlWriter.ToString()); } }
/// <summary> /// Provides the description of the model settings for summary (GetFullSummary) /// </summary> /// <param name="formatForParentControl">Use full verbose description</param> /// <returns></returns> public override string ModelSummary(bool formatForParentControl) { string html = ""; // get amount var grps = MonthlyValues.GroupBy(a => a).OrderBy(a => a.Key); RuminantFeedActivityTypes ft = (this.Parent as RuminantActivityFeed).FeedStyle; html += "\n<div class=\"activityentry\">"; if (grps.Count() > 1) { html += "From "; } html += "<span class=\"setvalue\">"; switch (ft) { case RuminantFeedActivityTypes.SpecifiedDailyAmount: html += grps.FirstOrDefault().Key.ToString() + "kg"; break; case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: if (grps.LastOrDefault().Key != 1) { html += (Convert.ToDecimal(grps.FirstOrDefault().Key, CultureInfo.InvariantCulture)).ToString("0.##%"); } break; default: break; } html += "</span>"; if (grps.Count() > 1) { html += " to "; html += "<span class=\"setvalue\">"; switch (ft) { case RuminantFeedActivityTypes.SpecifiedDailyAmount: html += grps.LastOrDefault().Key.ToString() + "kg"; break; case RuminantFeedActivityTypes.ProportionOfWeight: case RuminantFeedActivityTypes.ProportionOfPotentialIntake: case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: html += (Convert.ToDecimal(grps.LastOrDefault().Key, CultureInfo.InvariantCulture)).ToString("0.##%"); break; default: break; } html += "</span>"; } string starter = " of "; if (grps.Count() == 1 && grps.LastOrDefault().Key == 1) { starter = "The "; } html += "<span class=\"setvalue\">"; switch (ft) { case RuminantFeedActivityTypes.SpecifiedDailyAmount: html += " per day"; break; case RuminantFeedActivityTypes.ProportionOfWeight: html += starter + "live weight"; break; case RuminantFeedActivityTypes.ProportionOfPotentialIntake: html += starter + "potential intake"; break; case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired: html += starter + "remaining intake"; break; default: break; } html += "</span> is fed each month to the individuals that match the following conditions:"; html += "</div>"; html += "\n<div class=\"activityentry\">"; html += "Individual's intake will automatically be limited to 1.2 x potential intake, with excess food still utilised"; html += "</div>"; return(html); }