/// <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; } }
/// <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; } }
/// <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); }
internal void render(TextWriter writer,SessionQuery query) { IDataSetModel l = new DataSetModelStore(Structure, store); /* if (query._dataSetModel != null) { l = query._dataSetModel; l.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y); query._store.SetCriteria(this.Criterias); query.DatasetModel = l; } else { l.Initialize(this.Criterias); l.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y); query.DatasetModel = l; } */ if (query.DatasetModel != null) { //query.DatasetModel.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y); query.DatasetModel.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y, this.Criterias); query._store.SetCriteria(this.Criterias); } else { query.DatasetModel = new DataSetModelStore(Structure, store); query.DatasetModel.Initialize(this.Criterias); //query.DatasetModel.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y); query.DatasetModel.UpdateAxis(layObj.axis_z, layObj.axis_x, layObj.axis_y, this.Criterias); } HtmlRenderer htmlRenderer = new HtmlRenderer(this.codemap, true, _useAttr, cFrom, cTo); // { if (!DataStream.store.ExistsColumn(axisX)) DataStream.layObj.axis_x.Remove(axisX); }); //this.Criterias.ForEach(c => l.UpdateSliceKeyValue(c.component, c.values.FirstOrDefault())); /* for(int i=0; i<layObj.axis_z.Count; i++) { string criterio=layObj.axis_z[i]; this.Criterias.ForEach(c => {if (c.component==criterio) {l.UpdateSliceKeyValue(c.component, c.values.FirstOrDefault());}}); } */ //htmlRenderer.Render(l, writer); htmlRenderer.Render(query._dataSetModel, writer); //new HtmlRenderer(query.GetComponentCodeDescriptionMap(), true).Render( // query.DatasetModel, // context.Response.Output); }
public SessionImplObject GetLayout(SessionQuery query) { try { //ISdmxObjects structure = GetKeyFamily(); //IDataflowObject df = structure.Dataflows.First(); //IDataStructureObject kf = structure.DataStructures.First(); ISdmxObjects structure = query.Structure; IDataflowObject df = query.Dataflow; IDataStructureObject kf = query.KeyFamily; if (kf == null || df == null) { throw new InvalidOperationException("DataStructure is not set"); } if (this.SessionObj.DafaultLayout == null) { this.SessionObj.DafaultLayout = new Dictionary <string, LayoutObj>(); } if (!this.SessionObj.DafaultLayout.ContainsKey(Utils.MakeKey(df))) { LayoutObj deflay = GetDefaultLayout(df, kf); this.SessionObj.DafaultLayout[Utils.MakeKey(df)] = deflay; } DefaultLayoutResponseObject defaultLayoutResponseObject = new DefaultLayoutResponseObject(); defaultLayoutResponseObject.DefaultLayout = this.SessionObj.DafaultLayout[Utils.MakeKey(df)]; this.SessionObj.SavedDefaultLayout = new JavaScriptSerializer().Serialize(defaultLayoutResponseObject); return(this.SessionObj); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
private ISdmxObjects GetSdmxObject(EndpointSettings endpointSettings, SessionQuery sessionQuery) { // IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(endpointSettings); IGetSDMX GetSDMXObject = null; if (sessionQuery._IGetSDMX == null || (sessionQuery._endpointSettings != null && endpointSettings.EndPoint != sessionQuery._endpointSettings.EndPoint)) { GetSDMXObject = WebServiceSelector.GetSdmxImplementation(endpointSettings); sessionQuery._IGetSDMX = GetSDMXObject; } else { GetSDMXObject = sessionQuery._IGetSDMX; } return(GetSDMXObject.RetrieveTree()); }
/// <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); }
public DataWidget(GetDataObject dataObj, SessionImplObject sessionObj, bool useAttr, SessionQuery sessionQuery) { DataObj = dataObj; SessionObj = sessionObj; if (sessionQuery._IGetSDMX == null || (sessionQuery._endpointSettings != null && this.DataObj.Configuration.EndPoint != sessionQuery._endpointSettings.EndPoint)) { GetSDMXObject = WebServiceSelector.GetSdmxImplementation(this.DataObj.Configuration); sessionQuery._IGetSDMX = GetSDMXObject; } else { GetSDMXObject = sessionQuery._IGetSDMX; } BDO = new BaseDataObject(dataObj.Configuration, System.IO.Path.GetTempFileName()); this._useAttr = useAttr; }
public static void StreamDataTable(object DataObjectsForStreaming, TextWriter streamResponse, bool useAttr, CultureInfo cFrom, CultureInfo cTo, SessionQuery query) { if (DataObjectsForStreaming == null || !(DataObjectsForStreaming is DataObjectForStreaming)) { throw new Exception("Data not found"); } DataObjectForStreaming DataStream = (DataObjectForStreaming)DataObjectsForStreaming; #region CheckLayout DataStream.layObj.axis_x.ForEach(axisX => { if (!DataStream.store.ExistsColumn(axisX)) { DataStream.layObj.axis_x.Remove(axisX); } }); DataStream.layObj.axis_y.ForEach(axisY => { if (!DataStream.store.ExistsColumn(axisY)) { DataStream.layObj.axis_y.Remove(axisY); } }); DataStream.layObj.axis_z.ForEach(axisZ => { if (!DataStream.store.ExistsColumn(axisZ)) { DataStream.layObj.axis_z.Remove(axisZ); } }); #endregion DataRender rea = new DataRender( DataStream.store, DataStream.Criterias, DataStream.layObj, DataStream.structure, DataStream.codemap, useAttr, cFrom, cTo); rea.render(streamResponse, query); //DataStream.store.Dispose(); }
public SessionImplObject GetData(out object DataStream, SessionQuery query) { try { // Init session objects if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); this.SessionObj.SdmxObject = new SdmxObjectsImpl(); } if (BDO == null || GetSDMXObject == null) { throw new Exception(Messages.label_error_network + " " + DataObj.Configuration.Title); } codemapWidget = new CodemapWidget(new GetCodemapObject() { Configuration = this.DataObj.Configuration, Dataflow = this.DataObj.Dataflow, PreviusCostraint = this.DataObj.Criteria }, this.SessionObj, query); //ISdmxObjects structure = codemapWidget.GetDsd(); ISdmxObjects structure = query.Structure; IDataflowObject df = structure.Dataflows.FirstOrDefault(); IDataStructureObject kf = structure.DataStructures.First(); if (df == null) { throw new InvalidOperationException("Dataflow is not set"); } /****************/ // Get all codelist /****************/ //Dictionary<string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, true); Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(query, false); ComponentCodeDescriptionDictionary codemap = new ComponentCodeDescriptionDictionary(); foreach (string ConceptId in ConceptCodelists.Keys) { ICodelistObject codelist = ConceptCodelists[ConceptId]; Dictionary <string, string> codes = new Dictionary <string, string>(); foreach (ICode codeItem in codelist.Items) { codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.DataObj.Configuration.Locale)); } codemap.Add(ConceptId, codes); } /****************/ //codemapWidget.GetCodeListCostraint(df,kf,component) this.SessionObj.MergeObject(codemapWidget.SessionObj); int num1; #region Gestione last period if (this.DataObj.Criteria.ContainsKey(kf.TimeDimension.Id) && this.DataObj.Criteria[kf.TimeDimension.Id].Count == 1 && int.TryParse(this.DataObj.Criteria[kf.TimeDimension.Id].First(), out num1) && !this.DataObj.Layout.axis_z.Contains(kf.TimeDimension.Id)) { int offsetTime = int.Parse(this.DataObj.Criteria[kf.TimeDimension.Id].First()); var codMap = codemap; int lengthTime = codMap[kf.TimeDimension.Id].Count; if ((lengthTime - offsetTime) >= 0) { var codes = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime); List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>(); this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last()); this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First()); } else { this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key); this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key); } } #endregion LayoutObj layObj = InitLayout(df, kf); List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.DataObj.Criteria); //query.GetCriteria(); Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache; List <string> ret = null; List <DataCriteria> QueryCriterias = new List <DataCriteria>(); if (query.Criteria != null) //criteri nulli se proviene da un template { if (query._store != null) //.Count == 1) { query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]); } if (query.Criteria.TryGetValue(kf.TimeDimension.Id, out ret)) { if (ret.Count == 1) { query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]); } } QueryCriterias = query.GetCriteria(); /*if (query._store == null) //.Count == 1) * { QueryCriterias = Criterias; } * else * { QueryCriterias = query.GetCriteria(); }*/ } else { QueryCriterias = Criterias; } //aggiunta da fabio IDataSetStore store; if (query._store != null) { store = query._store; } else { //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr); store = BDO.GetDataset(df, kf, QueryCriterias, ref DataCache, _useAttr, query); query._store = store; } //fine nuovo SessionObj.DataCache = DataCache; DataStream = new DataObjectForStreaming() { Configuration = this.DataObj.Configuration, store = store, layObj = layObj, Criterias = Criterias, structure = structure, codemap = codemap }; return(this.SessionObj); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } }
public LayoutWidget(GetCodemapObject layoutObj, SessionImplObject sessionObj, SessionQuery sessionQuery) { LayObj = layoutObj; SessionObj = sessionObj; if (sessionQuery._IGetSDMX == null || (sessionQuery._endpointSettings != null && this.LayObj.Configuration.EndPoint != sessionQuery._endpointSettings.EndPoint)) { GetSDMXObject = WebServiceSelector.GetSdmxImplementation(this.LayObj.Configuration); sessionQuery._IGetSDMX = GetSDMXObject; } else { GetSDMXObject = sessionQuery._IGetSDMX; } }
public SessionImplObject GetLayout(SessionQuery query, ConnectionStringSettings connectionStringSetting) { try { /* * ISdmxObjects structure = GetKeyFamily(); * IDataflowObject df = structure.Dataflows.First(); * IDataStructureObject kf = structure.DataStructures.First(); */ ISdmxObjects structure = query.Structure; IDataflowObject df = query.Dataflow; IDataStructureObject kf = query.KeyFamily; if (kf == null || df == null) { throw new InvalidOperationException("DataStructure is not set"); } //if (this.SessionObj.DafaultLayout == null) this.SessionObj.DafaultLayout = new Dictionary <string, LayoutObj>(); //if (connectionStringSetting.ConnectionString!=null && connectionStringSetting.ConnectionString.ToLower() != "file") if (connectionStringSetting.ConnectionString != null) { // Get automatic timeserie layout System.Data.SqlClient.SqlConnection Sqlconn = new System.Data.SqlClient.SqlConnection(connectionStringSetting.ConnectionString); Sqlconn.Open(); string sqlquery = string.Format("Select * from Template where [tmplKey]='{0}'", new System.Web.Script.Serialization.JavaScriptSerializer().Serialize( LayObj.Dataflow.id + "+" + LayObj.Dataflow.agency + "+" + LayObj.Dataflow.version + "+" + LayObj.Configuration.EndPoint).Replace("'", "''")); using (System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(sqlquery, Sqlconn)) { var reader = comm.ExecuteReader(); if (reader.Read()) { string layout = reader.GetString(reader.GetOrdinal("Layout")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)] = (LayoutObj) new JavaScriptSerializer().Deserialize(layout, typeof(LayoutObj)); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_x = reader.GetBoolean(reader.GetOrdinal("BlockXAxe")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_y = reader.GetBoolean(reader.GetOrdinal("BlockYAxe")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_z = reader.GetBoolean(reader.GetOrdinal("BlockZAxe")); } } Sqlconn.Close(); } DefaultLayoutResponseObject defaultLayoutResponseObject = new DefaultLayoutResponseObject(); defaultLayoutResponseObject.DefaultLayout = (this.SessionObj.DafaultLayout.ContainsKey(Utils.MakeKey(df))) ? this.SessionObj.DafaultLayout[Utils.MakeKey(df)] : null; //if (defaultLayoutResponseObject.DefaultLayout == null){ return GetLayout(); } this.SessionObj.SavedDefaultLayout = new JavaScriptSerializer().Serialize(defaultLayoutResponseObject); return(this.SessionObj); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
public SessionImplObject GetDataChart(SessionQuery sessionQuery) { try { // Init session objects if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); this.SessionObj.SdmxObject = new SdmxObjectsImpl(); } JavaScriptSerializer ser = new JavaScriptSerializer(); ser.MaxJsonLength = int.MaxValue; #region +++ Caching +++ ConnectionStringSettings connectionStringSetting; CacheWidget cache = null; bool UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.UseWidgetCache : false; if (UseWidgetCache) { connectionStringSetting = ConfigurationManager.ConnectionStrings["ISTATWebClientConnection"]; cache = new CacheWidget(connectionStringSetting.ConnectionString); } if (ChartObj.WidgetId > 0 && UseWidgetCache) { SavedWidget widget = cache.GetWidget(ChartObj.WidgetId, ChartObj.Configuration.Locale); if (widget != null && !String.IsNullOrEmpty(widget.widgetData)) { this.SessionObj.SavedChart = widget.widgetData; return(this.SessionObj); } } #endregion if (BDO == null || GetSDMXObject == null) { throw new Exception(Messages.label_error_network); } codemapWidget = new CodemapWidget( new GetCodemapObject() { PreviusCostraint = this.ChartObj.Criteria, Configuration = this.ChartObj.Configuration, Dataflow = this.ChartObj.Dataflow }, this.SessionObj, sessionQuery); //ISdmxObjects structure = codemapWidget.GetDsd(); //IDataflowObject df = structure.Dataflows.FirstOrDefault(); //IDataStructureObject kf = structure.DataStructures.First(); ISdmxObjects structure = sessionQuery.Structure; //IDataflowObject df = structure.Dataflows.First(); IDataflowObject df = sessionQuery.Dataflow; //IDataStructureObject kf = structure.DataStructures.First(); IDataStructureObject kf = sessionQuery.KeyFamily; if (kf == null) { throw new InvalidOperationException("DSD is not set"); } if (df == null) { throw new InvalidOperationException("Dataflow is not set"); } Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, false); ComponentCodeDescriptionDictionary codemap = new ComponentCodeDescriptionDictionary(); foreach (string ConceptId in ConceptCodelists.Keys) { ICodelistObject codelist = ConceptCodelists[ConceptId]; Dictionary <string, string> codes = new Dictionary <string, string>(); foreach (ICode codeItem in codelist.Items) { codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.ChartObj.Configuration.Locale)); } codemap.Add(ConceptId, codes); //var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "true"); //fabio prova var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "false"); if (useFix20) { if (!(codelist.Items.Count > 1)) { this.ChartObj.Criteria.Remove(ConceptId); } } } this.SessionObj.MergeObject(codemapWidget.SessionObj); #region Gestione last period int num1; if (this.ChartObj.Criteria.ContainsKey(kf.TimeDimension.Id) && this.ChartObj.Criteria[kf.TimeDimension.Id].Count == 1 && int.TryParse(this.ChartObj.Criteria[kf.TimeDimension.Id].First(), out num1) ) { int offsetTime = int.Parse(this.ChartObj.Criteria[kf.TimeDimension.Id].First()); var codMap = codemap; int lengthTime = codMap[kf.TimeDimension.Id].Count; if ((lengthTime - offsetTime) >= 0) { var codes = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime); List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last()); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First()); } else { this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key); } } #endregion List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.ChartObj.Criteria); //List<DataCriteria> Criterias = sessionQuery.GetCriteria(); Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache; //aggiunta da fabio //IDataSetStore store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery); IDataSetStore store = sessionQuery._store; store.SetCriteria(Criterias); /* * IDataSetStore store; * if (sessionQuery._store != null) * { store = sessionQuery._store; } * else * { * //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr); * store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery); * sessionQuery._store = store; * } */ //fine nuovo //string DBFileName = null; //IDataSetStore store = BDO.FindDataCache(df, kf, Criterias, ref DataCache, false, out DBFileName); //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache); //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false); //da vedere se eliminare aggiunta fabio per svuotare datacache SessionObj.DataCache = null; SessionObj.DataCache = DataCache; DataObjectForStreaming DataStream = new DataObjectForStreaming() { store = store, Criterias = Criterias, structure = structure, codemap = codemap }; ChartResponseObject ChartResponse = new ChartResponseObject(); ChartResponse.series_title = TextTypeHelper.GetText(df.Names, this.ChartObj.Configuration.Locale); ChartResponse.series = BuildChart(store, kf, ConceptCodelists); ChartResponse.primary_name = (this.ChartObj.ObsValue[0] == "v") ? Messages.label_varValue : (this.ChartObj.ObsValue[0] == "vt") ? Messages.label_varTrend : (this.ChartObj.ObsValue[0] == "vc") ? Messages.label_varCyclical : string.Empty; ChartResponse.secondary_name = (this.ChartObj.ObsValue.Count > 1) ? (this.ChartObj.ObsValue[1] == "v") ? Messages.label_varValue : (this.ChartObj.ObsValue[1] == "vt") ? Messages.label_varTrend : (this.ChartObj.ObsValue[1] == "vc") ? Messages.label_varCyclical : string.Empty : string.Empty; ChartResponse.x_name = (!string.IsNullOrEmpty(ChartObj.DimensionAxe)) ? ChartObj.DimensionAxe : kf.TimeDimension.Id;; // 23/07/2015 // calcolo massimo e minimo decimal?primary_max = null; decimal?primary_min = null; decimal?secondary_max = null; decimal?secondary_min = null; decimal costantemax = 1.1m; decimal costantemin = 0.9m; foreach (serieType serie in ChartResponse.series) { if (serie.axisYType == "secondary") { //fabio 12/08/2015 //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y); decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y)); if (secondary_max == null || max > secondary_max) { secondary_max = max; } //fabio 12/08/2015 //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y); decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y)); if (secondary_min == null || min < secondary_min) { secondary_min = min; } //fabio 12/08/2015 if (secondary_min == secondary_max) { secondary_min = secondary_min * costantemin; secondary_max = secondary_max * costantemax; } } else { //fabio 12/08/2015 //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y); decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y)); if (primary_max == null || max > primary_max) { primary_max = max; } //fabio 12/08/2015 //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y); decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y)); if (primary_min == null || min < primary_min) { primary_min = min; } //fabio 12/08/2015 if (primary_min == primary_max) { primary_min = primary_min * costantemin; primary_max = primary_max * costantemax; } } } if (primary_max != null && primary_min != null) { //decimal delta = (decimal)primary_max - (decimal)primary_min; //ChartResponse.primary_max = (decimal)primary_max; //ChartResponse.primary_min = (decimal)primary_min; if (primary_max > 0) { ChartResponse.primary_max = (decimal)(primary_max * 1.1m); } else if (primary_max == 0) { ChartResponse.primary_max = (decimal) - 1.1m; } else { ChartResponse.primary_max = (decimal)(primary_max * 0.9m); } if (primary_min > 0) { ChartResponse.primary_min = (decimal)(primary_min * 0.9m); } else if (primary_min == 0) { ChartResponse.primary_min = (decimal) - 1.1m; } else { ChartResponse.primary_min = (decimal)(primary_min * 1.1m); } } if (secondary_max != null && secondary_min != null) { //ChartResponse.secondary_max = (decimal)secondary_max; //ChartResponse.secondary_min = (decimal)secondary_min; if (secondary_max > 0) { ChartResponse.secondary_max = (decimal)(secondary_max * 1.1m); } else if (secondary_max == 0) { ChartResponse.secondary_max = (decimal) - 1.1m; } else { ChartResponse.secondary_max = (decimal)(secondary_max * 0.9m); } if (secondary_min > 0) { ChartResponse.secondary_min = (decimal)(secondary_min * 0.9m); } else if (secondary_min == 0) { ChartResponse.secondary_min = (decimal) - 1.1m; } else { ChartResponse.secondary_min = (decimal)(secondary_min * 1.1m); } } this.SessionObj.SavedChart = ser.Serialize(ChartResponse); // +++ Caching +++ if (ChartObj.WidgetId > 0 && UseWidgetCache) { cache.InsertWidget(ChartObj.WidgetId, this.SessionObj.SavedChart, ChartObj.Configuration.Locale); } return(this.SessionObj); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } }
public ChartWidget(GetChartObject chartObj, SessionImplObject sessionObj, CultureInfo cFrom, CultureInfo cTo, SessionQuery sessionQuery) { ChartObj = chartObj; SessionObj = sessionObj; //GetSDMXObject = WebServiceSelector.GetSdmxImplementation(this.ChartObj.Configuration); if (sessionQuery._IGetSDMX == null || (sessionQuery._endpointSettings != null && this.ChartObj.Configuration.EndPoint != sessionQuery._endpointSettings.EndPoint)) { GetSDMXObject = WebServiceSelector.GetSdmxImplementation(this.ChartObj.Configuration); sessionQuery._IGetSDMX = GetSDMXObject; } else { GetSDMXObject = sessionQuery._IGetSDMX; } BDO = new BaseDataObject(chartObj.Configuration, System.IO.Path.GetTempFileName()); this.cFrom = cFrom; this.cTo = cTo; }
public SessionImplObject GetTree(SessionQuery sessionQuery) { var ser = new JavaScriptSerializer(); string json; try { //string decimalCulture=TreeObj.Configuration.Locale; //TreeObj.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToUpper(); CacheTree ct = new CacheTree(ConnectionString, TreeObj.Configuration); //controlla il parametro CachedTree del webconfig se utilizzare o meno la cache bool UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.CachedTree : false; string JsonTree = null; if (UseWidgetCache) { JsonTree = ct.GetCachedTree(); } if (!string.IsNullOrEmpty(JsonTree)) { return new SessionImplObject() { SavedTree = JsonTree } } ; //ISdmxObjects SdmxOBJ = GetSdmxObject(TreeObj.Configuration); ISdmxObjects SdmxOBJ = null; if (sessionQuery._IGetSDMXObject == null || TreeObj.Configuration.EndPoint != sessionQuery._endpointSettings.EndPoint) { SdmxOBJ = GetSdmxObject(TreeObj.Configuration, sessionQuery); sessionQuery._IGetSDMXObject = SdmxOBJ; } else { SdmxOBJ = sessionQuery._IGetSDMXObject; } //TreeObj.Configuration.Locale = decimalCulture; List <JsTreeNode> nodelist = BuildJSTree(SdmxOBJ, System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName); if (nodelist == null || nodelist.Count == 0) {//Invio Errore var x = new { error = true, dataflowError = true, message = ISTAT.WebClient.WidgetComplements.Model.App_GlobalResources.Messages.no_results_found }; throw new Exception(ser.Serialize(x)); } json = ser.Serialize(nodelist); JArray jobject = JArray.Parse(json); string appo = jobject.ToString(); ct.SaveCachedTree(json); return(new SessionImplObject() { SavedTree = json, SdmxObject = SdmxOBJ }); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
public static SessionQuery SaveSessionQuery(HttpSessionState session, SessionQuery query) { if (session == null) { throw new ArgumentNullException("session"); } session[Constants.HTTPSessionQueryAttr] = query; return query; }