コード例 #1
0
    public string GetDataForGenerateApiCall(string requestParam)
    {
        string RetVal;
        string[] Params;
        int DBNId;
        string SelectedFunction;
        string Id;
        string AgencyId;
        string Version;
        string UserIdAndType;
        string UploadedHeaderFileWPath, UploadedHeaderFolderPath;
        Registry.RegistryService Service;
        SDMXObjectModel.Message.StructureHeaderType Header;
        SDMXApi_2_0.Message.HeaderType Header_2_0;
        XmlDocument Query;
        XmlElement Element;
        XmlDocument Response;
        XmlDocument UploadedHeaderXml;

        string agencyId;
        List<bool> isSOAPMailIds;
        List<string> notificationMailIds;
        List<bool> isSOAPHTTPs;
        List<string> notificationHTTPs;
        DateTime startDate;
        DateTime endDate;
        string eventSelector;
        Dictionary<string, string> dictCategories;
        string mfdId;
        string CategoriesGIDAndSchemeIds;
        string CategoryGID;
        string CategorySchemeId;
        string DFDOrMFDId;
        string WebServiceURL;
        bool IsREST;
        string WADLURL;
        bool IsSOAP;
        string WSDLURL;
        string FileURL;
        string RequestURL;
        string ResponseURL;
        string preferredLangNid;
        string[] DBDetails;
        string checkIfSDMXDB;
        RetVal = string.Empty;
        Params = null;
        DBNId = -1;
        SelectedFunction = string.Empty;
        Id = string.Empty;
        AgencyId = string.Empty;
        Version = string.Empty;
        UserIdAndType = string.Empty;
        Service = new Registry.RegistryService();

        Service.Url = HttpContext.Current.Request.Url.OriginalString.Substring(0, HttpContext.Current.Request.Url.OriginalString.IndexOf("libraries")) + Constants.FolderName.SDMX.RegistryServicePath;
        Query = new XmlDocument();
        Response = new XmlDocument();
        Element = null;

        agencyId = string.Empty;
        isSOAPMailIds = new List<bool>();
        notificationMailIds = new List<string>();
        isSOAPHTTPs = new List<bool>();
        notificationHTTPs = new List<string>();
        startDate = new DateTime();
        endDate = new DateTime();
        eventSelector = string.Empty;
        dictCategories = new Dictionary<string, string>();
        mfdId = string.Empty;
        CategoriesGIDAndSchemeIds = string.Empty;
        CategoryGID = string.Empty;
        CategorySchemeId = string.Empty;

        DFDOrMFDId = string.Empty;
        WebServiceURL = string.Empty;
        IsREST = false;
        WADLURL = string.Empty;
        IsSOAP = false;
        WSDLURL = string.Empty;
        FileURL = string.Empty;
        RequestURL = string.Empty;
        ResponseURL = string.Empty;
        preferredLangNid = string.Empty;
        DBDetails = null;
        checkIfSDMXDB = string.Empty;
        Header = new SDMXObjectModel.Message.StructureHeaderType();
        Header_2_0 = new SDMXApi_2_0.Message.HeaderType();
        UploadedHeaderXml = new XmlDocument();
        UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            DBNId = Convert.ToInt32(Params[0].ToString().Trim());
            SelectedFunction = Params[1].ToString().Trim();

            DBDetails = Global.GetDbConnectionDetails(Convert.ToString(DBNId));
           checkIfSDMXDB = DBDetails[4].ToString();

            UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + DBNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            if (File.Exists(UploadedHeaderFileWPath))
            {
                UploadedHeaderXml.Load(UploadedHeaderFileWPath);
                if (checkIfSDMXDB == "true")
                {
                    SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType();
                    UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml);
                    Header_2_0 = UploadedDSDStructure.Header;
                }
                else
                {
                    SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
                    UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                    Header = UploadedDSDStructure.Header;
                }

            }

            if ((SelectedFunction == "QuerySubscription") || (SelectedFunction == "QueryRegistration"))
            {
                UserIdAndType = Params[2].ToString().Trim();
            }
            else if (SelectedFunction == "SubmitSubscription")
            {
                UserIdAndType = Params[2].ToString().Trim();

                if (Params[3].ToString().Trim() == "0")
                {
                    isSOAPMailIds = new List<bool>();
                    isSOAPMailIds.Add(false);
                    isSOAPHTTPs = new List<bool>();
                    isSOAPHTTPs.Add(false);
                }
                else
                {
                    isSOAPMailIds = new List<bool>();
                    isSOAPMailIds.Add(true);
                    isSOAPHTTPs = new List<bool>();
                    isSOAPHTTPs.Add(true);
                }
                notificationMailIds = new List<string>();
                notificationMailIds.Add(Params[4].ToString().Trim());
                notificationHTTPs = new List<string>();
                notificationHTTPs.Add(Params[5].ToString().Trim());
                startDate = DateTime.ParseExact(Params[6].ToString().Trim(), "dd-MM-yyyy", null);
                endDate = DateTime.ParseExact(Params[7].ToString().Trim(), "dd-MM-yyyy", null);
                eventSelector = Params[8].ToString().Trim();
                CategoriesGIDAndSchemeIds = Params[9].ToString().Trim();
                dictCategories = new Dictionary<string, string>();
                if (eventSelector == "Data Registration")
                {
                    foreach (string CategoryGIDAndSchemeId in Global.SplitString(CategoriesGIDAndSchemeIds, ","))
                    {
                        CategoryGID = CategoryGIDAndSchemeId.Split('|')[0];
                        CategorySchemeId = CategoryGIDAndSchemeId.Split('|')[1];
                        dictCategories.Add(CategoryGID, CategorySchemeId);
                    }
                }
                agencyId = Global.Get_AgencyId_From_DFD(DBNId.ToString());
                mfdId = Params[10].ToString().Trim();
                preferredLangNid = Params[11].ToString().Trim();
            }
            else if (SelectedFunction == "SubmitRegistration")
            {
                UserIdAndType = Params[2].ToString().Trim();
                agencyId = Global.Get_AgencyId_From_DFD(DBNId.ToString());
                DFDOrMFDId = Params[3].ToString().Trim();
                FileURL = Params[4].ToString().Trim();
            }
            else
            {
                Id = Params[2].ToString().Trim();
                AgencyId = Params[3].ToString().Trim();
                Version = Params[4].ToString().Trim();
            }

            Service.Url += "?p=" + DBNId.ToString();
            RetVal = Service.Url;
            RetVal += Constants.Delimiters.ParamDelimiter + SelectedFunction;
            switch (SelectedFunction)
            {
                case "GetDataflow":
                    Query = GetQueryXmlDocumentOnTypeBasis(0, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetDataflow(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetMetadataflow":
                    Query = GetQueryXmlDocumentOnTypeBasis(1, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetMetadataflow(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetDataStructure":
                    Query = GetQueryXmlDocumentOnTypeBasis(2, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetDataStructure(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetMetadataStructure":
                    Query = GetQueryXmlDocumentOnTypeBasis(3, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetMetadataStructure(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetCategoryScheme":
                    Query = GetQueryXmlDocumentOnTypeBasis(4, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetCategoryScheme(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetCategorisation":
                    Query = GetQueryXmlDocumentOnTypeBasis(5, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetCategorisation(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetConceptScheme":
                    Query = GetQueryXmlDocumentOnTypeBasis(6, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetConceptScheme(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetCodelist":
                    Query = GetQueryXmlDocumentOnTypeBasis(7, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetCodelist(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetOrganisationScheme":
                    Query = GetQueryXmlDocumentOnTypeBasis(8, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetOrganisationScheme(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetProvisionAgreement":
                    Query = GetQueryXmlDocumentOnTypeBasis(9, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetProvisionAgreement(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetConstraint":
                    Query = GetQueryXmlDocumentOnTypeBasis(10, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetConstraint(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetStructures":
                    Query = GetQueryXmlDocumentOnTypeBasis(11, Id, AgencyId, Version, string.Empty);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.GetStructures(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "QuerySubscription":
                    Query = GetQueryXmlDocumentOnTypeBasis(12, Id, AgencyId, Version, UserIdAndType);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.QuerySubscription(ref Element);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "QueryRegistration":
                    Query = GetQueryXmlDocumentOnTypeBasis(13, Id, AgencyId, Version, UserIdAndType);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.QueryRegistration(ref Element,preferredLangNid);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "SubmitSubscription":
                    Query = GetQueryXmlDocumentForSubmitSubscription(ActionType.Append, UserIdAndType, agencyId, isSOAPMailIds, notificationMailIds, isSOAPHTTPs, notificationHTTPs, startDate, endDate, eventSelector, dictCategories, mfdId, string.Empty,Header);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.SubmitSubscription(ref Element, preferredLangNid);//language code
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "SubmitRegistration":
                    Query = GetQueryXmlDocumentForSubmitRegistration(UserIdAndType, agencyId, DFDOrMFDId, WebServiceURL, IsREST, WADLURL, IsSOAP, WSDLURL, FileURL);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Query);
                    Element = Query.DocumentElement;
                    Service.SubmitRegistration(ref Element, string.Empty, preferredLangNid);
                    Response.LoadXml(Element.OuterXml);
                    RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
                    RequestURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Query));
                    ResponseURL = SaveContentTemporarilyandDeleteOtherFiles(this.Get_Formatted_XML(Response));
                    RetVal += Constants.Delimiters.ParamDelimiter + RequestURL;
                    RetVal += Constants.Delimiters.ParamDelimiter + ResponseURL;
                    break;
                case "GetGenericData":

                    break;
                case "GetGenericTimeSeriesData":

                    break;
                case "GetStructureSpecificData":

                    break;
                case "GetStructureSpecificTimeSeriesData":

                    break;
                case "GetGenericMetadata":

                    break;
                case "GetStructureSpecificMetadata":

                    break;
                case "SubmitStructure":

                    break;
                case "GetReportingTaxonomy":

                    break;
                case "GetStructureSet":

                    break;
                case "GetProcess":

                    break;
                case "GetHierarchicalCodelist":

                    break;
                case "GetDataSchema":

                    break;
                case "GetMetadataSchema":

                    break;
                default:
                    break;
            }
        }
        catch (SoapException SOAPex)
        {
            Response.LoadXml(SOAPex.Detail.InnerText);
            RetVal += Constants.Delimiters.ParamDelimiter + this.Get_Formatted_XML(Response);
            Global.CreateExceptionString(SOAPex, null);
        }
        catch (Exception ex)
        {
            RetVal += "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            Global.CreateExceptionString(ex, null);
        }
        finally
        {
        }

        return RetVal;
    }
コード例 #2
0
    private bool UpdateNonMAForUploadedDSDWithHeader(string DbNId, string UserNId, string DataBaseNId)
    {
        bool RetVal;
        SDMXObjectModel.Message.RegistryInterfaceType Registrations;
        SDMXApi_2_0.Message.GenericMetadataType MetadataFiles;
        //SDMXObjectModel.Message.GenericDataType DataFiles;

        SDMXApi_2_0.Message.CompactDataType DataFiles;
        SDMXObjectModel.Message.RegistryInterfaceType Subscriptions;
        RetVal = true;
        string UploadedHeaderFileWPath = string.Empty;
        string UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        string UploadedDSDHeaderFilePath = string.Empty;
        string UploadedHeaderName = string.Empty;
        string SubscriptionsFolderPath = string.Empty;
        string MetadataFolderPath = string.Empty;
        string RegistrationsFolderPath = string.Empty;
        string SDMXMLFolderPath = string.Empty;
        string MappingFolderPath = string.Empty;
        XmlDocument UploadedHeaderXml = new XmlDocument();
        XmlDocument UploadedHeaderXmlFor2_0 = new XmlDocument();
        FileInfo[] Files = null;

        DirectoryInfo dirRegs = null;
        DirectoryInfo dirMetadata = null;
        DirectoryInfo dirSubscriptions = null;
        DirectoryInfo dirSDMXML = null;

        try
        {
            UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + DataBaseNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            UploadedDSDHeaderFilePath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            dirRegs = new DirectoryInfo(UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Registrations");
            dirMetadata = new DirectoryInfo(UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Metadata");
            dirSDMXML = new DirectoryInfo(UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "SDMX-ML");
            dirSubscriptions = new DirectoryInfo(UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Subscriptions");
            MappingFolderPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + "Mappings";
            UploadedHeaderXml.Load(UploadedHeaderFileWPath);
            UploadedHeaderXmlFor2_0.Load(UploadedDSDHeaderFilePath);
            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
            SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();

            SDMXApi_2_0.Message.StructureType UploadedDSDStruct20 = new SDMXApi_2_0.Message.StructureType();
            SDMXApi_2_0.Message.HeaderType DSDHeader = new SDMXApi_2_0.Message.HeaderType();

            UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
            Header = UploadedDSDStructure.Header;
            UploadedDSDStruct20 = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXmlFor2_0);
            DSDHeader = UploadedDSDStruct20.Header;

            foreach (DirectoryInfo dirReg in dirRegs.GetDirectories())
            {
                Files = dirReg.GetFiles();
                foreach (FileInfo regfile in Files)
                {
                    Registrations = new SDMXObjectModel.Message.RegistryInterfaceType();

                    Registrations = (SDMXObjectModel.Message.RegistryInterfaceType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Registrations" + "\\" + dirReg.Name + "\\" + regfile.ToString());

                    Registrations.Header.ID = Header.ID.ToString();
                    Registrations.Header.Prepared = Header.Prepared.ToString();
                    foreach (PartyType receiver in Header.Receiver)
                    {
                        Registrations.Header.Receiver.Contact = receiver.Contact;
                        Registrations.Header.Receiver.id = receiver.id;
                        Registrations.Header.Receiver.Name = receiver.Name;
                    }
                    Registrations.Header.Sender = (SDMXObjectModel.Message.SenderType)Header.Sender;
                    Registrations.Header.Test = Header.Test;

                    Registrations.Footer = null;
                    SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), Registrations, UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Registrations" + "\\" + dirReg.Name + "\\" + regfile.ToString());
                }
            }

            foreach (DirectoryInfo dirMeta in dirMetadata.GetDirectories())
            {
                Files = null;
                Files = dirMeta.GetFiles();
                foreach (FileInfo metafile in Files)
                {
                    MetadataFiles = new SDMXApi_2_0.Message.GenericMetadataType();

                    MetadataFiles = (SDMXApi_2_0.Message.GenericMetadataType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.GenericMetadataType), UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Metadata" + "\\" + dirMeta.Name + "\\" + metafile.ToString());

                    MetadataFiles.Header.ID = DSDHeader.ID.ToString();
                    MetadataFiles.Header.Prepared = DSDHeader.Prepared.ToString();
                    MetadataFiles.Header.Receiver = DSDHeader.Receiver;
                    MetadataFiles.Header.Sender = DSDHeader.Sender;
                    MetadataFiles.Header.Test = DSDHeader.Test;

                    SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.GenericMetadataType), MetadataFiles, UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Metadata" + "\\" + dirMeta.Name + "\\" + metafile.ToString());
                }
            }

            foreach (DirectoryInfo dirSDMX in dirSDMXML.GetDirectories())
            {
                Files = null;
                Files = dirSDMX.GetFiles();
                foreach (FileInfo sdmxMlFile in Files)
                {
                    DataFiles = new SDMXApi_2_0.Message.CompactDataType();

                    DataFiles = (SDMXApi_2_0.Message.CompactDataType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.CompactDataType), UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "SDMX-ML" + "\\" + dirSDMX.Name + "\\" + sdmxMlFile.ToString());

                    DataFiles.Header.ID = DSDHeader.ID.ToString();
                    DataFiles.Header.Prepared = Header.Prepared.ToString();
                    DataFiles.Header.Receiver = DSDHeader.Receiver;
                    DataFiles.Header.Sender = DSDHeader.Sender;
                    DataFiles.Header.Test = DSDHeader.Test;

                    SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.CompactDataType), DataFiles, UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "SDMX-ML" + "\\" + dirSDMX.Name + "\\" + sdmxMlFile.ToString());
                }
            }

            foreach (DirectoryInfo dirSubs in dirSubscriptions.GetDirectories())
            {
                Files = null;
                Files = dirSubs.GetFiles();
                foreach (FileInfo subsFile in Files)
                {
                    Subscriptions = new SDMXObjectModel.Message.RegistryInterfaceType();

                    Subscriptions = (SDMXObjectModel.Message.RegistryInterfaceType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Subscriptions" + "\\" + dirSubs.Name + "\\" + subsFile.ToString());

                    Subscriptions.Header.ID = Header.ID.ToString();
                    Subscriptions.Header.Prepared = Header.Prepared.ToString();
                    foreach (PartyType receiver in Header.Receiver)
                    {
                        Subscriptions.Header.Receiver.Contact = receiver.Contact;
                        Subscriptions.Header.Receiver.id = receiver.id;
                        Subscriptions.Header.Receiver.Name = receiver.Name;
                    }
                    Subscriptions.Header.Sender = (SDMXObjectModel.Message.SenderType)Header.Sender;
                    Subscriptions.Header.Test = Header.Test;

                    Subscriptions.Footer = null;
                    SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), Subscriptions, UploadedHeaderFolderPath + "\\" + DbNId + "\\" + "sdmx" + "\\" + "Subscriptions" + "\\" + dirSubs.Name + "\\" + subsFile.ToString());
                }
            }

        }
        catch (Exception ex)
        {
            RetVal = false;
            Global.CreateExceptionString(ex, null);
            //Global.WriteErrorsInLog("Creating CategoryScheme For Uploaded DSD From Admin");
            //Global.WriteErrorsInLog(ex.StackTrace);
            //Global.WriteErrorsInLog(ex.Message);
        }
        finally
        {

        }

        return RetVal;
    }
コード例 #3
0
    public bool AdminUpdateArtifactsWithHeaderForDatabase(string requestParam)
    {
        bool RetVal = false;
        string DbNId = string.Empty;
        string[] Params;
        string DBConnectionsFile = string.Empty;
        string DBFile = string.Empty;
        XmlDocument UploadedHeaderXml = new XmlDocument();
        XmlDocument XmlDoc;
        XmlNodeList XmlNodes;
        string UploadedHeaderFileWPath = string.Empty;
        string UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        string UploadedHeaderName = string.Empty;
        string UserNId = string.Empty;

        string DatabaseNIdfor2_1 = string.Empty;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            DbNId = Params[0];
            UserNId = Params[1];
            UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;

            DBFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]);
            XmlDoc = new XmlDocument();
            XmlDoc.Load(DBFile);
            XmlNodes = XmlDoc.GetElementsByTagName("db");
            for (int i = 0; i < XmlNodes.Count; i++)
            {
                if ((XmlNodes[i].Attributes["sdmxdb"].Value == "false") && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id] != null))
                {
                    DatabaseNIdfor2_1 = XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value;
                }
            }

            UploadedHeaderXml.Load(UploadedHeaderFileWPath);

            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
            SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
            UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
            Header = UploadedDSDStructure.Header;
            UploadedHeaderFolderPath = UploadedHeaderFolderPath + "/" + DbNId;
            RetVal = UpdateCompleteWithHeaderForDB(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx");
            RetVal = UpdateCodelistsForDBWithHeader(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx" + "/" + "Codelists");
            RetVal = UpdateCategorySchemeForDBWithHeader(DbNId, UserNId, DatabaseNIdfor2_1);
            RetVal = UpdateArtefactsForDBWithHeader(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx", DatabaseNIdfor2_1);
            RetVal = UpdateNonMAForUploadedDBWithHeader(DbNId, UserNId, DatabaseNIdfor2_1);

        }
        catch (Exception ex)
        {
            RetVal = false;
            Global.CreateExceptionString(ex, null);
        }
        finally
        {

        }

        return RetVal;
    }
コード例 #4
0
    private SDMXObjectModel.Message.StructureHeaderType Get_Appropriate_Header_Of_StructureHeaderType()
    {
        SDMXObjectModel.Message.StructureHeaderType RetVal;
        SenderType Sender;
        PartyType Receiver;

        Sender = new SenderType(DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderId, DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderName, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(DevInfo.Lib.DI_LibSDMX.Constants.Header.Sender, DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderDepartment, DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderRole, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage));
        Sender.Contact[0].Items = new string[] { DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderTelephone, DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderEmail, DevInfo.Lib.DI_LibSDMX.Constants.Header.SenderFax };
        Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        Receiver = new PartyType(DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverId, DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverName, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(DevInfo.Lib.DI_LibSDMX.Constants.Header.Receiver, DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverDepartment, DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverRole, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage));
        Receiver.Contact[0].Items = new string[] { DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverTelephone, DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverEmail, DevInfo.Lib.DI_LibSDMX.Constants.Header.ReceiverFax };
        Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        RetVal = new StructureHeaderType(DevInfo.Lib.DI_LibSDMX.Constants.Header.Id, true, DateTime.Now, Sender, Receiver);
        return RetVal;
    }
コード例 #5
0
    private bool UpdateCategorySchemeForUploadedDSDWithHeader(string DbNId, string UserNId, string DataBaseNId)
    {
        bool RetVal;
        SDMXObjectModel.Message.StructureType CategorySchemeStructure;
        SDMXObjectModel.Message.StructureType ProvisioningMetadata;
        SDMXObjectModel.Message.StructureType ProvisionAgreement;
        RetVal = true;
        string UploadedHeaderFileWPath = string.Empty;
        string UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        string UploadedHeaderName = string.Empty;
        string CategorySchemeFolderPath = string.Empty;
        string ProvisonMetadataFolderPath = string.Empty;
        string ProvisionAgreementFolderPath = string.Empty;
        XmlDocument UploadedHeaderXml = new XmlDocument();
        string[] Files = null;
        string[] PAs = null;
        string[] PMetadata = null;
        string filename = string.Empty;
        try
        {
            UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + DataBaseNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            CategorySchemeFolderPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + "Categories";
            ProvisonMetadataFolderPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + "Provisioning Metadata";
            ProvisionAgreementFolderPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + "Provisioning Metadata" + "/" + "PAs";
            UploadedHeaderXml.Load(UploadedHeaderFileWPath);
            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
            SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
            UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
            Header = UploadedDSDStructure.Header;

            Files = Directory.GetFiles(CategorySchemeFolderPath);
            foreach (string categorySchemeFile in Files)
            {
                CategorySchemeStructure = new SDMXObjectModel.Message.StructureType();
                CategorySchemeStructure = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), categorySchemeFile);
                CategorySchemeStructure.Header = Header;
                CategorySchemeStructure.Structures.Categorisations = null;
                CategorySchemeStructure.Structures.Codelists = null;
                CategorySchemeStructure.Structures.HierarchicalCodelists = null;
                CategorySchemeStructure.Structures.Concepts = null;
                CategorySchemeStructure.Structures.Metadataflows = null;
                CategorySchemeStructure.Structures.MetadataStructures = null;
                CategorySchemeStructure.Structures.ProvisionAgreements = null;
                CategorySchemeStructure.Structures.ReportingTaxonomies = null;
                CategorySchemeStructure.Structures.StructureSets = null;
                CategorySchemeStructure.Structures.OrganisationSchemes = null;
                CategorySchemeStructure.Structures.Dataflows = null;
                CategorySchemeStructure.Structures.Constraints = null;
                CategorySchemeStructure.Structures.DataStructures = null;
                CategorySchemeStructure.Structures.Processes = null;
                CategorySchemeStructure.Footer = null;
                Remove_Extra_Annotations(CategorySchemeStructure);
                SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.StructureType), CategorySchemeStructure, categorySchemeFile);
            }

            PAs = Directory.GetFiles(ProvisionAgreementFolderPath);
            foreach (string paFile in PAs)
            {
                ProvisionAgreement = new SDMXObjectModel.Message.StructureType();
                ProvisionAgreement = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), paFile);
                ProvisionAgreement.Header = Header;
                ProvisionAgreement.Structures.Categorisations = null;
                ProvisionAgreement.Structures.Codelists = null;
                ProvisionAgreement.Structures.HierarchicalCodelists = null;
                ProvisionAgreement.Structures.Concepts = null;
                ProvisionAgreement.Structures.Metadataflows = null;
                ProvisionAgreement.Structures.MetadataStructures = null;
                ProvisionAgreement.Structures.ReportingTaxonomies = null;
                ProvisionAgreement.Structures.StructureSets = null;
                ProvisionAgreement.Structures.OrganisationSchemes = null;
                ProvisionAgreement.Structures.Dataflows = null;
                ProvisionAgreement.Structures.Constraints = null;
                ProvisionAgreement.Structures.DataStructures = null;
                ProvisionAgreement.Structures.Processes = null;
                ProvisionAgreement.Structures.CategorySchemes = null;
                ProvisionAgreement.Footer = null;
                Remove_Extra_Annotations(ProvisionAgreement);
                SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.StructureType), ProvisionAgreement, paFile);
            }

            PMetadata = Directory.GetFiles(ProvisonMetadataFolderPath);
            foreach (string pmetadataFile in PMetadata)
            {
                filename = string.Empty;
                ProvisioningMetadata = new SDMXObjectModel.Message.StructureType();
                ProvisioningMetadata = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), pmetadataFile);
                ProvisioningMetadata.Header = Header;
                filename = ExtractFilename(pmetadataFile);
                if (filename.Contains("DF"))
                {
                    ProvisioningMetadata.Structures.Metadataflows = null;
                }
                else
                {
                    ProvisioningMetadata.Structures.Dataflows = null;
                }
                ProvisioningMetadata.Structures.Categorisations = null;
                ProvisioningMetadata.Structures.Codelists = null;
                ProvisioningMetadata.Structures.HierarchicalCodelists = null;
                ProvisioningMetadata.Structures.Concepts = null;
                ProvisioningMetadata.Structures.MetadataStructures = null;
                ProvisioningMetadata.Structures.ProvisionAgreements = null;
                ProvisioningMetadata.Structures.ReportingTaxonomies = null;
                ProvisioningMetadata.Structures.StructureSets = null;
                ProvisioningMetadata.Structures.OrganisationSchemes = null;
                ProvisioningMetadata.Structures.Constraints = null;
                ProvisioningMetadata.Structures.DataStructures = null;
                ProvisioningMetadata.Structures.Processes = null;
                ProvisioningMetadata.Structures.CategorySchemes = null;
                ProvisioningMetadata.Footer = null;
                Remove_Extra_Annotations(ProvisioningMetadata);
                SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.StructureType), ProvisioningMetadata, pmetadataFile);
            }
        }
        catch (Exception ex)
        {
            RetVal = false;
            Global.CreateExceptionString(ex, null);
            //Global.WriteErrorsInLog("Creating CategoryScheme For Uploaded DSD From Admin");
            //Global.WriteErrorsInLog(ex.StackTrace);
            //Global.WriteErrorsInLog(ex.Message);
        }
        finally
        {

        }

        return RetVal;
    }
コード例 #6
0
    public string DataProviderGenerateMetadata(string requestParam)
    {
        string RetVal;
        string[] Params;
        string DBOrDSDDBId, IndicatorNIds, AreaNIds, SourceNIds, UserNId, ErrorMessage, HeaderFilePath;
        bool DBOrDSDFlag;
        int DBNId;
        string OriginalDBNId;
        List<string> GeneratedMetadataFiles, GeneratedIndicatorMetadataFiles, GeneratedAreaMetadataFiles, GeneratedSourceMetadataFiles, ListIndicatorForRegistrations, ListAreaForRegistrations, ListSourceForRegistrations;
        RetVal = string.Empty;
        Params = null;
        DBOrDSDDBId = string.Empty;
        IndicatorNIds = string.Empty;
        AreaNIds = string.Empty;
        SourceNIds = string.Empty;
        UserNId = string.Empty;
        ErrorMessage = string.Empty;
        DBOrDSDFlag = false;
        DBNId = -1;
        GeneratedMetadataFiles = new List<string>();
        GeneratedIndicatorMetadataFiles = new List<string>();
        GeneratedAreaMetadataFiles = new List<string>();
        GeneratedSourceMetadataFiles = new List<string>();
        ListIndicatorForRegistrations = new List<string>();
        ListAreaForRegistrations = new List<string>();
        ListSourceForRegistrations = new List<string>();
        HeaderFilePath = string.Empty;
        OriginalDBNId = string.Empty;
        RetVal = "false";
        try
        {
            Params = Global.SplitString(requestParam, "|");
            DBOrDSDDBId = Params[0].ToString().Trim();
            DBOrDSDFlag = Convert.ToBoolean(Params[1].ToString().Trim());
            IndicatorNIds = Params[2].ToString().Trim();
            AreaNIds = Params[3].ToString().Trim();
            SourceNIds = Params[4].ToString().Trim();
            UserNId = Params[5].ToString().Trim();

            this.Add_Minus_One_To_Selections(ref IndicatorNIds, ref AreaNIds, ref SourceNIds);

            ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, IndicatorNIds);

            HeaderFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.sdmx + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName);
            if (DBOrDSDFlag == true)
            {
                XmlDocument UploadedHeaderXml = new XmlDocument();
                SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
                SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();

                if (File.Exists(HeaderFilePath))
                {

                    UploadedHeaderXml.Load(HeaderFilePath);
                    UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                    Header = UploadedDSDStructure.Header;
                }
                DBNId = Convert.ToInt32(DBOrDSDDBId);
                OriginalDBNId = DBNId.ToString();
                RetVal = this.GenerateMetadata(DBNId, UserNId, IndicatorNIds, AreaNIds, SourceNIds, out GeneratedIndicatorMetadataFiles, out GeneratedAreaMetadataFiles, out GeneratedSourceMetadataFiles, Header);
                ListAreaForRegistrations = this.Get_Area_List_For_Registrations(DBOrDSDDBId, AreaNIds);
                ListSourceForRegistrations = this.Get_Source_List_For_Registrations(DBOrDSDDBId, SourceNIds);
                RetVal = "true";
            }
            else
            {
                DBNId = this.Get_AssociatedDB_NId(DBOrDSDDBId);
                OriginalDBNId = DBNId.ToString();
                RetVal = this.GenerateMetadata_For_UNSD(DBNId, DBOrDSDDBId, IndicatorNIds, out ErrorMessage, out GeneratedMetadataFiles, HeaderFilePath);

            }

            this.Register_MetadataReport(DBOrDSDDBId, UserNId, ListIndicatorForRegistrations, ListAreaForRegistrations, ListSourceForRegistrations, GeneratedMetadataFiles, GeneratedIndicatorMetadataFiles, GeneratedAreaMetadataFiles, GeneratedSourceMetadataFiles, OriginalDBNId);
        }
        catch (Exception ex)
        {
            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            Global.CreateExceptionString(ex, null);

        }
        finally
        {
        }

        return RetVal;
    }
コード例 #7
0
    //public string DataProviderGenerateSDMXML(string requestParam)
    //{
    //    string RetVal;
    //    string[] Params;
    //    string DBOrDSDDBId;
    //    bool DBOrDSDFlag;
    //    string IndicatorNIds, AreaNIds, TPNIds, SourceNIds, AgencyId, OutputFolder, AreaId, UserNId, HeaderFilePath, OriginalDBNId, DuplicateKey;
    //    int DBNId;
    //    int fileCount;
    //    string[] output;
    //    string[] SelectedCollection;
    //    DIConnection DIConnection;
    //    DIQueries DIQueries;
    //    Dictionary<string, string> DictQuery;
    //    Dictionary<string, string> DictMapping;
    //    Dictionary<string, string> DBConnections;
    //    XmlDocument Query;
    //    List<string> GeneratedFiles;
    //    List<string> ListIndicatorForRegistrations;
    //    string[] currentItem = null;
    //    string[] selectedField = null;
    //    string selectedType = string.Empty;
    //    string selectedValue = string.Empty;
    //    string selectedIndicator = string.Empty;
    //    RetVal = "false";
    //    fileCount = 0;
    //    Params = null;
    //    DBOrDSDDBId = string.Empty;
    //    DBOrDSDFlag = false;
    //    IndicatorNIds = string.Empty;
    //    AreaNIds = string.Empty;
    //    TPNIds = string.Empty;
    //    SourceNIds = string.Empty;
    //    AgencyId = string.Empty;
    //    OutputFolder = string.Empty;
    //    UserNId = string.Empty;
    //    DBNId = -1;
    //    DIConnection = null;
    //    DIQueries = null;
    //    DictQuery = new Dictionary<string, string>();
    //    DictMapping = new Dictionary<string, string>();
    //    Query = null;
    //    GeneratedFiles = new List<string>();// Get collection of files
    //    ListIndicatorForRegistrations = new List<string>();
    //    HeaderFilePath = string.Empty;
    //    OriginalDBNId = string.Empty;
    //    DBConnections = new Dictionary<string, string>();
    //    AreaId = string.Empty;
    //    output = null;
    //    DuplicateKey = string.Empty;
    //    SelectedCollection = null;
    //    DataTable dtSelections = null;
    //    DataRow dr;
    //    DataRow[] drSelections = null;
    //    string[] AgencyUserNid = null;
    //    string DevInfoOrCountryData = string.Empty;
    //    string xml = string.Empty;
    //    try
    //    {
    //        Params = Global.SplitString(requestParam, "|");
    //        DBOrDSDDBId = Params[0].ToString().Trim();
    //        DevInfoOrCountryData = Params[1].ToString().Trim();
    //        AgencyUserNid = Session["hLoggedInUserNId"].ToString().Trim().Split(new string[] { Constants.Delimiters.PivotColumnDelimiter }, StringSplitOptions.None);
    //        AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + AgencyUserNid[0].ToString();
    //        UserNId = AgencyUserNid[0].ToString().Trim();
    //        if (Params.Length > 2)
    //        {
    //            DBOrDSDFlag = Convert.ToBoolean(Params[1].ToString().Trim());
    //            IndicatorNIds = Params[2].ToString().Trim();
    //            AreaNIds = Params[3].ToString().Trim();
    //            TPNIds = Params[4].ToString().Trim();
    //            SourceNIds = Params[5].ToString().Trim();
    //            AreaId = Params[6].ToString().Trim();
    //            AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + Params[7].ToString().Trim();
    //            UserNId = Params[7].ToString().Trim();
    //            OriginalDBNId = Params[8].ToString().Trim();
    //            if (Params.Length > 9)
    //            {
    //                SelectedCollection = Params[9].ToString().Trim().Split(new string[] { Constants.Delimiters.RowDelimiter }, StringSplitOptions.None);
    //            }
    //        }
    //        else
    //        {
    //            Dictionary<string, string> DictConnections = new Dictionary<string, string>();
    //            DBConnections = Global.GetAllConnections("DevInfo");
    //            foreach (var item in DBConnections.Keys)
    //            {
    //                if (Convert.ToString(item) == DBOrDSDDBId && DevInfoOrCountryData == "DevInfo")
    //                {
    //                    RetVal = PublishDataFilesForDB(true, DBOrDSDDBId, AgencyId, UserNId);
    //                    output = RetVal.Split(new string[] { Constants.Delimiters.ParamDelimiter }, StringSplitOptions.None);
    //                    RetVal = output[0].ToString();
    //                }
    //                else if (Convert.ToString(item) != DBOrDSDDBId && DevInfoOrCountryData == "CountryData")
    //                {
    //                    RetVal = PublishDataFilesForDSD(false, Convert.ToString(item), AgencyId, UserNId);
    //                    output = RetVal.Split(new string[] { Constants.Delimiters.ParamDelimiter }, StringSplitOptions.None);
    //                    RetVal = output[0].ToString();
    //                }
    //            }
    //        }
    //        if (Params.Length > 2)
    //        {
    //            HeaderFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.sdmx + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName);
    //            if (DBOrDSDFlag == true)
    //            {
    //                DBNId = Convert.ToInt32(DBOrDSDDBId);
    //                DIConnection = Global.GetDbConnection(DBNId);
    //                DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
    //                XmlDocument UploadedHeaderXml = new XmlDocument();
    //                SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
    //                SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
    //                if (File.Exists(HeaderFilePath))
    //                {
    //                    UploadedHeaderXml.Load(HeaderFilePath);
    //                    UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
    //                    Header = UploadedDSDStructure.Header;
    //                }
    //                this.Clean_SDMX_ML_Folder(DBNId);
    //                this.Add_IUS_To_Dictionary(DictQuery, IndicatorNIds, DIConnection, DIQueries);
    //                this.Add_Area_To_Dictionary(DictQuery, AreaNIds, DIConnection, DIQueries);
    //                this.Add_TP_To_Dictionary(DictQuery, TPNIds, DIConnection, DIQueries);
    //                this.Add_Source_To_Dictionary(DictQuery, SourceNIds, DIConnection, DIQueries);
    //                Query = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, DictQuery, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, AgencyId, DIConnection, DIQueries);
    //                OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBNId.ToString() + "\\" + Constants.FolderName.SDMX.SDMX_ML);
    //                if (SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, Query, DataFormats.StructureSpecificTS, DIConnection, DIQueries, OutputFolder, out fileCount, out GeneratedFiles, Header) == true)
    //                {
    //                    if (fileCount == 0)
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "NDF";
    //                    }
    //                    else
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString();
    //                        ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, IndicatorNIds);
    //                        this.Register_SDMXFiles(DBOrDSDDBId, DBOrDSDFlag, UserNId, ListIndicatorForRegistrations, GeneratedFiles, DBNId.ToString());
    //                    }
    //                }
    //                else
    //                {
    //                    RetVal = "false";
    //                }
    //            }
    //            else
    //            {
    //                if (SelectedCollection != null)
    //                {
    //                    dtSelections = new DataTable();
    //                    dtSelections.TableName = "Data";
    //                    dtSelections.Columns.Add("Ind", typeof(int));
    //                    dtSelections.Columns.Add("areas", typeof(string));
    //                    dtSelections.Columns.Add("timeperiods", typeof(string));
    //                    dtSelections.Columns.Add("source", typeof(string));
    //                }
    //                else
    //                {
    //                    dtSelections = new DataTable();
    //                    dtSelections.TableName = "Data";
    //                    dtSelections.Columns.Add("Ind", typeof(int));
    //                    dtSelections.Columns.Add("areas", typeof(string));
    //                    dtSelections.Columns.Add("timeperiods", typeof(string));
    //                    dtSelections.Columns.Add("source", typeof(string));
    //                    foreach (string IndicatorNId in IndicatorNIds.Split(','))
    //                    {
    //                        dr = dtSelections.NewRow();
    //                        dr["Ind"] = IndicatorNId;
    //                        dr["areas"] = string.Empty;
    //                        dr["timeperiods"] = string.Empty;
    //                        dr["source"] = string.Empty;
    //                        dtSelections.Rows.Add(dr);
    //                    }
    //                }
    //                bool rowFound = false;
    //                currentItem = null;
    //                SelectedCollection = this.AddItemsInSelectedCollection(SelectedCollection, IndicatorNIds);
    //                if (SelectedCollection != null)
    //                    foreach (string item in SelectedCollection)
    //                    {
    //                        dr = dtSelections.NewRow();
    //                        currentItem = item.Split(new string[] { Constants.Delimiters.ColumnDelimiter }, StringSplitOptions.None);
    //                        foreach (string field in currentItem)
    //                        {
    //                            if (string.IsNullOrEmpty(field) == false)
    //                            {
    //                                selectedField = field.Split(new string[] { Constants.Delimiters.Underscore }, StringSplitOptions.None);
    //                                selectedType = selectedField[0];
    //                                selectedValue = selectedField[1];
    //                                if (selectedType == "Indicator")
    //                                {
    //                                    selectedIndicator = selectedValue;
    //                                }
    //                                if (dtSelections.Rows.Count > 0)
    //                                {
    //                                    foreach (DataRow datarow in dtSelections.Rows)
    //                                    {
    //                                        if (datarow[0].ToString() == selectedIndicator)
    //                                        {
    //                                            switch (selectedType)
    //                                            {
    //                                                case "Indicator":
    //                                                    datarow["Ind"] = selectedValue;
    //                                                    rowFound = true;
    //                                                    break;
    //                                                case "Area":
    //                                                    datarow["areas"] = selectedValue;
    //                                                    rowFound = true;
    //                                                    break;
    //                                                case "Time":
    //                                                    datarow["timeperiods"] = selectedValue;
    //                                                    rowFound = true;
    //                                                    break;
    //                                                case "Source":
    //                                                    datarow["source"] = selectedValue;
    //                                                    rowFound = true;
    //                                                    break;
    //                                                default:
    //                                                    break;
    //                                            }
    //                                        }
    //                                        else
    //                                        {
    //                                            switch (selectedType)
    //                                            {
    //                                                case "Indicator":
    //                                                    dr["Ind"] = selectedValue;
    //                                                    break;
    //                                                case "Area":
    //                                                    dr["areas"] = selectedValue;
    //                                                    break;
    //                                                case "Time":
    //                                                    dr["timeperiods"] = selectedValue;
    //                                                    break;
    //                                                case "Source":
    //                                                    dr["source"] = selectedValue;
    //                                                    break;
    //                                                default:
    //                                                    break;
    //                                            }
    //                                        }
    //                                    }
    //                                }
    //                                else
    //                                {
    //                                    switch (selectedType)
    //                                    {
    //                                        case "Indicator":
    //                                            dr["Ind"] = selectedValue;
    //                                            break;
    //                                        case "Area":
    //                                            dr["areas"] = selectedValue;
    //                                            break;
    //                                        case "Time":
    //                                            dr["timeperiods"] = selectedValue;
    //                                            break;
    //                                        case "Source":
    //                                            dr["source"] = selectedValue;
    //                                            break;
    //                                        default:
    //                                            break;
    //                                    }
    //                                }
    //                            }
    //                        }
    //                        if (rowFound == false)
    //                            dtSelections.Rows.Add(dr);
    //                        for (int i = 0; i < dtSelections.Rows.Count; i++)
    //                        {
    //                            if (dtSelections.Rows[i].IsNull("Ind") == true)
    //                            {
    //                                dtSelections.Rows.RemoveAt(i);
    //                            }
    //                        }
    //                    }
    //                DBNId = this.Get_AssociatedDB_NId(DBOrDSDDBId);
    //                DIConnection = Global.GetDbConnection(DBNId);
    //                DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
    //                DictMapping = this.Get_IUS_Mapping_Dict(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId + "\\" + Constants.FolderName.SDMX.Mapping + "IUSMapping.xml"));
    //                this.Clean_SDMX_ML_Folder_For_UNSD(DBNId, DBOrDSDDBId);
    //                OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.SDMX_ML);
    //                xml = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId + "\\sdmx" + "\\DataPublishedUserSelection.xml");
    //                if (RegTwoZeroData.Generate_Data(IndicatorNIds, AreaNIds, TPNIds, SourceNIds, DictMapping, OutputFolder, DIConnection, DIQueries, out fileCount, AreaId, DBOrDSDDBId, out GeneratedFiles, HeaderFilePath, xml, out DuplicateKey, dtSelections) == true)
    //                {
    //                    //MNF-Mapping Not found in case if IUS Mapping doesnot exist.
    //                    //NDF-No data Found if datavalues does not exist corresponding to the indicator(s) selected.
    //                    if (DictMapping.Count == 0)
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + "0" + Constants.Delimiters.ParamDelimiter + "MNF";
    //                    }
    //                    else if (fileCount == 0 && DictMapping.Count == 0)
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "MNF";
    //                    }
    //                    else if (fileCount == 0 && DictMapping.Count > 0 && string.IsNullOrEmpty(DuplicateKey) == false)
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "DK" + Constants.Delimiters.ParamDelimiter + DuplicateKey;
    //                    }
    //                    else if (fileCount == 0 && DictMapping.Count > 0)
    //                    {
    //                        RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "NDF";
    //                    }
    //                    else
    //                    {
    //                        if (string.IsNullOrEmpty(DuplicateKey) == false)
    //                        {
    //                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + DuplicateKey + Constants.Delimiters.ParamDelimiter + "DK";
    //                        }
    //                        else
    //                        {
    //                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString();
    //                        }
    //                        Session["GeneratedFiles"] = (List<string>)GeneratedFiles;
    //                        ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, IndicatorNIds);
    //                        this.Register_SDMXFiles(DBOrDSDDBId, DBOrDSDFlag, UserNId, ListIndicatorForRegistrations, GeneratedFiles, DBNId.ToString());
    //                    }
    //                }
    //                else
    //                {
    //                    RetVal = "false";
    //                    if (DictMapping.Count == 0)
    //                    {
    //                        RetVal = "false" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "MNF";
    //                    }
    //                }
    //            }
    //        }
    //    }
    //    catch (Exception ex)
    //    {
    //        if (ex.Message.Contains("The given key was not present in the dictionary"))
    //        {
    //            RetVal = "false" + Constants.Delimiters.ParamDelimiter + "MNF";
    //        }
    //        else
    //        {
    //            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
    //        }
    //        Global.CreateExceptionString(ex, null);
    //    }
    //    finally
    //    {
    //    }
    //    return RetVal;
    //}
    /// <summary>
    /// 
    /// </summary>
    /// <param name="requestParam">Selected Indicator[] Area []</param>
    /// <returns>FileCount and Status of Generated or Not generated files</returns>
    public string DataProviderGenerateSDMXML(string requestParam)
    {
        string RetVal;
        string[] Params;
        string DBOrDSDDBId;
        bool DBOrDSDFlag;
        string IndicatorNIds, AreaNIds, TPNIds, SourceNIds, AgencyId, OutputFolder, AreaId, UserNId, HeaderFilePath, OriginalDBNId, DuplicateKey;
        int DBNId;
        int fileCount;
        string[] output;
        string[] SelectedCollection;
        DIConnection DIConnection;
        DIQueries DIQueries;
        Dictionary<string, string> DictQuery;
        Dictionary<string, string> DictMapping;
        Dictionary<string, string> DBConnections;
        XmlDocument Query;
        List<string> GeneratedFiles;
           // List<string> ListIndicatorForRegistrations;
        RetVal = "false";
        fileCount = 0;
        Params = null;
        DBOrDSDDBId = string.Empty;
        DBOrDSDFlag = false;
        IndicatorNIds = string.Empty;
        AreaNIds = string.Empty;
        TPNIds = string.Empty;
        SourceNIds = string.Empty;
        AgencyId = string.Empty;
        OutputFolder = string.Empty;
        UserNId = string.Empty;
        DBNId = -1;
        DIConnection = null;
        DIQueries = null;
        DictQuery = new Dictionary<string, string>();
        DictMapping = new Dictionary<string, string>();
        Query = null;
        GeneratedFiles = new List<string>();// Get collection of files
         //   ListIndicatorForRegistrations = new List<string>();
        HeaderFilePath = string.Empty;
        OriginalDBNId = string.Empty;
        DBConnections = new Dictionary<string, string>();
        AreaId = string.Empty;
        output = null;
        DuplicateKey = string.Empty;
        SelectedCollection = null;
        DataTable dtSelections = null;
        DataRow dr;

        string[] AgencyUserNid = null;
        string DevInfoOrCountryData = string.Empty;
        string xml = string.Empty;
        string DataPublishUserSelectionFileNameWPath = string.Empty;
        string IndNId = string.Empty;
        string areas = string.Empty;
        string timeperiods = string.Empty;
        string source = string.Empty;
        string selectedState = string.Empty;
        string ErrorLogs = string.Empty;
        try
        {
            // 1. Split the parameter and set the variable
            Params = Global.SplitString(requestParam, "|");
            DBOrDSDDBId = Params[0].ToString().Trim();
            DevInfoOrCountryData = Params[1].ToString().Trim();
            AgencyUserNid = Session["hLoggedInUserNId"].ToString().Trim().Split(new string[] { Constants.Delimiters.PivotColumnDelimiter }, StringSplitOptions.None);
            AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + AgencyUserNid[0].ToString();
            UserNId = AgencyUserNid[0].ToString().Trim();

            if (Params.Length > 2)
            {
                // 1A. If reaching through Register tab ...
                DBOrDSDFlag = Convert.ToBoolean(Params[1].ToString().Trim());
                IndicatorNIds = Params[2].ToString().Trim();
                AreaNIds = Params[3].ToString().Trim();
                TPNIds = Params[4].ToString().Trim();
                SourceNIds = Params[5].ToString().Trim();
                AreaId = Params[6].ToString().Trim();
                AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + Params[7].ToString().Trim();
                UserNId = Params[7].ToString().Trim();
                OriginalDBNId = Params[8].ToString().Trim();
                if (Params.Length > 9)
                {
                    SelectedCollection = Params[9].ToString().Trim().Split(new string[] { Constants.Delimiters.RowDelimiter }, StringSplitOptions.None);
                }
                HeaderFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.sdmx + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName);
                if (DBOrDSDFlag == true)
                {
                    //  1Ai If DevInfo DSD
                    DBNId = Convert.ToInt32(DBOrDSDDBId);
                    DIConnection = Global.GetDbConnection(DBNId);
                    DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
                    XmlDocument UploadedHeaderXml = new XmlDocument();
                    SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
                    SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
                    if (File.Exists(HeaderFilePath))
                    {
                        UploadedHeaderXml.Load(HeaderFilePath);
                        UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                        Header = UploadedDSDStructure.Header;
                    }
                    this.Clean_SDMX_ML_Folder(DBNId);

                    this.Add_IUS_To_Dictionary(DictQuery, IndicatorNIds, DIConnection, DIQueries);
                    this.Add_Area_To_Dictionary(DictQuery, AreaNIds, DIConnection, DIQueries);
                    this.Add_TP_To_Dictionary(DictQuery, TPNIds, DIConnection, DIQueries);
                    this.Add_Source_To_Dictionary(DictQuery, SourceNIds, DIConnection, DIQueries);

                    Query = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, DictQuery, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, AgencyId, DIConnection, DIQueries);
                    OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBNId.ToString() + "\\" + Constants.FolderName.SDMX.SDMX_ML);
                    if (SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, Query, DataFormats.StructureSpecificTS, DIConnection, DIQueries, OutputFolder, out fileCount, out GeneratedFiles, Header) == true)
                    {
                        if (fileCount == 0)
                        {
                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "NDF";
                        }
                        else
                        {
                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString();
                            //ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, IndicatorNIds);

                            this.Register_SDMXFiles(DBOrDSDDBId, DBOrDSDFlag, UserNId, GeneratedFiles, DBNId.ToString());
                        }
                    }
                    else
                    {
                        RetVal = "false";
                    }
                }
                else
                {
                    // 1Aii If Country DSD

                    // Set Datatable to store user selction (Indicator -> Area - Time Period, Source)
                    dtSelections = new DataTable();
                    dtSelections.TableName = "Data";
                    dtSelections.Columns.Add("Ind", typeof(int));
                    dtSelections.Columns.Add("areas", typeof(string));
                    dtSelections.Columns.Add("timeperiods", typeof(string));
                    dtSelections.Columns.Add("source", typeof(string));
                    dtSelections.Columns.Add("selectedState", typeof(string));

                    foreach (string IndicatorNId in IndicatorNIds.Split(','))
                    {
                        dr = dtSelections.NewRow();
                        dr["Ind"] = IndicatorNId;

                        DataPublishUserSelectionFileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\sdmx" + "\\DataPublishedUserSelection.xml");
                        XmlDocument doc = new XmlDocument();
                        doc.Load(DataPublishUserSelectionFileNameWPath);
                        foreach (XmlElement element in doc.SelectNodes("/root/Data"))
                        {
                            IndNId = element.GetAttribute("Ind");
                            if (IndicatorNId == IndNId)
                            {

                                areas = element.GetAttribute("areas");
                                dr["areas"] = areas;

                                timeperiods = element.GetAttribute("timeperiods");
                                dr["timeperiods"] = timeperiods;

                                source = element.GetAttribute("source");

                                dr["source"] = source;

                                selectedState = element.GetAttribute("selectedState");

                                dr["selectedState"] = "true";
                            }

                        }

                        dtSelections.Rows.Add(dr);

                    }

                    DBNId = this.Get_AssociatedDB_NId(DBOrDSDDBId);
                    DIConnection = Global.GetDbConnection(DBNId);
                    DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
                    DictMapping = this.Get_IUS_Mapping_Dict(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId + "\\" + Constants.FolderName.SDMX.Mapping + "IUSMapping.xml"));

                    this.Clean_SDMX_ML_Folder_For_UNSD(DBNId, DBOrDSDDBId);
                    OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.SDMX_ML);
                    xml = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId + "\\sdmx" + "\\DataPublishedUserSelection.xml");

                    // Generate SDMX-mL data files
                    if (RegTwoZeroData.Generate_Data(DictMapping, OutputFolder, DIConnection, DIQueries, AreaId, DBOrDSDDBId, HeaderFilePath, xml, dtSelections, out fileCount, out GeneratedFiles, out ErrorLogs, out DuplicateKey) == true)
                    {

                        // Build Error Messages
                        if (DictMapping.Count == 0)
                        {
                            //MNF-Mapping Not found in case if IUS Mapping doesnot exist.
                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + "0" + Constants.Delimiters.ParamDelimiter + "MNF";
                        }
                        else if (fileCount == 0 && DictMapping.Count == 0)
                        {
                            //MNF-Mapping Not found in case if IUS Mapping doesnot exist.
                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "MNF";
                        }
                        else if (fileCount == 0 && DictMapping.Count > 0 && string.IsNullOrEmpty(DuplicateKey) == false)
                        {
                            // Duplicate Key
                            RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + DuplicateKey;
                            if (RetVal.EndsWith(Constants.Delimiters.ParamDelimiter))
                            {
                                RetVal = RetVal.Substring(0, RetVal.Length - 6);
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(DuplicateKey) == false)
                            {
                                RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + DuplicateKey;
                            }
                            else
                            {
                                RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString();
                            }
                            //ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, IndicatorNIds);

                            // Register SDMX-ML file generated

                            this.Register_SDMXFiles(DBOrDSDDBId, DBOrDSDFlag, UserNId, GeneratedFiles, DBNId.ToString());
                        }
                        RetVal = RetVal + Constants.Delimiters.ParamDelimiter + ErrorLogs;
                    }
                    else
                    {
                        RetVal = "false";
                        if (DictMapping.Count == 0)
                        {
                            RetVal = "false" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "MNF";
                        }
                    }
                }

            }
            else
            {
                // 1B. If reaching through Admin Optimize
                Dictionary<string, string> DictConnections = new Dictionary<string, string>();
                DBConnections = Global.GetAllConnections("DevInfo");
                foreach (var item in DBConnections.Keys)
                {
                    if (Convert.ToString(item) == DBOrDSDDBId && DevInfoOrCountryData == "DevInfo")
                    {
                        RetVal = PublishDataFilesForDB(true, DBOrDSDDBId, AgencyId, UserNId);
                        output = RetVal.Split(new string[] { Constants.Delimiters.ParamDelimiter }, StringSplitOptions.None);
                        RetVal = output[0].ToString();
                    }
                    else if (Convert.ToString(item) != DBOrDSDDBId && DevInfoOrCountryData == "CountryData")
                    {
                        RetVal = PublishDataFilesForDSD(false, Convert.ToString(item), AgencyId, UserNId);
                        output = RetVal.Split(new string[] { Constants.Delimiters.ParamDelimiter }, StringSplitOptions.None);
                        RetVal = output[0].ToString();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("The given key was not present in the dictionary"))
            {
                RetVal = "false" + Constants.Delimiters.ParamDelimiter + "MNF";

            }
            else
            {
                RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            }

            Global.CreateExceptionString(ex, null);

        }
        finally
        {

        }

        return RetVal;
    }
コード例 #8
0
 public StructureType()
 {
     this.footerField = new List<FooterMessageType>();
     this.structuresField = new StructuresType();
     this.headerField = new StructureHeaderType();
 }
コード例 #9
0
    private string PublishDataFilesForDB(bool DBOrDSDFlag, string DBOrDSDDBId, string AgencyId, string UserNId)
    {
        string RetVal = string.Empty;
        string IndicatorNIds, AreaNIds, TPNIds, SourceNIds, OutputFolder, AreaId, HeaderFilePath, OriginalDBNId;
        int DBNId;
        int fileCount;
        DIConnection DIConnection;
        DIQueries DIQueries;
        Dictionary<string, string> DictQuery;
        Dictionary<string, string> DictMapping;
        XmlDocument Query;
        List<string> GeneratedFiles;
        List<string> ListIndicatorForRegistrations;
        RetVal = "false";
        fileCount = 0;
        AreaId = string.Empty;
        IndicatorNIds = string.Empty;
        AreaNIds = string.Empty;
        TPNIds = string.Empty;
        SourceNIds = string.Empty;
        OutputFolder = string.Empty;
        DBNId = -1;
        DIConnection = null;
        DIQueries = null;
        DictQuery = new Dictionary<string, string>();
        DictMapping = new Dictionary<string, string>();
        Query = null;
        GeneratedFiles = new List<string>();// Get collection of files
        ListIndicatorForRegistrations = new List<string>();
        HeaderFilePath = string.Empty;
        OriginalDBNId = string.Empty;
        HeaderFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBOrDSDDBId.ToString() + "\\" + Constants.FolderName.SDMX.sdmx + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName);
        DBNId = Convert.ToInt32(DBOrDSDDBId);
        DIConnection = Global.GetDbConnection(DBNId);
        DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
        XmlDocument UploadedHeaderXml = new XmlDocument();
        SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
        SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
        if (File.Exists(HeaderFilePath))
        {
            UploadedHeaderXml.Load(HeaderFilePath);
            UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
            Header = UploadedDSDStructure.Header;
        }
        //   this.Clean_SDMX_ML_Folder(DBNId);
        IndicatorNIds = "-1";
        AreaNIds = "-1";
        TPNIds = "-1";
        SourceNIds = "-1";
        AreaId = "";

        this.Add_IUS_To_Dictionary(DictQuery, IndicatorNIds, DIConnection, DIQueries);
        this.Add_Area_To_Dictionary(DictQuery, AreaNIds, DIConnection, DIQueries);
        this.Add_TP_To_Dictionary(DictQuery, TPNIds, DIConnection, DIQueries);
        this.Add_Source_To_Dictionary(DictQuery, SourceNIds, DIConnection, DIQueries);

        Query = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, DictQuery, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, AgencyId, DIConnection, DIQueries);
        OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBNId.ToString() + "\\" + Constants.FolderName.SDMX.SDMX_ML);
        if (SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, Query, DataFormats.StructureSpecificTS, DIConnection, DIQueries, OutputFolder, out fileCount, out GeneratedFiles, Header) == true)
        {
            if (fileCount == 0)
            {
                RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString() + Constants.Delimiters.ParamDelimiter + "NDF";
            }
            else
            {
                RetVal = "true" + Constants.Delimiters.ParamDelimiter + fileCount.ToString();
                //ListIndicatorForRegistrations = this.Get_Indicator_List_For_Registrations(DBOrDSDDBId, DBOrDSDFlag, string.Empty);

                this.Register_SDMXFiles(DBOrDSDDBId, DBOrDSDFlag, UserNId, GeneratedFiles, DBNId.ToString());
            }
        }
        else
        {
            RetVal = "false";
        }

        return RetVal;
    }
コード例 #10
0
        public virtual SDMXObjectModel.Message.StructureHeaderType Get_Appropriate_Header()
        {
            SDMXObjectModel.Message.StructureHeaderType RetVal;
            SenderType Sender;
            PartyType Receiver;

            if (this.Header == null)
            {
                Sender = new SenderType(Constants.Header.SenderId, Constants.Header.SenderName, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(Constants.Header.Sender, Constants.Header.SenderDepartment, Constants.Header.SenderRole, Constants.DefaultLanguage));
                Sender.Contact[0].Items = new string[] { Constants.Header.SenderTelephone, Constants.Header.SenderEmail, Constants.Header.SenderFax };
                Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                Receiver = new PartyType(Constants.Header.ReceiverId, Constants.Header.ReceiverName, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(Constants.Header.Receiver, Constants.Header.ReceiverDepartment, Constants.Header.ReceiverRole, Constants.DefaultLanguage));
                Receiver.Contact[0].Items = new string[] { Constants.Header.ReceiverTelephone, Constants.Header.ReceiverEmail, Constants.Header.ReceiverFax };
                Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                RetVal = new StructureHeaderType(Constants.Header.Id, true, DateTime.Now, Sender, Receiver);
            }
            else
            {
                Sender = new SenderType(this.Header.Sender.ID, this.Header.Sender.Name, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(this.Header.Sender.Contact.Name, this.Header.Sender.Contact.Department, this.Header.Sender.Contact.Role, Constants.DefaultLanguage));
                Sender.Contact[0].Items = new string[] { this.Header.Sender.Contact.Telephone, this.Header.Sender.Contact.Email, this.Header.Sender.Contact.Fax };
                Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                Receiver = new PartyType(this.Header.Receiver.ID, this.Header.Receiver.Name, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(this.Header.Receiver.Contact.Name, this.Header.Receiver.Contact.Department, this.Header.Receiver.Contact.Role, Constants.DefaultLanguage));
                Receiver.Contact[0].Items = new string[] { this.Header.Receiver.Contact.Telephone, this.Header.Receiver.Contact.Email, this.Header.Receiver.Contact.Fax };
                Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                RetVal = new StructureHeaderType(this.Header.ID, true, DateTime.Now, Sender, Receiver);
            }

            return RetVal;
        }
コード例 #11
0
    private string GenerateSDMXML(int DbNid, string LoggedInUserNId)
    {
        string RetVal;
        DIConnection DIConnection;
        DIQueries DIQueries;
        string OutputFolder, AgencyId, HeaderFilePath;
        bool SDMXMLGenerated = false;
        XmlDocument query = new XmlDocument();
        Dictionary<string, string> DictQuery;
        int fileCount;
        List<string> GeneratedFiles;
        RetVal = "false";
        DIConnection = Global.GetDbConnection(DbNid);
        DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault()));
        OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNid.ToString() + "\\sdmx");
        AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + LoggedInUserNId;
        this.Clean_SDMX_ML_Folder(DbNid);
        DictQuery = new Dictionary<string, string>();
        fileCount = 0;
        GeneratedFiles = new List<string>();
        HeaderFilePath = string.Empty;
        try
        {
            HeaderFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNid.ToString() + "\\" + Constants.FolderName.SDMX.sdmx + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName);
            XmlDocument UploadedHeaderXml = new XmlDocument();
            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();
            SDMXObjectModel.Message.StructureHeaderType Header = new SDMXObjectModel.Message.StructureHeaderType();
            if (File.Exists(HeaderFilePath))
            {
                UploadedHeaderXml.Load(HeaderFilePath);
                UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                Header = UploadedDSDStructure.Header;
            }
            this.Add_All_IUS_To_Query_Dictionary(DictQuery, DIConnection, DIQueries);
            //Generation of SDMX-ML files
            query = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, DictQuery, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, AgencyId, DIConnection, DIQueries);

            SDMXMLGenerated = SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, query, DataFormats.StructureSpecificTS, DIConnection, DIQueries, Path.Combine(OutputFolder, "SDMX-ML"), out fileCount, out  GeneratedFiles, Header);
            if (SDMXMLGenerated == true)
            {
                RetVal = "true";
            }
            else
            {
                RetVal = "false";
            }
        }
        catch (Exception ex)
        {
            //Global.WriteErrorsInLog(ex.StackTrace);
            Global.CreateExceptionString(ex, null);
            throw ex;
        }

        return RetVal;
    }
コード例 #12
0
    public string UpdateRegistration(string requestParam)
    {
        string RetVal;
        string[] Params;
        string[] DBDetails;
        string DbNId, UserNId, DFDOrMFDId, RegistrationId, WebServiceURL, WADLURL, WSDLURL, FileURL, Language, UploadedHeaderFileWPath, UploadedHeaderFolderPath, OriginalDBNId, SDMXFileName;
        bool IsREST, IsSOAP, IsMetadata;
        RegistryInterfaceType RegistryInterfaceRequest, RegistryInterfaceResponse;
        Registry.RegistryService Service;
        XmlDocument Request;
        XmlElement Element;
        XmlDocument UploadedHeaderXml;
        SDMXObjectModel.Message.StructureHeaderType Header;
        RetVal = string.Empty;
        RegistryInterfaceRequest = null;
        RegistryInterfaceResponse = null;
        Service = null;
        Request = new XmlDocument();
        Element = null;
        Header = new SDMXObjectModel.Message.StructureHeaderType();
        UploadedHeaderXml = new XmlDocument();
        UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        DBDetails = null;
        OriginalDBNId = string.Empty;
        SDMXFileName = string.Empty;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            DbNId = Params[0].ToString().Trim();
            UserNId = Params[1].ToString().Trim();
            IsMetadata = bool.Parse(Params[2].ToString().Trim());
            DFDOrMFDId = Params[3].ToString().Trim();
            RegistrationId = Params[4].ToString().Trim();
            WebServiceURL = Params[5].ToString().Trim();
            IsREST = bool.Parse(Params[6].ToString().Trim());
            WADLURL = Params[7].ToString().Trim();
            IsSOAP = bool.Parse(Params[8].ToString().Trim());
            WSDLURL = Params[9].ToString().Trim();
            if (Params.Length > 10)
            {
                FileURL = Params[10].ToString().Trim();
            }
            else
            {
                FileURL = string.Empty;
            }
            if (Params.Length > 11)
            {
                Language = Params[11].ToString().Trim();
            }
            else
            {
                Language = Global.GetDefaultLanguageCode();
            }
            if (Params.Length > 12)
            {
                SDMXFileName = Params[12].ToString().Trim();
            }
            else
            {
                SDMXFileName = string.Empty;
            }
            RegistryInterfaceRequest = new RegistryInterfaceType();
            //RegistryInterfaceRequest.Header = Global.Get_Appropriate_Header();
            DBDetails = Global.GetDbConnectionDetails(DbNId);
            if (DBDetails[4] == "true")
            {
                OriginalDBNId = Convert.ToString(this.Get_AssociatedDB_NId(DbNId));
            }
            else
            {
                OriginalDBNId = DbNId;
            }
            UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + OriginalDBNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();

            if (File.Exists(UploadedHeaderFileWPath))
            {
                UploadedHeaderXml.Load(UploadedHeaderFileWPath);
                UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                Header = UploadedDSDStructure.Header;
            }

            RegistryInterfaceRequest = new RegistryInterfaceType();
            if (Header == null)
            {
                RegistryInterfaceRequest.Header = Global.Get_Appropriate_Header();
            }
            else
            {

                RegistryInterfaceRequest.Header.ID = Header.ID.ToString();
                RegistryInterfaceRequest.Header.Prepared = Header.Prepared.ToString();
                foreach (PartyType receiver in Header.Receiver)
                {
                    RegistryInterfaceRequest.Header.Receiver = new PartyType();
                    RegistryInterfaceRequest.Header.Receiver.Contact = receiver.Contact;
                    RegistryInterfaceRequest.Header.Receiver.id = receiver.id;
                    RegistryInterfaceRequest.Header.Receiver.Name = receiver.Name;
                }
                RegistryInterfaceRequest.Header.Sender = (SDMXObjectModel.Message.SenderType)Header.Sender;
                RegistryInterfaceRequest.Header.Test = Header.Test;

            }
            RegistryInterfaceRequest.Footer = null;

            RegistryInterfaceRequest.Item = new SDMXObjectModel.Registry.SubmitRegistrationsRequestType();
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest = new List<RegistrationRequestType>();
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest.Add(new RegistrationRequestType(null, ActionType.Replace));
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration = new RegistrationType(RegistrationId);
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.ProvisionAgreement = new ProvisionAgreementReferenceType();
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.ProvisionAgreement.Items = new List<object>();
            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.ProvisionAgreement.Items.Add(new ProvisionAgreementRefType(DevInfo.Lib.DI_LibSDMX.Constants.PA.Prefix + UserNId + "_" + DFDOrMFDId, Global.Get_AgencyId_From_DFD(DbNId), DevInfo.Lib.DI_LibSDMX.Constants.PA.Version));

            ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.Datasource = new List<object>();
            if (!string.IsNullOrEmpty(WebServiceURL))
            {
                ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.Datasource.Add(new SDMXObjectModel.Registry.QueryableDataSourceType(WebServiceURL, IsREST, WADLURL, IsSOAP, WSDLURL));
            }

            if (!string.IsNullOrEmpty(FileURL))
            {
                ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0].Registration.Datasource.Add(FileURL);
            }

            Service = new Registry.RegistryService();
            Service.Url = HttpContext.Current.Request.Url.OriginalString.Substring(0, HttpContext.Current.Request.Url.OriginalString.IndexOf("libraries")) + Constants.FolderName.SDMX.RegistryServicePath;
            Service.Url += "?p=" + DbNId.ToString();

            Request = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceRequest);
            Element = Request.DocumentElement;
            string languageNid = Global.GetLangNidFromlangCode(Language);
            Service.SubmitRegistration(ref Element, SDMXFileName, languageNid);
            RegistryInterfaceResponse = (RegistryInterfaceType)Deserializer.LoadFromText(typeof(RegistryInterfaceType), Element.OuterXml);

            if (((SDMXObjectModel.Registry.SubmitRegistrationsResponseType)RegistryInterfaceResponse.Item).RegistrationStatus[0].StatusMessage.status == StatusType.Success)
            {
                this.Frame_Message_And_Send_Registration_Mail(UserNId, RegistrationId, Language);
                RetVal = "true" + Constants.Delimiters.ParamDelimiter + ((SDMXObjectModel.Registry.SubmitRegistrationsResponseType)RegistryInterfaceResponse.Item).RegistrationStatus[0].Registration.id;
            }
            else
            {
                RetVal = "false" + Constants.Delimiters.ParamDelimiter + ((SDMXObjectModel.Registry.SubmitRegistrationsResponseType)RegistryInterfaceResponse.Item).RegistrationStatus[0].StatusMessage.MessageText[0].Text;
            }
        }
        catch (Exception ex)
        {
            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            Global.CreateExceptionString(ex, null);
        }
        finally
        {
        }

        return RetVal;
    }
コード例 #13
0
    public string DeleteSubscription(string requestParam)
    {
        string RetVal;
        string[] Params;
        string Action;
        string NotificationMail;
        string NotificationHTTP;
        int IsSOAP;
        string SubscriberAssignedID;
        string StartDate;
        string EndDate;
        string EventSelector;
        string CategoriesGIDAndSchemeIds;
        string MFDId;
        string DbNId;
        string CodelistId;
        string SubscriberIdAndType;
        string SubscriptionId;
        string CategoryGID;
        string CategorySchemeId;
        string UploadedHeaderFileWPath, UploadedHeaderFolderPath;
        string OriginalDBNId;
        string[] DBDetails;
        Registry.RegistryService Service;
        XmlDocument Query;
        XmlElement Element;
        XmlDocument Response;
        XmlDocument UploadedHeaderXml;
        SDMXObjectModel.Message.RegistryInterfaceType SubRegistryInterface;
        SDMXObjectModel.Message.StructureHeaderType Header;
        List<bool> isSOAPMailIds;
        List<string> notificationMailIds;
        List<bool> isSOAPHTTPs;
        List<string> notificationHTTPs;
        DateTime startDate;
        DateTime endDate;
        Dictionary<string, string> dictCategories;
        string AgencyId;

        RetVal = "true";
        Service = new Registry.RegistryService();
        Query = new XmlDocument();
        Response = new XmlDocument();
        Element = null;
        SubRegistryInterface = new SDMXObjectModel.Message.RegistryInterfaceType();
        Action = string.Empty;
        NotificationMail = string.Empty;
        NotificationHTTP = string.Empty;
        IsSOAP = 0;
        SubscriberAssignedID = string.Empty;
        StartDate = string.Empty;
        EndDate = string.Empty;
        EventSelector = string.Empty;
        CategoriesGIDAndSchemeIds = string.Empty;
        MFDId = string.Empty;
        DbNId = string.Empty;
        CodelistId = string.Empty;
        SubscriberIdAndType = string.Empty;
        CategoryGID = string.Empty;
        CategorySchemeId = string.Empty;
        isSOAPMailIds = new List<bool>();
        notificationMailIds = new List<string>();
        isSOAPHTTPs = new List<bool>();
        notificationHTTPs = new List<string>();
        dictCategories = new Dictionary<string, string>();
        AgencyId = string.Empty;
        Header = new SDMXObjectModel.Message.StructureHeaderType();
        UploadedHeaderXml = new XmlDocument();
        UploadedHeaderFolderPath = Server.MapPath("../../stock/data");
        OriginalDBNId = string.Empty;
        DBDetails = null;
        UploadedHeaderFileWPath = string.Empty;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);

            Action = Params[0];
            NotificationMail = Params[1];
            NotificationHTTP = Params[2];
            IsSOAP = Convert.ToInt16(Params[3]);
            StartDate = Params[4];
            EndDate = Params[5];
            EventSelector = Params[6];
            CategoriesGIDAndSchemeIds = Params[7];
            MFDId = Params[8];
            DbNId = Params[9];
            SubscriberIdAndType = Params[10];
            SubscriptionId = Params[11];
            OriginalDBNId = Params[12];
            AgencyId = Global.Get_AgencyId_From_DFD(DbNId.ToString());

            DBDetails = Global.GetDbConnectionDetails(DbNId);

            if (DbNId != OriginalDBNId && DBDetails[4] == "true")
            {
                UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + OriginalDBNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;

            }
            else
            {
                UploadedHeaderFileWPath = UploadedHeaderFolderPath + "/" + DbNId + "/" + "sdmx" + "/" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName;
            }
            SDMXObjectModel.Message.StructureType UploadedDSDStructure = new SDMXObjectModel.Message.StructureType();

            if (File.Exists(UploadedHeaderFileWPath))
            {
                UploadedHeaderXml.Load(UploadedHeaderFileWPath);
                UploadedDSDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), UploadedHeaderXml);
                Header = UploadedDSDStructure.Header;
            }

            if (IsSOAP == 0)
            {
                isSOAPMailIds = new List<bool>();
                isSOAPMailIds.Add(false);
                isSOAPHTTPs = new List<bool>();
                isSOAPHTTPs.Add(false);
            }
            else
            {
                isSOAPMailIds = new List<bool>();
                isSOAPMailIds.Add(true);
                isSOAPHTTPs = new List<bool>();
                isSOAPHTTPs.Add(true);
            }
            notificationMailIds = new List<string>();
            notificationMailIds.Add(NotificationMail);
            notificationHTTPs = new List<string>();
            notificationHTTPs.Add(NotificationHTTP);

            startDate = DateTime.ParseExact(StartDate.ToString().Trim(), "dd-MM-yyyy", null);
            endDate = DateTime.ParseExact(EndDate.ToString().Trim(), "dd-MM-yyyy", null);
            dictCategories = new Dictionary<string, string>();
            if (EventSelector == "Data Registration")
            {
                foreach (string CategoryGIDAndSchemeId in Global.SplitString(CategoriesGIDAndSchemeIds, ","))
                {
                    CategoryGID = CategoryGIDAndSchemeId.Split('|')[0];
                    CategorySchemeId = CategoryGIDAndSchemeId.Split('|')[1];
                    dictCategories.Add(CategoryGID, CategorySchemeId);
                }
            }
            Query = GetQueryXmlDocumentForSubmitSubscription(ActionType.Delete, SubscriberIdAndType, AgencyId, isSOAPMailIds, notificationMailIds, isSOAPHTTPs, notificationHTTPs, startDate, endDate, EventSelector, dictCategories, MFDId, SubscriptionId,Header);
            Element = Query.DocumentElement;

            Service.Url = HttpContext.Current.Request.Url.OriginalString.Substring(0, HttpContext.Current.Request.Url.OriginalString.IndexOf("libraries")) + Constants.FolderName.SDMX.RegistryServicePath;
            Service.Url += "?p=" + DbNId.ToString();

            Service.SubmitSubscription(ref Element, string.Empty);
            Response.LoadXml(Element.OuterXml);
            SubRegistryInterface = (SDMXObjectModel.Message.RegistryInterfaceType)(SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.RegistryInterfaceType), Response));
            if (((SDMXObjectModel.Registry.SubmitSubscriptionsResponseType)(SubRegistryInterface.Item)).SubscriptionStatus[0].StatusMessage.status == SDMXObjectModel.Registry.StatusType.Success)
            {
                RetVal = "true";
            }
            else
            {
                RetVal = "false";
            }
        }
        catch (Exception ex)
        {
            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            Global.CreateExceptionString(ex, null);
        }
        finally
        {
        }

        return RetVal;
    }
コード例 #14
0
    /// <summary>
    /// Sets header details to di structure header object and return object
    /// </summary>
    /// <param name="ObjHeaderDet">Class containg fields for header detail</param>
    /// <returns>Structure header object with fields initlized</returns>
    private SDMXObjectModel.Message.StructureHeaderType GetDiMessageHeaderStructure(HeaderDetailsTemplate ObjHeaderDet)
    {
        SDMXObjectModel.Message.StructureHeaderType ObjStructureHeader = null;
        SenderType Sender;
        PartyType Receiver;
        Sender = new SenderType(ObjHeaderDet.SenderId, ObjHeaderDet.SenderName, ObjHeaderDet.LanguageCode, new SDMXObjectModel.Message.ContactType(ObjHeaderDet.SenderContactName, ObjHeaderDet.SenderDepartment, ObjHeaderDet.SenderRole, ObjHeaderDet.LanguageCode));
        Sender.Contact[0].Items = new string[] { ObjHeaderDet.SenderTelephone, ObjHeaderDet.SenderEmail, ObjHeaderDet.SenderFax };
        Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        Receiver = new PartyType(ObjHeaderDet.RecieverId, ObjHeaderDet.RecieverName, ObjHeaderDet.LanguageCode, new SDMXObjectModel.Message.ContactType(ObjHeaderDet.RecieverContactName, ObjHeaderDet.RecieverDepartment, ObjHeaderDet.RecieverRole, ObjHeaderDet.LanguageCode));
        Receiver.Contact[0].Items = new string[] { ObjHeaderDet.RecieverTelephone, ObjHeaderDet.RecieverEmail, ObjHeaderDet.RecieverFax };
        Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        ObjStructureHeader = new StructureHeaderType(ObjHeaderDet.HeaderId, true, DateTime.Now, Sender, Receiver);
        return ObjStructureHeader;
    }