コード例 #1
0
        public TableReportContext DeserializeTableReport(byte[] data)
        {
            try
            {
                ReportDef def;

                var s   = Encoding.UTF8.GetString(data).TrimEnd('\0');
                var pos = s.IndexOf("<", StringComparison.Ordinal);
                if (pos > 0)
                {
                    s = s.Substring(pos);
                }

                //using (var stream = new StringStream(data))
                {
                    using (var streamReader = new StringReader(s /*, Encoding.UTF8*/))
                    {
                        var settings = new XmlReaderSettings
                        {
                            CheckCharacters = false
                        };
                        using (var reader = XmlTextReader.Create(streamReader, settings))
                        {
                            var serializer = new XmlSerializer(typeof(ReportDef));
                            def = (ReportDef)serializer.Deserialize(reader);
                        }
                    }
                }
                var relations = def.Sources.Select(sourceDef =>
                                                   new ReportSourceRelations
                {
                    SourceId  = sourceDef.Id,
                    Relations = new List <DocDefRelation>(DocDefRepo.GetDocDefRelations(sourceDef.DocDef.Id))
                }).ToList();

                var context = new TableReportContext
                {
                    Def             = def,
                    SourceRelations = relations
                };

                return(context);
            }
            catch (Exception e)
            {
                try
                {
                    var fn = Logger.GetLogFileName("ReportManagerError");
                    Logger.OutputLog(fn, e, "DeserializeReportDef Error");
                }
                catch
                {
                    ;
                }
                throw;
            }
        }
コード例 #2
0
        public TableReportContext CreateTableReport(Guid docDefId)
        {
            var docDef          = DocDefRepo.DocDefById(docDefId);
            var docDefRelations = DocDefRepo.GetDocDefRelations(docDefId);

            // var sourceItemId = Guid.NewGuid();
            var def     = ReportDefHelper.Create(docDef);
            var context = new TableReportContext
            {
                Def             = def,
                SourceRelations =
                    new List <ReportSourceRelations>(new[]
                {
                    new ReportSourceRelations
                    {
                        SourceId  = def.SourceId,
                        Relations = new List <DocDefRelation>(docDefRelations)
                    }
                })
            };

            return(context);
        }
コード例 #3
0
        public TableReportContext JoinTableReportSource(TableReportContext context, Guid masterSourceId, Guid docDefId, Guid attrDefId)
        {
            var joinDef = context.Def.JoinDocDefSource(masterSourceId, DocDefRepo.DocDefById(docDefId), attrDefId);

            var docDefNames = DocDefRepo.GetDocDefNames();
            var relations   =
                DocDefRepo.GetDocDefRelations(docDefId)
                .Where(
                    r => docDefNames.Any(dd => dd.Id == r.DocDefId) && docDefNames.Any(dd => dd.Id == r.RefDocDefId))
                .ToList();

            if (context.SourceRelations == null)
            {
                context.SourceRelations = new List <ReportSourceRelations>();
            }
            context.SourceRelations.Add(
                new ReportSourceRelations
            {
                SourceId  = joinDef.SourceId,
                Relations = relations
            });

            return(context);
        }