public ASPCDimNaturalizer(Server ASServer, Database ASDatabase, Dimension PCDimension, int ActionLevel) { try { srv = ASServer; db = ASDatabase; dim = PCDimension; txtNewView = ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbSchemaName"] + ".[DimNaturalized_" + ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbTableName"] + "]"; ASNaturalizationActionLevel = ActionLevel; InitIDCols(); } catch (Exception e) { UpdateStatus(BIDSHelper.Resources.Common.ProcessError); UpdateStatus("Error initializing naturalizer:\r\n" + e.ToString()); throw e; } }
public ASPCDimNaturalizer(string ASServer, string ASDatabase, string PCDimension, int ActionLevel) { try { srv = new Server(); srv.Connect("Integrated Security=SSPI;Persist Security Info=False;Data Source=" + ASServer); db = srv.Databases.GetByName(ASDatabase); dim = db.Dimensions.GetByName(PCDimension); if (((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbSchemaName"] != null) txtNewView = ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbSchemaName"] + ".[DimNaturalized_" + ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbTableName"] + "]"; else txtNewView = "[DimNaturalized_" + ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.TableName + "]"; ASNaturalizationActionLevel = ActionLevel; InitIDCols(); } catch (Exception e) { UpdateStatus(BIDSHelper.Resources.Common.ProcessError); UpdateStatus("Error initializing naturalizer:\r\n" + e.ToString()); throw e; } }
/// <summary> /// Creates an instance of <code>Dimension</code> whose width /// and height are the same as for the specified dimension. /// </summary> /// <param name="d"> /// the specified dimension for the /// <code>width</code> and /// <code>height</code> values. /// </param> public Dimension(Dimension d) : this(d.width, d.height) { }
private Dimension MaterializeSingleNonPCUserHierarchyAttribute(Dimension Dim, DataTable tblNew, DimensionAttribute attr) { Dimension dimNew = Dim; if (attr.Usage == AttributeUsage.Regular) { DimensionAttribute attrNew = CloneAttributeSkeleton(attr, attr.Name); for (int k = 0; k < attr.KeyColumns.Count; k++) { string ColName = "CurrentMember_" + ((EnhancedColumnBinding)attr.KeyColumns[k].Source).ColumnName.Trim('[').Trim(']'); attrNew.KeyColumns.Add(new DataItem(txtNewView, ColName, OleDbTypeConverter.GetRestrictedOleDbType(tblNew.Columns[ColName].DataType), tblNew.Columns[ColName].MaxLength)); } if (attr.NameColumn != null) { string ColName = "CurrentMember_" + ((EnhancedColumnBinding)attr.NameColumn.Source).ColumnName.Trim('[').Trim(']'); attrNew.NameColumn = new DataItem(txtNewView, ColName, OleDbType.WChar, // Name must always be string even though source column has in some customer cases not been... tblNew.Columns[ColName].MaxLength); } if (attr.ValueColumn != null) { string ColName = "CurrentMember_" + ((EnhancedColumnBinding)attr.ValueColumn.Source).ColumnName.Trim('[').Trim(']'); attrNew.ValueColumn = new DataItem(txtNewView, ColName, OleDbTypeConverter.GetRestrictedOleDbType(tblNew.Columns[ColName].DataType), tblNew.Columns[ColName].MaxLength); } dimNew.Attributes.Add(attrNew); } return dimNew; }
private Dimension MaterializeNonPCUserHierarchyAttributes(Dimension Dim, DataTable tblNew) { Dimension dimNew = Dim; foreach (DimensionAttribute attr in dim.Attributes) if (NonPCHierarchiesToInclude.Contains(attr.Name)) dimNew = MaterializeSingleNonPCUserHierarchyAttribute(dimNew, tblNew, attr); return dimNew; }
private Dimension MaterializeNaturalizedDimensionAttributes(Dimension Dim, DataTable tblNew) { Dimension dimNew = Dim; foreach (DimensionAttribute attrOrig in dim.Attributes) { DimensionAttribute attr = null; string strNewAttribName = null; for (int j = 2; j <= MinimumLevelCount + 1; j++) { if (PCAttributesToInclude.Contains(attrOrig.Name) || attrOrig.Usage == AttributeUsage.Key) { if (attrOrig.Usage != AttributeUsage.Parent) { if (attrOrig.Usage == AttributeUsage.Key) { if (j == 2) { attr = MaterializeAttributeColumns(attrOrig, tblNew, dim.KeyAttribute.Name); attr.Usage = AttributeUsage.Key; attr.AttributeHierarchyVisible = false; dimNew.Attributes.Add(attr); } strNewAttribName = GetNaturalizedLevelName(j); } else strNewAttribName = GetNaturalizedLevelName(j) + "_" + attrOrig.Name; attr = MaterializeAttributeColumns(attrOrig, tblNew, strNewAttribName); attr.Usage = AttributeUsage.Regular; // Do not create PC attribute hierarchy unless another attribute requires it to relate to key. // Non PC attribute hierarchies can be (and are by default) created side-by-side with PC hierarchy by selecting them in options dialog. if (attrOrig.Usage == AttributeUsage.Regular) { bool AttrRelatesOtherAttrToKey = false; foreach (DimensionAttribute attrTestRelated in dim.Attributes) if (IsAttributeRelated(attrTestRelated, attrOrig)) { AttrRelatesOtherAttrToKey = true; break; } if (!AttrRelatesOtherAttrToKey) { attr.AttributeHierarchyEnabled = false; attr.AttributeHierarchyVisible = false; } } dimNew.Attributes.Add(attr); } } } } return dimNew; }
private Dimension MaterializeNaturalizedAttributeRelationships(Dimension Dim, DataTable tblNew) { Dimension dimNew = Dim; // Prepare for headache... try { // For each attribute in the original dimension foreach (DimensionAttribute attRelOwner in dim.Attributes) // Skip it if it is the special parent attribute of PC dimension since that is not in the naturalized dimension if (attRelOwner.Usage != AttributeUsage.Parent) // Then loop through each attribute in the original dimension again to see if it is related to the first attribute foreach (DimensionAttribute attRelated in dim.Attributes) if (attRelOwner.AttributeRelationships.Contains(attRelated.ID) && attRelated.Usage != AttributeUsage.Parent) { // If the source and destination are both attributes selected for inclusion in the dimension and both are related to the dimension key directly or indirectly if ((PCAttributesToInclude.Contains(attRelOwner.Name) || attRelOwner.Usage == AttributeUsage.Key) && PCAttributesToInclude.Contains(attRelated.Name) && IsAttributeRelated(attRelated, dim.KeyAttribute)) // Then loop through the levels to add a relationship for each level member corresponding to the original PC attribute for (int k = 2; k <= MinimumLevelCount + 1; k++) // If it was related to the PC key, relate directly to level name in naturalized version, otherwise relate to the corresponding related attribute for the level... if (attRelOwner.Usage == AttributeUsage.Key) dimNew.Attributes[GetNaturalizedLevelName(k)].AttributeRelationships.Add( new AttributeRelationship(GetNaturalizedLevelName(k) + "_" + attRelated.Name)); else dimNew.Attributes[GetNaturalizedLevelName(k) + "_" + attRelOwner.Name].AttributeRelationships.Add( new AttributeRelationship(GetNaturalizedLevelName(k) + "_" + attRelated.Name)); // Finally if attribute exists as part of non-PC hierarchy, it will have a name without "LevelX" in front, so we need to add relationship for that if (dimNew.Attributes.Contains(attRelated.Name) && attRelOwner.Usage != AttributeUsage.Key) dimNew.Attributes[attRelOwner.Name].AttributeRelationships.Add( new AttributeRelationship(attRelated.Name)); } // Relate each level of the naturalized hierarchy to the one below it to optimize hierarchy navigation for (int i = 3; i <= MinimumLevelCount + 1; i++) dimNew.Attributes[GetNaturalizedLevelName(i)].AttributeRelationships.Add(new AttributeRelationship(GetNaturalizedLevelName(i - 1))); //relate the lowest level to the key dimNew.KeyAttribute.AttributeRelationships.Add(new AttributeRelationship(GetNaturalizedLevelName(MinimumLevelCount + 1))); //any attributes which aren't related directly or indirectly to the key, add that attribute relationship foreach (DimensionAttribute attr in dimNew.Attributes) { if (attr.ID != dimNew.KeyAttribute.ID && !IsAttributeRelated(attr, dimNew.KeyAttribute)) { dimNew.KeyAttribute.AttributeRelationships.Add(new AttributeRelationship(attr.ID)); } } return dimNew; } catch (Exception e) { throw e; } }
private Dimension MaterializeHierarchies(Dimension Dim, DataTable tblNew) { Dimension dimNew = Dim; Hierarchy hierNew = null; DimensionAttribute atParent = null; // Build naturalized PC hierarchy foreach (DimensionAttribute da in dim.Attributes) if (da.Usage == AttributeUsage.Parent) { atParent = da; break; } hierNew = dimNew.Hierarchies.Add(atParent.Name); hierNew.MemberKeysUnique = MemberKeysUnique.Unique; for (int i = 2; i <= MinimumLevelCount + 1; i++) { Level lvlNew = new Level(GetNaturalizedLevelName(i)); lvlNew.SourceAttribute = dimNew.Attributes[lvlNew.Name]; lvlNew.HideMemberIf = HideIfValue.ParentName; hierNew.Levels.Add(lvlNew); } // Migrate existing user hierarchies from PC dimension... foreach (Hierarchy hier in dim.Hierarchies) { if (NonPCHierarchiesToInclude.Contains(hier.Name)) { if (dimNew.Attributes.ContainsName(hier.Name)) hierNew = dimNew.Hierarchies.Add(hier.Name + "Hierarchy"); else hierNew = dimNew.Hierarchies.Add(hier.Name); for (int j = 0; j < hier.Levels.Count; j++) { hierNew.Levels.Add(new Level(hier.Levels[j].Name)); if (hier.Levels[j].SourceAttribute.Usage == AttributeUsage.Regular) hierNew.Levels[j].SourceAttribute = dimNew.Attributes[hier.Levels[j].SourceAttribute.Name]; else hierNew.Levels[j].SourceAttribute = dimNew.Attributes[dim.KeyAttribute.Name]; hierNew.Levels[j].HideMemberIf = hier.Levels[j].HideMemberIf; } } } return dimNew; }
void AddDimToCubes(Dimension Dim) { foreach (Cube cub in db.Cubes) { if (cub.Dimensions.Contains(dim.ID)) cub.Dimensions.Add(Dim.ID); foreach (MeasureGroup mg in cub.MeasureGroups) if (mg.Dimensions.Contains(dim.ID)) { RegularMeasureGroupDimension rmgd = mg.Dimensions.Add(Dim.ID); MeasureGroupAttribute mga = rmgd.Attributes.Add(Dim.KeyAttribute.ID); mga.Type = MeasureGroupAttributeType.Granularity; foreach (DataItem keyCol in ((RegularMeasureGroupDimension)mg.Dimensions[dim.ID]).Attributes[dim.KeyAttribute.ID].KeyColumns) mga.KeyColumns.Add(keyCol.Clone()); } } }
private void SwitchDimension(Dimension newDim) { overworldToolStripMenuItem.Checked = dim == Dimension.Overworld; netherToolStripMenuItem.Checked = dim == Dimension.Nether; endToolStripMenuItem.Checked = dim == Dimension.End; if (world == null) return; if (!SaveIfNecessary()) return; if (newDim == dim) return; ResetControls(); dim = newDim; overworldToolStripMenuItem.Checked = dim == Dimension.Overworld; netherToolStripMenuItem.Checked = dim == Dimension.Nether; endToolStripMenuItem.Checked = dim == Dimension.End; String[] regions = world.GetRegionPaths(dim); foreach (String r in regions) lstRegions.Items.Add(RegionFile.ToString(r)); return; }
private void ResetControls() { lstRegions.Items.Clear(); lastSelectedRegionIndex = -1; trackMagnification.Value = 1; lblMagnification.Text = "Magnification: 1x"; imgRegion.Reset(); region = null; dim = Dimension.Overworld; overworldToolStripMenuItem.Checked = true; netherToolStripMenuItem.Checked = false; endToolStripMenuItem.Checked = false; if (history != null) history.Dispose(); history = new HistoryManager(HistoryChange); history.RecordSelectionState(imgRegion.Layers[SELECTIONLAYER].Image, "Initial State"); }
private void scaleImage() { try { this.statusStrip1.Visible = this.WindowState != FormWindowState.Maximized; if (pictureBox1.Width > 0) { Dimension frame = new Dimension(pictureBox1.Width, pictureBox1.Height); int desiredWidth = ImageScaler.getDesiredWidth(item.Dimensions, frame); ImageScaler scaler = new ImageScaler(desiredWidth); MemoryStream streamIn = new MemoryStream(item.Image); MemoryStream streamOut = new MemoryStream(); scaler.scaleImage(streamIn, streamOut, ImageFormat.Bmp); Image bitmap = Image.FromStream(streamOut); pictureBox1.Image = bitmap; } } catch (System.Exception e) { System.Console.WriteLine(e.Message); } }
private static bool GetDimByName(Feature inFeature, string inName, out Dimension outDim) { bool ret = false; outDim = null; var swDispDim = (DisplayDimension)inFeature.GetFirstDisplayDimension(); while (swDispDim != null) { outDim = (Dimension)swDispDim.GetDimension(); if (outDim.Name.ToLower() == inName.ToLower()) { ret = true; break; } swDispDim = (DisplayDimension)inFeature.GetNextDisplayDimension(swDispDim); } return ret; }
private static List<string> GetRelatedTables(Dimension dMG, MeasureGroup mgOuter) { List<string> list = new List<string>(); foreach (Relationship relOuter in dMG.Relationships) { bool bFound = false; MeasureGroup mgFrom = dMG.Parent.Cubes[0].MeasureGroups[relOuter.FromRelationshipEnd.DimensionID]; Dimension dTo = dMG.Parent.Dimensions[relOuter.ToRelationshipEnd.DimensionID]; CubeDimension dToCube = dMG.Parent.Cubes[0].Dimensions[relOuter.ToRelationshipEnd.DimensionID]; foreach (MeasureGroupDimension mgdOuter in mgFrom.Dimensions) { ReferenceMeasureGroupDimension rmgdOuter = mgdOuter as ReferenceMeasureGroupDimension; if (rmgdOuter != null && rmgdOuter.Materialization == ReferenceDimensionMaterialization.Regular && rmgdOuter.RelationshipID == relOuter.ID) { //active relationships have a materialized reference relationship bFound = true; break; } } if (!bFound) { continue; //don't show inactive relationships } list.Add(dToCube.Name); list.AddRange(GetRelatedTables(dTo, mgOuter)); } return list; }
/// <summary> /// Resize the selected shapes according to the set dimension type. /// </summary> /// <param name="selectedShapes"></param> /// <param name="dimension"></param> private void ResizeVisualShapes(PowerPoint.ShapeRange selectedShapes, Dimension dimension) { try { var referenceHeight = GetReferenceHeight(selectedShapes); var referenceWidth = GetReferenceWidth(selectedShapes); if (!IsMoreThanOneShape(selectedShapes, Equalize_MinNoOfShapesRequired, true, Equalize_ErrorParameters) || (referenceHeight < 0) || (referenceWidth < 0)) { return; } for (int i = 1; i <= selectedShapes.Count; i++) { var shape = new PPShape(selectedShapes[i]); var anchorPoint = GetVisualAnchorPoint(shape); if ((dimension == Dimension.Height) || (dimension == Dimension.HeightAndWidth)) { shape.AbsoluteHeight = referenceHeight; } if ((dimension == Dimension.Width) || (dimension == Dimension.HeightAndWidth)) { shape.AbsoluteWidth = referenceWidth; } AlignVisualShape(shape, anchorPoint); } } catch (Exception e) { Logger.LogException(e, "ResizeVisualShapes"); } }
private void InitializeMCFrames() { Dimension luma = new Dimension(dec.format.width, dec.format.height); Dimension chro = new Dimension(dec.format.width >> dec.format.ChromaHShift(), dec.format.height >> dec.format.ChromaVShift()); mc_frame = new Block[3]; mc_frame[0] = new Block(luma); mc_frame[1] = new Block(chro); mc_frame[2] = new Block(chro); }