コード例 #1
0
        // ===================================================== Helper methods

        public KPIData GetKPIData(string key)
        {
            KPIData kpiData = null;

            if (!string.IsNullOrEmpty(key))
            {
                kpiData = this.KPIDataList.FirstOrDefault(kd => kd.Label == key);
            }

            return(kpiData ?? new KPIData(string.Empty, 0, 0));
        }
コード例 #2
0
        public IDictionary <string, object> GetExtendedData()
        {
            _kpiDataList = new List <KPIData>();
            var kpiDataDict = new Dictionary <string, object>();
            var kpiXmlValue = new XmlDocument();

            try
            {
                if (!string.IsNullOrEmpty(this.KPIData))
                {
                    kpiXmlValue.LoadXml(this.KPIData);
                }
            }
            catch (Exception ex)
            {
                SnLog.WriteException(ex);
            }

            var kpiDataNodes = kpiXmlValue.SelectNodes("KPI/data");

            if (kpiDataNodes != null)
            {
                foreach (XmlNode kpiDataNode in kpiDataNodes)
                {
                    var key = kpiDataNode.Attributes["Label"] == null ? string.Empty : kpiDataNode.Attributes["Label"].Value;
                    if (string.IsNullOrEmpty(key) || kpiDataDict.ContainsKey(key))
                    {
                        continue;
                    }

                    var goal   = kpiDataNode.SelectSingleNode("goal");
                    var actual = kpiDataNode.SelectSingleNode("actual");
                    if (goal == null || actual == null)
                    {
                        continue;
                    }

                    int goalValue;
                    int actualValue;

                    if (!int.TryParse(goal.InnerText, out goalValue) || !int.TryParse(actual.InnerText, out actualValue))
                    {
                        continue;
                    }

                    var kpiData = new KPIData(key, goalValue, actualValue);
                    kpiDataDict.Add(key, kpiData);
                    _kpiDataList.Add(kpiData);
                }
            }

            return(kpiDataDict);
        }
コード例 #3
0
ファイル: KPIDatasource.cs プロジェクト: jhuntsman/FlexNet
        public IDictionary<string, object> GetExtendedData()
        {
            _kpiDataList = new List<KPIData>();
            var kpiDataDict = new Dictionary<string, object>();
            var kpiXmlValue = new XmlDocument();

            try
            {
                if (!string.IsNullOrEmpty(this.KPIData))
                    kpiXmlValue.LoadXml(this.KPIData);
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
            }

            var kpiDataNodes = kpiXmlValue.SelectNodes("KPI/data");
            if (kpiDataNodes != null)
            {
                foreach (XmlNode kpiDataNode in kpiDataNodes)
                {
                    var key = kpiDataNode.Attributes["Label"] == null ? string.Empty : kpiDataNode.Attributes["Label"].Value;
                    if (string.IsNullOrEmpty(key) || kpiDataDict.ContainsKey(key)) 
                        continue;

                    var goal = kpiDataNode.SelectSingleNode("goal");
                    var actual = kpiDataNode.SelectSingleNode("actual");
                    if (goal == null || actual == null) 
                        continue;

                    int goalValue;
                    int actualValue;
                    
                    if (!int.TryParse(goal.InnerText, out goalValue) || !int.TryParse(actual.InnerText, out actualValue))
                        continue;

                    var kpiData = new KPIData(key, goalValue, actualValue);
                    kpiDataDict.Add(key, kpiData);
                    _kpiDataList.Add(kpiData);
                }
            }

            return kpiDataDict;
        }