Ejemplo n.º 1
0
        public ActionResult GetDataLayout()
        {
            try
            {
                // Not remove this linee
                Utils.App_Data_Path = HttpContext.Server.MapPath("~/App_Data/");

                GetDataObject PostDataArrived = CS.GetPostData<GetDataObject>(this.Request);
                PostDataArrived.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

                SessionImplObject sdmxObj =
                 (Session[SESSION_KEY] != null) ? Session[SESSION_KEY] as SessionImplObject : new SessionImplObject();

                DataWidget dataWidget = new DataWidget(
                    PostDataArrived, sdmxObj,
                    (ConfigurationManager.AppSettings["ParseSDMXAttributes"].ToString().ToLower() == "true"));

                object DataStream = null;

                SessionQuery query = SessionQueryManager.GetSessionQuery(Session);
                SessionImplObject ret = dataWidget.GetData(out DataStream, query);

                if (Session[SESSION_KEY] == null) Session[SESSION_KEY] = ret;
                else ((SessionImplObject)Session[SESSION_KEY]).MergeObject(ret);

                string CodeForStreaming = Guid.NewGuid().ToString();
                Session[CodeForStreaming] = DataStream;

                return CS.ReturnForJQuery("{\"code\":\"" + CodeForStreaming + "\"}");
            }
            catch (Exception ex)
            {
                return CS.ReturnForJQuery(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public ActionResult GetData()
        {
            try
            {
                // Not remove this linee
                Utils.App_Data_Path = HttpContext.Server.MapPath("~/App_Data/");

                    GetDataObject PostDataArrived = CS.GetPostData<GetDataObject>(this.Request);
                    PostDataArrived.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

                    SessionImplObject sdmxObj =
                    (Session[SESSION_KEY] != null) ? Session[SESSION_KEY] as SessionImplObject : new SessionImplObject();

                    SessionQuery query = SessionQueryManager.GetSessionQuery(Session);
                    query._endpointSettings = PostDataArrived.Configuration;

                    CodemapWidget codemapWidget = new CodemapWidget(new GetCodemapObject()
                    {
                        Configuration = PostDataArrived.Configuration
                    }, sdmxObj);

                        CacheWidget cache = new CacheWidget(connectionStringSetting.ConnectionString);

                        string CodeForStreaming = Guid.NewGuid().ToString();
                        // +++ Caching +++
                        if (PostDataArrived.WidgetId > 0 && UseWidgetCache)
                        {
                            SavedWidget widget = cache.GetWidget(PostDataArrived.WidgetId, System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);
                            if (widget != null && !String.IsNullOrEmpty(widget.widgetData))
                            {
                                Session[CodeForStreaming] = widget;
                                return CS.ReturnForJQuery("{\"code\":\"" + CodeForStreaming + "\"}");
                            }
                        }

                        var count = codemapWidget.GetCountObservation(query);
                        long maxResultObs = (long)ISTAT.WebClient.WidgetComplements.Model.Settings.WebClientSettings.Instance.MaxResultObs;

                        if (count <= maxResultObs)
                        {
                        DataWidget dataWidget = new DataWidget(
                            PostDataArrived, sdmxObj,
                            (ConfigurationManager.AppSettings["ParseSDMXAttributes"].ToString().ToLower() == "true"));

                        object DataStream = null;
                        SessionImplObject ret = dataWidget.GetData(out DataStream, query);

                        // store current SessionImplObject in session
                        //nuovo fabio
                        if (Session[SESSION_KEY] == null) Session[SESSION_KEY] = ret;
                        else ((SessionImplObject)Session[SESSION_KEY]).MergeObject(ret);
                        //fine nuovo fabio

                        DataObjectForStreaming dOFS = DataStream as DataObjectForStreaming;
                        if (dOFS != null && PostDataArrived.WidgetId > 0)
                            dOFS.WidgetID = PostDataArrived.WidgetId;

                        Session[CodeForStreaming] = DataStream;

                        return CS.ReturnForJQuery("{\"code\":\"" + CodeForStreaming + "\"}");
                    }
                    else
                        {
                            return CS.ReturnForJQuery(Messages.label_out_max_results + "(max:"+ maxResultObs + " - record:" + count + ")");
                        }
            }
            catch (Exception ex)
            {
                return CS.ReturnForJQuery(ex.Message);
            }
        }