Example #1
0
        protected override object OnBackgroundWorkerWorking()
        {
            //抓文字評量對照表
            CommentList   commentList = new CommentList();
            List <string> faceList    = new List <string>();
            DSXmlHelper   wcHelper    = JHSchool.Feature.Legacy.Config.GetWordCommentList().GetContent();

            foreach (XmlElement morality in wcHelper.GetElements("Content/Morality"))
            {
                DSXmlHelper moralityHelper = new DSXmlHelper(morality);
                string      face           = moralityHelper.GetText("@Face");
                if (!faceList.Contains(face))
                {
                    faceList.Add(face);
                }
                foreach (XmlElement item in moralityHelper.GetElements("Item"))
                {
                    string code    = item.GetAttribute("Code");
                    string comment = item.GetAttribute("Comment");
                    if (commentList.Add(face, code, comment) == false)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("文字評量代碼表有誤。");
                    }
                }
            }

            //取得學生清單資料
            DSXmlHelper helper = new DSXmlHelper("Request");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "TextScore");
            helper.AddElement("Field", "SchoolYear");
            helper.AddElement("Field", "Semester");
            helper.AddElement("Condition");
            helper.AddElement("Condition", "StudentIDList");
            helper.AddElement("Condition/StudentIDList", "ID", RunningID);
            helper.AddElement("Order");
            helper.AddElement("Order", "SchoolYear");
            helper.AddElement("Order", "Semester");

            DSResponse dsrsp = JHSchool.Feature.Legacy.QueryScore.GetSemesterMoralScore(new DSRequest(helper));

            if (!dsrsp.HasContent)
            {
                FISCA.Presentation.Controls.MsgBox.Show("取得回覆文件錯誤:" + dsrsp.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(new List <object>(new object[] { commentList, faceList }));
            }
            helper = dsrsp.GetContent();
            return(new List <object>(new object[] { commentList, faceList, helper }));
        }
Example #2
0
        public override bool IsValid()
        {
            CommentList list = (CommentList)Argument;

            if (ValidCell.Value == null)
            {
                return(true);
            }
            if (ValidCell.Value.ToString() == string.Empty)
            {
                return(true);
            }

            string        face = ValidCell.OwningColumn.HeaderText;
            StringBuilder sb   = new StringBuilder();

            string[] vs = ValidCell.Value.ToString().Split(',');
            foreach (string v in vs)
            {
                string comment = list.GetComment(face, v);
                if (!string.IsNullOrEmpty(comment))
                {
                    sb.Append(comment);
                }
                else
                {
                    sb.Append(v);
                }
                sb.Append(",");
            }
            if (sb.ToString().EndsWith(","))
            {
                sb.Remove(sb.Length - 1, 1);
            }

            ValidCell.Value = sb.ToString();

            //string comment = list.GetComment(ValidCell.OwningColumn.HeaderText, ValidCell.Value.ToString());
            //if (!string.IsNullOrEmpty(comment))
            //    ValidCell.Value = comment;

            return(true);
        }
Example #3
0
        protected override void OnBackgroundWorkerCompleted(object result)
        {
            _initialized = false;

            _deletedRows  = new Dictionary <string, string>();
            _addedRows    = new List <string>();
            _reserveFaces = new ReserveFaces();

            List <object> resultObject = result as List <object>;

            _commentList = resultObject[0] as CommentList;
            List <string> faceList = resultObject[1] as List <string>;
            DSXmlHelper   helper   = null;

            if (resultObject.Count > 2)
            {
                helper = resultObject[2] as DSXmlHelper;
            }
            else
            {
                helper = new DSXmlHelper("BOOM");
            }

            dgView.Rows.Clear();
            dgView.Columns.Clear();

            dgView.Columns.Add(colSchoolYear);
            dgView.Columns.Add(colSemester);
            //int columnIndex;
            //DataGridViewColumn col;
            //columnIndex = dataGridViewX1.Columns.Add(colSchoolYear);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 80;

            //columnIndex = dataGridViewX1.Columns.Add(colSemester);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 60;

            //columnIndex = dataGridViewX1.Columns.Add(colTB);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 125;

            //columnIndex = dataGridViewX1.Columns.Add(colTT);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 100;

            //文字評量 Face Column
            int index = 0;

            foreach (string face in faceList)
            {
                int colIndex = dgView.Columns.Add("colItem" + index, face);
                dgView.Columns[colIndex].SortMode = DataGridViewColumnSortMode.NotSortable;
                index++;
            }

            //int index = 0;
            //foreach (XmlElement element in helper.GetElements("DiffItem"))
            //{
            //    string name = element.GetAttribute("Name");
            //    System.Windows.Forms.DataGridViewTextBoxColumn newCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
            //    newCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
            //    newCol.HeaderText = name;
            //    newCol.MinimumWidth = 45;
            //    newCol.Name = "colItem" + index;
            //    newCol.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
            //    dataGridViewX1.Columns.Add(newCol);
            //    index++;
            //}
            //colTT.DisplayIndex = dataGridViewX1.Columns.Count - 1;


            _valueManager.AddValue(ADD_ROW_COUNT, "0");
            //helper = info.ScoreList.GetContent();
            _valueManager.AddValue(ORI_ROW_COUNT, helper.GetElements("SemesterMoralScore").Length.ToString());

            foreach (XmlElement element in helper.GetElements("SemesterMoralScore"))
            {
                int              rowIndex = dgView.Rows.Add();
                DataGridViewRow  row      = dgView.Rows[rowIndex];
                DataGridViewCell cell;
                string           schoolYear = element.SelectSingleNode("SchoolYear").InnerText;
                string           semester   = element.SelectSingleNode("Semester").InnerText;
                string           key;

                cell       = row.Cells[colSchoolYear.Index];
                cell.Value = schoolYear;
                cell.Tag   = schoolYear;
                key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", colSchoolYear.HeaderText);
                _valueManager.AddValue(key, cell.Value.ToString());
                cell.ReadOnly = true;

                cell       = row.Cells[colSemester.Index];
                cell.Value = element.SelectSingleNode("Semester").InnerText;
                cell.Tag   = element.SelectSingleNode("Semester").InnerText;
                key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", colSemester.HeaderText);
                _valueManager.AddValue(key, cell.Value.ToString());
                cell.ReadOnly = true;

                JHSchool.Legacy.RecordInfo rinfo = new JHSchool.Legacy.RecordInfo();
                rinfo.IsAddedRow = false;
                rinfo.ID         = element.GetAttribute("ID");
                row.Tag          = rinfo;

                foreach (XmlNode node in element.SelectNodes("TextScore/Morality"))
                {
                    string face = node.SelectSingleNode("@Face").InnerText;

                    //如果 face 不存在對照表中,偷偷保留下來
                    if (!_commentList.ContainsFace(face))
                    {
                        _reserveFaces.Add(rinfo.ID, face, node.InnerText);
                    }

                    foreach (DataGridViewColumn column in dgView.Columns)
                    {
                        if (column.HeaderText != face)
                        {
                            continue;
                        }
                        cell       = row.Cells[column.Index];
                        cell.Value = node.InnerText;
                        cell.Tag   = node.InnerText;
                        key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", column.HeaderText);
                        _valueManager.AddValue(key, cell.Value.ToString());
                        cell.ReadOnly = false;
                    }
                }
            }
            _initialized = true;
        }