Пример #1
0
        /// <summary>
        /// 重新设置子项的深度
        /// </summary>
        public virtual void SetItemLevel()
        {
            int level = Level;

            for (int i = 0; i < Items.Count; i++)
            {
                ScoreItem item = Items[i];
                item.Level = level + 1;
                ScoreGroup group = item as ScoreGroup;
                if (group != null)
                {
                    group.SetItemLevel();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 获取下一评分项的ItemID
        /// </summary>
        /// <returns></returns>
        public int GetNewItemID()
        {
            int intReturn = 0;
            List <ScoreItem> listItems = new List <ScoreItem>();

            GetAllScoreItem(ref listItems);
            int i = 1;

            while (i < int.MaxValue)
            {
                ScoreItem item = listItems.FirstOrDefault(l => l.ItemID == i);
                if (item == null)
                {
                    intReturn = i;
                    break;
                }
                i++;
            }
            return(intReturn);
        }
Пример #3
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;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 根据控制项改变得分
        /// </summary>
        public void ControlScore()
        {
            ScoreItem sourceItem = Source;
            ScoreItem targetItem = Target;

            if (sourceItem == null || targetItem == null)
            {
                return;
            }
            bool   bIsChange = false;
            double score     = sourceItem.Score;

            if (sourceItem.IsScoreControled)
            {
                //如果源项已经被其他控制项控制得分了,那么比较分数的时候要使用RealScore,即使用控制后的分数
                score = sourceItem.RealScore;
            }
            switch (JugeType)
            {
            case JugeType.Equal:
                if (score == JugeValue1)
                {
                    bIsChange = true;
                }
                break;

            case JugeType.Lower:
                if (score < JugeValue1)
                {
                    bIsChange = true;
                }
                break;

            case JugeType.LowerEqual:
                if (score <= JugeValue1)
                {
                    bIsChange = true;
                }
                break;

            case JugeType.Upper:
                if (score > JugeValue1)
                {
                    bIsChange = true;
                }
                break;

            case JugeType.UpperEqual:
                if (score >= JugeValue1)
                {
                    bIsChange = true;
                }
                break;

            case JugeType.Between:
                if (score >= JugeValue1 && score <= JugeValue2)
                {
                    bIsChange = true;
                }
                break;
            }
            if (bIsChange)
            {
                switch (ChangeType)
                {
                case ChangeType.Equal:
                    targetItem.RealScore        = ChangeValue;
                    targetItem.IsScoreControled = true;
                    break;

                case ChangeType.Sum:
                    targetItem.RealScore       += ChangeValue;
                    targetItem.IsScoreControled = true;
                    break;

                case ChangeType.Sub:
                    targetItem.RealScore       -= ChangeValue;
                    targetItem.IsScoreControled = true;
                    break;

                case ChangeType.Multi:
                    targetItem.RealScore       *= ChangeValue;
                    targetItem.IsScoreControled = true;
                    break;

                case ChangeType.Div:
                    targetItem.RealScore       /= ChangeValue;
                    targetItem.IsScoreControled = true;
                    break;

                case ChangeType.NA:
                    targetItem.IsNA             = true;
                    targetItem.IsScoreControled = true;
                    break;
                }
            }
        }
Пример #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);
        }