Example #1
0
        private void UpdateStatistics()
        {
            StatsData = ApplicationModel.Database.Value.Statistics;
            Statistics.Clear();
            ViewOptions.Clear();
            ViewOptions.Add("All");
            ViewOptions.Add("Single Items");

            if (StatsData.Value == null)
            {
                Thread.Sleep(100);
                UpdateStatistics();
                return;
            }

            foreach (var propertyInfo in StatsData.Value.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                var enumerable = propertyInfo.GetValue(StatsData.Value, null) as IEnumerable <object>;

                if (enumerable != null)
                {
                    var list = enumerable as List <object> ?? enumerable.ToList();
                    if (list.Count == 0)
                    {
                        continue;
                    }

                    if ((list.First() is string == false) && (list.First() is IndexStats == false))
                    {
                        continue;
                    }

                    var statInfo = new StatInfo
                    {
                        IsList    = true,
                        ListItems = new List <StatInfoItem>(),
                    };

                    foreach (var item in list)
                    {
                        var statInfoItem = new StatInfoItem(item);

                        if (statInfoItem.ItemType == typeof(IndexStats))
                        {
                            AddIndexStat(statInfoItem);
                        }

                        statInfo.ListItems.Add(statInfoItem);
                    }

                    Statistics.Add(propertyInfo.Name, statInfo);
                    ViewOptions.Add(propertyInfo.Name);
                }
                else
                {
                    if (string.IsNullOrEmpty(propertyInfo.GetValue(StatsData.Value, null).ToString()) || propertyInfo.GetValue(StatsData.Value, null).ToString() == "0")
                    {
                        continue;
                    }

                    Statistics.Add(propertyInfo.Name, new StatInfo
                    {
                        Message = GetValueWithFormat(propertyInfo.GetValue(StatsData.Value, null))
                    });
                }
            }

            OnPropertyChanged(() => StatsData);
            UpdateView();
        }
Example #2
0
		private void UpdateStatistics()
		{
			StatsData = ApplicationModel.Database.Value.Statistics;
			Statistics.Clear();
			ViewOptions.Clear();
			ViewOptions.Add("All");
			ViewOptions.Add("Single Items");

			if (StatsData.Value == null)
			{
				Thread.Sleep(100);
				UpdateStatistics();
				return;
			}

			foreach (var propertyInfo in StatsData.Value.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
			{
				var enumerable = propertyInfo.GetValue(StatsData.Value, null) as IEnumerable<object>;

				if (enumerable != null)
				{
					var list = enumerable as List<object> ?? enumerable.ToList();
					if (list.Count == 0)
						continue;

					if ((list.First() is string == false) && (list.First() is IndexStats == false))
						continue;

					var statInfo = new StatInfo
					{
						IsList = true,
						ListItems = new List<StatInfoItem>(),
					};

					foreach (var item in list)
					{
						var statInfoItem = new StatInfoItem(item);

						if (statInfoItem.ItemType == typeof(IndexStats))
							AddIndexStat(statInfoItem);

						statInfo.ListItems.Add(statInfoItem);
					}

					Statistics.Add(propertyInfo.Name, statInfo);
					ViewOptions.Add(propertyInfo.Name);
				}
				else
				{
					if (string.IsNullOrEmpty(propertyInfo.GetValue(StatsData.Value, null).ToString()) || propertyInfo.GetValue(StatsData.Value, null).ToString() == "0")
						continue;

					Statistics.Add(propertyInfo.Name, new StatInfo
					{
						Message = GetValueWithFormat(propertyInfo.GetValue(StatsData.Value, null))
					});
				}
			}

			OnPropertyChanged(() => StatsData);
			UpdateView();
		}