Ejemplo n.º 1
0
        public StreamResponseAction ExportSDMXQuery()
        {
            SessionQuery query = SessionQueryManager.GetSessionQuery(Session);

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

            string request = "";
            var    xdoc    = new XmlDocument();

            EndpointSettings DataObjConfiguration = new EndpointSettings();

            DataObjConfiguration = query._endpointSettings;


            //IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(DataObjConfiguration);
            IGetSDMX       GetSDMXObject = (query._IGetSDMX == null) ? WebServiceSelector.GetSdmxImplementation(DataObjConfiguration) : query._IGetSDMX;
            BaseDataObject BDO           = new BaseDataObject(DataObjConfiguration, "appo.xml");

            ISdmxObjects         structure = query.Structure;
            IDataflowObject      df        = structure.Dataflows.First();
            IDataStructureObject kf        = structure.DataStructures.First();
            IDataQuery           sdmxQuery = BDO.CreateQueryBean(df, kf, query.GetCriteria());

            GetSDMXObject.GetSdmxQuery(sdmxQuery, out request);

            string filename = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", query.Dataflow.Id, "xml");

            this.HttpContext.Response.Clear();
            this.HttpContext.Response.ContentType     = "text/xml";
            this.HttpContext.Response.ContentEncoding = Encoding.UTF8;
            string contentDisposition = string.Format(
                CultureInfo.InvariantCulture,
                Constants.AttachmentFilenameFormat,
                filename);

            this.HttpContext.Response.AddHeader(Constants.ContentDispositionHttpHeader, contentDisposition);



            this.HttpContext.Response.AddHeader("content-disposition", contentDisposition);
            this.HttpContext.Response.Write(request);
            this.HttpContext.Response.End();
            throw new NotImplementedException();
        }
Ejemplo n.º 2
0
        public void GetDataSet(IDataSetRenderer renderer, DataObjectForStreaming dataStream, TextWriter streamResponse, string endPointType, SessionQuery sessionQuery)
        {
            EndpointSettings DataObjConfiguration = dataStream.Configuration;

            IDataStructureObject kf = dataStream.structure.DataStructures.First();

            //DataObjectForStreaming
            SDMXWSFunction op = SDMXWSFunction.GetCompactData;
            //DataObjConfiguration

            bool cross = (DataObjConfiguration._TypeEndpoint == ISTAT.WebClient.WidgetComplements.Model.Enum.EndpointType.V21 || DataObjConfiguration._TypeEndpoint == ISTAT.WebClient.WidgetComplements.Model.Enum.EndpointType.REST)
                          ? NsiClientHelper.DataflowDsdIsCrossSectional(kf) : !Utils.IsTimeSeries(kf);

            if (cross)
            {
                op = SDMXWSFunction.GetCrossSectionalData;
            }
            var ser = new JavaScriptSerializer();

            ser.MaxJsonLength = int.MaxValue;
            try
            {
                //IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(DataObjConfiguration);
                IGetSDMX       GetSDMXObject = (sessionQuery._IGetSDMX == null) ? WebServiceSelector.GetSdmxImplementation(DataObjConfiguration) : sessionQuery._IGetSDMX;
                BaseDataObject BDO           = new BaseDataObject(DataObjConfiguration, "tem.txt");

                string fullPath = Utils.App_Data_Path + @"\Download\" + GetFileName(_iD, "xml");

                IDataQuery query = BDO.CreateQueryBean(dataStream.structure.Dataflows.First(), kf, dataStream.Criterias);
                GetSDMXObject.ExecuteQuery(query, op, fullPath);

                //if (endPointType == "V21")
                //{
                //    SendAttachment(ConvertTo21(fullPath),GetFileName(_iD, "xml")) ;
                //    return;
                //}
                SendAttachmentFile(fullPath);
            }
            catch (Exception ex)
            {
            }
            //throw new NotImplementedException();
        }