Beispiel #1
0
        public TableInfo Filter(TagInfo tags)
        {
            var tableInfo = this;

            tableInfo.Columns   = tableInfo.Columns.Where(item => (item.DerivedTags & tags) != TagInfo.Unused).ToArray();
            tableInfo.HashValue = CremaDataTable.GenerateHashValue(tableInfo.Columns);
            return(tableInfo);
        }
Beispiel #2
0
        public CremaDataTable Copy()
        {
            var tables    = this.Parent != null ? this.Parent.Childs : (this.DataSet != null ? this.DataSet.Tables : Enumerable.Empty <CremaDataTable>());
            var tableName = NameUtility.GenerateNewName("CopiedTable", tables.Select(item => item.TableName));
            var name      = CremaDataTable.GenerateName(this.ParentName, tableName);

            return(this.Copy(name));
        }
Beispiel #3
0
        public CremaDataRow[] GetChildRows(CremaDataTable childTable)
        {
            if (childTable.Parent != this.Table)
            {
                return(null);
            }

            var relationName = InternalSetBase.GenerateRelationName(childTable.InternalObject);

            return(this.InternalObject.GetChildRows(relationName).Select(item => (item as InternalDataRow).Target).ToArray());
        }
 // mac의 mono 환경에서 DataTable.AsDataView 메소드가 없다고 예외가 발생함.
 // 따라서 플랫폼에 따라서 다르게 호출되도록 구현을 해놓음.
 // 특히 보기 좋게 하려고 아래와 같이 한줄로 표현할 경우 아예 메소드 호출이 되질않음
 // var view = Environment.OSVersion.Platform == PlatformID.Unix ? new DataView(template.InternalObject) : template.InternalObject.AsDataView();
 public static DataView AsDataView(this CremaDataTable table)
 {
     if (Environment.OSVersion.Platform == PlatformID.Unix)
     {
         var view = AsDataViewUnix(table.InternalObject);
         view.Sort = string.Join(",", table.Columns.Select(item => item.ColumnName));
         return(view);
     }
     else
     {
         var view = AsDataViewNormal(table.InternalObject);
         view.Sort = string.Join(",", table.Columns.Select(item => item.ColumnName));
         return(view);
     }
 }
Beispiel #5
0
        public CremaTemplate(CremaDataTable targetTable)
        {
            if (targetTable == null)
            {
                throw new ArgumentNullException(nameof(targetTable));
            }
            if (targetTable.TemplateNamespace != string.Empty)
            {
                throw new ArgumentException(Resources.Exception_CannotEditInheritedTable, nameof(targetTable));
            }

            this.builder        = new CremaTemplateColumnBuilder(this);
            this.InternalObject = new InternalTemplate(this, this.builder)
            {
                TargetTable = (InternalDataTable)targetTable
            };
            this.Attributes = new CremaAttributeCollection(this.InternalObject);
            this.Columns    = new CremaTemplateColumnCollection(this.InternalObject);

            this.AttachEventHandlers();
        }
Beispiel #6
0
        public CremaDataTable Copy(ItemName itemName, bool copyData)
        {
            this.ValidateCopy(itemName);

            if (this.DataSet != null)
            {
                {
                    var items     = EnumerableUtility.FamilyTree(this, item => item.Childs);
                    var tableList = new List <CremaDataTable>(items.Count());
                    foreach (var item in items)
                    {
                        var schema = item.GetXmlSchema();
                        var xml    = copyData == true?item.GetXml() : null;

                        var newName = new ItemName(itemName.CategoryPath, itemName.Name + item.Name.Substring(this.Name.Length));
                        this.DataSet.ReadXmlSchemaString(schema, newName);
                        if (xml != null)
                        {
                            this.DataSet.ReadXmlString(xml, newName);
                        }
                        var newTable = this.DataSet.Tables[newName.Name, newName.CategoryPath];
                        newTable.SourceTable = item;
                        tableList.Add(newTable);
                    }

                    var signatureDate = this.SignatureDateProvider.Provide();
                    foreach (var item in tableList)
                    {
                        item.InternalTemplatedParent = null;
                        item.InternalTableID         = Guid.NewGuid();
                        item.InternalCreationInfo    = signatureDate;
                    }
                }

                var dataTable = this.DataSet.Tables[itemName.Name, itemName.CategoryPath];
                if (dataTable.Parent != null)
                {
                    foreach (var item in this.DerivedTables.ToArray())
                    {
                        var newName = item.ParentName + itemName.Name.Substring(this.ParentName.Length);
                        dataTable.InheritInternal(new ItemName(item.CategoryPath, newName), copyData);
                    }
                }

                return(dataTable);
            }
            else
            {
                var schema = this.GetXmlSchema();
                var xml    = copyData == true?this.GetXml() : null;

                using var sr     = new StringReader(schema);
                using var reader = XmlReader.Create(sr);
                var dataTable = CremaDataTable.ReadSchema(reader, itemName);
                if (xml != null)
                {
                    dataTable.ReadXmlString(xml);
                }
                return(dataTable);
            }
        }
Beispiel #7
0
        public static CremaTemplate Create(CremaDataTable parentTable)
        {
            var dataTable = parentTable.Childs.Add();

            return(new CremaTemplate(dataTable));
        }
 internal CremaDataRowBuilder(CremaDataTable table)
 {
     this.table = table;
 }