Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="operation"></param>
        private ISdmxObjects WSExecute(ArtefactIdentity artIdentity, WSConstants.wsOperation operation, bool stub, bool withLike)
        {
            XmlDocument xDomOutput = new XmlDocument();

            WSUtils wsUtils = new WSUtils();

            ISdmxObjects SdmxObject, FilteredSdmxObject;

            FilteredSdmxObject = new SdmxObjectsImpl();

            try
            {
                // File di appoggio per la creazione del xDom
                string OutputFilePath = HttpContext.Current.Server.MapPath("OutputFiles" + "\\" + HttpContext.Current.Session.SessionID + ".xml");

                WsConfigurationSettings wsSettings = null;

                if (operation == WSConstants.wsOperation.GetDataStructureWithRef)
                {
                    wsSettings = wsUtils.GetSettings(WSConstants.wsOperation.GetDataStructure.ToString());
                }
                else
                {
                    wsSettings = wsUtils.GetSettings(FindException(operation));
                }

                XmlDocument xDom = new XmlDocument();

                // Carico il template
                xDom.Load(getTemplate(operation));

                // Imposto ID,Agency e Version
                if (!withLike && artIdentity != null)
                    SetKey(ref xDom, artIdentity);
                else
                    RemoveFilter(xDom);

                if (stub)
                    SetStub(ref xDom);

                FlyCallWS.Streaming.CallWS objWS = new FlyCallWS.Streaming.CallWS(OutputFilePath, WSConstants.MaxOutputFileLength);

                xDomOutput.InnerXml = objWS.SendSOAPQuery(xDom, wsSettings);

                File.Delete(OutputFilePath);

                SdmxObject = LoadSDMXObject(xDomOutput);

                if (withLike && !IsNullOrEmptyArtefactIdentity(artIdentity))
                    switch (operation)
                    {
                        case WSConstants.wsOperation.GetAgencyScheme:
                            var filteredAgency = SdmxObject.AgenciesSchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.IAgencyScheme ag in filteredAgency)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && ag.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddAgencyScheme(ag);
                            }
                            break;
                        case WSConstants.wsOperation.GetCategorisation:
                            var filteredCat = SdmxObject.Categorisations.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.CategoryScheme.ICategorisationObject cat in filteredCat)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && cat.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddCategorisation(cat);
                            }
                            break;
                        case WSConstants.wsOperation.GetCategoryScheme:
                            var filteredCS = SdmxObject.CategorySchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.CategoryScheme.ICategorySchemeObject cat in filteredCS)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && cat.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddCategoryScheme(cat);
                            }
                            break;
                        case WSConstants.wsOperation.GetCodelist:
                            var filteredCL = SdmxObject.Codelists.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICodelistObject cl in filteredCL)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && cl.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddCodelist(cl);
                            }
                            break;
                        case WSConstants.wsOperation.GetConceptScheme:
                            var filteredCoS = SdmxObject.ConceptSchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.ConceptScheme.IConceptSchemeObject x in filteredCoS)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddConceptScheme(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetDataflow:
                            var filteredDF = SdmxObject.Dataflows.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataflowObject x in filteredDF)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddDataflow(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetStructureSet:
                            var filteredSS = SdmxObject.StructureSets.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Mapping.IStructureSetObject x in filteredSS)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddStructureSet(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetContentConstraint:
                            var filteredCC = SdmxObject.ContentConstraintObjects.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Registry.IContentConstraintObject x in filteredCC)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddContentConstraintObject(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetOrganisationUnitScheme:
                            var filteredOU = SdmxObject.OrganisationUnitSchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.IOrganisationUnitSchemeObject x in filteredOU)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddOrganisationUnitScheme(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetDataConsumerScheme:
                            var filteredDC = SdmxObject.DataConsumerSchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.IDataConsumerScheme x in filteredDC)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddDataConsumerScheme(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetDataProviderScheme:
                            var filteredDP = SdmxObject.DataProviderSchemes.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.IDataProviderScheme x in filteredDP)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddDataProviderScheme(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetDataStructureWithRef:
                        case WSConstants.wsOperation.GetDataStructure:
                            var filteredDSD = SdmxObject.DataStructures.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataStructureObject x in filteredDSD)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddDataStructure(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetHierarchicalCodelist:
                            var filteredHcl = SdmxObject.HierarchicalCodelists.Where(i => i.Id.ToUpper().Contains(artIdentity.ID.ToUpper()) && i.AgencyId.ToUpper().Contains(artIdentity.Agency.ToUpper()) && i.Version.ToUpper().Contains(artIdentity.Version.ToUpper()));
                            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.IHierarchicalCodelistObject x in filteredHcl)
                            {
                                if ((artIdentity.IsFinal == null || !(bool)artIdentity.IsFinal) || (bool)artIdentity.IsFinal && x.IsFinal.IsTrue)
                                    FilteredSdmxObject.AddHierarchicalCodelist(x);
                            }
                            break;
                        case WSConstants.wsOperation.GetStructures:
                            break;
                        default:
                            FilteredSdmxObject = SdmxObject;
                            break;
                    }
                else
                    FilteredSdmxObject = SdmxObject;

                return FilteredSdmxObject;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        private string FindException(WSConstants.wsOperation operation)
        {
            string sOperation = string.Empty;

            switch (operation)
            {
                case WSConstants.wsOperation.GetAgencyScheme:
                case WSConstants.wsOperation.GetDataConsumerScheme:
                case WSConstants.wsOperation.GetDataProviderScheme:
                case WSConstants.wsOperation.GetOrganisationUnitScheme:
                    sOperation = "GetOrganisationScheme";
                    break;
                case WSConstants.wsOperation.GetContentConstraint:
                    sOperation = "GetConstraint";
                    break;
                default:
                    return operation.ToString();
            }
            return sOperation;
        }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="operation"></param>
 /// <returns></returns>
 private string getTemplate(WSConstants.wsOperation operation)
 {
     return HttpContext.Current.Server.MapPath("SdmxQueryTemplate") + "\\" + operation.ToString().Replace("Get", "") + ".xml";
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        private string getTemplate(WSConstants.wsOperation operation)
        {
            string fileName;

            switch (operation)
            {
                case WSConstants.wsOperation.GetCategorySchemeWithParents:
                    fileName = "CategorySchemeWithParents.xml";
                    break;
                default:
                    fileName = operation.ToString().Replace("Get", "") + ".xml";
                    break;
            }

            return HttpContext.Current.Server.MapPath("SdmxQueryTemplate") + "\\" + fileName;
        }