示例#1
0
        public static ExportFieldCollection Match(ExportFieldCollection ruleFields, FieldCollection selectedFields)
        {
            ExportFieldCollection collection = new ExportFieldCollection();

            foreach (ExportField field in ruleFields)
            {
                foreach (Field sField in selectedFields)
                {
                    if (sField.FieldName != field.RequestName)
                    {
                        continue;
                    }
                    collection.Add(field);
                }
            }
            return(collection);
        }
示例#2
0
        public ExportFieldCollection Format(XmlElement source)
        {
            ExportFieldCollection _collection = new ExportFieldCollection();

            foreach (XmlNode node in source.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                XmlElement element = (XmlElement)node;
                if (element.Name == "Field")
                {
                    string name        = element.GetAttribute("Name");
                    string displaytext = element.GetAttribute("DisplayText");
                    string converter   = element.GetAttribute("Converter");
                    string dataType    = element.GetAttribute("DataType");

                    ExportField field = new ExportField();
                    field.FieldName   = name;
                    field.DisplayText = displaytext;
                    field.XPath       = name;
                    field.RequestName = name;
                    field.Converter   = converter;
                    field.DataType    = dataType;

                    _collection.Add(field);
                }
                else if (element.Name == "XmlField")
                {
                    XmlNode baseNode = element.SelectSingleNode("Element");
                    if (baseNode == null)
                    {
                        continue;
                    }

                    string name = element.GetAttribute("Name");
                    //string displaytext = element.GetAttribute("DisplayText");

                    //ExportField field = new ExportField();
                    //field.FieldName = name;
                    //field.DisplayText = displaytext;
                    XmlElement         baseElement = (XmlElement)baseNode;
                    List <ExportField> fields      = GetFields(baseElement, "", name, name, 1);
                    foreach (ExportField f in fields)
                    {
                        _collection.Add(f);
                    }
                    //foreach (XmlNode recNode in baseElement.SelectNodes("Element"))
                    //{
                    //    XmlElement recElement = (XmlElement)recNode;

                    //    int recIndex = 1;
                    //    foreach (XmlElement fieldNode in recElement.SelectNodes("Field"))
                    //    {
                    //        XmlElement fieldElement = (XmlElement)fieldNode;
                    //        ExportField field = new ExportField();
                    //        string baseDisplay = baseElement.GetAttribute("DisplayText");
                    //        string recDisplay = recElement.GetAttribute("DisplayText");
                    //        string fieldDisplay = fieldElement.GetAttribute("DisplayText");
                    //        string display = baseDisplay + ":" + recDisplay + (string.IsNullOrEmpty(recDisplay) ? "" : ":") + fieldDisplay;
                    //        field.DisplayText = display;

                    //        string baseName = baseElement.GetAttribute("Name");
                    //        string recName = recElement.GetAttribute("Name");
                    //        string fieldName = fieldElement.GetAttribute("Name");
                    //        string xpath = baseName + "/" + recName + "[" + recIndex + "]/" + fieldName;
                    //        field.XPath = xpath;

                    //        field.FieldName = element.GetAttribute("Name");
                    //        recIndex++;
                    //    }
                    //}
                }
            }
            return(_collection);
        }