Пример #1
0
        public void Initialize(string serviceFullName, XmlElement source)
        {
            this.Service = ServiceEntity.Parse(source);

            this.txtServiceName.Text = serviceFullName;
            this.txtSQLTemplate.Text = Service.SQLTemplate.Trim();
            this.LoadVariables();
            this.EditVarForm            = new EditVariableForm(this.Service);
            this.EditVarForm.Completed += delegate(object s, EventArgs arg)
            {
                LoadVariables();
            };

            txtRequestElement.Text = Service.ResponseRecordElement;
            LoadFields();
            LoadConditions();
            LoadOrders();
            LoadPreprocesses();
            LoadConverters();

            this.txtSQLTemplate.Document.LoadLanguageFromXml(Assembly.GetExecutingAssembly().GetManifestResourceStream("ProjectManager.ActiproSoftware.SQL.xml"), 0);
            MakeSuggest();

            _original = this.GetResult().OuterXml;
            _init     = true;
        }
Пример #2
0
        public System.Xml.XmlElement Generate(XmlElement serviceDefinition)
        {
            ServiceEntity service = ServiceEntity.Parse(serviceDefinition);

            XmlHelper  h2 = new XmlHelper("<Request/>");
            XmlElement e  = h2.AddElement(".", service.RequestRecordElement);
            XmlHelper  h  = new XmlHelper(e);

            XmlElement reqElement = h.GetElement(".");

            XmlElement conditionElement = h.GetElement(".");

            if (!string.IsNullOrWhiteSpace(service.ConditionList.Source))
            {
                conditionElement = h.AddElement(".", service.ConditionList.Source);
            }

            XmlHelper        conditionHelper = new XmlHelper(conditionElement);
            List <Condition> _requires       = new List <Condition>();
            List <Condition> _notRequires    = new List <Condition>();

            foreach (Condition condition in service.ConditionList.Conditions)
            {
                if (condition.SourceType != SourceType.Request)
                {
                    continue;
                }
                if (condition.Required)
                {
                    _requires.Add(condition);
                }
                else
                {
                    _notRequires.Add(condition);
                }
            }

            if (_requires.Count > 0)
            {
                XmlNode comment = conditionElement.OwnerDocument.CreateComment("以下為必要條件");
                conditionElement.AppendChild(comment);

                foreach (Condition con in _requires)
                {
                    conditionHelper.AddElement(".", con.Source);
                }
            }

            if (_notRequires.Count > 0)
            {
                XmlNode comment = conditionElement.OwnerDocument.CreateComment("以下為非必要條件");
                conditionElement.AppendChild(comment);

                foreach (Condition con in _notRequires)
                {
                    conditionHelper.AddElement(".", con.Source);
                }
            }
            return(h2.GetElement("."));
        }
        public void Initialize(string serviceFullName, XmlElement source)
        {
            this.Service = ServiceEntity.Parse(source);

            _source = new XmlHelper(source);

            this.txtServiceName.Text = serviceFullName;
            this.LoadVariables();
            this.EditVarForm            = new EditVariableForm(this.Service);
            this.EditVarForm.Completed += delegate(object s, EventArgs arg)
            {
                LoadVariables();
            };
            this.cboTable.Text     = _source.GetText("TargetTableName");
            txtRequestElement.Text = Service.RequestRecordElement;
            LoadFields();
            LoadPreprocesses();

            _original = source.OuterXml;
            _init     = true;
        }
        public System.Xml.XmlElement Generate(XmlElement serviceDefinition)
        {
            ServiceEntity service = ServiceEntity.Parse(serviceDefinition);

            XmlHelper  h          = new XmlHelper("<Request/>");
            XmlElement reqElement = h.GetElement(".");

            XmlElement fieldElement = h.GetElement(".");

            if (!string.IsNullOrWhiteSpace(service.FieldList.Source))
            {
                fieldElement = h.AddElement(".", service.FieldList.Source);
            }

            XmlHelper fieldHelper = new XmlHelper(fieldElement);

            fieldHelper.AddElement(".", "All");
            foreach (Field field in service.FieldList.Fields)
            {
                if (field.Mandatory)
                {
                    continue;
                }
                if (field.SourceType != SourceType.Request)
                {
                    continue;
                }

                fieldHelper.AddElement(".", field.Source);
            }

            XmlElement conditionElement = h.GetElement(".");

            if (!string.IsNullOrWhiteSpace(service.ConditionList.Source))
            {
                conditionElement = h.AddElement(".", service.ConditionList.Source);
            }

            XmlHelper        conditionHelper = new XmlHelper(conditionElement);
            List <Condition> _requires       = new List <Condition>();
            List <Condition> _notRequires    = new List <Condition>();

            foreach (Condition condition in service.ConditionList.Conditions)
            {
                if (condition.SourceType != SourceType.Request)
                {
                    continue;
                }
                if (condition.Required)
                {
                    _requires.Add(condition);
                }
                else
                {
                    _notRequires.Add(condition);
                }
            }

            if (_requires.Count > 0)
            {
                XmlNode comment = conditionElement.OwnerDocument.CreateComment("以下為必要條件");
                conditionElement.AppendChild(comment);

                foreach (Condition con in _requires)
                {
                    conditionHelper.AddElement(".", con.Source);
                }
            }

            if (_notRequires.Count > 0)
            {
                XmlNode comment = conditionElement.OwnerDocument.CreateComment("以下為非必要條件");
                conditionElement.AppendChild(comment);

                foreach (Condition con in _notRequires)
                {
                    conditionHelper.AddElement(".", con.Source);
                }
            }

            if (service.Orders.Orders.Count > 0)
            {
                XmlElement orderElement = h.GetElement(".");
                if (!string.IsNullOrWhiteSpace(service.Orders.Source))
                {
                    orderElement = h.AddElement(".", service.Orders.Source);
                }
                XmlHelper orderHelper = new XmlHelper(orderElement);
                foreach (Order order in service.Orders.Orders)
                {
                    orderHelper.AddElement(".", order.Source, "ASC_DESC");
                }
            }

            if (service.Pagination.AllowPagination)
            {
                XmlHelper ph = new XmlHelper("<Pagination/>");
                ph.AddElement(".", "StartPage", "1");
                ph.AddElement(".", "PageSize", service.Pagination.MaxPageSize.ToString());

                XmlNode node = reqElement.OwnerDocument.CreateComment(ph.XmlString);
                reqElement.AppendChild(node);
            }
            return(reqElement);
        }
Пример #5
0
        public XmlElement Generate(XmlElement serviceDefinition)
        {
            ServiceEntity service = ServiceEntity.Parse(serviceDefinition);

            XmlHelper  h          = new XmlHelper("<Request/>");
            XmlElement reqElement = h.GetElement(".");

            XmlElement recElement   = h.AddElement(".", service.RequestRecordElement);
            XmlHelper  recHelper    = new XmlHelper(recElement);
            XmlElement fieldElement = recHelper.GetElement(".");

            if (!string.IsNullOrWhiteSpace(service.FieldList.Source))
            {
                fieldElement = recHelper.AddElement(".", service.FieldList.Source);
            }

            XmlHelper    fieldHelper  = new XmlHelper(fieldElement);
            List <Field> _requires    = new List <Field>();
            List <Field> _notRequries = new List <Field>();

            foreach (Field field in service.FieldList.Fields)
            {
                if (field.SourceType != SourceType.Request)
                {
                    continue;
                }
                if (field.AutoNumber)
                {
                    continue;
                }

                if (field.InputType == IOType.Attribute)
                {
                    fieldElement.SetAttribute(field.Source, string.Empty);
                }
                else if (field.Required)
                {
                    _requires.Add(field);
                }
                else
                {
                    _notRequries.Add(field);
                }
            }

            if (_requires.Count > 0)
            {
                XmlNode node = reqElement.OwnerDocument.CreateComment("以下為必要欄位");
                fieldElement.AppendChild(node);

                foreach (Field field in _requires)
                {
                    string value = string.Empty;
                    if (field.InputType == IOType.Xml)
                    {
                        value = "xml";
                    }
                    fieldHelper.AddElement(".", field.Source, value);
                }
            }

            if (_notRequries.Count > 0)
            {
                XmlNode node = reqElement.OwnerDocument.CreateComment("以下為非必要欄位");
                fieldElement.AppendChild(node);

                foreach (Field field in _notRequries)
                {
                    string value = string.Empty;
                    if (field.InputType == IOType.Xml)
                    {
                        value = "xml";
                    }
                    fieldHelper.AddElement(".", field.Source, value);
                }
            }

            return(reqElement);
        }