Exemplo n.º 1
0
        /// <summary>
        /// 更新按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button_Update_Click(object sender, EventArgs e)
        {
            string id = ViewState["id"].ToString();
            //构造被考评人信息
            Evaluated evaluated = new Evaluated();

            evaluated.Id          = id;
            evaluated.Name        = TextBox_Name.Text.Trim();
            evaluated.Sex         = DropDownList_Sex.SelectedValue;
            evaluated.Company     = DropDownList_Company.SelectedValue;
            evaluated.Depart      = DropDownList_Depart.SelectedValue;
            evaluated.LaborDepart = TextBox_LaborDepart.Text.Trim();
            evaluated.PostName    = TextBox_PostName.Text.Trim();
            evaluated.PostType    = DropDownList_PostType.SelectedValue;
            evaluated.Fund        = TextBox_Fund.Text.Trim();
            evaluated.Character   = TextBox_Character.Text.Trim();
            evaluated.StartTime   = TextBox_StartTime.Text.Trim();
            evaluated.StopTime    = TextBox_StopTime.Text.Trim();

            string exception = "";

            if (EvaluatedManagementCtrl.UpdateEvaluatedById(evaluated, id, ref exception))
            {
                Alert.ShowInTop("更新成功!\n窗口即将关闭", MessageBoxIcon.Information);
                PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
            }
            else
            {
                Alert.ShowInTop("更新失败!\n原因:" + exception, MessageBoxIcon.Error);
                return;
            }
        }
        public object Evaluate(object arg)
        {
            var input  = (Tuple <string, string>)arg;
            var output = Comparison(input.Item1, input.Item2);

            Evaluated?.Invoke(this, new EvaluatedEventArgs {
                X      = input.Item1,
                Y      = input.Item2,
                Result = output
            });
            return(output);
        }
Exemplo n.º 3
0
        public List <string> Evaluate(int index)
        {
            if (Evaluated.ContainsKey(index))
            {
                return(Evaluated[index]);
            }

            var rule   = Rules[index];
            var result = new List <string>();

            // Iterate each entry in the rule
            foreach (var entry in rule)
            {
                var list = new List <string>()
                {
                    ""
                };

                // Iterate each component in the rule
                foreach (var component in entry)
                {
                    if (component.IsData)
                    {
                        return(new List <string>()
                        {
                            component.Data
                        });
                    }

                    if (!Evaluated.ContainsKey(component.RuleIndex))
                    {
                        Evaluated[component.RuleIndex] = Evaluate(component.RuleIndex);
                    }

                    var newList = new List <string>();

                    for (int p = 0; p < list.Count; p++)
                    {
                        for (int b = 0; b < Evaluated[component.RuleIndex].Count; b++)
                        {
                            newList.Add(list[p] + Evaluated[component.RuleIndex][b]);
                        }
                    }

                    list = newList;
                }

                result.AddRange(list);
            }

            return(result);
        }
        public virtual Volume <T> Evaluate(Session <T> session)
        {
            Evaluated?.Invoke(this, new EventArgs());

#if DEBUG
            var inputs = this.Result.ToArray();
            for (var index = 0; index < inputs.Length; index++)
            {
                var i = inputs[index];
                if (Core.Ops <T> .IsInvalid(i))
                {
                    throw new ArgumentException("Invalid input!");
                }
            }
#endif

            return(this.Result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 载入被考评人信息
        /// </summary>
        private void loadEvaluated()
        {
            string    id        = ViewState["id"].ToString();
            string    exception = "";
            Evaluated evaluated = new Evaluated();

            if (EvaluatedManagementCtrl.GetEvaluatedById(ref evaluated, id, ref exception))
            {
                Label_ID.Text     = evaluated.Id;
                TextBox_Name.Text = evaluated.Name;
                DropDownList_Sex.SelectedValue     = evaluated.Sex;
                DropDownList_Company.SelectedValue = evaluated.Company;
                DropDownList_Depart.SelectedValue  = evaluated.Depart;
                TextBox_LaborDepart.Text           = evaluated.LaborDepart;
                TextBox_PostName.Text = evaluated.PostName;
                DropDownList_PostType.SelectedValue = evaluated.PostType;
                TextBox_Fund.Text      = evaluated.Fund;
                TextBox_Character.Text = evaluated.Character;
                TextBox_StartTime.Text = evaluated.StartTime;
                TextBox_StopTime.Text  = evaluated.StopTime;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// マップを評価し、指定されたチームの得点を計算します。<see cref="AutoEvaluate"/>がfalseの場合はエージェントが移動した際に手動で呼び出す必要があります。
        /// 計算はほとんど時間がかからない(10ms未満)なので躊躇せず読んであげてね☆
        /// </summary>
        /// <param name="team">チーム</param>
        /// <returns></returns>
        public int EvaluateMap(Teams team)
        {
            if ((int)team > 2)
            {
                throw new NotSupportedException("複数フラグによる評価は対応していません。片方のチームのみで評価してください");
            }

            if (_ignoreUpdate)
            {
                return(team == Teams.Team1 ? Score1 : Score2);
            }

            _ignoreUpdate = true;
            int x = 0, y = 0;

            //マップからチームのタイルポイントを計算します
            var tile = Map.Cast <ICell>().Where((c, i) =>
            {
                y = i / Width;
                x = i - y * Width;

                //ついでに領域フラグ削除
                if (c.GetState(team).HasFlag(CellState.InRegion))
                {
                    c.SetState(team, CellState.None);
                }

                if (c.GetState(team).HasFlag(CellState.Occupied))
                {
                    return(true);
                }

                return(false);
            }).Sum(c => ((ScoreCell)c).Score);

            //領域点を計算します(塗りつぶしアルゴリズムを応用)

            //評価点を格納する
            int[,] evaluated = new int[Height, Width];

            evaluated.ForEach((point, _) =>
            {
                //未判定(評価点0)の場合
                if (evaluated[point.Y, point.X] == 0)
                {
                    var fillp  = new Point(point.X, point.Y);
                    var fills  = GetCell(fillp).GetState(team);
                    var filled = Helper.FieldUtils.FillField(this, fillp, team,
                                                             (state1, p) => state1 == fills, new Direction[] { Direction.Left, Direction.Up, Direction.Right, Direction.Down });

                    bool containsEdge = false;
                    filled.ForEach((p, c) =>
                    {
                        if (c != null)
                        {
                            if (Map.IsEdge(p.X, p.Y))
                            {
                                //端と当たった場合は領域ではない
                                containsEdge = true;
                            }

                            //評価点を加算してそのセルを評価済みにする
                            evaluated[p.Y, p.X]++;
                        }
                    });

                    if (!containsEdge)
                    {
                        filled.ForEach((p, c) =>
                        {
                            //占有されたセルは領域ではないので除外
                            if (c != null && !c.GetState(team).HasFlag(CellState.Occupied))
                            {
                                evaluated[p.Y, p.X]++;
                            }
                        });
                    }
                }
            });

            //評価点が2の場合は領域となる
            int region = 0;

            evaluated.ForEach((p, v) =>
            {
                if (v == 2)
                {
                    var cell = Map[p.Y, p.X];
                    cell.SetState(team, CellState.InRegion);
                    region += Math.Abs(cell.Score);
                }
            });

            if (AutoDump)
            {
                DumpMap(team);
            }

            var sum = tile + region;

            switch (team)
            {
            case Teams.Team1:
                Score1 = sum;
                break;

            case Teams.Team2:
                Score2 = sum;
                break;
            }

            Evaluated?.Invoke(this, new EventArgs());
            _ignoreUpdate = false;

            return(sum);
        }
Exemplo n.º 7
0
 protected virtual void OnEvaluated()
 {
     Evaluated?.Invoke();
 }