Beispiel #1
0
        /// <summary>
        /// 检查完整性,正确性
        /// </summary>
        /// <returns></returns>
        public override CheckValidResult CheckValid()
        {
            CheckValidResult result = base.CheckValid();

            if (result.Code != 0)
            {
                return(result);
            }
            bool       usePointSystem = false;
            ScoreSheet scoreSheet     = ScoreSheet;

            if (scoreSheet != null && scoreSheet.UsePointSystem)
            {
                usePointSystem = true;
            }
            //如果启用分制,检查分制是否有效
            if (usePointSystem)
            {
                if (PointSystem < 0)
                {
                    result.Code        = 202;
                    result.ScoreObject = this;
                    result.Message     = string.Format("PointSystem invalid.");
                    return(result);
                }
            }
            return(result);
        }
Beispiel #2
0
        public void InitUseItemID()
        {
            ScoreSheet scoreSheet = ScoreSheet;

            if (scoreSheet != null)
            {
                List <ScoreItem> listScoreItems = new List <ScoreItem>();
                scoreSheet.GetAllScoreItem(ref listScoreItems);
                listScoreItems.Add(scoreSheet);
                ScoreItem scoreItem = listScoreItems.FirstOrDefault(i => i.ItemID == SourceItemID);
                if (scoreItem != null)
                {
                    Source = scoreItem;
                }
                scoreItem = listScoreItems.FirstOrDefault(i => i.ItemID == TargetItemID);
                if (scoreItem != null)
                {
                    Target = scoreItem;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 检查完整性,正确性
        /// </summary>
        /// <returns></returns>
        public override CheckValidResult CheckValid()
        {
            CheckValidResult result = base.CheckValid();

            if (result.Code != 0)
            {
                return(result);
            }
            //检查最大值是否超出范围
            bool       usePonitSystem = false;
            ScoreSheet scoreSheet     = ScoreSheet;

            if (scoreSheet != null && scoreSheet.UsePointSystem)
            {
                usePonitSystem = true;
            }
            if (usePonitSystem && (MaxValue > PointSystem))
            {
                result.Code        = 300;
                result.ScoreObject = this;
                result.Message     = string.Format("MaxValue larger than PointSystem value.");
                return(result);
            }
            if (!usePonitSystem && (MaxValue > TotalScore))
            {
                result.Code        = 300;
                result.ScoreObject = this;
                result.Message     = string.Format("MaxValue larger than total value.");
                return(result);
            }
            if (DefaultValue < MinValue || DefaultValue > MaxValue)//如果默认值大于最大值小于最小值,直接设置为最小值
            {
                DefaultValue = MinValue;
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 检查完整性,正确性
        /// </summary>
        /// <returns></returns>
        public override CheckValidResult CheckValid()
        {
            CheckValidResult result = base.CheckValid();

            if (result.Code != 0)
            {
                return(result);
            }
            //检查子得分项的总分,分制是否匹配
            bool       usePonitSystem = false;
            ScoreSheet scoreSheet     = ScoreSheet;

            if (scoreSheet != null && scoreSheet.UsePointSystem)
            {
                usePonitSystem = true;
            }
            for (int i = 0; i < ValueItems.Count; i++)
            {
                StandardItem item = ValueItems[i];
                if (usePonitSystem && item.Value > PointSystem)
                {
                    result.Code        = 111;
                    result.ScoreObject = item;
                    result.Message     = string.Format("Child value item value large than PointSystem.");
                    return(result);
                }
                if (!usePonitSystem && item.Value > TotalScore)
                {
                    result.Code        = 110;
                    result.ScoreObject = item;
                    result.Message     = string.Format("Child value item value large than TotalScore.");
                    return(result);
                }
            }
            return(base.CheckValid());
        }
Beispiel #5
0
        /// <summary>
        /// 计算分数
        /// </summary>
        /// <returns></returns>
        public override double CaculateScore()
        {
            //如果得分被控制项控制了,就不用计算此项的得分了
            if (IsScoreControled)
            {
                return(RealScore);
            }
            //如果该项不计入总分,返回0
            if (IsAbortScore)
            {
                return(0.0);
            }
            double     doubleValue    = 0.0;
            bool       usePonitSystem = false;
            ScoreSheet scoreSheet     = ScoreSheet;

            if (scoreSheet != null && scoreSheet.UsePointSystem)
            {
                usePonitSystem = true;
            }
            //将NA项的分数累加记下
            double naScore = 0.0;

            for (int i = 0; i < Items.Count; i++)
            {
                ScoreItem scoreItem = Items[i];
                if (scoreItem.IsAllowNA && scoreItem.IsNA)
                {
                    naScore += scoreItem.TotalScore;
                }
            }
            //t     本项总分
            //a     子项得分
            //b     NA项多出的分值(即naScore)
            //子项实际得分的计算公式: x = (a * t) / (t - b)
            for (int i = 0; i < Items.Count; i++)
            {
                ScoreItem  scoreItem  = Items[i];
                double     t          = TotalScore;
                double     b          = naScore;
                double     a          = 0.0;
                ScoreGroup scoreGroup = scoreItem as ScoreGroup;
                if (scoreGroup != null)
                {
                    a = scoreGroup.CaculateScore();
                }
                else
                {
                    Standard standard = Items[i] as Standard;
                    if (standard != null && !standard.IsNA)
                    {
                        //如果此标准被控制项控制了,就不用计算得分,直接返回得分
                        if (standard.IsScoreControled)
                        {
                            a = standard.RealScore;
                        }
                        else
                        {
                            if (standard.IsAbortScore)
                            {
                                a = 0.0;
                            }
                            else
                            {
                                if (usePonitSystem)
                                {
                                    a = (standard.Score / standard.PointSystem) * standard.TotalScore;
                                }
                                else
                                {
                                    a = standard.Score;
                                }
                            }
                        }
                    }
                }
                //注意t-b不能为0,否则除数为0就出错了
                if (t == b)
                {
                    doubleValue = 0.0;
                }
                else
                {
                    doubleValue += (a * t) / (t - b);
                }
            }
            Score     = doubleValue;
            RealScore = Score;
            return(doubleValue);
        }