Exemplo n.º 1
0
        // get meta data for the node name
        private DataTable GetMetaDataForTable(string tableName)
        {
            MetadataDa mda = new MetadataDa();

            DataTable dt = mda.GetFieldMetadataByTableName(tableName);

            return(dt);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Binds the helper layer to a section 'secName' with title 'secTitle'
        /// </summary>
        /// <param name="secName"></param>
        /// <param name="secTitle"></param>
        protected void BindSection(string secName, string secTitle)
        {
            // Verify section name is given
            if (!string.IsNullOrEmpty(secName))
            {
                MetadataDa mdDa = new MetadataDa();

                // Set global meta field attribute values for use in binding repeater values
                metaTable = mdDa.GetFieldMetadataByTableName("Project");

                // Bind to meta field list
                DataTable metaFieldList = mdDa.GetFieldsByTableName("Project");
                HelpDescriptionRptr.DataSource = metaFieldList;
                HelpDescriptionRptr.DataBind();

                LayerSectionTitle.InnerText           = secTitle;
                LayerSectionTitle.Attributes["title"] = secTitle;
            }
        }
Exemplo n.º 3
0
    /// <summary>
    /// Bind the datagrid to a datasource, and set titles via metadata
    /// </summary>
    /// <param name="grid"></param>
    /// <param name="dt"></param>
    /// <param name="biz"></param>
    protected void BindGridViaMetaData(GridView grid, DataTable dt, string tablename)
    {
        MetadataDa mdDa         = new MetadataDa();
        DataTable  fieldsDt     = mdDa.GetFieldsByTableName(tablename);
        DataTable  attributesDt = mdDa.GetFieldMetadataByTableName(tablename);

        foreach (DataColumn col in dt.Columns)
        {
            if (col.ColumnName != "LoggedBy")
            {
                string     s          = CICHelper.GetFieldAttributeValue(attributesDt, col.ColumnName, "FieldLabel");
                BoundField newGridCol = new BoundField();
                newGridCol.DataField  = col.ColumnName;
                newGridCol.HeaderText = !string.IsNullOrEmpty(s) ? s : col.ColumnName;
                grid.Columns.Add(newGridCol);
            }
        }
        grid.DataSource = dt;
        grid.DataBind();
    }
Exemplo n.º 4
0
        // append the labels of the child nodes and their values
        private void AppendChildNodesOfParent(XmlNode parentNode)
        {
            MetadataDa mda = new MetadataDa();
            DataTable  dt  = mda.GetFieldMetadataByTableName(parentNode.Name);

            bool isEvenChildRow = false;  // using this to simulate style options available in a repeater - jf

            foreach (XmlNode childNode in parentNode)
            {
                // we want to display ONLY child nodes where at least one node within the record has a value ( xml considers a value within an element a child node)

                if (childNode.HasChildNodes.Equals(false) || (childNode.Value != "" && !childNode.FirstChild.NodeType.Equals(XmlNodeType.Element)))// && childNode.ChildNodes.Count > 0 && childNode.FirstChild.NodeType.Equals(XmlNodeType.Element) ) //ChildNodes.Count > 1) // NEED TO ADD CLAUSE HERE TO FIND OUT IF CHILD NODE IS A VALUE
                {
                    string s = GetFieldLabel(dt, childNode.Name);

                    string[] labelAndDescription = s.Split(new Char[] { '|' });

                    string label = labelAndDescription[0];

                    string description = "";

                    if (labelAndDescription.Length == 2)
                    {
                        description = labelAndDescription[1];
                    }

                    string recordId = "";

                    if (childNode.ParentNode.Attributes["RecordId"] != null)
                    {
                        recordId = parentNode.Attributes["RecordId"].Value;
                    }

                    // write string
                    this.BuildChildOutputString(label, description, childNode.Name, childNode.InnerText, recordId, isEvenChildRow);

                    isEvenChildRow = !isEvenChildRow;
                }
            }
        }
Exemplo n.º 5
0
        private void RecursivelyFillTables(XmlNode parentNode, XmlNodeList distinctTableNodes)
        {
            // Look through each distinct table names
            foreach (XmlNode table in distinctTableNodes)
            {
                // db/xml table name
                string tableName = table.Name;
                // meta data table name/label
                string metaDataTableName = GetTableLabelByTableName(tableName);

                // Get mata data table for Table's fields
                DataTable fieldsMetaTable = da.GetFieldMetadataByTableName(tableName);

                // Get a complete list of tables named by tableName
                XmlNodeList listOfTableRecords = parentNode.SelectNodes(tableName);

                // Create Table Label Attribute
                XmlAttribute tableLabelAttribute = xDoc.CreateAttribute("tableLabel");
                tableLabelAttribute.Value = string.Empty;

                bool tableNameSet = false;
                foreach (XmlNode record in listOfTableRecords)
                {
                    // Check if a table has data (i.e., if any field has data)
                    // If table contains fields with data, then the table has data
                    if (TableHasFieldsWithData(record))
                    {
                        // Set TableLable attribute for this record, as it has data
                        XmlAttribute clonedTableLabelAttribute = tableLabelAttribute.Clone() as XmlAttribute;
                        if (!tableNameSet)
                        {
                            clonedTableLabelAttribute.Value = metaDataTableName;
                            tableNameSet = true;
                        }
                        record.Attributes.Append(clonedTableLabelAttribute);

                        // Get a list of Fields for a Table
                        XmlNodeList tableFields = GetTableFields(record);

                        XmlAttribute hasDataAttribute = xDoc.CreateAttribute("hasData");
                        hasDataAttribute.Value = Boolean.TrueString.ToLower();
                        record.Attributes.Append(hasDataAttribute);


                        this.BuildFieldList(record, fieldsMetaTable);

                        XmlNodeList distinctChildTables = GetDistinctChildTables(record);
                        if (distinctChildTables.Count > 0)
                        {
                            RecursivelyFillTables(record, distinctChildTables);
                        }
                    }
                    else
                    {
                        if (!tablesWithoutRecords.Contains(tableName))
                        {
                            tablesWithoutRecords.Add(tableName);
                            XmlAttribute a = xDoc.CreateAttribute("noData");
                            a.Value = string.Empty;
                            record.Attributes.Append(a);
                        }
                    }
                }
            }
        }