예제 #1
0
        public override string ToString()
        {
            string xml = string.Empty;

            try
            {
                LevelExpandSchemaDoc  doc = new LevelExpandSchemaDoc();
                LevelExpandSchemaType xmlLevelExpandSchema = new LevelExpandSchemaType();
                doc.SetRootElementName("", "LevelExpandSchema");

                DesignTimeExpandItemsType xmlDesignTimeExpandItems = new DesignTimeExpandItemsType();
                foreach (LevelExpandItem lei in this._designTimeLevelExpandItems)
                {
                    LevelExpandItemType xmlLevelExpandItem = new LevelExpandItemType();
                    xmlLevelExpandItem.AddDepth(new Altova.Types.SchemaLong(lei.Depth));
                    xmlLevelExpandItem.AddLevelExpandType(new Altova.Types.SchemaLong((long)lei.ExpandType));
                    xmlLevelExpandItem.AddColumnName(new Altova.Types.SchemaString(lei.ColumnName));
                    xmlDesignTimeExpandItems.AddLevelExpandItem(xmlLevelExpandItem);
                }
                xmlLevelExpandSchema.AddDesignTimeExpandItems(xmlDesignTimeExpandItems);

                ReportLevelExpandsType xmlReportLevelExpands = new ReportLevelExpandsType();
                foreach (ReportLevelExpand rle in this._reportLevelExpands)
                {
                    ReportLevelExpandType xmlReportLevelExpand = new ReportLevelExpandType();
                    xmlReportLevelExpand.AddIsDefault(new Altova.Types.SchemaBoolean(rle.IsDefault));
                    xmlReportLevelExpand.AddName(new Altova.Types.SchemaString(rle.Name));

                    foreach (LevelExpandItem lei in rle.LevelExpandItems)
                    {
                        LevelExpandItemType xmlLevelExpandItem = new LevelExpandItemType();

                        xmlLevelExpandItem.AddDepth(new Altova.Types.SchemaLong(lei.Depth));
                        xmlLevelExpandItem.AddLevelExpandType(new Altova.Types.SchemaLong((long)lei.ExpandType));
                        xmlLevelExpandItem.AddColumnName(new Altova.Types.SchemaString(lei.ColumnName));

                        xmlReportLevelExpand.AddLevelExpandItem(xmlLevelExpandItem);
                    }
                    xmlReportLevelExpands.AddReportLevelExpand(xmlReportLevelExpand);
                }
                xmlLevelExpandSchema.AddReportLevelExpands(xmlReportLevelExpands);
                xml = doc.SaveToString(xmlLevelExpandSchema);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }

            return(xml);
        }
예제 #2
0
        public void LoadFromString(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return;
            }
            try
            {
                LevelExpandSchemaDoc  doc = new LevelExpandSchemaDoc();
                LevelExpandSchemaType xmlLevelExpandSchema = new LevelExpandSchemaType(doc.LoadFromString(xml));

                int count = xmlLevelExpandSchema.GetDesignTimeExpandItems().GetLevelExpandItemCount();
                for (int i = 0; i < count; i++)
                {
                    LevelExpandItem lei = new LevelExpandItem();
                    lei.ColumnName = xmlLevelExpandSchema.GetDesignTimeExpandItems().GetLevelExpandItemAt(i).ColumnName.Value;
                    lei.Depth      = (int)xmlLevelExpandSchema.GetDesignTimeExpandItems().GetLevelExpandItemAt(i).Depth.Value;
                    lei.ExpandType = (LevelExpandEnum)xmlLevelExpandSchema.GetDesignTimeExpandItems().GetLevelExpandItemAt(i).LevelExpandType.Value;
                    this._designTimeLevelExpandItems.Add(lei);
                }

                count = xmlLevelExpandSchema.GetReportLevelExpands().GetReportLevelExpandCount();
                for (int i = 0; i < count; i++)
                {
                    ReportLevelExpand     rle = new ReportLevelExpand();
                    ReportLevelExpandType xmlReportLevelExpand = xmlLevelExpandSchema.GetReportLevelExpands().GetReportLevelExpandAt(i);

                    rle.IsDefault = xmlReportLevelExpand.IsDefault.Value;
                    rle.Name      = xmlReportLevelExpand.Name.Value;

                    int itemCount = xmlReportLevelExpand.GetLevelExpandItemCount();
                    for (int j = 0; j < itemCount; j++)
                    {
                        LevelExpandItem lei = new LevelExpandItem();
                        lei.ColumnName = xmlReportLevelExpand.GetLevelExpandItemAt(j).ColumnName.Value;
                        lei.Depth      = (int)xmlReportLevelExpand.GetLevelExpandItemAt(j).Depth.Value;
                        lei.ExpandType = (LevelExpandEnum)xmlReportLevelExpand.GetLevelExpandItemAt(j).LevelExpandType.Value;

                        rle.AddLevelExpand(lei);
                    }

                    this._reportLevelExpands.Add(rle);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.Message);
            }
        }