示例#1
0
        /// <summary>
        /// Initializes a new instance of the Table class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the Table object belongs to.</param>
        /// <param name="tomTable">Tabular Object Model Table object abtstracted by the Table class.</param>
        public Table(TabularModel parentTabularModel, Tom.Table tomTable) : base(tomTable, parentTabularModel)
        {
            _parentTabularModel = parentTabularModel;
            _tomTable           = tomTable;

            PopulateProperties();
        }
示例#2
0
文件: Table.cs 项目: sk1020/tfs
        /// <summary>
        /// Initializes a new instance of the Table class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the Table object belongs to.</param>
        /// <param name="dimension">Analysis Management Objects Dimension object abtstracted by the Table class.</param>
        public Table(TabularModel parentTabularModel, Dimension dimension)
        {
            _parentTabularModel = parentTabularModel;
            _amoDimension       = dimension;

            PopulateProperties();
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the Model class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the Model object belongs to.</param>
        /// <param name="tomModel">Tabular Object Model Model object abtstracted by the Model class.</param>
        public Model(TabularModel parentTabularModel, Tom.Model tomModel) : base(tomModel)
        {
            _parentTabularModel = parentTabularModel;
            _tomModel           = tomModel;

            PopulateProperties();
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the Measure class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the measure belongs to.</param>
        /// <param name="tableName">Name of the table that the Measure belongs to.</param>
        /// <param name="measureName">Name of the measure.</param>
        /// <param name="expression">DAX expression</param>
        public Measure(TabularModel parentTabularModel, string tableName, string measureName, string expression)
        {
            _parentTabularModel = parentTabularModel;
            _tableName          = tableName;
            _name                  = measureName;
            _expression            = expression;
            _IsKpiReferenceMeasure = false;

            PopulateObjectDefinition();
        }
示例#5
0
文件: Kpi.cs 项目: sk1020/tfs
 /// <summary>
 /// Initializes a new instance of the Kpi class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel"></param>
 /// <param name="tableName"></param>
 /// <param name="measureName"></param>
 /// <param name="expression"></param>
 /// <param name="goalMeasure"></param>
 /// <param name="statusMeasure"></param>
 /// <param name="trendMeasure"></param>
 /// <param name="statusGraphic"></param>
 /// <param name="trendGraphic"></param>
 public Kpi(TabularModel parentTabularModel, string tableName, string measureName, string expression,
            Measure goalMeasure, Measure statusMeasure, Measure trendMeasure, string statusGraphic, string trendGraphic) //, Kpi kpi)
     : base(parentTabularModel, tableName, measureName, expression)
 {
     _goalMeasure   = goalMeasure;
     _statusMeasure = statusMeasure;
     _trendMeasure  = trendMeasure;
     _statusGraphic = statusGraphic;
     _trendGraphic  = trendGraphic;
     //_amoKpi = kpi;
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of an CalcDependency class using multiple parameters    .
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the CalcDependency object belongs to.</param>
        public CalcDependency(TabularModel parentTabularModel, string objectType, string tableName, string objectName, string expression, string referencedObjectType, string referencedTableName, string referencedObjectName, string referencedExpression)
        {
            _parentTabularModel = parentTabularModel;
            switch (objectType)
            {
            case "PARTITION":
                _objectType = CalcDependencyObjectType.Partition;
                break;

            case "M_EXPRESSION":
                _objectType = CalcDependencyObjectType.Expression;
                break;

            default:
                break;
            }
            _tableName  = tableName;
            _objectName = objectName;
            _expression = expression;
            switch (referencedObjectType)
            {
            case "PARTITION":
                _referencedObjectType = CalcDependencyObjectType.Partition;
                break;

            case "M_EXPRESSION":
                _referencedObjectType = CalcDependencyObjectType.Expression;
                break;

            case "DATA_SOURCE":
                _referencedObjectType = CalcDependencyObjectType.DataSource;
                break;

            default:
                break;
            }
            _referencedTableName  = referencedTableName;
            _referencedObjectName = referencedObjectName;
            _referencedExpression = referencedExpression;
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the Role class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the Role object belongs to.</param>
 /// <param name="role">Tabular Object Model Role object abtstracted by the Role class.</param>
 public Role(TabularModel parentTabularModel, ModelRole role) : base(role, parentTabularModel)
 {
     _parentTabularModel = parentTabularModel;
     _tomRole            = role;
 }
示例#8
0
文件: Action.cs 项目: sk1020/tfs
        public Action(TabularModel parentTabularModel, Amo.Action Action)
        {
            _parentTabularModel = parentTabularModel;
            _amoAction          = Action;
            _objectDefinition   = "";

            if (_amoAction.Caption != null)
            {
                _objectDefinition += "Caption: " + _amoAction.Caption + "\n";
            }
            _objectDefinition += "Caption is MDX: " + _amoAction.CaptionIsMdx.ToString() + "\n";
            if (_amoAction.Description != null)
            {
                _objectDefinition += "Description: " + _amoAction.Description + "\n";
            }
            _objectDefinition += "Action Type: " + _amoAction.Type.ToString() + "\n";
            if (_amoAction.Target != null)
            {
                _objectDefinition += "Target: " + _amoAction.Target + "\n";
            }
            if (_amoAction.Condition != null)
            {
                _objectDefinition += "Condition: " + _amoAction.Condition + "\n";
            }
            _objectDefinition += "Invocation: " + _amoAction.Invocation.ToString() + "\n\n";

            switch (_amoAction.Type)
            {
            case ActionType.DrillThrough:
                if (_amoAction is DrillThroughAction)
                {
                    DrillThroughAction drillThroughAction = (DrillThroughAction)_amoAction;
                    _objectDefinition += "Drillthrough Columns:\n";
                    foreach (CubeAttributeBinding column in drillThroughAction.Columns)
                    {
                        if (drillThroughAction.Parent.Dimensions.Contains(column.CubeDimensionID) && drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Attributes.Contains(column.AttributeID))
                        {
                            _objectDefinition += "Table: " + drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Name + ", Column: " + drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Attributes[column.AttributeID].Attribute.Name + "\n";
                        }
                    }
                    if (drillThroughAction.Columns.Count > 0)
                    {
                        _objectDefinition += "\n";
                    }
                    _objectDefinition += "Default: " + drillThroughAction.Default.ToString() + "\n";
                    _objectDefinition += "Maximum Rows: " + drillThroughAction.MaximumRows.ToString() + "\n";
                }
                break;

            case ActionType.Report:
                if (_amoAction is ReportAction)
                {
                    ReportAction reportAction = (ReportAction)_amoAction;
                    _objectDefinition += "Report Parameters:\n";
                    foreach (ReportParameter reportParameter in reportAction.ReportParameters)
                    {
                        if (reportParameter.Name != null && reportParameter.Value != null)
                        {
                            _objectDefinition += "Name: " + reportParameter.Name + ", Value: " + reportParameter.Value + "\n";
                        }
                    }
                    if (reportAction.ReportParameters.Count > 0 || reportAction.ReportFormatParameters.Count > 0)
                    {
                        _objectDefinition += "\n";
                    }
                    if (reportAction.ReportServer != null)
                    {
                        _objectDefinition += "Report Server: " + reportAction.ReportServer + "\n";
                    }
                    if (reportAction.Path != null)
                    {
                        _objectDefinition += "Maximum Path: " + reportAction.Path + "\n";
                    }
                }
                break;

            default:
                if (_amoAction is StandardAction)
                {
                    StandardAction standardAction = (StandardAction)_amoAction;
                    if (standardAction.Expression != null)
                    {
                        _objectDefinition += "Expression:\n" + standardAction.Expression + "\n";
                    }
                }
                break;
            }

            //if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionTranslations)
            //{
            //    _objectDefinition += "\nFormat & Visibility:\n";

            //    _objectDefinition += "Action Translations: ";
            //    if (_amoAction.Translations.Count > 0)
            //    {
            //        _objectDefinition += "[";
            //        foreach (Translation actionTranslation in _amoAction.Translations)
            //        {
            //            _objectDefinition += CultureInfo.GetCultureInfo(actionTranslation.Language).DisplayName + ": " + actionTranslation.Caption + ", ";
            //        }
            //        _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]";
            //    }

            //    if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionDisplayFolders)
            //    {
            //        _objectDefinition += ", Display Folder Translations: ";
            //        if (_amoAction.Translations.Count > 0)
            //        {
            //            _objectDefinition += "[";
            //            foreach (Translation actionDisplayFolderTranslation in _amoAction.Translations)
            //            {
            //                _objectDefinition += CultureInfo.GetCultureInfo(actionDisplayFolderTranslation.Language).DisplayName + ": " + actionDisplayFolderTranslation.DisplayFolder + ", ";
            //            }
            //            _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]";
            //        }
            //    }
            //    _objectDefinition += "\n";
            //}
        }
        /*public static async void Email(string htmlString, string email, string subject, MemoryStream ms = null)
         * {
         *  try
         *  {
         *      MailMessage message = new MailMessage();
         *      SmtpClient smtp = new SmtpClient();
         *      message.From = new MailAddress("*****@*****.**");
         *      message.To.Add(new MailAddress(email));
         *      message.Subject = subject;
         *      message.IsBodyHtml = true; //to make message body as html
         *      message.Body = htmlString;
         *      if (ms != null)
         *      {
         *          ms.Position = 0;
         *          message.Attachments.Add(new System.Net.Mail.Attachment(ms, "Test.pdf", "application/pdf"));
         *      }
         *      smtp.Port = 587;
         *      smtp.Host = "smtp.gmail.com"; //for gmail host
         *      smtp.EnableSsl = true;
         *      smtp.UseDefaultCredentials = false;
         *      smtp.Credentials = new NetworkCredential("*****@*****.**", "testpassword123!");
         *      smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
         *      await smtp.SendMailAsync(message);
         *  }
         *  catch (Exception) { }
         * }*/

        private async Task <AllModel> GetQuestionList(string examID, bool hideSolution = true)
        {
            cosmosClient = new CosmosClient(EndpointUri, PrimaryKey);
            Qdatabase    = await CreateDatabaseAsync(QdatabaseId);

            Qcontainer = await CreateContainerAsync(Qdatabase, QcontainerId, "id");

            QueryDefinition        query     = new QueryDefinition("select * from questions where questions.examid=\"" + examID + "\"");
            FeedIterator <dynamic> resultSet = Qcontainer.GetItemQueryIterator <dynamic>(
                query,
                requestOptions: new QueryRequestOptions()
            {
                MaxItemCount = 10
            });

            List <dynamic> questions = new List <dynamic>();

            while (resultSet.HasMoreResults)
            {
                FeedResponse <dynamic> response = await resultSet.ReadNextAsync();

                if (response.Diagnostics != null)
                {
                    Console.WriteLine($" Diagnostics {response.Diagnostics.ToString()}");
                }

                foreach (var item in response)
                {
                    if (hideSolution)
                    {
                        item.Solutions = null;
                    }
                    questions.Add(item);
                }
            }

            //questions.ElementAt(0).type;
            AllModel questionModel = new AllModel();

            foreach (var item in questions)
            {
                switch ((string)item.qtype)
                {
                case "mcq":
                {
                    MCQModel q = JsonConvert.DeserializeObject <MCQModel>(JsonConvert.SerializeObject(item));
                    questionModel.McqType.Add(q);
                    break;
                }

                case "arrange":
                {
                    ArrangeModel q = JsonConvert.DeserializeObject <ArrangeModel>(JsonConvert.SerializeObject(item));
                    questionModel.ArrangeType.Add(q);
                    break;
                }

                case "dnd":
                {
                    DnDModel q = JsonConvert.DeserializeObject <DnDModel>(JsonConvert.SerializeObject(item));
                    questionModel.DnDType.Add(q);
                    break;
                }

                case "select":
                {
                    SelectModel q = JsonConvert.DeserializeObject <SelectModel>(JsonConvert.SerializeObject(item));
                    questionModel.SelectType.Add(q);
                    break;
                }

                case "tabular":
                {
                    TabularModel q = JsonConvert.DeserializeObject <TabularModel>(JsonConvert.SerializeObject(item));
                    questionModel.TabularType.Add(q);
                    break;
                }

                default: break;
                }
            }

            return(questionModel);
        }
        /*[Authorize]*/
        public async Task <string> AddQuestion([FromForm] string type, [FromForm] string info)
        {
            cosmosClient = new CosmosClient(EndpointUri, PrimaryKey);
            Qdatabase    = await CreateDatabaseAsync(QdatabaseId);

            Qcontainer = await CreateContainerAsync(Qdatabase, QcontainerId, "id");

            string response;

            switch (type)
            {
            case "mcq":
            {
                MCQModel questionDetails = JsonConvert.DeserializeObject <MCQModel>(info);
                questionDetails.Id = Guid.NewGuid().ToString();
                response           = await AddHelper(questionDetails);

                break;
            }

            case "arrange":
            {
                ArrangeModel questionDetails = JsonConvert.DeserializeObject <ArrangeModel>(info);
                questionDetails.Id = Guid.NewGuid().ToString();
                response           = await AddHelper(questionDetails);

                break;
            }

            case "dnd":
            {
                DnDModel questionDetails = JsonConvert.DeserializeObject <DnDModel>(info);
                questionDetails.Id = Guid.NewGuid().ToString();
                response           = await AddHelper(questionDetails);

                break;
            }

            case "select":
            {
                SelectModel questionDetails = JsonConvert.DeserializeObject <SelectModel>(info);
                questionDetails.Id = Guid.NewGuid().ToString();
                response           = await AddHelper(questionDetails);

                break;
            }

            case "tabular":
            {
                TabularModel questionDetails = JsonConvert.DeserializeObject <TabularModel>(info);
                questionDetails.Id = Guid.NewGuid().ToString();
                response           = await AddHelper(questionDetails);

                break;
            }

            default:
            {
                response = "Unable to add type.";
                break;
            }
            }
            return(response);
        }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the Perspective class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the perspective belongs to.</param>
 /// <param name="tomPerspective">Tabular Object Model Perspective object abtstracted by the Perspective class.</param>
 public Perspective(TabularModel parentTabularModel, Tom.Perspective tomPerspective) : base(tomPerspective, parentTabularModel)
 {
     _parentTabularModel = parentTabularModel;
     _tomPerspective     = tomPerspective;
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the Expression class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the Expression object belongs to.</param>
 /// <param name="expression">Tabular Object Model Expression object abtstracted by the Expression class.</param>
 public Expression(TabularModel parentTabularModel, NamedExpression expression)
     : base(expression, parentTabularModel.Model.Name)
 {
     _parentTabularModel = parentTabularModel;
     _tomExpression      = expression;
 }
示例#13
0
文件: DataSource.cs 项目: sk1020/tfs
 /// <summary>
 /// Initializes a new instance of the DataSource class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the DataSource object belongs to.</param>
 /// <param name="datasource">Analysis Management Objects DataSource object abtstracted by the DataSource object.</param>
 public DataSource(TabularModel parentTabularModel, Microsoft.AnalysisServices.DataSource datasource)
 {
     _parentTabularModel = parentTabularModel;
     _amoDataSource      = datasource;
 }
示例#14
0
        /// <summary>
        /// Initializes a new instance of the Role class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the Role object belongs to.</param>
        /// <param name="role">Analysis Management Objects Role object abtstracted by the Role class.</param>
        public Role(TabularModel parentTabularModel, Amo.Role role)
        {
            _parentTabularModel = parentTabularModel;
            _amoRole            = role;

            _objectDefinition = "Permissions:\n";
            foreach (DatabasePermission dbPermission in _parentTabularModel.AmoDatabase.DatabasePermissions)
            {
                if (dbPermission.RoleID == _amoRole.ID)
                {
                    if (dbPermission.Administer)
                    {
                        _objectDefinition += "Administrator\n";
                    }
                    else if (dbPermission.Read == ReadAccess.Allowed && dbPermission.Process)
                    {
                        _objectDefinition += "Read and Process\n";
                    }
                    else if (dbPermission.Read == ReadAccess.Allowed)
                    {
                        _objectDefinition += "Read\n";
                    }
                    else if (dbPermission.Process)
                    {
                        _objectDefinition += "Process\n";
                    }
                    else
                    {
                        _objectDefinition += "None\n";
                    }
                }
            }

            _objectDefinition += "\nRow Filters:\n";
            List <string> rowFilters = new List <string>(); //need to be added in alphabetical order to allow comparison if obj definitions

            foreach (Dimension dimension in _parentTabularModel.AmoDatabase.Dimensions)
            {
                foreach (DimensionPermission dimPermission in dimension.DimensionPermissions)
                {
                    if (dimPermission.RoleID == _amoRole.ID)
                    {
                        //_objectDefinition += "[" + dimension.Name + "]=" + dimPermission.AllowedRowsExpression + "\n";
                        rowFilters.Add("[" + dimension.Name + "]=" + dimPermission.AllowedRowsExpression + "\n");
                    }
                }
            }
            rowFilters.Sort();
            foreach (string rowFilter in rowFilters)
            {
                _objectDefinition += rowFilter;
            }

            _objectDefinition += "\nMembers:\n";
            List <string> roleMembers = new List <string>(); //need to be added in alphabetical order to allow comparison if obj definitions

            foreach (RoleMember roleMember in _amoRole.Members)
            {
                //_objectDefinition += roleMember.Name + "\n";
                roleMembers.Add(roleMember.Name + "\n");
            }
            roleMembers.Sort();
            foreach (string roleMember in roleMembers)
            {
                _objectDefinition += roleMember;
            }
        }
示例#15
0
文件: Perspective.cs 项目: sk1020/tfs
        /// <summary>
        /// Initializes a new instance of the Perspective class using multiple parameters.
        /// </summary>
        /// <param name="parentTabularModel">TabularModel object that the perspective belongs to.</param>
        /// <param name="amoPerspective">Analysis Management Objects Perspective object abtstracted by the Perspective class.</param>
        public Perspective(TabularModel parentTabularModel, Amo.Perspective amoPerspective)
        {
            _parentTabularModel = parentTabularModel;
            _amoPerspective     = amoPerspective;
            _objectDefinition   = "";

            List <string> perspectiveTableNames = new List <string>();  // put in here to sort

            foreach (PerspectiveDimension perspectiveDimension in _amoPerspective.Dimensions)
            {
                perspectiveTableNames.Add(perspectiveDimension.Dimension.Name);
            }
            // now need to check if there are measures/KPIs where no other table objects are selected in the perspective - because if so won't have a .Dimension value
            foreach (PerspectiveCalculation perspectiveCalculation in _amoPerspective.Calculations)
            {
                string measureName = perspectiveCalculation.Name.Replace("[Measures].[", "").Replace("]", "");
                if (_parentTabularModel.Measures.ContainsName(measureName) &&
                    !perspectiveTableNames.Contains(_parentTabularModel.Measures.FindByName(measureName).TableName))
                {
                    perspectiveTableNames.Add(_parentTabularModel.Measures.FindByName(measureName).TableName);
                }
            }
            foreach (PerspectiveKpi perspectiveKpi in _amoPerspective.Kpis)
            {
                string kpiName = perspectiveKpi.ToString();
                if (_parentTabularModel.Kpis.ContainsName(kpiName) &&
                    !perspectiveTableNames.Contains(_parentTabularModel.Kpis.FindByName(kpiName).TableName))
                {
                    perspectiveTableNames.Add(_parentTabularModel.Kpis.FindByName(kpiName).TableName);
                }
            }
            perspectiveTableNames.Sort();

            foreach (string perspectiveTableName in perspectiveTableNames)
            {
                _objectDefinition += perspectiveTableName + "\n";

                // find the PerspectiveDimension again
                foreach (PerspectiveDimension perspectiveDimension in _amoPerspective.Dimensions)
                {
                    if (perspectiveDimension.Dimension.Name == perspectiveTableName)
                    {
                        //Attributes
                        List <string> perspectiveAttributeNames = new List <string>();  // put in here to sort
                        foreach (PerspectiveAttribute perspectiveAttribute in perspectiveDimension.Attributes)
                        {
                            perspectiveAttributeNames.Add(perspectiveAttribute.Attribute.Name);
                        }
                        perspectiveAttributeNames.Sort();
                        foreach (string perspectiveAttributeName in perspectiveAttributeNames)
                        {
                            _objectDefinition += "   " + perspectiveAttributeName + "\n";
                        }

                        //Hierarchies
                        List <string> perspectiveHierarchyNames = new List <string>();  // put in here to sort
                        foreach (PerspectiveHierarchy perspectiveHierarchy in perspectiveDimension.Hierarchies)
                        {
                            perspectiveHierarchyNames.Add(perspectiveHierarchy.Hierarchy.Name);
                        }
                        perspectiveHierarchyNames.Sort();
                        foreach (string perspectiveHierarchyName in perspectiveHierarchyNames)
                        {
                            _objectDefinition += "   " + perspectiveHierarchyName + "\n";
                        }
                    }
                }

                //Measures
                List <string> perspectiveMeasureNames = new List <string>();  // put in here to sort
                foreach (PerspectiveCalculation perspectiveCalculation in _amoPerspective.Calculations)
                {
                    string measureName = perspectiveCalculation.Name.Replace("[Measures].[", "").Replace("]", "");
                    if (_parentTabularModel.Measures.ContainsName(measureName) &&
                        _parentTabularModel.Measures.FindByName(measureName).TableName == perspectiveTableName)
                    {
                        perspectiveMeasureNames.Add(measureName);
                    }
                }
                perspectiveMeasureNames.Sort();
                foreach (string perspectiveCalculationName in perspectiveMeasureNames)
                {
                    _objectDefinition += "   " + perspectiveCalculationName + "\n";
                }

                //KPIs
                List <string> perspectiveKpiNames = new List <string>();  // put in here to sort
                foreach (PerspectiveKpi perspectiveKpi in _amoPerspective.Kpis)
                {
                    string kpiName = perspectiveKpi.ToString();
                    if (_parentTabularModel.Kpis.ContainsName(kpiName) &&
                        _parentTabularModel.Kpis.FindByName(kpiName).TableName == perspectiveTableName &&
                        !perspectiveMeasureNames.Contains(kpiName))  //last check in case already added as a measure
                    {
                        perspectiveKpiNames.Add(kpiName);
                    }
                }
                perspectiveKpiNames.Sort();
                foreach (string perspectiveCalculationName in perspectiveKpiNames)
                {
                    _objectDefinition += "   " + perspectiveCalculationName + "\n";
                }
            }

            //Actions
            List <string> perspectiveActionNames = new List <string>();  // put in here to sort

            foreach (PerspectiveAction perspectiveAction in _amoPerspective.Actions)
            {
                if (perspectiveAction.ParentCube.Actions.Contains(perspectiveAction.ActionID))  //need this check or .Action returns error
                {
                    string actionName = perspectiveAction.Action.Name;
                    if (_parentTabularModel.Actions.ContainsName(actionName))
                    {
                        perspectiveActionNames.Add(actionName);
                    }
                }
            }
            perspectiveActionNames.Sort();
            foreach (string perspectiveActionName in perspectiveActionNames)
            {
                _objectDefinition += "Action: " + perspectiveActionName + "\n";
            }

            //if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionTranslations)
            //{
            //    _objectDefinition += "\nFormat & Visibility:\nPerspective Translations: ";
            //    if (_amoPerspective.Translations.Count > 0)
            //    {
            //        _objectDefinition += "[";
            //        foreach (Translation perspectiveTranslation in _amoPerspective.Translations)
            //        {
            //            _objectDefinition += CultureInfo.GetCultureInfo(perspectiveTranslation.Language).DisplayName + ": " + perspectiveTranslation.Caption + ", ";
            //        }
            //        _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]";
            //    }

            //    if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionDisplayFolders)
            //    {
            //        _objectDefinition += ", Display Folder Translations: ";
            //        if (_amoPerspective.Translations.Count > 0)
            //        {
            //            _objectDefinition += "[";
            //            foreach (Translation perspectiveDisplayFolderTranslation in _amoPerspective.Translations)
            //            {
            //                _objectDefinition += CultureInfo.GetCultureInfo(perspectiveDisplayFolderTranslation.Language).DisplayName + ": " + perspectiveDisplayFolderTranslation.DisplayFolder + ", ";
            //            }
            //            _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]";
            //        }
            //    }
            //    _objectDefinition += "\n";
            //}

            _objectDefinition += "\n";
        }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the Culture class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the Culture object belongs to.</param>
 /// <param name="tomCulture">Tabular Object Model Culture object abtstracted by the Culture class.</param>
 public Culture(TabularModel parentTabularModel, Tom.Culture tomCulture) : base(tomCulture, parentTabularModel)
 {
     _parentTabularModel = parentTabularModel;
     _tomCulture         = tomCulture;
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the DataSource class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the DataSource object belongs to.</param>
 /// <param name="datasource">Tabular Object Model ProviderDataSource object abtstracted by the DataSource class.</param>
 public DataSource(TabularModel parentTabularModel, Microsoft.AnalysisServices.Tabular.DataSource dataSource) : base(dataSource, parentTabularModel)
 {
     _parentTabularModel = parentTabularModel;
     _tomDataSource      = dataSource;
 }
        /// <summary>
        /// Initializes a new instance of the TabularObject class.
        /// </summary>
        /// <param name="namedMetaDataObject">The Tabular Object Model supertype of the class being abstracted.</param>
        public TabularObject(NamedMetadataObject namedMetaDataObject, TabularModel parentTabularModel)
        {
            _name = namedMetaDataObject.Name;
            if (namedMetaDataObject is Tom.Model)
            {
                return;                                   //Model has custom JSON string
            }
            _parentTabularModel = parentTabularModel;

            //Serialize json
            SerializeOptions options = new SerializeOptions();

            options.IgnoreInferredProperties = true;
            options.IgnoreInferredObjects    = true;
            options.IgnoreTimestamps         = true;
            options.SplitMultilineStrings    = true;
            _objectDefinition = Tom.JsonSerializer.SerializeObject(namedMetaDataObject, options);

            //Remove annotations
            {
                JToken token = JToken.Parse(_objectDefinition);
                RemovePropertyFromObjectDefinition(token, "annotations");
                _objectDefinition = token.ToString(Formatting.Indented);
            }

            //Remove lineageTag if required
            if (_parentTabularModel != null && _parentTabularModel.ComparisonInfo != null &&
                !_parentTabularModel.ComparisonInfo.OptionsInfo.OptionLineageTag)
            {
                JToken token = JToken.Parse(_objectDefinition);
                RemovePropertyFromObjectDefinition(token, "lineageTag");
                _objectDefinition = token.ToString(Formatting.Indented);
            }

            ////todo: remove with Giri's fix
            ////Remove return characters
            //if (namedMetaDataObject is Tom.NamedExpression || namedMetaDataObject is Tom.Table)
            //{
            //    _objectDefinition = _objectDefinition.Replace("\\r", "");
            //}

            //Order table columns
            if (namedMetaDataObject is Tom.Table)
            {
                if (((Tom.Table)namedMetaDataObject).CalculationGroup != null)
                {
                    JToken token = JToken.Parse(_objectDefinition);
                    RemovePropertyFromObjectDefinition(token, "calculationItems");
                    _objectDefinition = token.ToString(Formatting.Indented);
                }

                _objectDefinition = SortArray(_objectDefinition, "columns");
                _objectDefinition = SortArray(_objectDefinition, "partitions");
            }

            //Order role members
            if (namedMetaDataObject is Tom.ModelRole)
            {
                _objectDefinition = SortArray(_objectDefinition, "members");
            }

            //Hide privacy setting on structured data sources
            if (namedMetaDataObject is Tom.StructuredDataSource)
            {
                JToken token = JToken.Parse(_objectDefinition);
                RemovePropertyFromObjectDefinition(token, "PrivacySetting");
                _objectDefinition = token.ToString(Formatting.Indented);
            }
        }