示例#1
0
 private List<ColumnMetaInfo> QueryColumns(string connString, object ob, string tableName)
 {
     
     List<FKSpecification> fkList = ForeignKeyUtils.QueryForeignKeyRelationships(connString, tableName);
     List<ColumnMetaInfo> colList = new List<ColumnMetaInfo>();
     foreach (PropertyInfo pi in ob.GetType().GetProperties())
     {
         MemberTypes mt = pi.MemberType;
         string val = mt.ToString();
         PropertyAttributes patt = pi.Attributes;
         string nm = pi.PropertyType.Name;
         String name = pi.Name;
         FKSpecification fkSpec = null;
         bool hasFK = LookupFKForColumn(name, out fkSpec, fkList);
         Type rt = pi.GetMethod.ReturnType;
         string tName = GuessMainType(rt.FullName);
         ColumnMetaInfo cmi = new ColumnMetaInfo() { columnName = name, fkSpec = fkSpec, hasFK = hasFK, dbTypeName = tName };
         colList.Add(cmi);
     }
     return colList;
 }
示例#2
0
        public List<ColumnMetaInfo> GetCoalQualityColumns(string connectionString)
        {
            List<ColumnMetaInfo> colList = new List<ColumnMetaInfo>();

            List<FKSpecification> fkList = ForeignKeyUtils.QueryForeignKeyRelationships(connectionString, "X_Sample");

            Sample xag = new Sample();
            QueryColumnData(colList, fkList, xag);
            AssayGroupTestResult xtr = new AssayGroupTestResult();
            fkList = ForeignKeyUtils.QueryForeignKeyRelationships(connectionString, "X_AssayGroupTestResult");
            QueryColumnData(colList, fkList, xtr);

            List<string> removeStubs = new List<string>();
            removeStubs.Add("SampleCategoryID");
            removeStubs.Add("SampleStateID");
            removeStubs.Add("SampleTypeID");
            //removeStubs.Add("Sample");
            removeStubs.Add("Assay");
            removeStubs.Add("Version");
            removeStubs.Add("Dict");
            List<ColumnMetaInfo> colListP = new List<ColumnMetaInfo>();
            colListP = PruneColumnList(removeStubs, colList);

            ColumnMetaInfo ci5 = new ColumnMetaInfo();
            ci5.columnName = "[RESULT]";
            ci5.fkSpec = null;
            colListP.Insert(0, ci5);
            

            ColumnMetaInfo ci4 = new ColumnMetaInfo();
            ci4.columnName = "[WASH FRACTION]";
            ci4.fkSpec = null;
            colListP.Insert(0, ci4);

            ColumnMetaInfo ci3 = new ColumnMetaInfo();
            ci3.columnName = "[SIZE FRACTION]";
            ci3.fkSpec = null;
            colListP.Insert(0, ci3);

            ColumnMetaInfo ci2 = new ColumnMetaInfo();
            ci2.columnName = "[STAGE]";
            ci2.isMandatory = true;
            ci2.fkSpec = null;
            colListP.Insert(0, ci2);

            ColumnMetaInfo ci0 = new ColumnMetaInfo();
            ci0.columnName = "[PROGRAM]";
            ci0.isMandatory = true;
            ci0.fkSpec = null;
            colListP.Insert(0, ci0);

            // now mark only the mandatory fields - for assay this will be header id, from, to and result
            foreach (ColumnMetaInfo c in colListP) {
                
                if (c.columnName.Equals("HeaderID")) {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("FromDepth")) {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("ToDepth")) {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("SampleID"))
                {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("[PROCESS]"))
                {
                    c.isMandatory = false;
                }
                else if (c.columnName.Equals("[SCREEN]"))
                {
                    c.isMandatory = false;
                }
                else if (c.columnName.Equals("[FLOAT]"))
                {
                    c.isMandatory = false;
                }
                else if (c.columnName.Equals("[QUALITY]"))
                {
                    c.isMandatory = false;
                }
            }

            return colListP;
        }
示例#3
0
        private void QueryColumnData(List<ColumnMetaInfo> colList, List<FKSpecification> fkList, object xag)
        {
            foreach (PropertyInfo pi in xag.GetType().GetProperties())
            {

                MemberTypes mt = pi.MemberType;
                string val = mt.ToString();
                PropertyAttributes patt = pi.Attributes;
                string nm = pi.PropertyType.Name;
                String name = pi.Name;
                Type rt = pi.GetMethod.ReturnType;
                string tName = GuessMainType(rt.FullName);

                FKSpecification fkSpec = null;

                bool hasFK = LookupFKForColumn(name, out fkSpec, fkList);
                ColumnMetaInfo cmi = new ColumnMetaInfo() { columnName = name, fkSpec = fkSpec, hasFK = hasFK, dbTypeName = tName };
                colList.Add(cmi);
            }
        }
示例#4
0
        public List<ColumnMetaInfo> GetAssayColumns(string connectionString)
        {
            List<ColumnMetaInfo> colList = new List<ColumnMetaInfo>();

            List<FKSpecification> fkList = ForeignKeyUtils.QueryForeignKeyRelationships(connectionString, "X_Sample");

            Sample xag = new Sample();
            QueryColumnData(colList, fkList, xag);
            AssayGroupTestResult xtr = new AssayGroupTestResult();
            fkList = ForeignKeyUtils.QueryForeignKeyRelationships(connectionString, "X_AssayGroupTestResult");
            QueryColumnData(colList, fkList, xtr);

            List<string> removeStubs = new List<string>();
            removeStubs.Add("Sample");
            removeStubs.Add("Assay");
            removeStubs.Add("Version");
            removeStubs.Add("Dict");
            List<ColumnMetaInfo> colListP = new List<ColumnMetaInfo>();
            colListP = PruneColumnList(removeStubs, colList);
            ColumnMetaInfo ci = new ColumnMetaInfo();
            ci.columnName = "[ASSAY RESULT]";
            ci.fkSpec = null;
            colListP.Insert(0,ci);
            ColumnMetaInfo ci2 = new ColumnMetaInfo();
            ci2.columnName = "SampleNumber";
            ci2.fkSpec = null;
            colListP.Insert(1, ci2);
            ColumnMetaInfo ci3 = new ColumnMetaInfo();
            ci3.columnName = "SampleMassKg";
            ci3.fkSpec = null;
            colListP.Insert(2, ci3);
            ColumnMetaInfo ci4 = new ColumnMetaInfo();
            ci4.columnName = "StandardSampleTypeName";
            ci4.fkSpec = null;
            colListP.Insert(3, ci4);


            // now mark only the mandatory fields - for assay this will be header id, from, to and result
            foreach (ColumnMetaInfo c in colListP) {
                
                if (c.columnName.Equals("HeaderID")) {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("FromDepth")) {
                    c.isMandatory = true;
                }
                else if (c.columnName.Equals("ToDepth")) {
                    c.isMandatory = true;
                }
            }

            return colListP;
        }