Ejemplo n.º 1
0
        private void loadTableColumns(int tableId, string tableName)
        {
            MetadataNewDa MNDa = new MetadataNewDa();
            DataTable     cols = MNDa.GetTableColumns(tableId, tableName);

            if (cols.Rows.Count < 1)
            {
                lblEtNotUsedFields.Visible = true;
                lblEtNotUsedFields.Text    = "None";
                dgEtFieldsNotUsed.Visible  = false;
                btnEtAddSelectedColumnsToMetaFields.Visible     = false;
                btnEtAddSelectedColumnsToMetaFieldsInfo.Visible = false;
            }
            else
            {
                lblEtNotUsedFields.Visible   = false;
                lblEtNotUsedFields.Text      = "";
                dgEtFieldsNotUsed.DataSource = cols.DefaultView;
                dgEtFieldsNotUsed.DataBind();
                dgEtFieldsNotUsed.Visible = true;
                btnEtAddSelectedColumnsToMetaFields.Visible     = true;
                btnEtAddSelectedColumnsToMetaFieldsInfo.Visible = true;
                lblEtNotUsedFields.Text    = "Add selected items as meta fields:&nbsp;";
                lblEtNotUsedFields.Visible = true;
            }
            btnEtAddSelectedColumnsToMetaFieldsCancel.Visible = btnEtAddSelectedColumnsToMetaFields.Visible;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds a list of available MetadataTables
        /// </summary>
        protected override void PopulateAttributeValues()
        {
            if (tableId.HasValue)
            {
                // populate main table attributes
                PopulateTableAttributes();

                // populate table field attributes
                MetadataDa da = new MetadataDa();
                DataTable  dt = da.GetFieldMetadata(tableId.Value, QueryDiseaseId);

                // build a list of unique metadata tables with there associated metadata
                var tableToAttributes = from row in dt.AsEnumerable()
                                        let fieldId = (int)row[MetadataField.FieldId]
                                                      group row by fieldId into groupByField
                                                      let filedName = groupByField.First()[MetadataField.FieldName].ToString()
                                                                      let fieldOrderMetadata = from record in groupByField
                                                                                               let attributeName = record[MetadataFieldAttribute.AttributeName].ToString()
                                                                                                                   let attributeValue = record[MetadataFieldAttributeValue.AttributeValue].ToString()
                                                                                                                                        // filter by FieldOrder attribute
                                                                                                                                        where attributeName.Equals(MetadataField.FieldOrder, StringComparison.OrdinalIgnoreCase) && PageUtil.IsInteger(attributeValue)
                                                                                                                                        // filter by disease (or defaul=NULL)
                                                                                                                                        where (!QueryDiseaseId.HasValue && record.IsNull(Disease.DiseaseId)) || (QueryDiseaseId.HasValue && !record.IsNull(Disease.DiseaseId))
                                                                                                                                        let fieldOrder = int.Parse(attributeValue)
                                                                                                                                                         select fieldOrder
                                                                                                                                                         // sort by field sort order, with null to bottom
                                                                                                                                                         let fieldOrder = fieldOrderMetadata.Count() > 0 ? fieldOrderMetadata.First() : int.MaxValue
                                                                                                                                                         //let sort = !string.IsNullOrEmpty(fieldSort) ? int.Parse(fieldSort) : int.MaxValue
                                                                                                                                                                          orderby fieldOrder ascending, filedName ascending
                    select new
                {
                    TableId    = tableId,
                    FieldId    = groupByField.Key,
                    FieldName  = filedName,
                    FieldOrder = fieldOrder,
                    //FieldSuppress = false,
                    Data = groupByField,
                    DiseaseAttributes = from record in groupByField
                                        where !record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId)
                                        select record
                };
                MetadataGrid.DataSource = tableToAttributes;
                MetadataGrid.DataBind();

                // build fields without metadata
                MetadataTable biz = new MetadataTable();
                biz.Get(tableId.Value);

                MetadataNewDa MNDa = new MetadataNewDa();
                DataTable     cols = MNDa.GetTableColumns(tableId.Value, biz[MetadataTable.TableName_Field].ToString());
                // build a list of actual fields not yet assigned metadata
                var nonMetadataFields = from row in cols.AsEnumerable()
                                        select new
                {
                    COLUMN_NAME  = row["COLUMN_NAME"].ToString(),
                    DATA_TYPE    = row["DATA_TYPE"].ToString(),
                    CHAR_MAX_LEN = row["CHAR_MAX_LEN"].ToString(),
                    IS_VIRTUAL   = false
                };
                // build blank rows for new virtual fields
                var blankVirtualFields = from i in Enumerable.Range(0, 1)
                                         select new
                {
                    COLUMN_NAME  = string.Empty,
                    DATA_TYPE    = string.Empty,
                    CHAR_MAX_LEN = string.Empty,
                    IS_VIRTUAL   = true
                };
                var dataSource = nonMetadataFields.Concat(blankVirtualFields);
                NonMetadataFields.DataSource = dataSource;
                NonMetadataFields.DataBind();
            }
        }