internal PivotCacheRecord ToPivotCacheRecord() { PivotCacheRecord pcr = new PivotCacheRecord(); foreach (SLPivotCacheRecordItemsTypeIndexPair pair in this.Items) { switch (pair.Type) { case SLPivotCacheRecordItemsType.Missing: pcr.Append(this.MissingItems[pair.Index].ToMissingItem()); break; case SLPivotCacheRecordItemsType.Number: pcr.Append(this.NumberItems[pair.Index].ToNumberItem()); break; case SLPivotCacheRecordItemsType.Boolean: pcr.Append(this.BooleanItems[pair.Index].ToBooleanItem()); break; case SLPivotCacheRecordItemsType.Error: pcr.Append(this.ErrorItems[pair.Index].ToErrorItem()); break; case SLPivotCacheRecordItemsType.String: pcr.Append(this.StringItems[pair.Index].ToStringItem()); break; case SLPivotCacheRecordItemsType.DateTime: pcr.Append(this.DateTimeItems[pair.Index].ToDateTimeItem()); break; case SLPivotCacheRecordItemsType.Field: pcr.Append(new FieldItem() { Val = this.FieldItems[pair.Index] }); break; } } return(pcr); }
internal PivotCacheRecord ToPivotCacheRecord() { var pcr = new PivotCacheRecord(); foreach (var pair in Items) { switch (pair.Type) { case SLPivotCacheRecordItemsType.Missing: pcr.Append(MissingItems[pair.Index].ToMissingItem()); break; case SLPivotCacheRecordItemsType.Number: pcr.Append(NumberItems[pair.Index].ToNumberItem()); break; case SLPivotCacheRecordItemsType.Boolean: pcr.Append(BooleanItems[pair.Index].ToBooleanItem()); break; case SLPivotCacheRecordItemsType.Error: pcr.Append(ErrorItems[pair.Index].ToErrorItem()); break; case SLPivotCacheRecordItemsType.String: pcr.Append(StringItems[pair.Index].ToStringItem()); break; case SLPivotCacheRecordItemsType.DateTime: pcr.Append(DateTimeItems[pair.Index].ToDateTimeItem()); break; case SLPivotCacheRecordItemsType.Field: pcr.Append(new FieldItem { Val = FieldItems[pair.Index] }); break; } } return(pcr); }
internal PivotCacheRecord ToPivotCacheRecord() { PivotCacheRecord pcr = new PivotCacheRecord(); foreach (SLPivotCacheRecordItemsTypeIndexPair pair in this.Items) { switch (pair.Type) { case SLPivotCacheRecordItemsType.Missing: pcr.Append(this.MissingItems[pair.Index].ToMissingItem()); break; case SLPivotCacheRecordItemsType.Number: pcr.Append(this.NumberItems[pair.Index].ToNumberItem()); break; case SLPivotCacheRecordItemsType.Boolean: pcr.Append(this.BooleanItems[pair.Index].ToBooleanItem()); break; case SLPivotCacheRecordItemsType.Error: pcr.Append(this.ErrorItems[pair.Index].ToErrorItem()); break; case SLPivotCacheRecordItemsType.String: pcr.Append(this.StringItems[pair.Index].ToStringItem()); break; case SLPivotCacheRecordItemsType.DateTime: pcr.Append(this.DateTimeItems[pair.Index].ToDateTimeItem()); break; case SLPivotCacheRecordItemsType.Field: pcr.Append(new FieldItem() { Val = this.FieldItems[pair.Index] }); break; } } return pcr; }
internal void FromPivotCacheRecord(PivotCacheRecord pcr) { this.SetAllNull(); SLMissingItem mi; SLNumberItem ni; SLBooleanItem bi; SLErrorItem ei; SLStringItem si; SLDateTimeItem dti; FieldItem fi; using (OpenXmlReader oxr = OpenXmlReader.Create(pcr)) { while (oxr.Read()) { // make sure to add to Items first, because of the Count thing. if (oxr.ElementType == typeof(MissingItem)) { mi = new SLMissingItem(); mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Missing, this.MissingItems.Count)); this.MissingItems.Add(mi); } else if (oxr.ElementType == typeof(NumberItem)) { ni = new SLNumberItem(); ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Number, this.NumberItems.Count)); this.NumberItems.Add(ni); } else if (oxr.ElementType == typeof(BooleanItem)) { bi = new SLBooleanItem(); bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Boolean, this.BooleanItems.Count)); this.BooleanItems.Add(bi); } else if (oxr.ElementType == typeof(ErrorItem)) { ei = new SLErrorItem(); ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Error, this.ErrorItems.Count)); this.ErrorItems.Add(ei); } else if (oxr.ElementType == typeof(StringItem)) { si = new SLStringItem(); si.FromStringItem((StringItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.String, this.StringItems.Count)); this.StringItems.Add(si); } else if (oxr.ElementType == typeof(DateTimeItem)) { dti = new SLDateTimeItem(); dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement()); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.DateTime, this.DateTimeItems.Count)); this.DateTimeItems.Add(dti); } else if (oxr.ElementType == typeof(FieldItem)) { fi = (FieldItem)oxr.LoadCurrentElement(); this.Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Field, this.FieldItems.Count)); this.FieldItems.Add(fi.Val.Value); } } } }
// Generates content of pivotTableCacheRecordsPart1. private void GeneratePivotTableCacheRecordsPart1Content(PivotTableCacheRecordsPart pivotTableCacheRecordsPart1) { PivotCacheRecords pivotCacheRecords1 = new PivotCacheRecords() { Count = (UInt32Value)3U }; PivotCacheRecord pivotCacheRecord1 = new PivotCacheRecord(); FieldItem fieldItem1 = new FieldItem() { Val = (UInt32Value)0U }; NumberItem numberItem4 = new NumberItem() { Val = 100D }; pivotCacheRecord1.Append(fieldItem1); pivotCacheRecord1.Append(numberItem4); PivotCacheRecord pivotCacheRecord2 = new PivotCacheRecord(); FieldItem fieldItem2 = new FieldItem() { Val = (UInt32Value)1U }; NumberItem numberItem5 = new NumberItem() { Val = 120D }; pivotCacheRecord2.Append(fieldItem2); pivotCacheRecord2.Append(numberItem5); PivotCacheRecord pivotCacheRecord3 = new PivotCacheRecord(); FieldItem fieldItem3 = new FieldItem() { Val = (UInt32Value)2U }; NumberItem numberItem6 = new NumberItem() { Val = 132D }; pivotCacheRecord3.Append(fieldItem3); pivotCacheRecord3.Append(numberItem6); pivotCacheRecords1.Append(pivotCacheRecord1); pivotCacheRecords1.Append(pivotCacheRecord2); pivotCacheRecords1.Append(pivotCacheRecord3); pivotTableCacheRecordsPart1.PivotCacheRecords = pivotCacheRecords1; }
// Generates content of pivotTableCacheRecordsPart2. private void GeneratePivotTableCacheRecordsPart2Content(PivotTableCacheRecordsPart pivotTableCacheRecordsPart2) { PivotCacheRecords pivotCacheRecords2 = new PivotCacheRecords(){ Count = (UInt32Value)5U }; pivotCacheRecords2.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); PivotCacheRecord pivotCacheRecord5 = new PivotCacheRecord(); FieldItem fieldItem26 = new FieldItem(){ Val = (UInt32Value)0U }; FieldItem fieldItem27 = new FieldItem(){ Val = (UInt32Value)0U }; NumberItem numberItem9 = new NumberItem(){ Val = 13D }; NumberItem numberItem10 = new NumberItem(){ Val = 1287D }; DateTimeItem dateTimeItem14 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-02T04:31:50Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) }; StringItem stringItem44 = new StringItem(){ Val = "sales staff H" }; pivotCacheRecord5.Append(fieldItem26); pivotCacheRecord5.Append(fieldItem27); pivotCacheRecord5.Append(numberItem9); pivotCacheRecord5.Append(numberItem10); pivotCacheRecord5.Append(dateTimeItem14); pivotCacheRecord5.Append(stringItem44); PivotCacheRecord pivotCacheRecord6 = new PivotCacheRecord(); FieldItem fieldItem28 = new FieldItem(){ Val = (UInt32Value)1U }; FieldItem fieldItem29 = new FieldItem(){ Val = (UInt32Value)1U }; NumberItem numberItem11 = new NumberItem(){ Val = 27D }; NumberItem numberItem12 = new NumberItem(){ Val = 11529D }; DateTimeItem dateTimeItem15 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-04T03:14:24Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) }; StringItem stringItem45 = new StringItem(){ Val = "sales staff I" }; pivotCacheRecord6.Append(fieldItem28); pivotCacheRecord6.Append(fieldItem29); pivotCacheRecord6.Append(numberItem11); pivotCacheRecord6.Append(numberItem12); pivotCacheRecord6.Append(dateTimeItem15); pivotCacheRecord6.Append(stringItem45); PivotCacheRecord pivotCacheRecord7 = new PivotCacheRecord(); FieldItem fieldItem30 = new FieldItem(){ Val = (UInt32Value)2U }; FieldItem fieldItem31 = new FieldItem(){ Val = (UInt32Value)0U }; NumberItem numberItem13 = new NumberItem(){ Val = 19D }; NumberItem numberItem14 = new NumberItem(){ Val = 1881D }; DateTimeItem dateTimeItem16 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-03T11:10:19Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) }; StringItem stringItem46 = new StringItem(){ Val = "sales staff J" }; pivotCacheRecord7.Append(fieldItem30); pivotCacheRecord7.Append(fieldItem31); pivotCacheRecord7.Append(numberItem13); pivotCacheRecord7.Append(numberItem14); pivotCacheRecord7.Append(dateTimeItem16); pivotCacheRecord7.Append(stringItem46); PivotCacheRecord pivotCacheRecord8 = new PivotCacheRecord(); FieldItem fieldItem32 = new FieldItem(){ Val = (UInt32Value)3U }; FieldItem fieldItem33 = new FieldItem(){ Val = (UInt32Value)2U }; NumberItem numberItem15 = new NumberItem(){ Val = 25D }; NumberItem numberItem16 = new NumberItem(){ Val = 1250D }; DateTimeItem dateTimeItem17 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-02T06:54:09Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) }; StringItem stringItem47 = new StringItem(){ Val = "sales staff B" }; pivotCacheRecord8.Append(fieldItem32); pivotCacheRecord8.Append(fieldItem33); pivotCacheRecord8.Append(numberItem15); pivotCacheRecord8.Append(numberItem16); pivotCacheRecord8.Append(dateTimeItem17); pivotCacheRecord8.Append(stringItem47); PivotCacheRecord pivotCacheRecord9 = new PivotCacheRecord(); FieldItem fieldItem34 = new FieldItem(){ Val = (UInt32Value)4U }; FieldItem fieldItem35 = new FieldItem(){ Val = (UInt32Value)2U }; NumberItem numberItem17 = new NumberItem(){ Val = 16D }; NumberItem numberItem18 = new NumberItem(){ Val = 800D }; DateTimeItem dateTimeItem18 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2003-01-01T04:01:28Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) }; StringItem stringItem48 = new StringItem(){ Val = "sales staff F" }; pivotCacheRecord9.Append(fieldItem34); pivotCacheRecord9.Append(fieldItem35); pivotCacheRecord9.Append(numberItem17); pivotCacheRecord9.Append(numberItem18); pivotCacheRecord9.Append(dateTimeItem18); pivotCacheRecord9.Append(stringItem48); pivotCacheRecords2.Append(pivotCacheRecord5); pivotCacheRecords2.Append(pivotCacheRecord6); pivotCacheRecords2.Append(pivotCacheRecord7); pivotCacheRecords2.Append(pivotCacheRecord8); pivotCacheRecords2.Append(pivotCacheRecord9); pivotTableCacheRecordsPart2.PivotCacheRecords = pivotCacheRecords2; }
// Generates content of pivotTableCacheRecordsPart1. private void GeneratePivotTableCacheRecordsPart1Content(PivotTableCacheRecordsPart pivotTableCacheRecordsPart1) { PivotCacheRecords pivotCacheRecords1 = new PivotCacheRecords(){ Count = (UInt32Value)4U }; pivotCacheRecords1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); PivotCacheRecord pivotCacheRecord1 = new PivotCacheRecord(); FieldItem fieldItem12 = new FieldItem(){ Val = (UInt32Value)0U }; FieldItem fieldItem13 = new FieldItem(){ Val = (UInt32Value)0U }; NumberItem numberItem1 = new NumberItem(){ Val = 19D }; NumberItem numberItem2 = new NumberItem(){ Val = 2375D }; FieldItem fieldItem14 = new FieldItem(){ Val = (UInt32Value)0U }; StringItem stringItem30 = new StringItem(){ Val = "sales staff G" }; pivotCacheRecord1.Append(fieldItem12); pivotCacheRecord1.Append(fieldItem13); pivotCacheRecord1.Append(numberItem1); pivotCacheRecord1.Append(numberItem2); pivotCacheRecord1.Append(fieldItem14); pivotCacheRecord1.Append(stringItem30); PivotCacheRecord pivotCacheRecord2 = new PivotCacheRecord(); FieldItem fieldItem15 = new FieldItem(){ Val = (UInt32Value)1U }; FieldItem fieldItem16 = new FieldItem(){ Val = (UInt32Value)1U }; NumberItem numberItem3 = new NumberItem(){ Val = 13D }; NumberItem numberItem4 = new NumberItem(){ Val = 15990D }; FieldItem fieldItem17 = new FieldItem(){ Val = (UInt32Value)1U }; StringItem stringItem31 = new StringItem(){ Val = "sales staff B" }; pivotCacheRecord2.Append(fieldItem15); pivotCacheRecord2.Append(fieldItem16); pivotCacheRecord2.Append(numberItem3); pivotCacheRecord2.Append(numberItem4); pivotCacheRecord2.Append(fieldItem17); pivotCacheRecord2.Append(stringItem31); PivotCacheRecord pivotCacheRecord3 = new PivotCacheRecord(); FieldItem fieldItem18 = new FieldItem(){ Val = (UInt32Value)2U }; FieldItem fieldItem19 = new FieldItem(){ Val = (UInt32Value)2U }; NumberItem numberItem5 = new NumberItem(){ Val = 4D }; NumberItem numberItem6 = new NumberItem(){ Val = 312D }; FieldItem fieldItem20 = new FieldItem(){ Val = (UInt32Value)2U }; StringItem stringItem32 = new StringItem(){ Val = "sales staff E" }; pivotCacheRecord3.Append(fieldItem18); pivotCacheRecord3.Append(fieldItem19); pivotCacheRecord3.Append(numberItem5); pivotCacheRecord3.Append(numberItem6); pivotCacheRecord3.Append(fieldItem20); pivotCacheRecord3.Append(stringItem32); PivotCacheRecord pivotCacheRecord4 = new PivotCacheRecord(); FieldItem fieldItem21 = new FieldItem(){ Val = (UInt32Value)3U }; FieldItem fieldItem22 = new FieldItem(){ Val = (UInt32Value)2U }; NumberItem numberItem7 = new NumberItem(){ Val = 29D }; NumberItem numberItem8 = new NumberItem(){ Val = 2262D }; FieldItem fieldItem23 = new FieldItem(){ Val = (UInt32Value)3U }; StringItem stringItem33 = new StringItem(){ Val = "sales staff E" }; pivotCacheRecord4.Append(fieldItem21); pivotCacheRecord4.Append(fieldItem22); pivotCacheRecord4.Append(numberItem7); pivotCacheRecord4.Append(numberItem8); pivotCacheRecord4.Append(fieldItem23); pivotCacheRecord4.Append(stringItem33); pivotCacheRecords1.Append(pivotCacheRecord1); pivotCacheRecords1.Append(pivotCacheRecord2); pivotCacheRecords1.Append(pivotCacheRecord3); pivotCacheRecords1.Append(pivotCacheRecord4); pivotTableCacheRecordsPart1.PivotCacheRecords = pivotCacheRecords1; }
internal void FromPivotCacheRecord(PivotCacheRecord pcr) { SetAllNull(); SLMissingItem mi; SLNumberItem ni; SLBooleanItem bi; SLErrorItem ei; SLStringItem si; SLDateTimeItem dti; FieldItem fi; using (var oxr = OpenXmlReader.Create(pcr)) { while (oxr.Read()) { if (oxr.ElementType == typeof(MissingItem)) { mi = new SLMissingItem(); mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Missing, MissingItems.Count)); MissingItems.Add(mi); } else if (oxr.ElementType == typeof(NumberItem)) { ni = new SLNumberItem(); ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Number, NumberItems.Count)); NumberItems.Add(ni); } else if (oxr.ElementType == typeof(BooleanItem)) { bi = new SLBooleanItem(); bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Boolean, BooleanItems.Count)); BooleanItems.Add(bi); } else if (oxr.ElementType == typeof(ErrorItem)) { ei = new SLErrorItem(); ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Error, ErrorItems.Count)); ErrorItems.Add(ei); } else if (oxr.ElementType == typeof(StringItem)) { si = new SLStringItem(); si.FromStringItem((StringItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.String, StringItems.Count)); StringItems.Add(si); } else if (oxr.ElementType == typeof(DateTimeItem)) { dti = new SLDateTimeItem(); dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.DateTime, DateTimeItems.Count)); DateTimeItems.Add(dti); } else if (oxr.ElementType == typeof(FieldItem)) { fi = (FieldItem)oxr.LoadCurrentElement(); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Field, FieldItems.Count)); FieldItems.Add(fi.Val.Value); } } } }