Example #1
0
        private static void GetGlobalConf(XmlNode GlobalSettingsNode)
        {
            try
            {
                foreach (XmlNode item in GlobalSettingsNode.ChildNodes)
                {
                    if (item.Name == "HeaderSettings")
                    {
                        FlyConfiguration.HeaderSettings = new HeaderBuilder(item);
                        continue;
                    }

                    if (item.Name != "add" || item.Attributes == null || item.Attributes["key"] == null || item.Attributes["value"] == null)
                    {
                        continue;
                    }
                    switch (item.Attributes["key"].Value)
                    {
                    case "UserName":
                        FlyConfiguration.UserName = item.Attributes["value"].Value;
                        break;

                    case "Domain":
                        FlyConfiguration.Domain = item.Attributes["value"].Value;
                        break;

                    case "DatasetTitle":
                        bool _datasetTitle;
                        bool.TryParse(item.Attributes["value"].Value, out _datasetTitle);
                        FlyConfiguration.DatasetTitle = _datasetTitle;
                        break;

                    case "OrganisationScheme":
                        FlyConfiguration.AgencyOrganisationId          = item.Attributes["value"].Value;
                        FlyConfiguration.AgencyOrganisationDescription = SdmxObjectNameDescription.GetNameDescriptions(item);
                        break;

                    case "MainAgencyId":
                        FlyConfiguration.MainAgencyId          = item.Attributes["value"].Value;
                        FlyConfiguration.MainAgencyDescription = SdmxObjectNameDescription.GetNameDescriptions(item);
                        break;

                    case "Version":
                        FlyConfiguration.Version = item.Attributes["value"].Value;
                        break;
                    }
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(typeof(FlyController.FlyConfiguration), FlyExceptionObject.FlyExceptionTypeEnum.InitConfigError, ex);
            }
        }
Example #2
0
        /// <summary>
        /// retrieves the Dataflows from database
        /// </summary>
        /// <returns>list of Dataflow in Dictionary structure (Code, Descriptions)</returns>
        public Dictionary <string, List <SdmxObjectNameDescription> > GetDataflows(string DataflowCodeMaintenableId)
        {
            try
            {
                Dictionary <string, List <SdmxObjectNameDescription> > _Dataflows = new Dictionary <string, List <SdmxObjectNameDescription> >();

                List <IParameterValue> parametri = new List <IParameterValue>()
                {
                    new ParameterValue()
                    {
                        Item = "UserName", Value = FlyConfiguration.UserName
                    },
                    new ParameterValue()
                    {
                        Item = "Domain", Value = FlyConfiguration.Domain
                    },
                };

                if (!string.IsNullOrEmpty(this.parsingObject.TimeStamp))
                {
                    parametri.Add(new ParameterValue()
                    {
                        Item = "TimeStamp", Value = this.parsingObject.TimeStamp, SqlType = SqlDbType.DateTime
                    });
                }

                //EFFETTUO LA RICHIESTA AL DB
                List <XmlNode> risposta = this.DbAccess.Execute(DBOperationEnum.GetDataflows, parametri);

                //PARSO LA RISPOSTA E CREO L'OGGETTO
                if (risposta.Count > 0)
                {
                    foreach (XmlNode dataset in risposta)
                    {
                        if (dataset.Attributes == null || dataset.Attributes["Code"] == null)
                        {
                            continue;
                        }

                        _Dataflows.Add(dataset.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(dataset));
                    }
                }
                return(_Dataflows);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateDataflowBuilder, ex);
            }
        }
 /// <summary>
 /// If not Exist Frequency Dimension in database, the application adds it because it is mandatory and takes the Names Description from the file "FrequencyCodelist.xml"
 /// </summary>
 /// <returns></returns>
 private List <SdmxObjectNameDescription> GetFakeFreqNames()
 {
     try
     {
         XmlDocument configuration = new XmlDocument();
         configuration.Load(FlyConfiguration.FrequencyCodelistFile);
         return(SdmxObjectNameDescription.GetNameDescriptions(configuration.ChildNodes[0]));
     }
     catch (SdmxException) { throw; }
     catch (Exception ex)
     {
         throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetFrequencyCodelist, ex);
     }
 }
        private void RecursivePopulateTreeCategorySP(string IdCategoryParent, List <XmlNode> figli, ref List <InternalCategoryObject> categorie, ref List <InternalCategoryObject> _categoriesLinear, ref List <InternalDatasetObject> _datasetsLinear)
        {
            try
            {
                foreach (XmlNode ContentObject in figli)
                {
                    if (ContentObject.Name == "ContentObject" && ContentObject.ChildNodes.Count > 0)
                    {
                        InternalCategoryObject categoria = new InternalCategoryObject();
                        categoria.PadreId = IdCategoryParent;

                        if (ContentObject.Attributes["Code"] != null)
                        {
                            categoria.Id = ContentObject.Attributes["Code"].Value.ToString();
                        }
                        categoria.Nomi = SdmxObjectNameDescription.GetNameDescriptions(ContentObject);
                        List <InternalCategoryObject> SubCategory = new List <InternalCategoryObject>();
                        foreach (XmlNode CategoryProperty in ContentObject.ChildNodes)
                        {
                            switch (CategoryProperty.Name)
                            {
                            case "DatasetList":
                                PopolaDataSets_inCategorySP(categoria.Id, CategoryProperty.ChildNodes, ref _datasetsLinear);
                                break;

                            case "ContentObject":
                                RecursivePopulateTreeCategorySP(categoria.Id, new List <XmlNode>()
                                {
                                    CategoryProperty
                                }, ref SubCategory, ref _categoriesLinear, ref _datasetsLinear);
                                break;
                            }
                        }
                        categoria.SubCategory = SubCategory;

                        categorie.Add(categoria);
                        _categoriesLinear.Add(categoria);
                    }
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex);
            }
        }
        /// <summary>
        /// Get Attribute Concept from file AttributeConcepts.xml
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <returns>list of Attribute</returns>
        public List <IAttributeConcept> GetAttribute(string DataflowCode)
        {
            try
            {
                List <IAttributeConcept> Attributes = new List <IAttributeConcept>();
                try
                {
                    XmlDocument configuration = new XmlDocument();
                    configuration.Load(FlyConfiguration.AttributeFile);
                    foreach (XmlNode item in configuration.ChildNodes[0].ChildNodes)
                    {
                        if (item.Name != "Attribute" && item.Attributes == null || item.Attributes["Code"] == null || item.Attributes["attachmentLevel"] == null || item.Attributes["assignmentStatus"] == null)
                        {
                            continue;
                        }

                        IAttributeConcept AttributeConcept = new AttributeConcept(item.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(item));
                        AttributeConcept.AttributeAttachmentLevelType = (AttributeAttachmentLevel)Enum.Parse(typeof(AttributeAttachmentLevel), item.Attributes["attachmentLevel"].Value, true);
                        AttributeConcept.AssignmentStatusType         = (AssignmentStatusTypeEnum)Enum.Parse(typeof(AssignmentStatusTypeEnum), item.Attributes["assignmentStatus"].Value, true);
                        Attributes.Add(AttributeConcept);
                    }
                }
                catch (SdmxException) { throw; }
                catch (Exception ex)
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetAttributeError, ex);
                }

                return(Attributes);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetListConcepts, ex);
            }
        }
        /// <summary>
        /// Get hierachical codelist
        /// </summary>
        /// <param name="xmlNodeList">list of XmlNode (child nodes)</param>
        /// <param name="ParentCode">dimension Parent Code</param>
        /// <returns>list of Mutable Code Object</returns>
        private List <ICodeMutableObject> GetRecurviveDimension(XmlNodeList xmlNodeList, string ParentCode)
        {
            try
            {
                List <ICodeMutableObject> dim = new List <ICodeMutableObject>();

                foreach (XmlNode Member in xmlNodeList)
                {
                    if (((Member.Name != "Dimension" && Member.Name != "ChildMember" && Member.Name != "Member")) || Member.Attributes == null || Member.Attributes["Code"] == null)
                    {
                        continue;
                    }
                    string code = Member.Attributes["Code"].Value;

                    dim.Add(CodelistItemBuilder.BuildCodeObjects(Member.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(Member), ParentCode));

                    dim.AddRange(GetRecurviveDimension(Member.ChildNodes, code));
                }
                return(dim);
            }
            catch (SdmxException) { throw; }
            catch (Exception)
            {
                return(new List <ICodeMutableObject>());
            }
        }
Example #7
0
        private static void GetMappingSettingsConf(XmlNode MappingSettings)
        {
            try
            {
                foreach (XmlNode item in MappingSettings.ChildNodes)
                {
                    if (item.Name == "StoreProcedureSettings")
                    {
                        FlyConfiguration.StoreProcedureSettings = DatabaseStoreProcedureSettings.GetDbStoreSetting(item);
                        continue;
                    }
                    if (item.Name == "RIWebService")
                    {
                        FlyConfiguration.RIWebServices = new RIWebServiceConfiguration();
                        FlyConfiguration.RIWebServices.Configure(item);
                        continue;
                    }
                    if (item.Name == "CategorySettings")
                    {
                        foreach (XmlNode cats in item.ChildNodes)
                        {
                            if (cats.Name != "add" || cats.Attributes == null || cats.Attributes["key"] == null || cats.Attributes["value"] == null)
                            {
                                continue;
                            }
                            switch (cats.Attributes["key"].Value)
                            {
                            case "ConnectionStringCategory":
                                FlyConfiguration.ConnectionStringCategory = cats.Attributes["value"].Value;
                                break;

                            case "CategoryName":
                                FlyConfiguration.CategoryName = cats.Attributes["value"].Value;
                                break;
                            }
                        }
                    }

                    if (item.Name != "add" || item.Attributes == null || item.Attributes["key"] == null || item.Attributes["value"] == null)
                    {
                        continue;
                    }
                    switch (item.Attributes["key"].Value)
                    {
                    case "ConnectionSTAT":
                        DBStatExtra = false;
                        FlyConfiguration.ConnectionString = item.Attributes["value"].Value;
                        break;

                    case "ConnectionDDB":
                        DBStatExtra = true;
                        FlyConfiguration.ConnectionString = item.Attributes["value"].Value;
                        break;

                    case "MsConnectionString":
                        FlyConfiguration.ConnectionStringMR = item.Attributes["value"].Value;
                        break;

                    case "DsdFormat":
                        FlyConfiguration.DsdFormat = item.Attributes["value"].Value;
                        break;

                    case "ConceptSchemeFormat":
                        FlyConfiguration.ConceptSchemeFormat = item.Attributes["value"].Value;
                        break;

                    case "CategorySchemeFormat":
                        FlyConfiguration.CategorySchemeFormat = item.Attributes["value"].Value;
                        break;

                    case "CodelistFormat":
                        FlyConfiguration.CodelistFormat = item.Attributes["value"].Value;
                        break;

                    case "CategorisationFormat":
                        FlyConfiguration.CategorisationFormat = item.Attributes["value"].Value;
                        break;

                    case "CodelistWhitoutConstrain":
                        FlyConfiguration.CodelistWhitoutConstrain = bool.Parse(item.Attributes["value"].Value);
                        break;

                    case "ConceptObservationFlag":
                        try
                        {
                            if (!string.IsNullOrEmpty(item.Attributes["value"].Value))
                            {
                                FlyConfiguration.ConceptObservationAttribute = new AttributeConcept(item.Attributes["value"].Value, SdmxObjectNameDescription.GetNameDescriptions(item));
                                FlyConfiguration.ConceptObservationAttribute.AttributeAttachmentLevelType = (AttributeAttachmentLevel)Enum.Parse(typeof(AttributeAttachmentLevel), item.Attributes["attachmentLevel"].Value, true);
                                FlyConfiguration.ConceptObservationAttribute.AssignmentStatusType         = (AssignmentStatusTypeEnum)Enum.Parse(typeof(AssignmentStatusTypeEnum), item.Attributes["assignmentStatus"].Value, true);
                                FlyConfiguration.ConceptObservationAttribute.IsFlagAttribute = true;
                            }
                        }
                        catch (Exception)
                        {
                            FlyConfiguration.ConceptObservationAttribute = null;
                        }
                        break;
                    }
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(typeof(FlyController.FlyConfiguration), FlyExceptionObject.FlyExceptionTypeEnum.InitConfigError, ex);
            }
        }
        /// <summary>
        /// retrieves the codelist of Frequency dimension from the file "FrequencyCodelist.xml"
        /// </summary>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodeMutableObject> GetFrequencyCodelist()
        {
            List <ICodeMutableObject> FrequencyCodesObjects = new List <ICodeMutableObject>();

            try
            {
                XmlDocument configuration = new XmlDocument();
                configuration.Load(FlyConfiguration.FrequencyCodelistFile);
                foreach (XmlNode item in configuration.ChildNodes[0].ChildNodes)
                {
                    if (item.Name != "Code" && item.Attributes == null || item.Attributes["Code"] == null)
                    {
                        continue;
                    }
                    FrequencyCodesObjects.Add(CodelistItemBuilder.BuildCodeObjects(item.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(item), null));
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetFrequencyCodelist, ex);
            }

            return(FrequencyCodesObjects);
        }
        /// <summary>
        /// retrieves the Dataflows from database
        /// </summary>
        /// <returns>list of Dataflow in Dictionary structure (Code, Descriptions)</returns>
        public List <MSDataflow> GetDataflows()
        {
            try
            {
                List <MSDataflow> _Dataflows = new List <MSDataflow>();

                BuilderParameter bp = new BuilderParameter()
                {
                    TimeStamp = this.parsingObject.TimeStamp,
                };

                //EFFETTUO LA RICHIESTA AL DB
                FlyDotStat_implementation.Build.DWHAccess OtherDbAccess = new FlyDotStat_implementation.Build.DWHAccess(FlyConfiguration.ConnectionString);
                List <XmlNode> risposta = OtherDbAccess.Execute(DBOperationEnum.GetDataflows, bp.GetParameter());

                //PARSO LA RISPOSTA E CREO L'OGGETTO
                if (risposta.Count > 0)
                {
                    foreach (XmlNode dataset in risposta)
                    {
                        if (dataset.Attributes == null || dataset.Attributes["Code"] == null)
                        {
                            continue;
                        }

                        _Dataflows.Add(new MSDataflow()
                        {
                            IdDf      = Convert.ToInt32(dataset.Attributes["DfID"].Value),
                            DFCode    = dataset.Attributes["Code"].Value,
                            DFAgency  = FlyConfiguration.MainAgencyId,
                            DFVersion = FlyConfiguration.Version,
                            Descr     = SdmxObjectNameDescription.GetNameDescriptions(dataset)
                        });
                    }
                }

                List <MSDataflow> Ms_Dataflows = GetMSDataflows(bp);

                if (_Dataflows != null && _Dataflows.Count > 0)
                {//Scarto i Cancellati e quelli con Production MA
                    for (int i = _Dataflows.Count - 1; i >= 0; i--)
                    {
                        MSDataflow Ms_Dataflow = Ms_Dataflows.Find(dfNode => dfNode.IdDf.ToString() == _Dataflows[i].IdDf.ToString());
                        if (Ms_Dataflow == null)
                        {
                            _Dataflows.RemoveAt(i);
                            continue;
                        }

                        if (!string.IsNullOrEmpty(Ms_Dataflow.DFProduction))
                        {
                            if (Ms_Dataflow.DFProduction.Trim().ToUpper() == "MA")
                            {
                                _Dataflows.RemoveAt(i);
                                continue;
                            }
                            _Dataflows[i].DFProduction = Ms_Dataflow.DFProduction;
                        }
                        if (!string.IsNullOrEmpty(Ms_Dataflow.DFAgency))
                        {
                            _Dataflows[i].DFAgency = Ms_Dataflow.DFAgency;
                        }
                        if (!string.IsNullOrEmpty(Ms_Dataflow.DFVersion))
                        {
                            _Dataflows[i].DFVersion = Ms_Dataflow.DFVersion;
                        }

                        if (!string.IsNullOrEmpty(Ms_Dataflow.DsdCode))
                        {
                            _Dataflows[i].DsdCode = Ms_Dataflow.DsdCode;
                        }
                        if (!string.IsNullOrEmpty(Ms_Dataflow.DsdAgency))
                        {
                            _Dataflows[i].DsdAgency = Ms_Dataflow.DsdAgency;
                        }
                        if (!string.IsNullOrEmpty(Ms_Dataflow.DsdVersion))
                        {
                            _Dataflows[i].DsdVersion = Ms_Dataflow.DsdVersion;
                        }
                    }
                }
                foreach (var MaDf in Ms_Dataflows.FindAll(madf => madf.DFProduction.Trim().ToUpper() == "MA"))
                {//Aggiungo quelli che verranno elaborati dal MA
                    _Dataflows.Add(new MSDataflow()
                    {
                        IdDf        = MaDf.IdDf,
                        DFCode      = MaDf.DFCode,
                        DFAgency    = MaDf.DFAgency,
                        DFVersion   = MaDf.DFVersion,
                        DsdCode     = MaDf.DsdCode,
                        DsdAgency   = MaDf.DsdAgency,
                        DsdVersion  = MaDf.DsdVersion,
                        DatasetList = MaDf.DatasetList,
                        Descr       = MaDf.Descr
                    });
                }

                return(_Dataflows);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateDataflowBuilder, ex);
            }
        }
        /// <summary>
        /// Get Dataflow from MS Database
        /// </summary>
        /// <param name="bp">Parameter <see cref="BuilderParameter"/></param>
        /// <returns>list of dataflow in <see cref="MSDataflow"/> structure</returns>
        public List <MSDataflow> GetMSDataflows(BuilderParameter bp)
        {
            try
            {
                List <MSDataflow> MSDataflows = new List <MSDataflow>();

                this.DbAccess = new DWHAccess(FlyConfiguration.ConnectionString);
                List <XmlNode> Ms_Dataflows = this.DbAccess.Execute(DBOperationEnum.MSGetDataflows, bp.GetParameter());

                foreach (var Ms_Dataflow in Ms_Dataflows)
                {
                    MSDataflow df = new MSDataflow();

                    if (Ms_Dataflow.Attributes["id"] != null)
                    {
                        df.IdDf = Convert.ToInt32(Ms_Dataflow.Attributes["id"].Value);
                    }

                    if (Ms_Dataflow.Attributes["Production"] != null)
                    {
                        df.DFProduction = Ms_Dataflow.Attributes["Production"].Value;
                    }
                    if (Ms_Dataflow.Attributes["Code"] != null)
                    {
                        df.DFCode = Ms_Dataflow.Attributes["Code"].Value;
                    }
                    if (Ms_Dataflow.Attributes["AgencyId"] != null)
                    {
                        df.DFAgency = Ms_Dataflow.Attributes["AgencyId"].Value;
                    }
                    if (Ms_Dataflow.Attributes["Version"] != null)
                    {
                        df.DFVersion = Ms_Dataflow.Attributes["Version"].Value;
                    }

                    if (Ms_Dataflow.Attributes["DSDCode"] != null)
                    {
                        df.DsdCode = Ms_Dataflow.Attributes["DSDCode"].Value;
                    }
                    if (Ms_Dataflow.Attributes["DSDAgencyId"] != null)
                    {
                        df.DsdAgency = Ms_Dataflow.Attributes["DSDAgencyId"].Value;
                    }
                    if (Ms_Dataflow.Attributes["DSDVersion"] != null)
                    {
                        df.DsdVersion = Ms_Dataflow.Attributes["DSDVersion"].Value;
                    }

                    XmlNode datasets = Ms_Dataflow.ChildNodes.Cast <XmlNode>().FirstOrDefault(n => n.LocalName.Trim().ToUpper() == "DATASETLIST");
                    if (datasets != null && datasets.ChildNodes != null && datasets.ChildNodes.Count > 0)
                    {
                        df.DatasetList = new List <string>();
                        foreach (XmlNode dataset in datasets.ChildNodes)
                        {
                            if (dataset.LocalName == "Dataset" && dataset.Attributes["Code"] != null)
                            {
                                df.DatasetList.Add(dataset.Attributes["Code"].Value);
                            }
                        }
                    }
                    df.Descr = SdmxObjectNameDescription.GetNameDescriptions(Ms_Dataflow);

                    MSDataflows.Add(df);
                }
                return(MSDataflows);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateDataflowBuilder, ex);
            }
        }
        /// <summary>
        /// retrieves all Concept Dimension from database
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <param name="Names">return Dataflow NameDescription</param>
        /// <returns>list of Dimension</returns>
        public List <IDimensionConcept> GetDimensionConceptObjects(string DataflowCode, out List <SdmxObjectNameDescription> Names)
        {
            try
            {
                Names = new List <SdmxObjectNameDescription>();
                List <IDimensionConcept> dimConcepts = new List <IDimensionConcept>();

                List <IParameterValue> parametri = new List <IParameterValue>()
                {
                    new ParameterValue()
                    {
                        Item = "Code", Value = DataflowCode
                    }
                };
                if (!string.IsNullOrEmpty(this.parsingObject.TimeStamp))
                {
                    parametri.Add(new ParameterValue()
                    {
                        Item = "TimeStamp", Value = this.parsingObject.TimeStamp, SqlType = SqlDbType.DateTime
                    });
                }

                //EFFETTUO LA RICHIESTA AL DB
                List <XmlNode> risposta = this.DbAccess.Execute(DBOperationEnum.GetDimensions, parametri);

                //PARSO LA RISPOSTA E CREO L'OGGETTO
                if (risposta.Count == 1 && risposta[0].Name == "DataSet")
                {
                    Names = SdmxObjectNameDescription.GetNameDescriptions(risposta[0]);
                    foreach (XmlNode Dimension in risposta[0].ChildNodes)
                    {
                        if (Dimension.Attributes == null || Dimension.Attributes["Code"] == null)
                        {
                            continue;
                        }

                        IDimensionConcept newconcept = new DimensionConcept(Dimension.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(Dimension));
                        if (Dimension.Attributes["IsTimeSeriesDim"] != null && Dimension.Attributes["IsTimeSeriesDim"].Value.Trim().ToLower() == "true")
                        {
                            newconcept.DimensionType = DimensionTypeEnum.Time;
                        }
                        dimConcepts.Add(newconcept);
                    }
                }

                if (!dimConcepts.Exists(co => co.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)co).DimensionType == DimensionTypeEnum.Frequency))
                {
                    IDimensionConcept Freq = new DimensionConcept("FREQ", GetFakeFreqNames())
                    {
                        IsFakeFrequency = true
                    };
                    dimConcepts.Add(Freq);
                }

                return(dimConcepts);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetDimensionConceptObjects, ex);
            }
        }
        private List <ICodeMutableObject> AttributeCodelistFromFile(IAttributeConcept attribute)
        {
            List <ICodeMutableObject> AttributeCodesObjects = new List <ICodeMutableObject>();

            try
            {
                XmlDocument configuration = new XmlDocument();
                configuration.Load(FlyConfiguration.AttributeFile);
                foreach (XmlNode item in configuration.ChildNodes[0].ChildNodes)
                {
                    if (item.Name != "Attribute" && item.Attributes == null || item.Attributes["Code"] == null)
                    {
                        continue;
                    }
                    if (item.Attributes["Code"].Value == attribute.ConceptObjectCode)
                    {
                        foreach (XmlNode nodoCodelistAttr in CommonFunction.FindSubNodo(item, "Codelist").ChildNodes)
                        {
                            if (nodoCodelistAttr.Name == "Code" && nodoCodelistAttr.Attributes != null && nodoCodelistAttr.Attributes["value"] != null)
                            {
                                AttributeCodesObjects.Add(CodelistItemBuilder.BuildCodeObjects(nodoCodelistAttr.Attributes["value"].Value, SdmxObjectNameDescription.GetNameDescriptions(nodoCodelistAttr), null));
                            }
                        }
                        break;
                    }
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetAttributeError, ex);
            }

            return(AttributeCodesObjects);
        }
        /// <summary>
        /// retrieves the codelist of FlagDimension (OBS_STATUS) from database
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <param name="flag">Instance of Attribute "AttributeConcept"</param>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodeMutableObject> GetFlagCodelist(string DataflowCode, IAttributeConcept flag)
        {
            try
            {
                if (!this.DbAccess.CheckExistStoreProcedure(DBOperationEnum.GetFlags))
                {
                    return(new List <ICodeMutableObject>());
                }
                List <ICodeMutableObject> _CodesObjects = new List <ICodeMutableObject>();

                //prima capisco se non รจ un attributo o un flag
                List <IParameterValue> parametri = new List <IParameterValue>()
                {
                    new ParameterValue()
                    {
                        Item = "Code", Value = DataflowCode
                    },
                };
                if (!string.IsNullOrEmpty(this.parsingObject.TimeStamp))
                {
                    parametri.Add(new ParameterValue()
                    {
                        Item = "TimeStamp", Value = this.parsingObject.TimeStamp, SqlType = SqlDbType.DateTime
                    });
                }

                //EFFETTUO LA RICHIESTA AL DB
                List <XmlNode> risposta = this.DbAccess.Execute(DBOperationEnum.GetFlags, parametri);


                ////PARSO LA RISPOSTA E CREO L'OGGETTO
                if (risposta.Count == 1 && risposta[0].Name == "DataSet" && risposta[0].ChildNodes.Count > 0)
                {
                    foreach (XmlNode Member in risposta[0])
                    {
                        if (Member.Name != "Flag" || Member.Attributes == null || Member.Attributes["Code"] == null)
                        {
                            continue;
                        }
                        string code = Member.Attributes["Code"].Value;
                        _CodesObjects.Add(CodelistItemBuilder.BuildCodeObjects(Member.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(Member), null));
                    }
                }
                return(_CodesObjects);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateICodeMutableObject, ex);
            }
        }
Example #14
0
        /// <summary>
        /// Get Attribute Concept from file AttributeConcepts.xml
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <returns>list of Attribute</returns>
        public List <IAttributeConcept> GetAttribute(string DataflowCode)
        {
            List <IAttributeConcept> Attributes = new List <IAttributeConcept>();

            try
            {
                List <IParameterValue> parametri = new List <IParameterValue>()
                {
                    new ParameterValue()
                    {
                        Item = "Code", Value = DataflowCode
                    }
                };
                if (!string.IsNullOrEmpty(this.parsingObject.TimeStamp))
                {
                    parametri.Add(new ParameterValue()
                    {
                        Item = "TimeStamp", Value = this.parsingObject.TimeStamp, SqlType = SqlDbType.DateTime
                    });
                }

                //EFFETTUO LA RICHIESTA AL DB
                List <XmlNode> risposta = this.DbAccess.Execute(DBOperationEnum.GetAttributes, parametri);

                //PARSO LA RISPOSTA E CREO L'OGGETTO
                if (risposta.Count == 1 && risposta[0].Name == "DataSet")
                {
                    foreach (XmlNode Attribute in risposta[0].ChildNodes)
                    {
                        if (Attribute.Attributes == null || Attribute.Attributes["Code"] == null)
                        {
                            continue;
                        }

                        IAttributeConcept newconcept = new AttributeConcept(Attribute.Attributes["Code"].Value, SdmxObjectNameDescription.GetNameDescriptions(Attribute));
                        if (Attribute.Attributes["CodelistTable"] != null)
                        {
                            newconcept.CodelistCode = Attribute.Attributes["CodelistTable"].Value;
                        }
                        if (Attribute.Attributes["assignmentStatus"] != null)
                        {
                            newconcept.AssignmentStatusType = (AssignmentStatusTypeEnum)Enum.Parse(typeof(AssignmentStatusTypeEnum), Attribute.Attributes["assignmentStatus"].Value, true);
                        }
                        if (Attribute.Attributes["attachmentLevel"] != null)
                        {
                            newconcept.AttributeAttachmentLevelType = (AttributeAttachmentLevel)Enum.Parse(typeof(AttributeAttachmentLevel), Attribute.Attributes["attachmentLevel"].Value, true);
                        }
                        Attributes.Add(newconcept);
                    }
                }
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetAttributeError, ex);
            }

            return(Attributes);
        }