Esempio n. 1
0
        public TabularTranslatedItem(string table, IModelComponent obj, TabularTranslatedItemProperty property, TabularTranslatedItem caption, SSAS.TabularTranslationsAnnotation annotations)
        {
            _Table    = table;
            _object   = obj;
            _Property = property;

            TranslationCollection translations;
            string sCaption;
            string sDescription;
            string sDisplayFolder = null;

            if (obj is DimensionAttribute)
            {
                _ObjectType = TabularTranslatedItemType.Column;
                DimensionAttribute typedobj = (DimensionAttribute)obj;
                translations   = typedobj.Translations;
                sDisplayFolder = typedobj.AttributeHierarchyDisplayFolder;
                sCaption       = typedobj.Name;
                sDescription   = typedobj.Description;
            }
            else if (obj is Hierarchy)
            {
                _ObjectType = TabularTranslatedItemType.Hierarchy;
                Hierarchy typedobj = (Hierarchy)obj;
                translations   = typedobj.Translations;
                sDisplayFolder = typedobj.DisplayFolder;
                sCaption       = typedobj.Name;
                sDescription   = typedobj.Description;
            }
            else if (obj is Level)
            {
                _ObjectType = TabularTranslatedItemType.Level;
                Level typedobj = (Level)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is CalculationProperty)
            {
                _ObjectType = TabularTranslatedItemType.Measure;
                CalculationProperty typedobj = (CalculationProperty)obj;
                translations   = typedobj.Translations;
                sDisplayFolder = typedobj.DisplayFolder;
                sCaption       = typedobj.CalculationReference;
                sDescription   = typedobj.Description;

                if (sCaption.StartsWith("[") && sCaption.EndsWith("]"))
                {
                    sCaption = sCaption.Substring(1, sCaption.Length - 2);
                }
            }
            else if (obj is Database)
            {
                _ObjectType = TabularTranslatedItemType.Database;
                Database typedobj = (Database)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Cube)
            {
                _ObjectType = TabularTranslatedItemType.Cube;
                Cube typedobj = (Cube)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Perspective)
            {
                _ObjectType = TabularTranslatedItemType.Perspective;
                Perspective typedobj = (Perspective)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Dimension)
            {
                _ObjectType = TabularTranslatedItemType.Table;
                Dimension typedobj = (Dimension)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Microsoft.AnalysisServices.Action)
            {
                _ObjectType = TabularTranslatedItemType.Action;
                Microsoft.AnalysisServices.Action typedobj = (Microsoft.AnalysisServices.Action)obj;
                translations = typedobj.Translations;
                sCaption     = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else
            {
                throw new Exception("Unexpected object type: " + obj.GetType().Name);
            }

            _ObjectName = sCaption;

            if (property == TabularTranslatedItemProperty.Caption)
            {
                _DefaultLanguage = sCaption;

                SSAS.TabularTranslationObjectAnnotation annotation = annotations.Find(obj);
                if (annotation != null && translations.Count == 0)
                {
                    foreach (SSAS.TabularTranslationAnnotation tranAnnotation in annotation.TabularTranslations)
                    {
                        Translation t = new Translation(tranAnnotation.Language);
                        if (obj is DimensionAttribute)
                        {
                            t = new AttributeTranslation(tranAnnotation.Language);
                        }
                        t.Caption       = tranAnnotation.Caption;
                        t.Description   = tranAnnotation.Description;
                        t.DisplayFolder = tranAnnotation.DisplayFolder;
                        translations.Add(t);
                    }
                    _restoredTranslations = true;
                }
            }
            else if (property == TabularTranslatedItemProperty.Description)
            {
                _DefaultLanguage = sDescription;
            }
            else if (property == TabularTranslatedItemProperty.DisplayFolder)
            {
                _DefaultLanguage = sDisplayFolder;
            }

            Languages = new Core.DirtyMonitoredDictionary <int, string>();
            foreach (Translation t in translations)
            {
                if (property == TabularTranslatedItemProperty.Caption)
                {
                    Languages.Add(t.Language, t.Caption);
                }
                else if (property == TabularTranslatedItemProperty.Description)
                {
                    Languages.Add(t.Language, t.Description);
                }
                else if (property == TabularTranslatedItemProperty.DisplayFolder)
                {
                    Languages.Add(t.Language, t.DisplayFolder);
                }
            }

            if (caption != null)
            {
                caption.DependentProperties.Add(this);
            }
        }
Esempio n. 2
0
        public TabularTranslatedItem(string table, IModelComponent obj, TabularTranslatedItemProperty property, TabularTranslatedItem caption, SSAS.TabularTranslationsAnnotation annotations)
        {
            _Table = table;
            _object = obj;
            _Property = property;

            TranslationCollection translations;
            string sCaption;
            string sDescription;
            string sDisplayFolder = null;
            if (obj is DimensionAttribute)
            {
                _ObjectType = TabularTranslatedItemType.Column;
                DimensionAttribute typedobj = (DimensionAttribute)obj;
                translations = typedobj.Translations;
                sDisplayFolder = typedobj.AttributeHierarchyDisplayFolder;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Hierarchy)
            {
                _ObjectType = TabularTranslatedItemType.Hierarchy;
                Hierarchy typedobj = (Hierarchy)obj;
                translations = typedobj.Translations;
                sDisplayFolder = typedobj.DisplayFolder;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Level)
            {
                _ObjectType = TabularTranslatedItemType.Level;
                Level typedobj = (Level)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is CalculationProperty)
            {
                _ObjectType = TabularTranslatedItemType.Measure;
                CalculationProperty typedobj = (CalculationProperty)obj;
                translations = typedobj.Translations;
                sDisplayFolder = typedobj.DisplayFolder;
                sCaption = typedobj.CalculationReference;
                sDescription = typedobj.Description;

                if (sCaption.StartsWith("[") && sCaption.EndsWith("]"))
                {
                    sCaption = sCaption.Substring(1, sCaption.Length - 2);
                }
            }
            else if (obj is Database)
            {
                _ObjectType = TabularTranslatedItemType.Database;
                Database typedobj = (Database)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Cube)
            {
                _ObjectType = TabularTranslatedItemType.Cube;
                Cube typedobj = (Cube)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Perspective)
            {
                _ObjectType = TabularTranslatedItemType.Perspective;
                Perspective typedobj = (Perspective)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Dimension)
            {
                _ObjectType = TabularTranslatedItemType.Table;
                Dimension typedobj = (Dimension)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else if (obj is Microsoft.AnalysisServices.Action)
            {
                _ObjectType = TabularTranslatedItemType.Action;
                Microsoft.AnalysisServices.Action typedobj = (Microsoft.AnalysisServices.Action)obj;
                translations = typedobj.Translations;
                sCaption = typedobj.Name;
                sDescription = typedobj.Description;
            }
            else
            {
                throw new Exception("Unexpected object type: " + obj.GetType().Name);
            }

            _ObjectName = sCaption;

            if (property == TabularTranslatedItemProperty.Caption)
            {
                _DefaultLanguage = sCaption;

                SSAS.TabularTranslationObjectAnnotation annotation = annotations.Find(obj);
                if (annotation != null && translations.Count == 0)
                {
                    foreach (SSAS.TabularTranslationAnnotation tranAnnotation in annotation.TabularTranslations)
                    {
                        Translation t = new Translation(tranAnnotation.Language);
                        if (obj is DimensionAttribute)
                            t = new AttributeTranslation(tranAnnotation.Language);
                        t.Caption = tranAnnotation.Caption;
                        t.Description = tranAnnotation.Description;
                        t.DisplayFolder = tranAnnotation.DisplayFolder;
                        translations.Add(t);
                    }
                    _restoredTranslations = true;
                }
            
            }
            else if (property == TabularTranslatedItemProperty.Description)
            {
                _DefaultLanguage = sDescription;
            }
            else if (property == TabularTranslatedItemProperty.DisplayFolder)
            {
                _DefaultLanguage = sDisplayFolder;
            }

            Languages = new Core.DirtyMonitoredDictionary<int, string>();
            foreach (Translation t in translations)
            {
                if (property == TabularTranslatedItemProperty.Caption)
                {
                    Languages.Add(t.Language, t.Caption);
                }
                else if (property == TabularTranslatedItemProperty.Description)
                {
                    Languages.Add(t.Language, t.Description);
                }
                else if (property == TabularTranslatedItemProperty.DisplayFolder)
                {
                    Languages.Add(t.Language, t.DisplayFolder);
                }
            }

            if (caption != null)
            {
                caption.DependentProperties.Add(this);
            }
        }