SqlToGraphite.Plugin.Wmi.WmiClient.Get C# (CSharp) Method

Get() public method

public Get ( ) : IList
return IList
        public override IList<IResult> Get()
        {
            var rtn = new List<IResult>();

            try
            {
                foreach (var o in this.GetWmiObject(this.Sql, this.machineName, RootPath))
                {
                    var value = -1;
                    var dateTime = DateTime.Now;
                    var name = string.Empty;

                    foreach (var col in o.Properties)
                    {
                        if (col.Type == CimType.String)
                        {
                            name = Convert.ToString(col.Value);
                        }

                        if (col.Type == CimType.UInt32)
                        {
                            value = Convert.ToInt32(col.Value);
                        }

                        if (col.Type == CimType.UInt64)
                        {
                            value = Convert.ToInt32(col.Value);
                        }

                        if (col.Type == CimType.DateTime)
                        {
                            dateTime = Convert.ToDateTime(col.Value);
                        }
                    }

                    this.Log.Debug(string.Format("Name {0} value {1} datetime {2}", name, value, dateTime));
                    var r = new Result(name, dateTime, this.Path);
                    r.SetValue(value);
                    rtn.Add(r);
                }
            }
            catch (ManagementException e)
            {
                this.Log.Error(string.Format("Error with {0} {1} {2}", this.Type, this.Path, this.Sql));
                this.Log.Error(e.Message);
                this.Log.Error(e.StackTrace);
            }

            return rtn;
        }