/// <summary> /// Write a data body content into FlyWriter /// </summary> /// <param name="writer">object of transport used for transmitting data in streaming <see cref="IFlyWriter"/></param> public override void WriterBody(IFlyWriter writer) { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Writing Data Result"); Parser(Rea, Builder, writer); Conn.Close(); FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Writing the result successfully completed"); }
protected override void OnError(EventArgs e) { string str_msg = Server.GetLastError().ToString(); string str_errorCode = DateTime.Now.Day + DateTime.Now.ToLongTimeString().Replace(":", ""); FlyLog.WriteLog(string.Format("{0}\r\n{1}", str_errorCode, str_msg)); Response.Redirect(string.Format("Error.aspx?code={0}", str_errorCode)); }
/// <summary> /// Performs correct store procedures and it process results /// </summary> /// <param name="operation">Operations Type (indicates the store procedure to execute)</param> /// <param name="parameter">Parameters to be passed to the store procedure</param> /// <returns>Returns a list of xmlNode with which the builder that identifies the response</returns> public List <XmlNode> Execute(DBOperationEnum operation, List <IParameterValue> parameter) { try { _conn = new SqlConnection(); _conn.ConnectionString = this.ConnectionString; _conn.Open(); SqlCommand cmd = new SqlCommand(GetStoreRef(operation), _conn); cmd.CommandType = CommandType.StoredProcedure; if (parameter != null) { parameter.ForEach(p => cmd.Parameters.Add(((ParameterValue)p).CreateParameter())); } StringBuilder dbres = new StringBuilder(); using (SqlDataReader rea = cmd.ExecuteReader()) { while (rea.Read()) { dbres.Append(rea.GetValue(0).ToString()); } } // cmd.ExecuteScalar();//perche ritorna sempre un valore E'LIMITATO A 2033 CARATTERI _conn.Close(); if (dbres == null || string.IsNullOrEmpty(dbres.ToString())) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse); } XmlDocument risposta = new XmlDocument(); risposta.LoadXml(dbres.ToString()); if (risposta.ChildNodes.Count > 0) { StringBuilder Par = new StringBuilder(); foreach (var item in parameter) { Par.AppendLine(String.Format("{0} \t\t-> {1}", item.Item, item.Value)); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Execution Store procedure {0} for {1} Successfully. Reading results {2}", cmd.CommandText, operation.ToString(), Par); return(new List <XmlNode>(risposta.ChildNodes[0].ChildNodes.Cast <XmlNode>())); } else { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.Error, "Execution Store procedure {0} for {1}. NO RESULT", cmd.CommandText, operation.ToString()); } throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse); } catch (SdmxException) { throw; } catch (Exception e) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse, e); } }
/// <summary> /// Add External reference into SdmxObject /// </summary> public override void AddReferences() { try { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "No References for AgencyScheme"); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.AddReferences, ex); } }
/// <summary> ///Start Write data message and Call Write20DataMessage or Write21DataMessage /// Create a XElement to return back /// </summary> /// <param name="TableResponse">Headers of response</param> /// <param name="writer"> Contains the object of transport used for transmitting data in streaming</param> internal void WriteDataMessage(IDataTableMessageObject TableResponse, IFlyWriter writer) { try { this._tableResponse = TableResponse; WriterDataBase writerData = null; if (writer.FlyMediaType == FlyMediaEnum.Rdf) { writerData = new WriteRDFDataMessage(); } else if (writer.FlyMediaType == FlyMediaEnum.Dspl) { writerData = new WriteDSPLDataMessage(); } else if (writer.FlyMediaType == FlyMediaEnum.Json) { writerData = new WriteJsonDataMessage(); } else if (_versionTypeResp == SdmxSchemaEnumType.VersionTwo) { writerData = new Write20DataMessage(); } else { writerData = new Write21DataMessage(); } writerData.MessageType = this.MessageType; writerData._tableResponse = this._tableResponse; writerData._retrievalManager = this._retrievalManager; writerData.DimensionAtObservation = this.DimensionAtObservation; writerData.WriteDataMessage(writer); FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Total Rows return from Database {0}", this._tableResponse.RowsCounter); //StreamReader rdr = new System.IO.StreamReader(ms); //ms.Position = 0; //string DSDris = rdr.ReadToEnd(); ////return XElement.Parse(DSDris); //ms.Position = 0; } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.WriteDataMessage, ex); } }
/// <summary> /// Call CreateDSD and Write SdmxObject in XElement Streaming to return with processed metadata result /// </summary> /// <returns>Object for Write response in streaming <see cref="IFlyWriterBody"/></returns> public virtual IFlyWriterBody WriteDSD() { try { ISdmxObjects sdmxObject = CreateDSD(); sdmxObject.Action = DatasetAction.GetFromEnum(DatasetActionEnumType.Append); //Oggetto che crea l'output StructureWriterManager swm = new StructureWriterManager(); StructureOutputFormat sofType = null; if (VersionTypeResp == SdmxSchemaEnumType.VersionTwo) { sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument); } else if (VersionTypeResp == SdmxSchemaEnumType.VersionTwoPointOne) { sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument); } else { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.UnrecognizedVersion, new Exception("Version: " + VersionTypeResp.ToString())); } SdmxStructureFormat sof = new SdmxStructureFormat(sofType); //IStructureFormat //Dove metto il risultato Stream IFlyWriterBody WriterBody = new FlyMetadataWriterBody() { StructureFormat = sof, SdmxObject = sdmxObject }; FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Create Callback for Writing SDMXObject"); return(WriterBody); //MemoryStream ms = new MemoryStream(); //swm.WriteStructures(sdmxObject, sof, ms); //ms.Position = 0; //StreamReader rdr = new System.IO.StreamReader(ms); //ms.Position = 0; //string DSDris = rdr.ReadToEnd(); //return XElement.Parse(DSDris); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateSdmxObjectError, ex); } }
/// <summary> /// Execute a store procedure for get a Data for DataMessage /// </summary> /// <param name="parameter">Parameters to be passed to the store procedure</param> /// <param name="parse">Delegate to call for parse result</param> /// <param name="builder">Delegate to pass at GetDBResponseDelegate for write result</param> /// <returns>Object for Write response in streaming <see cref="IFlyWriterBody"/></returns> public IFlyWriterBody ExecuteGetData(List <IParameterValue> parameter, GetDBResponseDelegate parse, WriteResponseDelegate builder) { try { _conn = new SqlConnection(); _conn.ConnectionString = this.ConnectionString; _conn.Open(); SqlCommand cmd = new SqlCommand(GetStoreRef(DBOperationEnum.GetData), _conn); cmd.CommandType = CommandType.StoredProcedure; if (parameter != null) { parameter.ForEach(p => cmd.Parameters.Add(((ParameterValue)p).CreateParameter())); } //if (true)//FAKE //{ // cmd = new SqlCommand("SELECT TOP 1000000 * FROM [Datawarehouse].[dbo].[Dataset_6_ViewAllData]", _conn); // cmd.CommandType = CommandType.Text; // cmd.Parameters.Clear(); //} cmd.CommandTimeout = int.MaxValue; SqlDataReader rea = cmd.ExecuteReader(); StringBuilder Par = new StringBuilder(); foreach (var item in parameter) { Par.AppendLine(String.Format("{0} \t\t-> {1}", item.Item, item.Value)); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, @"Execution Store procedure {0} for data request Successfully. Reading results {1}", cmd.CommandText, Par); return(new FlyDataWriterBody() { Rea = rea, Conn = _conn, Builder = builder, Parser = parse }); } catch (SdmxException) { throw; } catch (Exception e) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse, e); } }
/// <summary> /// Get structured Data Message from Database /// </summary> /// <param name="idDataset">Dataset Code</param> /// <param name="whereStatement">Where condition</param> /// <param name="BuilderCallback">delegate to call for write data response</param> /// <param name="TimeStamp">LastUpdate parameter request only observation from this date onwards</param> /// <returns>Object for Write response in streaming <see cref="IFlyWriterBody"/></returns> public IFlyWriterBody GetTableMessage(string idDataset, IDataWhereStatment whereStatement, WriteResponseDelegate BuilderCallback, string TimeStamp) { try { string TimeWhere = ""; List <IParameterValue> parametri = new List <IParameterValue>() { new ParameterValue() { Item = "DataSetCode", Value = idDataset }, new ParameterValue() { Item = "WhereStatement", Value = ConvertIDataQueryToWhereStatement(whereStatement, out TimeWhere) }, new ParameterValue() { Item = "Time", Value = TimeWhere }, new ParameterValue() { Item = "UserName", Value = FlyConfiguration.UserName }, new ParameterValue() { Item = "Domain", Value = FlyConfiguration.Domain }, }; if (!string.IsNullOrEmpty(TimeStamp)) { parametri.Add(new ParameterValue() { Item = "TimeStamp", Value = TimeStamp, SqlType = SqlDbType.DateTime }); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, @"GetData parameter: {0}", string.Join("\n", parametri)); //EFFETTUO LA RICHIESTA AL DB return(this.DbAccess.ExecuteGetData(parametri, new GetDBResponseDelegate(GetDBResponse), BuilderCallback)); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetTableMessage, ex); } }
/// <summary> /// Connection preliminary to determine if the credentials are correct and whether the DataBase is reached /// </summary> public void TestConnection() { try { _conn = new SqlConnection(); _conn.ConnectionString = this.ConnectionString; _conn.Open(); //Connessione riuscita _conn.Close(); FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Database Test Connection successfully"); } catch (SdmxException) { throw; } catch (Exception e) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.ErrorConnectionDB, e); } }
/// <summary> /// Create Instance of SdmxException /// </summary> /// <param name="Control">Object that fired Exception (this for all Object, typeof(ClassName) for staticFunction)</param> /// <param name="typeErr">Internal Exception type Enumerator</param> /// <param name="Ex">Additional Exception</param> public SdmxException(object Control, FlyExceptionObject.FlyExceptionTypeEnum typeErr, Exception Ex) { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.Error, "Start Writing Error type {0} message {1}", typeErr.ToString(), Ex == null?"":Ex.Message); this.FlyException = FlyExceptionObject.Get(typeErr); //Fault this.SDMXFaultCode = this.FlyException.SDMXException._sdmxErrorCode; this.SDMXFaultMessage = this.FlyException.SDMXException._sdmxErrorText; //detail this.MessageText = string.Format("{0}", FlyException.FlyExceptionText); bool IsEmptyDetail = false; if (Ex == null) { IsEmptyDetail = true; Ex = new Exception(this.MessageText); } this.MessageError = new FlyMessageError(Ex, IsEmptyDetail); try { if (Control is string) { this.ProcSource = Control as string; } else if (Control is Type) { this.ProcSource = (Control as Type).FullName; } else { this.ProcSource = Control.GetType().FullName; } } catch (Exception) { this.ProcSource = Ex.Source; } }
/// <summary> /// Return a Number of record of Data result of GetData StoreProcedure /// </summary> /// <param name="parameter">Parameters to be passed to the store procedure</param> /// <returns>Number of record of Observation</returns> public int GetCL_COUNT(List <IParameterValue> parameter) { try { _conn = new SqlConnection(); _conn.ConnectionString = this.ConnectionString; _conn.Open(); string datasetCode = parameter.Find(p => p.Item == "DataSetCode").Value.ToString(); string SqlQuery = @" declare @DataSetCode varchar(100) = '" + datasetCode + @"' declare @IDSet int= NULL declare @req_FiltTableName nvarchar(255) select TOP 1 @IDSet = IDSet from CatSet where Code=@DataSetCode IF (@IDSet IS NULL) BEGIN RAISERROR ('Dataset not found',15,1) END SET @req_FiltTableName= 'Dataset_'+ convert(varchar(50),@IDSet) +'_ViewAllData' exec('select count(*) from ' + @req_FiltTableName)"; int conta = 0; SqlCommand cmd = new SqlCommand(SqlQuery, _conn); cmd.CommandTimeout = int.MaxValue; cmd.CommandType = CommandType.Text; conta = Convert.ToInt32(cmd.ExecuteScalar()); _conn.Close(); FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, @"Execution Store procedure {0} for Get CL_COUNT request Successfully. Reading results", cmd.CommandText); return(conta); } catch (SdmxException) { throw; } catch (Exception e) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse, e); } }
/// <summary> /// Write a metadata body content into FlyWriter /// </summary> /// <param name="writer">object of transport used for transmitting data in streaming <see cref="IFlyWriter"/></param> public override void WriterBody(IFlyWriter writer) { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Writing Metadata Result"); switch (writer.FlyMediaType) { case FlyMediaEnum.Sdmx: Org.Sdmxsource.Sdmx.Structureparser.Manager.StructureWriterManager Struwriter = new Org.Sdmxsource.Sdmx.Structureparser.Manager.StructureWriterManager(new Org.Sdmxsource.Sdmx.Structureparser.Factory.SdmxStructureWriterFactory(writer.__SdmxXml)); Struwriter.WriteStructures(SdmxObject, StructureFormat, null); break; case FlyMediaEnum.Rdf: RDFProvider.Structure.Manager.StructureRDFWritingManager RDFStruwriter = new RDFProvider.Structure.Manager.StructureRDFWritingManager(new RDFProvider.Structure.Factory.RDFStructureWriterFactory(writer.__SdmxXml)); RDFStruwriter.RDFWriteStructures(SdmxObject, null); break; case FlyMediaEnum.Dspl: case FlyMediaEnum.Json: default: throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.NotImplemented, new Exception("MediaType=" + writer.FlyMediaType.ToString())); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Writing the result successfully completed"); }
/// <summary> /// Entrypoint of class FlyEngine that processes the request /// and produces a response or an error /// </summary> /// <param name="_parsingObject">Processed request</param> /// <param name="_versionType">Sdmx Version</param> public void Engine(ISdmxParsingObject _parsingObject, SdmxSchemaEnumType _versionType) { try { this.VersionTypeResp = _versionType; //IDBAccess DbAccess = new DWHAccess(FlyConfiguration.ConnectionString); _parsingObject.PreliminarCheck(); FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Query Preliminar Check passed. Start creation of SDMXObject"); Builder = CreateBuilder(_parsingObject, _versionType); if (Builder == null) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.NotSupportedRegistryType, new Exception(_parsingObject.SdmxStructureType.ToString())); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Parsing Metadata: {0}", _parsingObject.SdmxStructureType.ToString()); Builder.Build(); ParseOtherRegistry(_parsingObject); Builder.AddReferences(); } catch (SdmxException sdmxerr) { HaveError = true; ErrorMessage = sdmxerr; } catch (Exception err) { HaveError = true; ErrorMessage = new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, err); } }
/// <summary> /// calculates the value of StructureUrl (<see cref="RetreivalStructureUrl"/>) /// </summary> /// <param name="obj">Type of artifact</param> /// <param name="MaintenableId">Artefact Code</param> /// <param name="Agencyid">Artefact AgencyId</param> /// <param name="Version">Artefact Version</param> /// <returns>Parsed StructureUrl Uri</returns> public static Uri Get(ObjectBuilder obj, string MaintenableId, string Agencyid, string Version) { try { string Uri = System.ServiceModel.OperationContext.Current.Host.BaseAddresses[0].ToString(); int Fromindex = 0; if (Uri.Contains("/" + Constant.ContractNamespaceSdmx20)) { Fromindex = Uri.IndexOf("/" + Constant.ContractNamespaceSdmx20); } if (Uri.Contains("/" + Constant.ContractNamespaceSdmx21)) { Fromindex = Uri.IndexOf("/" + Constant.ContractNamespaceSdmx21); } if (Uri.Contains("/rest")) { Fromindex = Uri.IndexOf("/rest"); } if (Fromindex > 0) { string restV = "/rest/"; if (obj is CategorySchemeBuilder) { if (obj.ParsingObject.SdmxStructureType != SdmxStructureEnumType.Categorisation) { restV += "CategoryScheme/"; } else { restV += "Categorisation/"; } } else if (obj is CodelistBuilder) { restV += "Codelist/"; } else if (obj is ConceptBuilder) { restV += "ConceptScheme/"; } else if (obj is DataflowBuilder) { restV += "Dataflow/"; } else if (obj is DataStructureBuilder) { restV += "DataStructure/"; } restV += string.Format("{0}/{1}/{2}/", Agencyid, MaintenableId, Version); return(new Uri(Uri.Substring(0, Fromindex) + restV)); } } catch (Exception ex) { FlyLog.WriteLog(typeof(RetreivalStructureUrl), FlyLog.LogTypeEnum.Error, "Error when parsing Uri for StructureUrl err: {0}", ex.Message); } return(new Uri("http://OntheFly/ExternalReference/StructureURL")); }
private void ParseOtherRegistry(ISdmxParsingObject _parsingObject) { if (_parsingObject.OtherRegistry != null && _parsingObject.OtherRegistry.Count > 0) { foreach (var _parsingOther in _parsingObject.OtherRegistry) { ISDMXObjectBuilder OtherRegistry = CreateBuilder(_parsingOther, this.VersionTypeResp); if (OtherRegistry == null) { FlyLog.WriteLog(this, FlyLog.LogTypeEnum.Error, "NotSupportedRegistryType (Other Registry) SdmxStructureType {0}", _parsingOther.SdmxStructureType.ToString()); continue; } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Parsing Metadata (Other Registry): {0}", _parsingOther.SdmxStructureType.ToString()); OtherRegistry.Build(); switch (_parsingOther.SdmxStructureType) { case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.Dataflow: if (Builder._Dataflows == null || Builder._Dataflows.Count == 0) { Builder._Dataflows = OtherRegistry._Dataflows; } else { Builder._Dataflows.AddRange(OtherRegistry._Dataflows); } break; case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.ConceptScheme: if (Builder._Conceptscheme == null || Builder._Conceptscheme.Count == 0) { Builder._Conceptscheme = OtherRegistry._Conceptscheme; } else { Builder._Conceptscheme.AddRange(OtherRegistry._Conceptscheme); } break; case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.CodeList: if (Builder._Codelists == null || Builder._Codelists.Count == 0) { Builder._Codelists = OtherRegistry._Codelists; } else { Builder._Codelists.AddRange(OtherRegistry._Codelists); } break; case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.AgencyScheme: case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.OrganisationScheme: Builder._AgencyScheme = OtherRegistry._AgencyScheme; break; case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.CategoryScheme: case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.Categorisation: if (Builder._CategorisationObject == null || Builder._CategorisationObject.Count == 0) { Builder._CategorisationObject = OtherRegistry._CategorisationObject; } else { Builder._CategorisationObject.AddRange(OtherRegistry._CategorisationObject); } break; case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.Dsd: if (Builder._KeyFamily == null || Builder._KeyFamily.Count == 0) { Builder._KeyFamily = OtherRegistry._KeyFamily; } else { Builder._KeyFamily.AddRange(OtherRegistry._KeyFamily); } break; } } } }
/// <summary> /// Create a SdmxObjects from all parameter configured /// </summary> /// <returns>SdmxObject for write message</returns> public ISdmxObjects CreateDSD() { try { StringBuilder sdmxObjectDescription = new StringBuilder(); sdmxObjectDescription.AppendLine(); ISdmxObjects sdmxObject = new SdmxObjectsImpl(); sdmxObject.Header = FlyConfiguration.HeaderSettings.GetHeader(); //sdmxObject.AddRegistration( if (_CategorySchemeObject != null) { foreach (ICategorySchemeObject CSObj in _CategorySchemeObject) { sdmxObject.AddCategoryScheme(CSObj); sdmxObjectDescription.AppendLine(string.Format("CategoryScheme: {0} category", CSObj.Items == null ? 0 : CSObj.Items.Count)); } } if (_CategorisationObject != null) { foreach (var categorisation in _CategorisationObject) { sdmxObject.AddCategorisation(categorisation); } sdmxObjectDescription.AppendLine(string.Format("Categorisation: {0} categorisation", _CategorisationObject.Count)); } if (_AgencyScheme != null) { sdmxObject.AddAgencyScheme(_AgencyScheme); sdmxObjectDescription.AppendLine(string.Format("AgencyScheme")); } if (_Codelists != null) { try { int totalcode = 0; _Codelists.ForEach(cl => { sdmxObject.AddCodelist(cl.ImmutableInstance); totalcode += cl.Items.Count; }); sdmxObjectDescription.AppendLine(string.Format("Codelists: {0} codelists, {1} code_objects", _Codelists.Count, totalcode)); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex); } } if (_Conceptscheme != null) { foreach (var conceptscheme in _Conceptscheme) { sdmxObject.AddConceptScheme(conceptscheme); sdmxObjectDescription.AppendLine(string.Format("Conceptscheme: {0} concepts -> {1}", (conceptscheme.Items == null ? 0 : conceptscheme.Items.Count), conceptscheme.Id)); } } if (_KeyFamily != null) { foreach (DataStructureObjectImpl keyFamily in _KeyFamily) { sdmxObject.AddDataStructure(keyFamily.Immutated); sdmxObjectDescription.AppendLine(string.Format("Structure: {0} dimensions, {1} attributes -> {2}", keyFamily.Immutated.GetDimensions() == null ? 0 : keyFamily.Immutated.GetDimensions().Count, keyFamily.Attributes == null ? 0 : keyFamily.Attributes.Count, keyFamily.Id)); } } if (_Dataflows != null) { _Dataflows.ForEach(df => sdmxObject.AddDataflow(df)); sdmxObjectDescription.AppendLine(string.Format("Dataflows: {0} dataflows", _Dataflows.Count)); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, @"Writing sdmxObject complete succesfully. the Sdmx Contains: {0}", sdmxObjectDescription.ToString().Trim()); return(sdmxObject); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateDSDObject, ex); } }
/// <summary> /// Return a Minor and Max DateTime into recorSet data results of GetData StoreProcedure /// </summary> /// <param name="parameter">Parameters to be passed to the store procedure</param> /// <param name="FirstTime">OUT Minor DateTime into recorSet data results</param> /// <param name="EndTime">OUT Max DateTime into recorSet data results</param> public void GetCL_TIME_PERIOD(List <IParameterValue> parameter, out string FirstTime, out string EndTime) { try { _conn = new SqlConnection(); _conn.ConnectionString = this.ConnectionString; _conn.Open(); string datasetCode = parameter.Find(p => p.Item == "DataSetCode").Value.ToString(); string SqlQuery = @" declare @DataSetCode varchar(100) = '" + datasetCode + @"' declare @TimeCol varchar(100) = NULL declare @IDSet int= NULL declare @req_FiltTableName nvarchar(255) select TOP 1 @IDSet = IDSet from CatSet where Code=@DataSetCode IF (@IDSet IS NULL) BEGIN RAISERROR ('Dataset not found',15,1) END select TOP 1 @TimeCol='_' + Code from CatDim where IDSet=@IDSet AND IsTimeSeriesDim=1 IF (@TimeCol IS NULL) BEGIN RAISERROR ('Time dimension not found',15,1) END SET @req_FiltTableName= 'Dataset_'+ convert(varchar(50),@IDSet) +'_ViewAllData' exec('select TOP 1 (select DISTINCT top 1 '+@TimeCol+' as tempo from ' + @req_FiltTableName + ' order by tempo) as startPeriod, (select DISTINCT top 1 '+@TimeCol+' as tempo from ' + @req_FiltTableName + ' order by tempo desc) as endPeriod from '+ @req_FiltTableName )"; FirstTime = null; EndTime = null; SqlCommand cmd = new SqlCommand(SqlQuery, _conn); cmd.CommandTimeout = int.MaxValue; cmd.CommandType = CommandType.Text; using (SqlDataReader rea = cmd.ExecuteReader()) { while (rea.Read()) { FirstTime = rea["startPeriod"].ToString(); EndTime = rea["endPeriod"].ToString(); } } _conn.Close(); if (!string.IsNullOrEmpty(FirstTime)) { FirstTime = FirstTime.Substring(0, 4); } if (!string.IsNullOrEmpty(EndTime)) { EndTime = EndTime.Substring(0, 4); } FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, @"Execution Store procedure {0} for Get CL_TIME_PERIOD request Successfully. Reading results", cmd.CommandText); } catch (SdmxException) { throw; } catch (Exception e) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse, e); } }