Ejemplo n.º 1
0
        public XmlElement GetResult()
        {
            //TODO
            XmlHelper h = new XmlHelper("<Definition />");

            h.SetAttribute(".", "Type", "DBHelper");
            h.AddElement(".", "Action", ServiceAction.Select.ToString());

            XmlElement      sqlTmp  = h.AddElement(".", "SQLTemplate");
            XmlCDataSection section = sqlTmp.OwnerDocument.CreateCDataSection(this.txtSQLTemplate.Text);

            sqlTmp.AppendChild(section);

            h.AddElement(".", "ResponseRecordElement", txtRequestElement.Text);
            FieldList fields = new FieldList(this.txtFieldListName.Text, this.txtFieldListSource.Text);

            foreach (DataGridViewRow row in this.dgFieldList.Rows)
            {
                Field f = Field.Parse(row);
                fields.Fields.Add(f);
            }
            h.AddElement(".", fields.GetXml(ServiceAction.Select));

            ConditionList conditions = new ConditionList(this.txtConditionName.Text, this.txtConditionSource.Text, chkRequired.Checked);

            foreach (DataGridViewRow row in this.dgConditions.Rows)
            {
                Condition condition = Condition.Parse(row);
                conditions.Conditions.Add(condition);
            }
            h.AddElement(".", conditions.GetXml());

            OrderList orders = new OrderList(txtOrderName.Text, txtOrderSource.Text);

            foreach (DataGridViewRow row in dgOrder.Rows)
            {
                string target = row.Cells[colOrderTarget.Name].Value + string.Empty;
                string source = row.Cells[colOrderSource.Name].Value + string.Empty;
                Order  o      = new Order(target, source);
                orders.Orders.Add(o);
            }
            h.AddElement(".", orders.GetXml());

            int max = 0;

            if (!int.TryParse(txtMaxPageSize.Text, out max))
            {
                max = 0;
            }
            Pagination p = new Pagination(chkAllowPagination.Checked, max);

            h.AddElement(".", p.GetXml());

            if (this.Service.Variables.Count > 0)
            {
                XmlElement varElement = h.AddElement(".", "InternalVariable");
                foreach (IVariable v in this.Service.Variables)
                {
                    h.AddElement("InternalVariable", v.GetXml());
                }
            }

            if (this.Service.Converters.Count > 0)
            {
                XmlElement cvElement = h.AddElement(".", "Converters");
                foreach (IConverter c in this.Service.Converters)
                {
                    h.AddElement("Converters", c.Output());
                }
            }

            if (this.dgProcessor.Rows.Count > 0)
            {
                XmlElement proElement = h.AddElement(".", "Preprocesses");
                foreach (DataGridViewRow row in this.dgProcessor.Rows)
                {
                    Preprocess pp = row.Tag as Preprocess;
                    if (pp == null)
                    {
                        continue;
                    }

                    h.AddElement("Preprocesses", pp.GetXml());
                }
            }
            return(h.GetElement("."));
        }