Example #1
0
        public void Save(List <SSAS.TabularTranslationObjectAnnotation> annotationsList)
        {
            if (_Property != TabularTranslatedItemProperty.Caption)
            {
                return;                                                     //every object will have a caption, so only perform the save on the caption
            }
            Dictionary <int, string> DisplayFolderLanguages = new Dictionary <int, string>();
            Dictionary <int, string> DescriptionLanguages   = new Dictionary <int, string>();
            bool bDependentPropertyDirty = false;

            foreach (TabularTranslatedItem dependent in DependentProperties)
            {
                bDependentPropertyDirty = bDependentPropertyDirty || dependent.Dirty;
                if (dependent.Property == TabularTranslatedItemProperty.DisplayFolder)
                {
                    DisplayFolderLanguages = dependent.Languages;
                }
                else if (dependent.Property == TabularTranslatedItemProperty.Description)
                {
                    DescriptionLanguages = dependent.Languages;
                }
            }

            //if (!Dirty && !bDependentPropertyDirty) return; //would be nice if we could short-circuit here, but we need to build the annotation

            SSAS.TabularTranslationObjectAnnotation annotation = new TabularTranslationObjectAnnotation();
            annotation.ObjectType = _ObjectType;

            if (_object is DimensionAttribute)
            {
                DimensionAttribute da = (DimensionAttribute)_object;
                annotation.ObjectID = da.ID;
                annotation.TableID  = da.Parent.ID;
                SaveInternal(da.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Hierarchy)
            {
                Hierarchy h = (Hierarchy)_object;
                annotation.ObjectID = h.ID;
                annotation.TableID  = h.Parent.ID;
                SaveInternal(h.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Level)
            {
                Level l = (Level)_object;
                annotation.ObjectID    = l.ID;
                annotation.HierarchyID = l.Parent.ID;
                annotation.TableID     = l.ParentDimension.ID;
                SaveInternal(l.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is CalculationProperty)
            {
                CalculationProperty calc = (CalculationProperty)_object;
                annotation.ObjectID = _ObjectName;
                //no need to save table
                SaveInternal(calc.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Database)
            {
                Database db = (Database)_object;
                annotation.ObjectID = db.ID;
                SaveInternal(db.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Cube)
            {
                Cube cube = (Cube)_object;
                annotation.ObjectID = cube.ID;
                SaveInternal(cube.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Perspective)
            {
                Perspective p = (Perspective)_object;
                annotation.ObjectID = p.ID;
                SaveInternal(p.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Dimension)
            {
                Dimension dim = (Dimension)_object;
                annotation.ObjectID = dim.ID;
                SaveInternal(dim.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
                foreach (Cube cube in dim.Parent.Cubes)
                {
                    foreach (CubeDimension cd in cube.Dimensions)
                    {
                        if (cd.DimensionID == dim.ID)
                        {
                            SaveInternal(cd.Translations, DisplayFolderLanguages, DescriptionLanguages, null);
                        }
                    }
                    foreach (MeasureGroup mg in cube.MeasureGroups)
                    {
                        if (mg.ID == dim.ID)
                        {
                            SaveInternal(mg.Translations, DisplayFolderLanguages, DescriptionLanguages, null);
                        }
                    }
                }
            }
            else if (_object is Microsoft.AnalysisServices.Action)
            {
                Microsoft.AnalysisServices.Action actionMaster = (Microsoft.AnalysisServices.Action)_object;
                foreach (Microsoft.AnalysisServices.Action action in actionMaster.Parent.Actions)
                {
                    if (action.ID.StartsWith(actionMaster.ID))
                    {
                        annotation.ObjectID = action.ID;
                        SaveInternal(action.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
                    }
                }
            }
            else
            {
                throw new Exception("Unexpected object type: " + _object.GetType().Name);
            }

            if (annotation.TabularTranslations.Length > 0)
            {
                annotationsList.Add(annotation);
            }
        }
Example #2
0
        public void Save(List<SSAS.TabularTranslationObjectAnnotation> annotationsList)
        {
            if (_Property != TabularTranslatedItemProperty.Caption) return; //every object will have a caption, so only perform the save on the caption

            Dictionary<int, string> DisplayFolderLanguages = new Dictionary<int, string>();
            Dictionary<int, string> DescriptionLanguages = new Dictionary<int, string>();
            bool bDependentPropertyDirty = false;
            foreach (TabularTranslatedItem dependent in DependentProperties)
            {
                bDependentPropertyDirty = bDependentPropertyDirty || dependent.Dirty;
                if (dependent.Property == TabularTranslatedItemProperty.DisplayFolder)
                    DisplayFolderLanguages = dependent.Languages;
                else if (dependent.Property == TabularTranslatedItemProperty.Description)
                    DescriptionLanguages = dependent.Languages;
            }

            //if (!Dirty && !bDependentPropertyDirty) return; //would be nice if we could short-circuit here, but we need to build the annotation

            SSAS.TabularTranslationObjectAnnotation annotation = new TabularTranslationObjectAnnotation();
            annotation.ObjectType = _ObjectType;

            if (_object is DimensionAttribute)
            {
                DimensionAttribute da = (DimensionAttribute)_object;
                annotation.ObjectID = da.ID;
                annotation.TableID = da.Parent.ID;
                SaveInternal(da.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Hierarchy)
            {
                Hierarchy h = (Hierarchy)_object;
                annotation.ObjectID = h.ID;
                annotation.TableID = h.Parent.ID;
                SaveInternal(h.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Level)
            {
                Level l = (Level)_object;
                annotation.ObjectID = l.ID;
                annotation.HierarchyID = l.Parent.ID;
                annotation.TableID = l.ParentDimension.ID;
                SaveInternal(l.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is CalculationProperty)
            {
                CalculationProperty calc = (CalculationProperty)_object;
                annotation.ObjectID = _ObjectName;
                //no need to save table
                SaveInternal(calc.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Database)
            {
                Database db = (Database)_object;
                annotation.ObjectID = db.ID;
                SaveInternal(db.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Cube)
            {
                Cube cube = (Cube)_object;
                annotation.ObjectID = cube.ID;
                SaveInternal(cube.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Perspective)
            {
                Perspective p = (Perspective)_object;
                annotation.ObjectID = p.ID;
                SaveInternal(p.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
            }
            else if (_object is Dimension)
            {
                Dimension dim = (Dimension)_object;
                annotation.ObjectID = dim.ID;
                SaveInternal(dim.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
                foreach (Cube cube in dim.Parent.Cubes)
                {
                    foreach (CubeDimension cd in cube.Dimensions)
                    {
                        if (cd.DimensionID == dim.ID)
                        {
                            SaveInternal(cd.Translations, DisplayFolderLanguages, DescriptionLanguages, null);
                        }
                    }
                    foreach (MeasureGroup mg in cube.MeasureGroups)
                    {
                        if (mg.ID == dim.ID)
                        {
                            SaveInternal(mg.Translations, DisplayFolderLanguages, DescriptionLanguages, null);
                        }
                    }
                }
            }
            else if (_object is Microsoft.AnalysisServices.Action)
            {
                Microsoft.AnalysisServices.Action actionMaster = (Microsoft.AnalysisServices.Action)_object;
                foreach (Microsoft.AnalysisServices.Action action in actionMaster.Parent.Actions)
                {
                    if (action.ID.StartsWith(actionMaster.ID))
                    {
                        annotation.ObjectID = action.ID;
                        SaveInternal(action.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation);
                    }
                }
            }
            else
            {
                throw new Exception("Unexpected object type: " + _object.GetType().Name);
            }

            if (annotation.TabularTranslations.Length > 0)
            {
                annotationsList.Add(annotation);
            }
        }