示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
 /// <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);
        }