Esempio n. 1
0
        private void ExpendMembers(TreeNode root)
        {
            if (!root.ImageKey.Equals("Level") && !root.ImageKey.Equals("Member"))
            {
                return;
            }
            if (root.Nodes.Count > 0)
            {
                return;
            }

            CubeOperate co         = cos[GetCubeNodeOfCubeInfoTree(tvCubeInfo.SelectedNode).Parent.Name];
            string      connString = co.ConnectionString.ToLower();

            if (connString.Contains("mondrian"))
            {
                ExpendMondrianMembers(co, root);
            }
            else if (connString.Contains("msolap"))
            {
                ExpendSSASMembers(root);
            }

            root.Expand();
        }
Esempio n. 2
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         cos.Clear();
         if (this.ConnStr.ToLower().Contains("catalog"))
         {
             CubeOperate co = new CubeOperate(this.ConnStr);
             cos.Add(co.Conn.Database, co);
         }
         else
         {
             AdomdConnection conn = new AdomdConnection(this.ConnStr);
             conn.Open();
             DataSet dsCatalogs = conn.GetSchemaDataSet("DBSCHEMA_CATALOGS", null);
             conn.Close();
             foreach (DataRow catalogRow in dsCatalogs.Tables[0].Rows.Cast <DataRow>())
             {
                 string catalog = catalogRow[0].ToString();
                 string connStr = string.Format("{0};Catalog ={1};", this.ConnStr.EndsWith(";") ? this.ConnStr.Remove(this.ConnStr.Length - 1) : this.ConnStr, catalog);
                 cos.Add(catalog, new CubeOperate(connStr));
             }
         }
         BindServerInfo();
     }
     catch (Exception ex)
     {
         this.ShowMessage(ex);
     }
 }
Esempio n. 3
0
        private void BindMeasuresForCube(TreeNode measuresNode, string cubeName, CubeOperate co)
        {
            IEnumerable <Measure> measures = co.GetMeasures(cubeName);

            measuresNode.Nodes.Clear();

            if (measures == null)
            {
                return;
            }
            bool hasGroup = measures.FirstOrDefault().Properties.Find("MEASUREGROUP_NAME") != null;

            if (hasGroup)
            {
                var groups = measures.Select(r => r.Properties["MEASUREGROUP_NAME"].Value.ToString()).Distinct();
                foreach (var group in groups.OrderBy(r => r))
                {
                    var tempMeasures = measures.Where(r => r.Properties["MEASUREGROUP_NAME"].Value.ToString().Equals(group));
                    measuresNode.Nodes.Add(group, group, "Group", "Group");
                    foreach (var item in tempMeasures.OrderBy(r => r.Caption))
                    {
                        string   name     = item.Name;    //.Replace("$", "");
                        string   caption  = item.Caption; //.Replace("$", "");
                        TreeNode tempNode = new TreeNode(caption);
                        tempNode.Name = name;
                        tempNode.Tag  = item;
                        bool     visible            = item.Properties["MEASURE_IS_VISIBLE"].Value.Value <bool>(true);
                        Property expressionProperty = item.Properties.Find("EXPRESSION");
                        string   expression         = expressionProperty == null ? "" : expressionProperty.Value.ToJString();
                        string   key = string.IsNullOrEmpty(expression) ? "Measure" : "CalMeasure";
                        tempNode.SelectedImageKey = tempNode.ImageKey = visible ? key : "" + key;
                        tempNode.ToolTipText      = string.Format("Measure Name:[{0}]Caption:[{1}]", item.Name, item.Caption);
                        measuresNode.Nodes[group].Nodes.Add(tempNode);
                    }
                }
            }
            else
            {
                measuresNode.Nodes.Add("DefaultGroup", "DefaultGroup", "Group", "Group");
                foreach (var item in measures.OrderBy(r => r.Caption))
                {
                    string   name     = item.Name;    //.Replace("$", "");
                    string   caption  = item.Caption; //.Replace("$", "");
                    TreeNode tempNode = new TreeNode(caption);
                    tempNode.Name = name;
                    tempNode.Tag  = item;
                    bool     visible            = item.Properties["MEASURE_IS_VISIBLE"].Value.Value <bool>(true);
                    Property expressionProperty = item.Properties.Find("EXPRESSION");
                    string   expression         = expressionProperty == null ? "" : expressionProperty.Value.ToJString();
                    string   key = string.IsNullOrEmpty(expression) ? "Measure" : "CalMeasure";
                    tempNode.SelectedImageKey = tempNode.ImageKey = visible ? key : "" + key;
                    tempNode.ToolTipText      = string.Format("Measure Name:[{0}]Caption:[{1}]", item.Name, item.Caption);
                    measuresNode.Nodes[0].Nodes.Add(tempNode);
                }
            }
            measuresNode.Collapse();
        }
Esempio n. 4
0
        private DataTable QueryMondrianMembers(CubeOperate co, Dictionary <string, object> dic)
        {
            AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();

            foreach (var item in dic)
            {
                restrictions.Add(item.Key, item.Value);
            }
            if (co.Conn.State != ConnectionState.Open)
            {
                co.Conn.Open();
            }
            return(co.Conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions).Tables[0]);
        }
Esempio n. 5
0
        private void ExpendMondrianMembers(CubeOperate co, TreeNode root)
        {
            DataTable membersData = null;

            if (root.ImageKey.Equals("Level"))
            {
                Level level = root.Tag as Level;
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("CATALOG_NAME", level.Properties["CATALOG_NAME"].Value.ToString());
                dic.Add("CUBE_NAME", level.Properties["CUBE_NAME"].Value.ToString());
                dic.Add("LEVEL_UNIQUE_NAME", level.Properties["LEVEL_UNIQUE_NAME"].Value.ToString());
                membersData = QueryMondrianMembers(co, dic);
            }
            else if (root.ImageKey.Equals("Member"))
            {
                MemberInfo rootMember           = root.Tag as MemberInfo;
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("CATALOG_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("CATALOG_NAME")).Value.ToString());
                dic.Add("CUBE_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("CUBE_NAME")).Value.ToString());
                dic.Add("MEMBER_UNIQUE_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("MEMBER_UNIQUE_NAME")).Value.ToString());
                dic.Add("TREE_OP", 1);
                membersData = QueryMondrianMembers(co, dic);
            }
            List <MemberInfo> childMembers = GetMemberList(membersData);

            if (childMembers == null || childMembers.Count <= 0)
            {
                return;
            }
            foreach (var member in childMembers)
            {
                string   name     = member.Name.Replace("$", "");
                string   caption  = member.Caption.Replace("$", "");
                TreeNode tempNode = new TreeNode(caption);
                tempNode.Name             = name;
                tempNode.SelectedImageKey = tempNode.ImageKey = "Member";
                tempNode.ToolTipText      = string.Format("Member Name:[{0}]Caption:[{1}]", name, caption);

                tempNode.Tag = member;

                root.Nodes.Add(tempNode);
            }
        }
Esempio n. 6
0
        private DataTable QueryMondrianMembers(CubeOperate co, Dictionary<string, object> dic)
        {
            AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();

            foreach (var item in dic)
            {
                restrictions.Add(item.Key, item.Value);
            }
            if (co.Conn.State != ConnectionState.Open)
            {
                co.Conn.Open();
            }
            return co.Conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions).Tables[0];
        }
Esempio n. 7
0
        private void ExpendMondrianMembers(CubeOperate co, TreeNode root)
        {
            DataTable membersData = null;

            if (root.ImageKey.Equals("Level"))
            {
                Level level = root.Tag as Level;
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("CATALOG_NAME", level.Properties["CATALOG_NAME"].Value.ToString());
                dic.Add("CUBE_NAME", level.Properties["CUBE_NAME"].Value.ToString());
                dic.Add("LEVEL_UNIQUE_NAME", level.Properties["LEVEL_UNIQUE_NAME"].Value.ToString());
                membersData = QueryMondrianMembers(co, dic);
            }
            else if (root.ImageKey.Equals("Member"))
            {
                MemberInfo rootMember = root.Tag as MemberInfo;
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("CATALOG_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("CATALOG_NAME")).Value.ToString());
                dic.Add("CUBE_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("CUBE_NAME")).Value.ToString());
                dic.Add("MEMBER_UNIQUE_NAME", rootMember.Properties.FirstOrDefault(p => p.Name.Equals("MEMBER_UNIQUE_NAME")).Value.ToString());
                dic.Add("TREE_OP", 1);
                membersData = QueryMondrianMembers(co, dic);
            }
            List<MemberInfo> childMembers = GetMemberList(membersData);
            if (childMembers == null || childMembers.Count <= 0) return;
            foreach (var member in childMembers)
            {
                string name = member.Name.Replace("$", "");
                string caption = member.Caption.Replace("$", "");
                TreeNode tempNode = new TreeNode(caption);
                tempNode.Name = name;
                tempNode.SelectedImageKey = tempNode.ImageKey = "Member";
                tempNode.ToolTipText = string.Format("Member Name:[{0}]Caption:[{1}]", name, caption);

                tempNode.Tag = member;

                root.Nodes.Add(tempNode);
            }
        }
Esempio n. 8
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         cos.Clear();
         if (this.ConnStr.ToLower().Contains("catalog"))
         {
             CubeOperate co = new CubeOperate(this.ConnStr);
             cos.Add(co.Conn.Database, co);
         }
         else
         {
             AdomdConnection conn = new AdomdConnection(this.ConnStr);
             conn.Open();
             DataSet dsCatalogs = conn.GetSchemaDataSet("DBSCHEMA_CATALOGS", null);
             conn.Close();
             foreach (DataRow catalogRow in dsCatalogs.Tables[0].Rows.Cast<DataRow>())
             {
                 string catalog = catalogRow[0].ToString();
                 string connStr = string.Format("{0};Catalog ={1};", this.ConnStr.EndsWith(";") ? this.ConnStr.Remove(this.ConnStr.Length - 1) : this.ConnStr, catalog);
                 cos.Add(catalog, new CubeOperate(connStr));
             }
         }
         BindServerInfo();
     }
     catch (Exception ex)
     {
         this.ShowMessage(ex);
     }
 }
Esempio n. 9
0
        private void BindMeasuresForCube(TreeNode measuresNode, string cubeName, CubeOperate co)
        {
            IEnumerable<Measure> measures = co.GetMeasures(cubeName);
            measuresNode.Nodes.Clear();

            if (measures == null) return;
            bool hasGroup = measures.FirstOrDefault().Properties.Find("MEASUREGROUP_NAME") != null;
            if (hasGroup)
            {
                var groups = measures.Select(r => r.Properties["MEASUREGROUP_NAME"].Value.ToString()).Distinct();
                foreach (var group in groups.OrderBy(r => r))
                {
                    var tempMeasures = measures.Where(r => r.Properties["MEASUREGROUP_NAME"].Value.ToString().Equals(group));
                    measuresNode.Nodes.Add(group, group, "Group", "Group");
                    foreach (var item in tempMeasures.OrderBy(r => r.Caption))
                    {
                        string name = item.Name;//.Replace("$", "");
                        string caption = item.Caption;//.Replace("$", "");
                        TreeNode tempNode = new TreeNode(caption);
                        tempNode.Name = name;
                        tempNode.Tag = item;
                        bool visible = item.Properties["MEASURE_IS_VISIBLE"].Value.Value<bool>(true);
                        Property expressionProperty = item.Properties.Find("EXPRESSION");
                        string expression = expressionProperty == null ? "" : expressionProperty.Value.ToJString();
                        string key = string.IsNullOrEmpty(expression) ? "Measure" : "CalMeasure";
                        tempNode.SelectedImageKey = tempNode.ImageKey = visible ? key : "" + key;
                        tempNode.ToolTipText = string.Format("Measure Name:[{0}]Caption:[{1}]", item.Name, item.Caption);
                        measuresNode.Nodes[group].Nodes.Add(tempNode);
                    }
                }
            }
            else
            {
                measuresNode.Nodes.Add("DefaultGroup", "DefaultGroup", "Group", "Group");
                foreach (var item in measures.OrderBy(r => r.Caption))
                {
                    string name = item.Name;//.Replace("$", "");
                    string caption = item.Caption;//.Replace("$", "");
                    TreeNode tempNode = new TreeNode(caption);
                    tempNode.Name = name;
                    tempNode.Tag = item;
                    bool visible = item.Properties["MEASURE_IS_VISIBLE"].Value.Value<bool>(true);
                    Property expressionProperty = item.Properties.Find("EXPRESSION");
                    string expression = expressionProperty == null ? "" : expressionProperty.Value.ToJString();
                    string key = string.IsNullOrEmpty(expression) ? "Measure" : "CalMeasure";
                    tempNode.SelectedImageKey = tempNode.ImageKey = visible ? key : "" + key;
                    tempNode.ToolTipText = string.Format("Measure Name:[{0}]Caption:[{1}]", item.Name, item.Caption);
                    measuresNode.Nodes[0].Nodes.Add(tempNode);
                }
            }
            measuresNode.Collapse();
        }