예제 #1
0
        public SerializationSet Serialize(TagInfo tags, string filterExpression, bool isDevmode, long revision)
        {
            this.Dispatcher.VerifyAccess();

            if (filterExpression == null)
            {
                throw new ArgumentNullException(nameof(filterExpression));
            }

            if (revision == -1)
            {
                var cacheKey = tags.ToString() + filterExpression;

                if (isDevmode == false && this.caches.ContainsKey(cacheKey) == true)
                {
                    return(this.caches[cacheKey]);
                }

                var dataSet = new SerializationSet()
                {
                    Name     = this.DataBaseName,
                    Revision = this.Revision,
                };

                var tableItems = this.ReadTables(isDevmode);
                dataSet.Tables = tableItems.Cast <SerializationTable>().ToArray();

                var typeItems = this.ReadTypes(isDevmode);
                dataSet.Types = typeItems.Cast <SerializationType>().ToArray();

                dataSet = dataSet.Filter(tags);
                if (filterExpression != string.Empty)
                {
                    dataSet = dataSet.Filter(filterExpression);
                }

                if (isDevmode == false)
                {
                    this.caches[cacheKey] = dataSet;
                }

                return(dataSet);
            }
            else
            {
                var dataSet       = this.DataBase.GetDataSet(this.authentication, revision);
                var serializedSet = new SerializationSet(dataSet)
                {
                    Name     = this.DataBaseName,
                    Revision = this.Revision,
                };
                serializedSet = serializedSet.Filter(tags);
                if (filterExpression != string.Empty)
                {
                    serializedSet = serializedSet.Filter(filterExpression);
                }
                return(serializedSet);
            }
        }
예제 #2
0
        private ZipFileResultEntry[] SerializePerTable(SerializationSet serializationSet, DataRequest request)
        {
            var filteredMetaDataList = new List <SerializationSet>();

            foreach (var table in serializationSet.Tables)
            {
                var filteredMetaData = serializationSet.Filter(table.Name);
                filteredMetaData = ReplaceOptionProcessor.Process(filteredMetaData, request);

                if (filteredMetaData.Tables.Any())
                {
                    filteredMetaDataList.Add(filteredMetaData);
                }
            }

            var entries = new List <ZipFileResultEntry>();

            foreach (var dataSet in filteredMetaDataList)
            {
                var filename = $"{dataSet.Tables[0].Name}.{request.Ext}";
                var serializationSetStream = new MemoryStream();
                var serializer             = this.GetDataSerializer(request.OutputType);
                serializer.Serialize(serializationSetStream, dataSet);

                entries.Add(new ZipFileResultEntry(filename, serializationSetStream));
            }

            return(entries.ToArray());
        }
예제 #3
0
        private void SerializePerTable(SerializationSet metaData)
        {
            var filteredMetaDataList = new List <SerializationSet>();

            foreach (var table in metaData.Tables)
            {
                var filteredMetaData = metaData.Filter(table.Name);
                filteredMetaData = ReplaceOptionProcessor.Process(filteredMetaData);

                if (filteredMetaData.Tables.Any())
                {
                    filteredMetaDataList.Add(filteredMetaData);
                }
            }

            foreach (var dataSet in filteredMetaDataList)
            {
                var filepath   = Path.Combine(this.Filename, $"{dataSet.Tables[0].Name}.{DataSplitSetting.Ext}");
                var serializer = this.GetDataSerializer(this.OutputType);
                serializer.Serialize(filepath, dataSet);
            }
        }