Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            if (dataSummaryManager == null) dataSummaryManager = new DataSummaryManager();

            APIRequestParams filterSettings = new APIRequestParams();
            filterSettings.ParseParameters(filterSettings,context);

            string action = "totals_per_country";

            if (!String.IsNullOrEmpty(context.Request["action"]))
            {
                action = context.Request["action"].ToString();
            }

            if (action == "totals_per_country")
            {
                context.Response.ContentType = "application/javascript";
                context.Response.Write(dataSummaryManager.GetTotalsPerCountrySummary(true,"ocm_getdatasummary", filterSettings ));
                context.Response.Flush();
            }

            if (action == "full_summary")
            {
                // Output JSON summary of:
                // - Current totals per country
                // - Total added (per country? based on date range, location/distance filter?)
                // - Total modified
                // - User Comments Count

                // - per month values, current month first? default last 12 months
            }

            if (action == "activity_summary")
            {
                // Based on date range, location and distance:
                // - list of recent comments, checkins, id & title etc of items added & modified
                var o = new JSONOutputProvider();

                context.Response.ContentType = o.ContentType;
                var summary = dataSummaryManager.GetActivitySummary(filterSettings);
                o.PerformSerialisationV2(context.Response.OutputStream, summary, filterSettings.Callback);

                context.Response.Flush();
            }
        }
Пример #2
0
        /// <summary>
        /// Output compact (id's only for reference data) POI list
        /// </summary>
        /// <param name="context"></param>
        /// <param name="filter"></param>
        private void OutputCompactPOIList(HttpContext context, APIRequestParams filter)
        {
            //get list of charge points as compact POISearchResult List for output:
            List<OCM.API.Common.Model.ChargePoint> dataList = new POIManager().GetChargePoints(filter);
            int numResults = dataList.Count;

            List<POISearchResult> poiList = new List<POISearchResult>();
            foreach (var c in dataList)
            {
                var poi = new POISearchResult
                {
                    ID = c.ID,
                    Title = c.AddressInfo.Title,
                    Address = c.AddressInfo.AddressLine1,
                    Distance = c.AddressInfo.Distance,
                    Latitude = (double)c.AddressInfo.Latitude,
                    Longitude = (double)c.AddressInfo.Longitude,
                    Postcode = c.AddressInfo.Postcode,
                    UsageTypeID = c.UsageType != null ? c.UsageType.ID : 0,
                    StatusTypeID = c.StatusType != null ? c.StatusType.ID : 0
                };
                poiList.Add(poi);
            }
            var o = new JSONOutputProvider();
            string description = "Compact POI List: id=ID, t= Title, u= UsageTypeID, s= StatusTypeID, a=Address, p=Postcode, lt=Latitude, lg=Longitude, d= Distance";
            o.PerformSerialisationV2(context.Response.OutputStream, new { status = "OK", description = description, count = poiList.Count, results = poiList }, filter.Callback);
        }