Пример #1
0
        public void Load()
        {
            m_Classes.Clear();
            if (!System.IO.File.Exists(ConfigFile))
            {
                return;
            }
            XmlDocument xml = new XmlDocument();

            xml.Load(ConfigFile);
            foreach (XmlElement cnode in xml.DocumentElement.GetElementsByTagName("Class"))
            {
                int        cId    = Convert.ToInt32(cnode.GetAttribute("ID"));
                string     cName  = cnode.GetAttribute("Name");
                int        cScore = Convert.ToInt32(cnode.GetAttribute("Score"));
                JudgeClass jc     = new JudgeClass(cId, cName, cScore);
                foreach (XmlElement inode in cnode.GetElementsByTagName("Item"))
                {
                    int       iId    = Convert.ToInt32(inode.GetAttribute("ID"));
                    string    iName  = inode.GetAttribute("Name");
                    int       iScore = Convert.ToInt32(inode.GetAttribute("Score"));
                    JudgeItem ji     = new JudgeItem(jc, iId, iName, iScore);
                    foreach (XmlElement dnode in inode.GetElementsByTagName("Deduct"))
                    {
                        string dDesc  = dnode.GetAttribute("Desc");
                        float  dScore = Convert.ToSingle(dnode.GetAttribute("Score"));
                        var    jd     = new JudgeDeduction(dDesc, dScore);
                        ji.Deductions.Add(jd);
                    }
                    jc.Items.Add(ji);
                }
                m_Classes[jc.ID] = jc;
            }
        }
Пример #2
0
        public void ApplyItemsFromTable(DataTable tb)
        {
            foreach (var cls in m_Classes.Values)
            {
                cls.Items.Clear();
            }
            int iIndex = 0;

            foreach (DataRow row in tb.Rows)
            {
                int        cId = (int)row[0];
                JudgeClass jc  = GetJudgeClass(cId);
                if (jc != null)
                {
                    int iId = ++iIndex;
                    row[3] = iId;
                    string iName  = (string)row[4];
                    float  iScore = (float)row[5];

                    var item = new JudgeItem(jc, iId, iName, iScore);
                    item.DeductionText = (string)row[6];
                    jc.Items.Add(item);
                }
            }
        }
Пример #3
0
 public JudgeItem(JudgeClass parent, JudgeItem item)
     : this(parent, item.ID, item.Name, item.Score, item.DeductionText)
 {
 }