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(); }
internal IDataSetStore GetDataset(IDataflowObject df, IDataStructureObject kf, List <DataCriteria> Criterias, ref Dictionary <string, List <DataChacheObject> > DataCache, bool useAttr) { // if it is not time series then assume it is cross SDMXWSFunction op = SDMXWSFunction.GetCompactData; bool cross = (DataObjConfiguration._TypeEndpoint == EndpointType.V21 || DataObjConfiguration._TypeEndpoint == EndpointType.REST) ? NsiClientHelper.DataflowDsdIsCrossSectional(kf) : !Utils.IsTimeSeries(kf); if (cross) { op = SDMXWSFunction.GetCrossSectionalData; } var ser = new JavaScriptSerializer(); ser.MaxJsonLength = int.MaxValue; try { //commentato vecchio codice //IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(DataObjConfiguration); //GetSDMXObject.ExecuteQuery(CreateQueryBean(df, kf, Criterias), op, FileTmpData); /* #region Connessione e Creazione DB SQLLite * string table = Path.Combine(Utils.GetAppPath(), string.Format(CultureInfo.InvariantCulture, "{0}-{1}.sqlite", Utils.MakeKey(df).Replace("+", "_").Replace(".", ""), Guid.NewGuid())); * string ConnectionString = string.Format(CultureInfo.InvariantCulture, Constants.FileDBSettingsFormat, table); * var info = new DBInfo(ConnectionString); * string tempTable = "table_" + Utils.MakeKey(df).Replace("+", "_").Replace(".", ""); * IDataSetStore store = new DataSetStoreDB(info, tempTable, kf, true, useAttr); #endregion * fine vecchio codice*/ //Salvo in Session /* * if (DataCache == null) * DataCache = new Dictionary<string, List<DataChacheObject>>(); * if (!DataCache.ContainsKey(Utils.MakeKey(df))) * DataCache[Utils.MakeKey(df)] = new List<DataChacheObject>(); */ //string table=null; //FABIO NEW //IDataSetStore store = FindDataCacheChart(df, kf, Criterias, ref DataCache, useAttr,out table); //if (store == null) store = GetDataset(df, kf, Criterias, ref DataCache, useAttr); #region Connessione e Creazione DB SQLLite FABIO se nullo lo istanzio // if (store == null) // { string table = null; IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(DataObjConfiguration); GetSDMXObject.ExecuteQuery(CreateQueryBean(df, kf, Criterias), op, FileTmpData); #region Connessione e Creazione DB SQLLite table = Path.Combine(Utils.GetAppPath(), string.Format(CultureInfo.InvariantCulture, "{0}-{1}.sqlite", Utils.MakeKey(df).Replace("+", "_").Replace(".", ""), Guid.NewGuid())); string ConnectionString = string.Format(CultureInfo.InvariantCulture, Constants.FileDBSettingsFormat, table); var info = new DBInfo(ConnectionString); string tempTable = "table_" + Utils.MakeKey(df).Replace("+", "_").Replace(".", ""); IDataSetStore store = new DataSetStoreDB(info, tempTable, kf, true, useAttr); #endregion using (var dataLocation = new FileReadableDataLocation(FileTmpData)) { switch (op) { case SDMXWSFunction.GetCompactData: var compact = new CompactDataReaderEngine(dataLocation, df, kf); var readerCompact = new SdmxDataReader(kf, store); readerCompact.ReadData(compact); break; case SDMXWSFunction.GetCrossSectionalData: var dsdCrossSectional = (ICrossSectionalDataStructureObject)kf; var crossSectional = new CrossSectionalDataReaderEngine(dataLocation, dsdCrossSectional, df); var reader = new SdmxDataReader(kf, store); reader.ReadData(crossSectional); break; default: throw new ArgumentException(Resources.ExceptionUnsupported_operation + op.ToString(), "operation"); } } // } #endregion FABIO //using (var dataLocation = new FileReadableDataLocation(FileTmpData)) //{ // switch (op) // { // case SDMXWSFunction.GetCompactData: // var compact = new CompactDataReaderEngine(dataLocation, df, kf); // var readerCompact = new SdmxDataReader(kf, store); // readerCompact.ReadData(compact); // break; // case SDMXWSFunction.GetCrossSectionalData: // var dsdCrossSectional = (ICrossSectionalDataStructureObject)kf; // var crossSectional = new CrossSectionalDataReaderEngine(dataLocation, dsdCrossSectional, df); // var reader = new SdmxDataReader(kf, store); // reader.ReadData(crossSectional); // break; // default: // throw new ArgumentException(Resources.ExceptionUnsupported_operation + op.ToString(), "operation"); // } //} /* * Dictionary<string, List<string>> Criteri = new Dictionary<string, List<string>>(); * Criterias.ForEach(c => Criteri.Add(c.component, c.values)); * DataChacheObject dco = new DataChacheObject() * { * Criterias = Criteri, * DBFileName = table, * }; * * //aggiunta da fabio * DataCache[Utils.MakeKey(df)].Clear(); * //fine aggiunta fabio * DataCache[Utils.MakeKey(df)].Add(dco); */ return(store); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } finally { //delete the temporary file if (File.Exists(FileTmpData)) { File.Delete(FileTmpData); } } }
internal IDataSetStore GetDataset(IDataflowObject df, IDataStructureObject kf, List <DataCriteria> Criterias, ref Dictionary <string, List <DataChacheObject> > DataCache, bool useAttr, SessionQuery query) { // if it is not time series then assume it is cross SDMXWSFunction op = SDMXWSFunction.GetCompactData; bool cross = (DataObjConfiguration._TypeEndpoint == EndpointType.V21 || DataObjConfiguration._TypeEndpoint == EndpointType.REST) ? NsiClientHelper.DataflowDsdIsCrossSectional(kf) : !Utils.IsTimeSeries(kf); if (cross) { op = SDMXWSFunction.GetCrossSectionalData; } var ser = new JavaScriptSerializer(); ser.MaxJsonLength = int.MaxValue; try { #region Connessione e Creazione DB SQLLite FABIO se nullo lo istanzio string table = null; IGetSDMX GetSDMXObject = (query._IGetSDMX == null) ? WebServiceSelector.GetSdmxImplementation(DataObjConfiguration) : query._IGetSDMX; GetSDMXObject.ExecuteQuery(CreateQueryBean(df, kf, Criterias), op, FileTmpData); #region Connessione e Creazione DB SQLLite table = Path.Combine(Utils.GetAppPath(), string.Format(CultureInfo.InvariantCulture, "{0}-{1}.sqlite", Utils.MakeKey(df).Replace("+", "_").Replace(".", ""), Guid.NewGuid())); string ConnectionString = string.Format(CultureInfo.InvariantCulture, Constants.FileDBSettingsFormat, table); var info = new DBInfo(ConnectionString); string tempTable = "table_" + Utils.MakeKey(df).Replace("+", "_").Replace(".", ""); IDataSetStore store = new DataSetStoreDB(info, tempTable, kf, true, useAttr); #endregion using (var dataLocation = new FileReadableDataLocation(FileTmpData)) { switch (op) { case SDMXWSFunction.GetCompactData: var compact = new CompactDataReaderEngine(dataLocation, df, kf); var readerCompact = new SdmxDataReader(kf, store); readerCompact.ReadData(compact); break; case SDMXWSFunction.GetCrossSectionalData: var dsdCrossSectional = (ICrossSectionalDataStructureObject)kf; var crossSectional = new CrossSectionalDataReaderEngine(dataLocation, dsdCrossSectional, df); var reader = new SdmxDataReader(kf, store); reader.ReadData(crossSectional); break; default: throw new ArgumentException(Resources.ExceptionUnsupported_operation + op.ToString(), "operation"); } } #endregion FABIO return(store); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } finally { //delete the temporary file if (File.Exists(FileTmpData)) { File.Delete(FileTmpData); } } }