Пример #1
0
        /// <summary>
        /// Возвращает KPI
        /// </summary>
        /// <param name="cubeName"></param>
        /// <returns></returns>
        public KpiInfo GetKPI(String cubeName, String kpiName)
        {
            try
            {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Kpi '{1}' Started \r\n cubeName: '{2}'",
                                                          DateTime.Now.ToString(), kpiName, cubeName);

                if (String.IsNullOrEmpty(kpiName))
                {
                    return(null);
                }

                CubeDef cube = FindCube(cubeName);
                if (cube != null)
                {
                    foreach (Kpi kpi in cube.Kpis)
                    {
                        KpiInfo info = InfoHelper.CreateKpiInfo(kpi);
                        if (info != null && info.Name.ToLower() == kpiName.ToLower())
                        {
                            return(info);
                        }
                    }
                }
                return(null);
            }
            finally {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Kpi '{1}' Completed \r\n", DateTime.Now.ToString(), kpiName);
            }
        }
Пример #2
0
 public Kpi_AreaItemWrapper(KpiInfo info, KpiControlType type)
     : base(info)
 {
     Name             = info.Name;
     Type             = type;
     Custom_KpiGoal   = info.Custom_KpiGoal;
     Custom_KpiStatus = info.Custom_KpiStatus;
     Custom_KpiTrend  = info.Custom_KpiTrend;
     Custom_KpiValue  = info.Custom_KpiValue;
 }
Пример #3
0
        public KpiInfoItem(KpiInfo kpiInfo)
        {
            Name          = kpiInfo.Name;
            Description   = kpiInfo.Description;
            ApplyCycle    = kpiInfo.ApplyCycle;
            UseType       = kpiInfo.UseType;
            Active        = kpiInfo.Active;
            DefaultSymbol = kpiInfo.DefaultSymbol;
            GoalValue1    = kpiInfo.GoalValue1;
            GoalValue2    = kpiInfo.GoalValue2;

            KpiInfo = kpiInfo;
        }
Пример #4
0
        /// <summary>
        /// Возвращает список KPI
        /// </summary>
        /// <param name="cubeName"></param>
        /// <returns></returns>
        public Dictionary <String, KpiInfo> GetKPIs(String cubeName)
        {
            try
            {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Kpis List Started \r\n cubeName: '{1}'",
                                                          DateTime.Now.ToString(), cubeName);

                Dictionary <String, KpiInfo> list = new Dictionary <String, KpiInfo>();

                CubeDef cube = FindCube(cubeName);
                if (cube != null)
                {
                    foreach (Kpi kpi in cube.Kpis)
                    {
                        KpiInfo info = InfoHelper.CreateKpiInfo(kpi);
                        if (info != null)
                        {
                            if (!list.ContainsKey(info.Name))
                            {
                                list.Add(info.Name, info);
                            }
                        }
                    }
                }
                else
                {
                    String str = String.Format(Localization.MetadataResponseException_CubeNotFound, cubeName, Connection.ConnectionID);
                    System.Diagnostics.Trace.TraceError("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider: {1} \r\n",
                                                        DateTime.Now.ToString(), cubeName, str);
                    throw new OlapMetadataResponseException(str);
                }

                return(list);
            }
            finally {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Kpis List Completed \r\n", DateTime.Now.ToString());
            }
        }
Пример #5
0
        // Will only return the direct KPI's associated to a hierarchy.
        // If there is a need to retrive all the KPI's under a folder, the Javascript client will take care of consolidating.
        public Dictionary <string, List <KpiInfo> > GetConsolidatedHierarchyKpiOrig()
        {
            Dictionary <string, List <KpiInfo> > retDict = new Dictionary <string, List <KpiInfo> >();

            using (SqlCommand command = new SqlCommand(@"select FullPath, NodeName, g.Name as KpiGroupName, k.Name as KpiName " +
                                                       "from DimHierarchyKpiConsolidated conso " +
                                                       "JOIN DimHierarchyConsolidated h ON conso.HierarchyConsoId = h.Id " +
                                                       "JOIN DimKpi k ON conso.KpiConsoId = k.Id " +
                                                       "JOIN DimKpiGroup g ON g.Id = k.KpiGroupId ",
                                                       connection))
            {
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string         FullPath    = reader["FullPath"].ToString();
                        List <KpiInfo> currKpiList = null;

                        if (!retDict.TryGetValue(FullPath, out currKpiList))
                        {
                            currKpiList       = new List <KpiInfo>();
                            retDict[FullPath] = currKpiList;
                        }

                        KpiInfo newData = new KpiInfo()
                        {
                            KpiGroupName = reader["KpiGroupName"].ToString(),
                            KpiName      = reader["KpiName"].ToString(),
                        };

                        // We can assume that all items from the query are unique
                        currKpiList.Add(newData);
                    }
                }
            }

            return(retDict);
        }
Пример #6
0
        /// <summary>
        /// Возвращает список кубов
        /// </summary>
        /// <returns></returns>
        public CubeDefInfo  GetCubeMetadata(String cubeName, MetadataQueryType type)
        {
            try
            {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Getting Cube '{1}' Metadata Started",
                                                          DateTime.Now.ToString(), cubeName);

                CubeDef cube = FindCube(cubeName);
                if (cube != null)
                {
                    CubeDefInfo cube_info = InfoHelper.CreateCubeInfo(cube);
                    foreach (Dimension dim in cube.Dimensions)
                    {
                        DimensionInfo dim_info = InfoHelper.CreateDimensionInfo(dim);
                        cube_info.Dimensions.Add(dim_info);

                        foreach (Hierarchy hierarchy in dim.Hierarchies)
                        {
                            HierarchyInfo hier_info = InfoHelper.CreateHierarchyInfo(hierarchy);
                            dim_info.Hierarchies.Add(hier_info);

                            foreach (Level level in hierarchy.Levels)
                            {
                                LevelInfo level_info = InfoHelper.CreateLevelInfo(level);
                                hier_info.Levels.Add(level_info);
                            }

                            //AdomdConnection conn = GetConnection(ConnectionString);

                            //// Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.All
                            //try
                            //{
                            //    AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();
                            //    restrictions.Add("CATALOG_NAME", conn.Database);
                            //    restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName));
                            //    restrictions.Add("DIMENSION_UNIQUE_NAME", dim.UniqueName);
                            //    restrictions.Add("HIERARCHY_UNIQUE_NAME", hierarchy.UniqueName);
                            //    restrictions.Add("MEMBER_TYPE", 2/*MemberTypeEnum.All*/);

                            //    DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions);
                            //    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            //    {
                            //        DataTable table = ds.Tables[0];
                            //        if (table.Columns.Contains("MEMBER_UNIQUE_NAME"))
                            //        {
                            //            object obj = ds.Tables[0].Rows[0]["MEMBER_UNIQUE_NAME"];
                            //            if (obj != null)
                            //                hier_info.Custom_AllMemberUniqueName = obj.ToString();
                            //        }
                            //    }
                            //}catch
                            //{
                            //}

                            //// Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.Unknown
                            //try
                            //{
                            //    AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();
                            //    restrictions.Add("CATALOG_NAME", conn.Database);
                            //    restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName));
                            //    restrictions.Add("DIMENSION_UNIQUE_NAME", dim.UniqueName);
                            //    restrictions.Add("HIERARCHY_UNIQUE_NAME", hierarchy.UniqueName);
                            //    restrictions.Add("MEMBER_TYPE", 0 /*MemberTypeEnum.Unknown.All*/);

                            //    DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions);
                            //    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            //    {
                            //        DataTable table = ds.Tables[0];
                            //        if (table.Columns.Contains("MEMBER_UNIQUE_NAME"))
                            //        {
                            //            object obj = ds.Tables[0].Rows[0]["MEMBER_UNIQUE_NAME"];
                            //            if (obj != null)
                            //                hier_info.Custom_UnknownMemberUniqueName = obj.ToString();
                            //        }
                            //    }
                            //}
                            //catch
                            //{
                            //}
                        }
                    }

                    foreach (Kpi kpi in cube.Kpis)
                    {
                        KpiInfo kpi_info = InfoHelper.CreateKpiInfo(kpi);
                        cube_info.Kpis.Add(kpi_info);
                    }

                    foreach (Measure measure in cube.Measures)
                    {
                        MeasureInfo measure_info = InfoHelper.CreateMeasureInfo(measure);
                        cube_info.Measures.Add(measure_info);
                    }

                    foreach (NamedSet set in cube.NamedSets)
                    {
                        NamedSetInfo set_info = InfoHelper.CreateNamedSetInfo(set);
                        cube_info.NamedSets.Add(set_info);
                    }

                    if (type == MetadataQueryType.GetCubeMetadata_AllMembers)
                    {
                        AdomdConnection conn = GetConnection();
                        // Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.All
                        try
                        {
                            AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();
                            restrictions.Add("CATALOG_NAME", conn.Database);
                            restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName));
                            restrictions.Add("MEMBER_TYPE", 2 /*MemberTypeEnum.All*/);

                            DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions);
                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                DataTable table = ds.Tables[0];
                                if (table.Columns.Contains("MEMBER_UNIQUE_NAME") &&
                                    table.Columns.Contains("HIERARCHY_UNIQUE_NAME") &&
                                    table.Columns.Contains("DIMENSION_UNIQUE_NAME"))
                                {
                                    foreach (DataRow row in ds.Tables[0].Rows)
                                    {
                                        String dimension_UniqueName = row["DIMENSION_UNIQUE_NAME"] != null ? row["DIMENSION_UNIQUE_NAME"].ToString() : String.Empty;
                                        String hierarchy_UniqueName = row["HIERARCHY_UNIQUE_NAME"] != null ? row["HIERARCHY_UNIQUE_NAME"].ToString() : String.Empty;
                                        String member_UniqueName    = row["MEMBER_UNIQUE_NAME"] != null ? row["MEMBER_UNIQUE_NAME"].ToString() : String.Empty;

                                        if (!String.IsNullOrEmpty(dimension_UniqueName) &&
                                            !String.IsNullOrEmpty(hierarchy_UniqueName) &&
                                            !String.IsNullOrEmpty(member_UniqueName))
                                        {
                                            DimensionInfo dimension = cube_info.GetDimension(dimension_UniqueName);
                                            if (dimension != null)
                                            {
                                                HierarchyInfo hierarchy = dimension.GetHierarchy(hierarchy_UniqueName);
                                                if (hierarchy != null)
                                                {
                                                    hierarchy.Custom_AllMemberUniqueName = member_UniqueName;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            //throw ex;
                        }
                    }

                    cube_info.MeasureGroups = GetMeasureGroups(cubeName);

                    return(cube_info);
                }

                return(null);
            }
            finally {
                System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Getting Cube '{1}' Metadata Completed",
                                                          DateTime.Now.ToString(), cubeName);
            }
        }
 public KpiValueTreeNode(KpiInfo info)
     : base(info)
 {
     Icon = UriResources.Images.Kpi16;
     Text = "Value";
 }
Пример #8
0
 public KpiTreeNode(KpiInfo info)
     : base(info)
 {
     Icon = UriResources.Images.Kpi16;
 }
Пример #9
0
 //加载所有的KPI详细信息
 private void LoadKpiDetailInfo()
 {
     try
     {
         WebRequest webRequest = new WebRequest();
         webRequest.Code    = (int)S4601Codes.GetAllKPIInfoLists;
         webRequest.Session = CurrentApp.Session;
         Service46011Client client = new Service46011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                            WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service46011"));
         //Service46011Client client = new Service46011Client();
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
             return;
         }
         mListKpiInfoItems.Clear();
         for (int i = 0; i < webReturn.ListData.Count; i++)
         {
             OperationReturn optReturn = XMLHelper.DeserializeObject <KpiInfo>(webReturn.ListData[i]);
             if (!optReturn.Result)
             {
                 ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                 return;
             }
             KpiInfo item = optReturn.Data as KpiInfo;
             if (item != null)
             {
                 KpiInfoItem temp = new KpiInfoItem(item);
                 temp.StrActive      = CurrentApp.GetLanguageInfo(string.Format("4601IsActive{0}", temp.Active), temp.Active);
                 temp.StrDescription = CurrentApp.GetLanguageInfo(string.Format("4601KPI{0}", temp.KpiInfo.KpiID), temp.Description);
                 if (Regex.Matches(temp.UseType, @"1").Count > 0)
                 {
                     temp.StrUseType = string.Empty;
                     if (temp.UseType.Substring(0, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "1000000000"), "1000000000") + ",";
                     }
                     if (temp.UseType.Substring(1, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "0100000000"), "0100000000") + ",";
                     }
                     if (temp.UseType.Substring(2, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "0010000000"), "0010000000") + ",";
                     }
                     if (temp.UseType.Substring(3, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "0001000000"), "0001000000") + ",";
                     }
                     if (temp.UseType.Substring(4, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "0000100000"), "0001000000") + ",";
                     }
                     if (temp.UseType.Substring(5, 1) == "1")
                     {
                         temp.StrUseType += CurrentApp.GetLanguageInfo(string.Format("4601BPOBJ{0}", "0000010000"), "0001000000") + " ";
                     }
                 }
                 if (Regex.Matches(temp.ApplyCycle, @"1").Count > 0)
                 {
                     temp.StrApplyCycle = string.Empty;
                     if (temp.ApplyCycle.Substring(0, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "1000000001"), "1000000001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(1, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0100000001"), "0100000001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(2, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0010000001"), "0010000001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(3, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0001000001"), "0001000001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(4, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0000100001"), "0000100001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(5, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0000010001"), "0000010001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(6, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0000001001"), "0000001001") + ",";
                     }
                     if (temp.ApplyCycle.Substring(7, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0000000101"), "0000000101") + ",";
                     }
                     if (temp.ApplyCycle.Substring(8, 1) == "1")
                     {
                         temp.StrApplyCycle += CurrentApp.GetLanguageInfo(string.Format("4601BP{0}", "0000000011"), "0000000011") + " ";
                     }
                 }
                 mListKpiInfoItems.Add(temp);
             }
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
 public KpiStatusTreeNode(KpiInfo info)
     : base(info)
 {
     Icon = UriResources.Images.Kpi16;
     Text = "Status";
 }
 public KpiGoalTreeNode(KpiInfo info)
     : base(info)
 {
     Icon = UriResources.Images.Kpi16;
     Text = "Goal";
 }