示例#1
0
        /* ==================================================================================================== Fill Data */

        private static void CreateData(DataSet dataSet, RepositorySchemaData schema)
        {
            var propertyTypes = dataSet.Tables[TableName.PropertyTypes];

            foreach (var propertyType in schema.PropertyTypes)
            {
                var row = propertyTypes.NewRow();
                SetPropertyTypeRow(row, propertyType);
                propertyTypes.Rows.Add(row);
            }

            var nodeTypes = dataSet.Tables[TableName.NodeTypes];

            foreach (var nodeType in schema.NodeTypes)
            {
                var row = nodeTypes.NewRow();
                SetNodeTypeRow(row, nodeType, schema.NodeTypes);
                nodeTypes.Rows.Add(row);
            }

            var contentListTypes = dataSet.Tables[TableName.ContentListTypes];

            foreach (var contentListType in schema.ContentListTypes)
            {
                var row = contentListTypes.NewRow();
                SetContentListTypeRow(row, contentListType);
                contentListTypes.Rows.Add(row);
            }
        }
示例#2
0
        public override async Task WriteSchemaAsync(RepositorySchemaData schema)
        {
            var propertyTypes = schema.PropertyTypes.Where(x => x.Id == 0).ToArray();

            if (propertyTypes.Any())
            {
                var lastId = schema.PropertyTypes.Max(x => x.Id);
                foreach (var propertyType in propertyTypes)
                {
                    propertyType.Id = ++lastId;
                }
            }
            var nodeTypes = schema.NodeTypes.Where(x => x.Id == 0).ToArray();

            if (nodeTypes.Any())
            {
                var lastId = schema.NodeTypes.Max(x => x.Id);
                foreach (var nodeType in nodeTypes)
                {
                    nodeType.Id = ++lastId;
                }
            }
            var contentListTypes = schema.ContentListTypes.Where(x => x.Id == 0).ToArray();

            if (contentListTypes.Any())
            {
                var lastId = schema.ContentListTypes.Max(x => x.Id);
                foreach (var contentListType in contentListTypes)
                {
                    contentListType.Id = ++lastId;
                }
            }
            await MsSqlSchemaInstaller.InstallSchemaAsync(schema).ConfigureAwait(false);
        }
示例#3
0
        // -------------------------------------------------------------------------------- Load from RepositorySchemaData

        private void Load(RepositorySchemaData schemaData)
        {
            BuildPropertyTypes(schemaData.PropertyTypes);
            BuildNodeTypes(schemaData.NodeTypes);
            BuildContentListTypes(schemaData.ContentListTypes);

            SchemaTimestamp = schemaData.Timestamp;
        }
示例#4
0
        public static async Task InstallSchemaAsync(RepositorySchemaData schema, string connectionString = null)
        {
            var dataSet = new DataSet();

            CreateTableStructure(dataSet);

            _columnNames = dataSet.Tables.Cast <DataTable>().ToDictionary(
                table => table.TableName,
                table => table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray());

            CreateData(dataSet, schema);

            await WriteToDatabaseAsync(dataSet, connectionString).ConfigureAwait(false);
        }
示例#5
0
 public abstract Task WriteSchemaAsync(RepositorySchemaData schema);
示例#6
0
 public override Task WriteSchemaAsync(RepositorySchemaData schema)
 {
     throw new NotSupportedException();
 }
示例#7
0
 public InMemorySchemaWriter(RepositorySchemaData originalSchema, Action finishedCallback)
 {
     _schema           = originalSchema;
     _finishedCallback = finishedCallback;
 }
示例#8
0
 public override System.Threading.Tasks.Task WriteSchemaAsync(RepositorySchemaData schema)
 {
     throw new NotSupportedException();
 }