public void ReadDataDictionary()
        {
            Table.TableList = new List<Table>();//am i haveing trouble with this static field?
            using(StreamReader reader = this.GetDataDictionaryReader())
            {
                reader.ReadLine(); //skip header

                String[] row = reader.ReadLine().Split(',');
                Table currentTable = new Table();
                currentTable.ReadLine(row);
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    row = line.Split(',');
                    currentTable = currentTable.ReadLine(row);
                }

                foreach(Table t in Table.TableList)
                {
                    this.AllTables.Add(t.Name, t);
                }
            }
        }
示例#2
0
        public Table ReadLine(String[] row)
        {
            string tName = row[Table_Ord].Trim();
            if (Name == null)
            {
                Name = tName;
                TableList.Add(this);
            }
            else if (Name != tName)
            {
                Table newTable = new Table(tName);
                newTable.ReadLine(row);
                TableList.Add(newTable);
                return newTable;
            }
            //if(IsMarked(row[Depreciated_Ord])) { return this; }

            //if (DEPRECIATED_FIELDNAMES.Contains(row[Column_Ord])) { return this; }

            Field newField = new Field
            {
                Name = row[Column_Ord],
                Type = row[Type_Ord],
                IsPK = IsMarked(row[PK_Ord]),
                IsAutoI = IsMarked(row[AutoI_Ord]),
                IsTransitionalPK = IsMarked(row[TPK_Ord]),
                IsUnique = IsMarked(row[Unique_Ord]),
                IsFK = IsMarked(row[FK_Ord]),
                IsReq = IsMarked(row[Req_Ord]),
                Default = row[Default_Ord].Replace("\"",String.Empty),
                NotNull = IsMarked(row[NotNull_Ord]),
                Min = (!String.IsNullOrEmpty(row[Min_Ord])) ? (float?)Convert.ToSingle(row[Min_Ord]) : null,
                Max = (!String.IsNullOrEmpty(row[Max_Ord])) ? (float?)Convert.ToSingle(row[Max_Ord]) : null,
                Values = row[Values_Ord],
                ErrorMessage = row[ErrorMessage_Ord],
                Description = row[Description_Ord],
                IsDepreciated = IsMarked(row[Depreciated_Ord]),
                DontTrackChanges = IsMarked(row[DontTrackChanges_Ord])
            };

            if (newField.IsTransitionalPK)
            {
                this.HasTransitionalPK = true;
            }

            if (newField.IsPK == true)
            {
                PKFields.Add(newField);

            }
            else if (newField.IsFK == true)
            {
                newField.Ref = row[Ref_Ord];
                FKFields.Add(newField);
            }
            else { DataFields.Add(newField); }

            if(UTILITY_FIELDS.Contains(newField.Name))
            {
                newField.DontTrackChanges = true;
            }

            if (newField.IsUnique == true) { UniqueFields.Add(newField); }
            Fields.Add(newField);

            if (newField.Min != null || newField.Max != null || !String.IsNullOrEmpty(newField.Values))
            {
                AuditFields.Add(newField);
            }

            //TODO comment out
            //? I guess if a table has no non depreciated fields then it is depreciated,
            if (newField.IsDepreciated == false)
            {
                this.IsDepreciated = false;
            }

            if (!newField.DontTrackChanges)
            {
                this.TrackedFields.Add(newField);
            }
            return this;
        }