/// <summary>
 /// Gets the field as XML.
 /// </summary>
 /// <returns></returns>
 private static string CreateFieldAsXml()
 {
     XmlElement element = new XmlDocument().CreateElement("Field");
     element.SetAttribute("ID", "61cbb965-1e04-4273-b658-eedaa662f48d");
     element.SetAttribute("Type", "TargetTo");
     element.SetAttribute("Name", "TargetTo");
     element.SetAttribute("DisplayName", "Target Audiences");
     element.SetAttribute("Required", "FALSE");
     return element.OuterXml;
 }
Example #2
0
 private static XmlElement CreateXmlTaskNode(string condition)
 {
     XmlElement taskNode;
     taskNode = new XmlDocument().CreateElement("MockTask");
     taskNode.SetAttribute("MyRequiredBoolParam", "true");
     taskNode.SetAttribute("MyRequiredBoolArrayParam", "true");
     taskNode.SetAttribute("MyRequiredIntParam", "1");
     taskNode.SetAttribute("MyRequiredIntArrayParam", "1");
     taskNode.SetAttribute("MyRequiredStringParam", "a");
     taskNode.SetAttribute("MyRequiredStringArrayParam", "a");
     taskNode.SetAttribute("MyRequiredITaskItemParam", "a");
     taskNode.SetAttribute("MyRequiredITaskItemArrayParam", "a");
     if (null != condition)
     {
         taskNode.SetAttribute("Condition", condition);
     }
     return taskNode;
 }
Example #3
0
        public List<Answer> GetAnswer()
        {
            Dictionary<string, Answer> result = new Dictionary<string, Answer>();

            //找出所有 tag 值為 Question type 的控制項,
            foreach (Control ctrl in this.allQControls.Values)
            {
                Question q = ctrl.Tag as Question;
                if (q != null)
                {
                    if (!result.ContainsKey(q.GetQuestionName()))
                        result.Add(q.GetQuestionName(), new Answer());
                    Answer ans = result[q.GetQuestionName()];
                    ans.SetName(q.GetQuestionName());

                    if (ctrl is CheckBox)   //如果是 checkbox :
                    {
                        CheckBox chk = (CheckBox)ctrl;

                        if (chk.Checked)
                        {
                            //這是複選題
                            AnswerItem theAi = new AnswerItem();
                            string ctrlName = ctrl.Name;
                            QuestionListItem questionListItem = q.GetListItemByLable(ctrlName);
                            theAi.SetValueName(ctrlName);
                            if (questionListItem != null)
                            {
                                if (questionListItem.HasText)  //有 remark
                                {
                                    string remarkCtrlName = ctrlName + "_remark";
                                    if (this.allQControls.ContainsKey(remarkCtrlName))
                                    {
                                        theAi.SetValueRemark(this.allQControls[remarkCtrlName].Text);
                                    }
                                    else
                                        theAi.SetValueRemark("");
                                }
                            }
                            ans.AddAnswerItem(theAi);
                        } //end of (chk.Checked)
                    }
                    else if (ctrl is DataGridView)
                    {
                        DataGridView dg = (DataGridView)ctrl;
                        Dictionary<string, string> value = new Dictionary<string, string>();
                        foreach (DataGridViewRow row in dg.Rows)
                        {
                            if (!row.IsNewRow)
                            {
                                AnswerItem ai = new AnswerItem();
                                Dictionary<string, string> itemContents = new Dictionary<string, string>();
                                foreach (GridColumn gc in q.GetColumns())
                                {
                                    itemContents.Add(gc.GetName(), (row.Cells[gc.GetName()].Value == null) ? "" : row.Cells[gc.GetName()].Value.ToString());
                                }
                                ai.SetContent(itemContents);
                                ans.GetAnswerItems().Add(ai);
                            }
                        }
                    }
                    else   //視為單選題
                    {
                        if (q.GetQuestionType().ToLower() == "textboxdropdown")
                        {
                            ctrl.Text = ctrl.Text.Trim();
                            string[] strArr = ctrl.Text.Split(',');
                            foreach (string str in strArr)
                            {
                                if (!string.IsNullOrEmpty(str))
                                {
                                    XmlElement elm = new XmlDocument().CreateElement("Item");
                                    elm.SetAttribute("value", str.Trim ());
                                    AnswerItem ai = new AnswerItem(elm);
                                    ans.AddAnswerItem(ai);
                                }
                            }

                        }
                        else
                        ans.SetValue(ctrl.Text);
                    }
                }
            }

            return result.Values.ToList<Answer>();
        }
 private XmlElement CreateMemberElement(IDeclaredElement element)
 {
     var xmlElement = new XmlDocument().CreateElement("member");
     xmlElement.SetAttribute("name", element == null ? string.Empty : GetId());
     return xmlElement;
 }