/// <summary>
        /// Create cube dimension
        /// </summary>
        /// <param name="sqlHelper"></param>
        /// <param name="asMeta"></param>
        /// <param name="cubeDB"></param>
        /// <param name="DSV"></param>
        public void CREATE_CUBE_DIMENSION(DB_SQLHELPER_BASE sqlHelper
                                          , AS_METADATA asMeta
                                          , Microsoft.AnalysisServices.Database cubeDB
                                          , Microsoft.AnalysisServices.DataSourceView DSV
                                          )
        {
            try
            {
                sqlHelper.ADD_MESSAGE_LOG("[Create dimension] Starting create dimension"
                                          , MESSAGE_TYPE.DIMENSION
                                          , MESSAGE_RESULT_TYPE.Normal);
                DataTable DimensionSet = asMeta.GET_SSAS_DIMENSION_SET(sqlHelper);
                foreach (DataRow dimension_row in DimensionSet.Rows)
                {
                    String DimensionID    = dimension_row["dimension_id"].ToString();
                    String DimensionName  = dimension_row["dimension_name"].ToString();
                    String DimensionType  = dimension_row["dimension_type"].ToString();
                    String DataSourceName = dimension_row["dsv_schema_name"].ToString();
                    String dsvName        = DSV.Name;
                    Microsoft.AnalysisServices.Dimension dim = AS_API.ADD_DIMENSION(sqlHelper, cubeDB, dsvName, DimensionID, DimensionName, DimensionType);

                    DataTable AttributeSet = asMeta.GET_SSAS_ATTRIBUTES_SET(sqlHelper, DimensionID);
                    if (AttributeSet == null || AttributeSet.Rows == null || AttributeSet.Rows.Count == 0)
                    {
                        sqlHelper.ADD_MESSAGE_LOG(
                            String.Format("[Create dimension] Dimension {0} has not any attributes, is it expected?", DimensionID)
                            , MESSAGE_TYPE.DIMENSION
                            , MESSAGE_RESULT_TYPE.Warning);
                    }
                    else
                    {
                        sqlHelper.ADD_MESSAGE_LOG(
                            String.Format("[Create dimension] Adding {0} attributeds for dimension {1}", AttributeSet.Rows.Count.ToString(), DimensionID)
                            , MESSAGE_TYPE.DIMENSION
                            , MESSAGE_RESULT_TYPE.Normal);
                    }
                    foreach (DataRow attribute_row in AttributeSet.Rows)
                    {
                        String AttributeID    = attribute_row["attribute_id"].ToString();
                        String AttributeName  = attribute_row["attribbute_name"].ToString();
                        String DSVSchemaName  = attribute_row["dsv_schema_name"].ToString();
                        String DBColumn       = attribute_row["key_column_db_column"].ToString();
                        String OleDbType      = attribute_row["key_column_oledb_type"].ToString();
                        String AttributeUsage = attribute_row["attribute_usage"].ToString();
                        String NameColumn     = attribute_row["name_column"].ToString();
                        String Visible        = attribute_row["visible"].ToString();
                        String AttHierEnabled = attribute_row["atthier_enabled"].ToString();
                        String OrderBy        = attribute_row["order_by"].ToString();
                        Microsoft.AnalysisServices.OrderBy attribute_order_by = Microsoft.AnalysisServices.OrderBy.Name;
                        if (OrderBy.ToLower() == "key")
                        {
                            attribute_order_by = Microsoft.AnalysisServices.OrderBy.Key;
                        }
                        AS_API.ADD_ATTRIBUTE_TO_DIMENSION(
                            sqlHelper,
                            DSV,
                            dim,
                            DataSourceName,
                            DBColumn,
                            AttributeID,
                            AttributeName,
                            AS_API_HELPER.GET_SSAS_OLEDB_TYPE_BY_NAME(OleDbType),
                            AS_API_HELPER.GET_SSAS_ATTRIBUTE_USAGE_BY_NAME(AttributeUsage),
                            NameColumn, Convert.ToBoolean(Visible),
                            Convert.ToBoolean(AttHierEnabled),
                            attribute_order_by
                            );
                    }

                    DataTable AttributeRelationShipSet = asMeta.GET_SSAS_ATTRIBUTE_RELATION_SHIPS_SET(sqlHelper, DimensionID);

                    sqlHelper.ADD_MESSAGE_LOG(String.Format("[Create dimension] Adding {0} attribute relationships for dimension {1}", AttributeRelationShipSet.Rows.Count.ToString(), DimensionID)
                                              , MESSAGE_TYPE.ATTRIBUTE_RELATIONSHIP
                                              , MESSAGE_RESULT_TYPE.Normal);

                    foreach (DataRow row in AttributeRelationShipSet.Rows)
                    {
                        String BasedAttributeID   = row["based_attribute_id"].ToString();
                        String RelatedAttributeID = row["related_attribute_id"].ToString();
                        String RelationShipType   = row["relationship_type"].ToString();
                        Microsoft.AnalysisServices.RelationshipType AttributeRelationShipType = AS_API_HELPER.GET_SSAS_ATTRIBUTE_RELATION_SHIP_TYPE_BY_NAME(RelationShipType);

                        AS_API.ADD_ATTRIBUTE_RELATIONSHIP(
                            sqlHelper,
                            dim,
                            BasedAttributeID,
                            RelatedAttributeID,
                            AttributeRelationShipType);
                    }


                    DataTable HierarchiesSet = asMeta.GET_SSAS_HIERARCHIES_SET(sqlHelper, DimensionID);

                    sqlHelper.ADD_MESSAGE_LOG(
                        String.Format("[Create dimension] Adding {0} hierarchy levels for dimension {1}", HierarchiesSet.Rows.Count.ToString(), DimensionID)
                        , MESSAGE_TYPE.HIERARCHIES
                        , MESSAGE_RESULT_TYPE.Normal);
                    foreach (DataRow row in HierarchiesSet.Rows)
                    {
                        String HierarchyName     = row["hierarchy_name"].ToString();
                        String LevelName         = row["level_name"].ToString();
                        String LevelID           = row["level_id"].ToString();
                        String SourceAttributeID = row["source_attribute_id"].ToString();
                        AS_API.ADD_ATTRIBUTE_HIERACHIES(
                            sqlHelper,
                            dim,
                            HierarchyName,
                            LevelName,
                            SourceAttributeID);
                        sqlHelper.ADD_MESSAGE_LOG(
                            "[Create dimension->Hierarchy] |" + new string('_', Convert.ToInt16(LevelID)) + LevelName
                            , MESSAGE_TYPE.HIERARCHIES
                            , MESSAGE_RESULT_TYPE.Normal);
                    }
                    sqlHelper.ADD_MESSAGE_LOG(
                        "[Create dimension] Updating changes of dimension objects.."
                        , MESSAGE_TYPE.DIMENSION
                        , MESSAGE_RESULT_TYPE.Normal);
                    dim.Update();
                    sqlHelper.ADD_MESSAGE_LOG(
                        "[Create dimension] Succeed to add changes to dimension objects.."
                        , MESSAGE_TYPE.DIMENSION
                        , MESSAGE_RESULT_TYPE.Normal);
                }
            }
            catch (Exception ex)
            {
                sqlHelper.ADD_MESSAGE_LOG("[Create dimension] " + ex.Message.ToString(), MESSAGE_TYPE.ADD_DIMENSION, MESSAGE_RESULT_TYPE.Error);
                throw (ex);
            }
        }