public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); SourceSchemaMap ds = new SourceSchemaMap(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "MapDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return(type); }
public override System.Data.DataSet Clone() { SourceSchemaMap cln = ((SourceSchemaMap)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { SourceSchemaMap ds = new SourceSchemaMap(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return(type); }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); SourceSchemaMap ds = new SourceSchemaMap(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "MapDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { SourceSchemaMap ds = new SourceSchemaMap(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return type; }
public void LoadMap(string filePath) { if (_map != null) { return; } if (filePath == null || filePath == "") { throw new ArgumentException("Invalid path"); } try { // load schema from file _map = new SourceSchemaMap(); _map.BeginInit(); if (File.Exists(filePath)) { _map.ReadXml(filePath); } _map.AcceptChanges(); // remove unmatched members from source schema for (int i = _map.Map.Rows.Count - 1; i >= 0; i--) { if (SourceSchemaMap.LookupAdomdSchemaObject(_srcCube, _map.Map[i]) == null) { _map.Map.Rows.RemoveAt(i); } } // add or validate existing memebrs foreach (Dimension dim in _srcCube.Dimensions) { if (_map.Map.FindBySourceUniqueName("Dimension:" + dim.UniqueName) == null) { _map.Map.AddMapRow("Dimension:" + dim.UniqueName, ""); } foreach (Hierarchy hier in dim.Hierarchies) { if (_map.Map.FindBySourceUniqueName("Hierarchy:" + hier.UniqueName) == null) { _map.Map.AddMapRow("Hierarchy:" + hier.UniqueName, ""); } foreach (Level lev in hier.Levels) { if (_map.Map.FindBySourceUniqueName("Level:" + lev.UniqueName) == null) { _map.Map.AddMapRow("Level:" + lev.UniqueName, ""); } } // measures handled separately if (dim.DimensionType != DimensionTypeEnum.Measure) { // default member or first member in first level Member defMem = (Member)SourceSchemaMap.LookupAdomdSchemaObject(_srcCube, "Member", hier.DefaultMember); if (defMem == null) { defMem = hier.Levels[0].GetMembers(0, 1)[0]; } if (_map.Map.FindBySourceUniqueName("Member:" + defMem.UniqueName) == null) { _map.Map.AddMapRow("Member:" + defMem.UniqueName, ""); } // calculated members MemberCollection mems = (hier.Levels[0].LevelType == LevelTypeEnum.All ? hier.Levels[1].GetMembers() : hier.Levels[0].GetMembers()); foreach (Member mem in mems) { if (mem.Type != MemberTypeEnum.Formula) { continue; } if (_map.Map.FindBySourceUniqueName("Member:" + mem.UniqueName) == null) { _map.Map.AddMapRow("Member:" + mem.UniqueName, ""); } } } } // measures if (dim.DimensionType == DimensionTypeEnum.Measure) { foreach (Measure mea in _srcCube.Measures) { if (_map.Map.FindBySourceUniqueName("Measure:" + mea.UniqueName) == null) { _map.Map.AddMapRow("Measure:" + mea.UniqueName, ""); } } } } // load dest schema _destSchema.BeginInit(); // empty member _destSchema.Schema.AddSchemaRow(""); // dimension hierarchies foreach (Dimension dim in _destCube.Dimensions) { if (_destSchema.Schema.FindByUniqueName("Dimension:" + dim.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Dimension:" + dim.UniqueName); } foreach (Hierarchy hier in dim.Hierarchies) { if (_destSchema.Schema.FindByUniqueName("Hierarchy:" + hier.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Hierarchy:" + hier.UniqueName); } foreach (Level lev in hier.Levels) { if (_destSchema.Schema.FindByUniqueName("Level:" + lev.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Level:" + lev.UniqueName); } } // measures handeled separately if (dim.DimensionType != DimensionTypeEnum.Measure) { // default member or first member in first level Member defMem = (Member)SourceSchemaMap.LookupAdomdSchemaObject(_destCube, "Member", hier.DefaultMember); if (defMem == null) { defMem = hier.Levels[0].GetMembers(0, 1)[0]; } if (_destSchema.Schema.FindByUniqueName("Member:" + defMem.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Member:" + defMem.UniqueName); } // calculated members MemberCollection mems = (hier.Levels[0].LevelType == LevelTypeEnum.All ? hier.Levels[1].GetMembers() : hier.Levels[0].GetMembers()); foreach (Member mem in mems) { if (mem.Type != MemberTypeEnum.Formula) { continue; } if (_destSchema.Schema.FindByUniqueName("Member:" + mem.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Member:" + mem.UniqueName); } } } } // measures if (dim.DimensionType == DimensionTypeEnum.Measure) { foreach (Measure mea in _destCube.Measures) { if (_destSchema.Schema.FindByUniqueName("Measure:" + mea.UniqueName) == null) { _destSchema.Schema.AddSchemaRow("Measure:" + mea.UniqueName); } } } } // merge dest schema to file foreach (SourceSchemaMap.MapRow srcRow in _map.Map.Rows) { // assign is empty and exact match if (srcRow.IsDestUniqueNameNull() || srcRow.DestUniqueName == "") { DestSchema.SchemaRow destRow = _destSchema.Schema.FindByUniqueName(srcRow.SourceUniqueName); srcRow.DestUniqueName = (destRow == null ? "" : destRow.UniqueName); } else // check assigned { DestSchema.SchemaRow destRow = _destSchema.Schema.FindByUniqueName(srcRow.DestUniqueName); if (destRow == null) { srcRow.DestUniqueName = ""; } } } } finally { if (_map != null) { _map.EndInit(); } if (_destSchema != null) { _destSchema.AcceptChanges(); _destSchema.EndInit(); } } }
private string ValidateOlapObject(SchemaObjectType type, string uniqueName, ReportsValidation.OlapReportsRow row) { // resolve source object object srcObject = (_srcUnmatched.Contains(uniqueName) ? null : SourceSchemaMap.LookupAdomdSchemaObject(_srcCube, type, uniqueName)); if (srcObject == null) { if (!_srcUnmatched.Contains(uniqueName)) { _srcUnmatched.Add(uniqueName); } row.ObjectsInvalid++; } // try to convert manually string destUniqueName = null; if (!_destUnmatched.Contains(uniqueName)) { if (uniqueName.StartsWith("[Central Chain]")) { destUniqueName = LookupCentralChain(uniqueName); } else if (uniqueName.StartsWith("[Chain]")) { destUniqueName = LookupChain(uniqueName); } else if (uniqueName.StartsWith("[Store].[Chain]")) { destUniqueName = LookupStoreChain(uniqueName); } else if (uniqueName.StartsWith("[Store].[Postal Code]")) { destUniqueName = LookupStorePostalCode(uniqueName); } else if (uniqueName.StartsWith("[Time].[Monthly]")) { destUniqueName = LookupTimeMonthly(uniqueName); } else if (uniqueName.StartsWith("[Time].[Weekly]")) { destUniqueName = LookupTimeWeekly(uniqueName); } else if (uniqueName.StartsWith("[Expand Compound Products]")) { destUniqueName = LookupExpandProductGroups(uniqueName); } // convert using map if (destUniqueName == null) { destUniqueName = _map.ConvertSchemaObjectUN(type, uniqueName); } } // lookup dest object (if matched) if (destUniqueName == null || SourceSchemaMap.LookupAdomdSchemaObject(_destCube, type, destUniqueName) == null) { destUniqueName = null; if (!_srcUnmatched.Contains(uniqueName) && !_destUnmatched.Contains(uniqueName)) { _destUnmatched.Add(uniqueName); } row.ObjectsInvalidNew++; } // diff row.InvalidDiff = (row.ObjectsInvalidNew - row.ObjectsInvalid); // return return(destUniqueName == null ? uniqueName : destUniqueName); }