public void CreateDataSetSchemaMetaInformation(WorkEntity workEntity) { if (uowImpl == null) uowImpl = UnitOfWork.Start(); if (workEntity == null) return; if (DataHolder.ImportType == ImportType.Append) { TableInfo ti = UnitOfWork.CurrentSession.Get<TableInfo>(DataHolder.ParentTable.Id); TableInformation = ti; SchemaInformation = ti.Schema; DataHolder.Data = new DataSet(); DataHolder.Data.ReadXml(new XmlNodeReader(ti.Storage)); for (int i = 0; i< DataHolder.Columns.Count; i++) { ImportColumn ic = DataHolder.Columns[i]; bool found = false; foreach (SchemaColumn sc in SchemaInformation.Columns.Where(sc => sc.OrigName == ic.OrigName)) found = true; if (!found) { SchemaColumn sc = new SchemaColumn(); sc.Name = ic.Name; sc.OrigName = ic.OrigName; sc.Schema = SchemaInformation; sc.Type = ic.StorageType; sc.ValidBegin = DateTime.Now; sc.ColOrder = i+1; // The _UniqueRow is already added. if (!String.IsNullOrEmpty(ic.DateFormat)) sc.DateFormat = ic.DateFormat; UnitOfWork.CurrentSession.Save(sc); SchemaInformation.Columns.Add(sc); DataHolder.Data.Tables[0].Columns.Add(sc.OrigName); } // Loop though the new added stuff. } } else { SchemaInfo schema = new SchemaInfo(); schema.ValidBegin = DateTime.Now; //schema.SchemaParent = latestSchema; schema.Name = "Import Demo"; UnitOfWork.CurrentSession.Save(schema); UnitOfWork.CurrentSession.Flush(); for (int i = 0; i < DataHolder.Columns.Count;i++ ) { ImportColumn ic = DataHolder.Columns[i]; SchemaColumn sc = new SchemaColumn(); sc.Name = ic.Name; sc.OrigName = ic.OrigName; sc.Schema = schema; sc.Type = ic.StorageType; sc.ValidBegin = DateTime.Now; sc.ColOrder = i; if (!String.IsNullOrEmpty(ic.DateFormat)) sc.DateFormat = ic.DateFormat; UnitOfWork.CurrentSession.Save(sc); schema.Columns.Add(sc); } SchemaInformation = schema; } workEntity.Completed = true; }
public void CreateDataSetTableMetaInformation(WorkEntity workEntity) { if (uowImpl == null) uowImpl = UnitOfWork.Start(); if (SchemaInformation == null) return; if (DataHolder.ImportType != ImportType.Append) { TableInfo ti = new TableInfo(); ti.TableDescription = DataHolder.TableDescription; ti.ValidBegin = DateTime.Now; ti.Schema = SchemaInformation; ti.Dataset = workEntity.WorkingDataset; if (DataHolder.ParentTable != null) ti.Parents.Add(DataHolder.ParentTable); UnitOfWork.CurrentSession.Save(ti); TableInformation = ti; } if (workEntity != null) workEntity.Completed = true; }