/// <summary>
 /// Apply query culture to current thread.
 /// </summary>
 /// <param name="query">
 /// The session query containing the culture
 /// </param>
 public static void ApplyCultureToThread(SessionQuery query)
 {
     if (query != null && query.CurrentCulture != null)
     {
         Thread.CurrentThread.CurrentUICulture = query.CurrentCulture;
     }
 }
Example #2
0
 /// <summary>
 /// Apply query culture to current thread.
 /// </summary>
 /// <param name="query">
 /// The session query containing the culture
 /// </param>
 public static void ApplyCultureToThread(SessionQuery query)
 {
     if (query != null && query.CurrentCulture != null)
     {
         Thread.CurrentThread.CurrentUICulture = query.CurrentCulture;
     }
 }
Example #3
0
        private void SetEndPoint(SessionQuery query, INsiClient nsiClient, EndPointStructure ep, bool clearQuery = false)
        {
            if (ep == null)
            {
                return;
            }

            //Session[Estat.Nsi.Client.Web.ISTATSettings.Session_key_endpoint] = ep;

            ISTATSettings.CurrentEndPoint = ep;

            NSIClientSettings.Instance.SetEndPoint(ISTATSettings.CurrentEndPoint);

            // NSIClientSettings settings = NSIClientSettings.GetSection(System.Configuration.ConfigurationUserLevel.None);
            NSIClientSettings settings = NSIClientSettings.Instance;

            SessionObject.InitializeNSIClient();


            // clear criteria only if was set a data end point
            if (clearQuery)
            {
                if (query != null)
                {
                    query.Clear();
                    query.Reset();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Save the specified session query to the specified Session
        /// </summary>
        /// <param name="session">
        /// The HTTP Session
        /// </param>
        /// <param name="query">
        /// The new session query
        /// </param>
        /// <exception cref="ArgumentNullException">session is null</exception>
        /// <returns>
        /// The saved <paramref name="query"/>
        /// </returns>
        public static SessionQuery SaveSessionQuery(HttpSessionStateBase session, SessionQuery query)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            session[Constants.HTTPSessionQueryAttr] = query;
            return(query);
        }
Example #5
0
        private string ChangeEndPoint(SessionQuery query, INsiClient nsiClient, string id)
        {
            IEnumerable <EndPointStructure> _ep =
                (from ep in ISTATSettings.ListEndPoint
                 where ep.ID.Equals(id)
                 select ep).OfType <EndPointStructure>();

            SetEndPoint(query, nsiClient, _ep.First());


            return("{\"change\" : true }");
        }
Example #6
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();
        }
Example #7
0
        public StreamResponseAction ExportSDMXDataSet(string id, string sdmxVersion)
        {
            try
            {
                _iD = id;
                InitObject();
                SessionQuery query = SessionQueryManager.GetSessionQuery(Session);
                GetDataSet(_datasetRenderer, _dataStream, _textWriter, sdmxVersion, query);

                //var x = _dataStream.store;

                //Copy(query.GetSdmxMLDataSet(true), context.Response.Output);

                //SaveSDMXFile(_dataStream.structure, sdmxEnumType, GetFileName(_iD, "xml"));

                return(null);

                /*
                 * SessionQuery query = SessionQueryManager.GetSessionQuery(context.Session);
                 * if (query.GetSdmxMLDataSet(false) == null)
                 * {
                 *  SessionExpired(context);
                 *  return;
                 * }
                 *
                 * context.Response.ContentType = ContentType;
                 * context.Response.ContentEncoding = Encoding.UTF8;
                 *
                 * string contentDisposition = string.Format(
                 *  CultureInfo.InvariantCulture,
                 *  Constants.AttachmentFilenameFormat,
                 *  GetFileName(query.Dataflow, "dataset.xml"));
                 * context.Response.AddHeader(Constants.ContentDispositionHttpHeader, contentDisposition);
                 *
                 * ////            StreamReader sdmx = new StreamReader(query.GetSDMX_MLDataSet(true), Encoding.UTF8);
                 * Copy(query.GetSdmxMLDataSet(true), context.Response.Output);
                 */
            }
            catch (Exception ex)
            {
                return(new StreamResponseAction(ex.Message));
            }
        }
Example #8
0
        public ActionResult dataflowChange()
        {
            dynamic PostDataArrived = CS.GetPostData(this.Request);

            try
            {
                SessionQuery query = sessionObject.GetSessionQuery();

                if (NSIClientSettings.Instance.EndPointCenterEnable)
                {
                    EndPointStructure ep = new EndPointStructure()
                    {
                        ID           = "WS of " + (string)PostDataArrived.agency + "+" + (string)PostDataArrived.id + "+" + (string)PostDataArrived.version,
                        DisplayName  = "WS of " + (string)PostDataArrived.agency + "+" + (string)PostDataArrived.id + "+" + (string)PostDataArrived.version,
                        EndPoint     = (string.IsNullOrEmpty((string)PostDataArrived.urlV21)) ? ISTATSettings.ListEndPoint.First().EndPoint : (string)PostDataArrived.urlV21,
                        EndPointV20  = (string.IsNullOrEmpty((string)PostDataArrived.urlV20)) ? ISTATSettings.ListEndPoint.First().EndPointV20 : (string)PostDataArrived.urlV20,
                        EndPointType = "V21",
                    };
                    SetEndPoint(query, sessionObject.GetNSIClient(), ep, true);
                }


                ActionResult res = CS.ReturnForJQuery(
                    JR.DataflowChange(
                        query,
                        sessionObject.GetNSIClient(),
                        (string)PostDataArrived.agency,
                        (string)PostDataArrived.id,
                        (string)PostDataArrived.version,
                        Server.MapPath("~/query/")));

                SessionQueryManager.SaveSessionQuery(HttpContext.ApplicationInstance.Context.Session, query);
                return(res);
            }
            catch (Exception)
            {
                return(CS.ReturnForJQuery(ControllerSupport.ErrorOccured));
            }
        }
Example #9
0
        /// <summary>
        /// Retrieves the query saved into specified HTTP session.
        /// </summary>
        /// <param name="session">
        /// the HTTP session
        /// </param>
        /// <returns>
        /// the query instance, which will never be <c>null</c> if the method succeeds
        /// </returns>
        public static SessionQuery GetSessionQuery(HttpSessionStateBase session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            SessionQuery query = (SessionQuery)session[Constants.HTTPSessionQueryAttr];

            //getting EndpointType
            NSIClientSettings settings     = NSIClientSettings.Instance;
            EndpointType      endPointType = (EndpointType)Enum.Parse(typeof(EndpointType), settings.EndPointType);

            query.EndPointType = Enum.IsDefined(typeof(EndpointType), endPointType) ? endPointType : EndpointType.V20;

            ApplyCultureToThread(query);

            // if (query == null)
            // {
            // throw new ArgumentException("No query instance found into HTTP session");
            // }
            return(query);
        }
Example #10
0
        public ActionResult SetLocale()
        {
            dynamic PostDataArrived = CS.GetPostData(this.Request);

            try
            {
                //LocaleResolver.RemoveCookie(HttpContext.ApplicationInstance.Context);

                CultureInfo c = Messages.SetLocale((string)PostDataArrived.locale);

                Thread.CurrentThread.CurrentUICulture = c;
                Thread.CurrentThread.CurrentCulture   = c;

                LocaleResolver.SendCookie(c, HttpContext.ApplicationInstance.Context);
                SessionQuery query = SessionQueryManager.GetSessionQuery(Session);
                query.CurrentCulture = c;

                return(CS.ReturnForJQuery(new JavaScriptSerializer().Serialize(string.Empty)));
            }
            catch (Exception)
            {
                return(CS.ReturnForJQuery(ControllerSupport.ErrorOccured));
            }
        }
Example #11
0
        public ActionResult getDataflows()
        {
            if (!SessionQueryManager.SessionQueryExistsAndIsValid(HttpContext.ApplicationInstance.Context))
            {
                SessionQuery query = new SessionQuery();
                SessionQueryManager.SaveSessionQuery(HttpContext.ApplicationInstance.Context.Session, query);
            }

            EndPointStructure ep = ISTATSettings.CurrentEndPoint;

            if (NSIClientSettings.Instance.EndPointCenterEnable)
            {
                SetEndPoint(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient(), ISTATSettings.CentralEndPoint);
            }

            var res = CS.ReturnForJQuery(JR.GetTree(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient()));

            if (NSIClientSettings.Instance.EndPointCenterEnable)
            {
                SetEndPoint(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient(), ep);
            }

            return(res);
        }
Example #12
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();
        }
        public ActionResult getDataflows()
        {
            if (!SessionQueryManager.SessionQueryExistsAndIsValid(HttpContext.ApplicationInstance.Context))
            {
                SessionQuery query = new SessionQuery();
                SessionQueryManager.SaveSessionQuery(HttpContext.ApplicationInstance.Context.Session, query);
            }

            EndPointStructure ep = ISTATSettings.CurrentEndPoint;
            if (NSIClientSettings.Instance.EndPointCenterEnable)
                SetEndPoint(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient(), ISTATSettings.CentralEndPoint);

            var res= CS.ReturnForJQuery(JR.GetTree(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient()));

            if (NSIClientSettings.Instance.EndPointCenterEnable)
                SetEndPoint(sessionObject.GetSessionQuery(), sessionObject.GetNSIClient(), ep);

            return res;
        }
        private void SetEndPoint(SessionQuery query, INsiClient nsiClient, EndPointStructure ep, bool clearQuery = false)
        {
            if (ep == null) return;

            //Session[Estat.Nsi.Client.Web.ISTATSettings.Session_key_endpoint] = ep;

            ISTATSettings.CurrentEndPoint = ep;

            NSIClientSettings.Instance.SetEndPoint(ISTATSettings.CurrentEndPoint);

            // NSIClientSettings settings = NSIClientSettings.GetSection(System.Configuration.ConfigurationUserLevel.None);
            NSIClientSettings settings = NSIClientSettings.Instance;

            SessionObject.InitializeNSIClient();

            // clear criteria only if was set a data end point
            if (clearQuery)
            {

                if (query != null)
                {
                    query.Clear();
                    query.Reset();
                }
            }
        }
        private string ChangeEndPoint(SessionQuery query, INsiClient nsiClient, string id)
        {
            IEnumerable<EndPointStructure> _ep =
                    (from ep in ISTATSettings.ListEndPoint
                     where ep.ID.Equals(id)
                     select ep).OfType<EndPointStructure>();

            SetEndPoint(query, nsiClient, _ep.First());

            return "{\"change\" : true }";
        }
        public static SessionQuery SaveSessionQuery(HttpSessionState session, SessionQuery query)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            session[Constants.HTTPSessionQueryAttr] = query;
            return query;
        }