private void AddFactLinkDimensionMeasureGroup(CbDimension_M aCbDimension, CbMeasureGroup_M aCbMeasureGroup) { try { DegenerateMeasureGroupDimension objMGFactDim = new DegenerateMeasureGroupDimension(); objMGFactDim.CubeDimensionID = aCbDimension.CubeDimensionObj.ID; aCbMeasureGroup.MeasureGroupObj.Dimensions.Add(objMGFactDim); MeasureGroupAttribute objMGA = new MeasureGroupAttribute(); //Link TableKey in DimensionTable with TableKey in FactTable Measure Group objMGA = objMGFactDim.Attributes.Add(aCbDimension.DimensionObj.KeyAttribute.ID); objMGA.Type = MeasureGroupAttributeType.Granularity; objMGA.KeyColumns.Add( CreateDataItem(aCbMeasureGroup.ReferenceToDsDwTableMap.DwTableName, aCbMeasureGroup.KeyName, NullProcessing.UnknownMember, null)); } catch (Exception ex) { AppendLogLine("Error in creating fact link between measure group and dimension. Error Message -> " + ex.Message); throw; } }
private void AddDimensionToCube(CbDimension_M aCbDimension) { try { aCbDimension.CubeDimensionObj = _CbCube.Dimensions.Add(aCbDimension.DimensionObj.ID); } catch (Exception ex) { AppendLogLine("Error in adding dimension to cube. Error Message -> " + ex.Message); throw; } }
private void GenerateDimension(CbDimension_M aCbDimension) { try { aCbDimension.DimensionObj = new Dimension(); //Add Dimension to the Database aCbDimension.DimensionObj = _CbDatabase.Dimensions.Add(aCbDimension.Name); aCbDimension.DimensionObj.Source = new DataSourceViewBinding(_CbDataSourceView.ID); aCbDimension.DimensionObj.UnknownMember = UnknownMemberBehavior.Visible; aCbDimension.DimensionObj.StorageMode = DimensionStorageMode.Molap; DimensionAttributeCollection objDimensionAttributesColl = aCbDimension.DimensionObj.Attributes; //Add attributes to dimension foreach (CbDimensionAttribute_M cbDimensionAttributeM in aCbDimension.AttributeList.Where(da => da.Include)) { DimensionAttribute objAttribute = objDimensionAttributesColl.Add(cbDimensionAttributeM.Name); objAttribute.Usage = cbDimensionAttributeM.Usage; objAttribute.AttributeHierarchyVisible = cbDimensionAttributeM.AttributeHierarchyVisible; objAttribute.KeyColumns.Add( CreateDataItem(aCbDimension.ReferenceToDsDwTableMap.DwTableName, cbDimensionAttributeM.ReferenceToDsDwColumnMap.DwColumn.Name, NullProcessing.UnknownMember, cbDimensionAttributeM.ReferenceToDsDwColumnMap.DwColumn.DataType )); } //Save dimension to database aCbDimension.DimensionObj.Update(); } catch (Exception ex) { AppendLogLine("Error in creating a dimension. Error Message -> " + ex.Message); throw; } }
public void SyncToDsDwMap(DsDwMap_M aDsDwMap, bool aReload) { ReferenceToDsDwMap = aDsDwMap; if (aReload) { MeasureGroupList.AList.Clear(); DimensionList.AList.Clear(); } if (aDsDwMap != null) { foreach (DsDwTableMap_M aDsDwTableMap in aDsDwMap.DsDwTableMapList.Where(tm => tm != null)) { CbMeasureGroup_M aCbMeasureGroup = MeasureGroupList.AList.FirstOrDefault(mg => mg.ReferenceToDsDwTableMapGuid == aDsDwTableMap.MyGuid); if (aCbMeasureGroup != null) { aCbMeasureGroup.ReferenceToDsDwTableMap = aDsDwTableMap; } else { aCbMeasureGroup = new CbMeasureGroup_M { Name = aDsDwTableMap.DwSchemaTableName.Replace("dbo.", "").Replace(".", ""), ReferenceToDsDwTableMap = aDsDwTableMap }; MeasureGroupList.AList.Add(aCbMeasureGroup); } CbDimension_M aCbDimension = DimensionList.AList.FirstOrDefault(mg => mg.ReferenceToDsDwTableMapGuid == aDsDwTableMap.MyGuid); if (aCbDimension != null) { aCbDimension.ReferenceToDsDwTableMap = aDsDwTableMap; } else { aCbDimension = new CbDimension_M { Name = aDsDwTableMap.DwSchemaTableName.Replace("dbo.", "").Replace(".", ""), ReferenceToDsDwTableMap = aDsDwTableMap }; DimensionList.AList.Add(aCbDimension); } aCbMeasureGroup.FactDimension = aCbDimension; if (aDsDwTableMap.DsDwColumnMapList != null) { foreach (DsDwColumnMap_M aDsDwColumnMap in aDsDwTableMap.DsDwColumnMapList.Where(cm => cm != null && cm.Include)) { CbMeasure_M aCbMeasure = aCbMeasureGroup.MeasureList.FirstOrDefault(mg => mg.ReferenceToDsDwColumnMapGuid == aDsDwColumnMap.MyGuid); if (aCbMeasure != null) { aCbMeasure.ReferenceToDsDwColumnMap = aDsDwColumnMap; } else { aCbMeasure = new CbMeasure_M { Name = aDsDwColumnMap.DwColumn.Name, ReferenceToDsDwColumnMap = aDsDwColumnMap }; aCbMeasureGroup.MeasureList.Add(aCbMeasure); aCbMeasure.UpdateProperties(); } CbDimensionAttribute_M aCbDimensionAttribute = aCbDimension.AttributeList.FirstOrDefault(mg => mg.ReferenceToDsDwColumnMapGuid == aDsDwColumnMap.MyGuid); if (aCbDimensionAttribute != null) { aCbDimensionAttribute.ReferenceToDsDwColumnMap = aDsDwColumnMap; } else { aCbDimensionAttribute = new CbDimensionAttribute_M { Name = aDsDwColumnMap.DwColumn.Name, ReferenceToDsDwColumnMap = aDsDwColumnMap }; aCbDimension.AttributeList.Add(aCbDimensionAttribute); aCbDimensionAttribute.UpdateProperties(); } } aCbMeasureGroup.MeasureList.RemoveAll(m => m == null || m.ReferenceToDsDwColumnMap == null); aCbDimension.AttributeList.RemoveAll(a => a == null || a.ReferenceToDsDwColumnMap == null); } } MeasureGroupList.AList.RemoveAll(mg => mg == null || mg.ReferenceToDsDwTableMap == null); DimensionList.AList.RemoveAll(d => d == null || d.ReferenceToDsDwTableMap == null); //fix ReferenceToDimension links //SerializableObject.FixAllReferences(); foreach (CbMeasureGroup_M aCbMeasureGroup in MeasureGroupList.AList) { foreach (CbMeasure_M aCbMeasure in aCbMeasureGroup.MeasureList.Where(m => m != null && m.ReferenceToDsDwColumnMap != null)) { if (aCbMeasure.ReferenceToDsDwColumnMap.Transformation == DsDwColumnTransformation.ForeignKey) { aCbMeasure.ReferenceToDimension = DimensionList.AList.FirstOrDefault( dm => dm.ReferenceToDsDwTableMap == aCbMeasure.ReferenceToDsDwColumnMap.DwForeignKeyReferencedTableMap); } else { aCbMeasure.ReferenceToDimension = null; } } } } }