SuperMap.Connector.DataProvider.Statistic C# (CSharp) Method

Statistic() public method

public Statistic ( string datasourceName, string datasetName, string fieldName, StatisticMode statisticMode ) : double
datasourceName string
datasetName string
fieldName string
statisticMode StatisticMode
return double
        public double Statistic(string datasourceName, string datasetName, string fieldName, StatisticMode statisticMode)
        {
            if (string.IsNullOrEmpty(datasourceName)) throw new ArgumentNullException("datasourceName", Resources.ArgumentIsNotNull);
            if (string.IsNullOrEmpty(datasetName)) throw new ArgumentNullException("datasetName", Resources.ArgumentIsNotNull);
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("fieldName", Resources.ArgumentIsNotNull);
            string uri = string.Format("{0}/data/datasources/{1}/datasets/{2}/fields/{3}/{4}.json?", this._serviceUrl,
                HttpUtility.UrlEncode(datasourceName), HttpUtility.UrlEncode(datasetName), HttpUtility.UrlEncode(fieldName), statisticMode.ToString());
            string result = SynchHttpRequest.GetRequestString(uri);
            Dictionary<string, object> hasResult = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
            double statisticResult = -9999;
            if (hasResult != null && hasResult.ContainsKey("result") && hasResult["result"] != null)
            {
                double.TryParse(hasResult["result"].ToString(), out statisticResult);
            }
            return statisticResult;
        }