private static List<string> Get_Registrations_OverlapList(RegistrationType Registration, bool IsMetadata, bool IsAdminUploadedDSD) { List<string> RetVal; string FileURL, WSURL, Content, ElementName, AttributeName, PAIdPrefixRemoved, MFDId; WebRequest Request; WebResponse Response; StreamReader DataReader; Stream DataStream; XmlElement QueryElement; Registry.RegistryService Service; XmlDocument FileXML; RetVal = new List<string>(); FileURL = string.Empty; WSURL = string.Empty; Content = string.Empty; ElementName = string.Empty; AttributeName = string.Empty; PAIdPrefixRemoved = string.Empty; MFDId = string.Empty; Request = null; Response = null; DataReader = null; DataStream = null; QueryElement = null; Service = new Registry.RegistryService(); FileXML = new XmlDocument(); if (IsMetadata == false) { if (Registration.Datasource[0] is SDMXObjectModel.Registry.QueryableDataSourceType) { WSURL = ((SDMXObjectModel.Registry.QueryableDataSourceType)Registration.Datasource[0]).DataURL; if (Registration.Datasource.Count == 2) { FileURL = Registration.Datasource[1].ToString(); } } else { FileURL = Registration.Datasource[0].ToString(); if (Registration.Datasource.Count == 2) { WSURL = ((SDMXObjectModel.Registry.QueryableDataSourceType)Registration.Datasource[1]).DataURL; } } if (IsAdminUploadedDSD == false) { if (!string.IsNullOrEmpty(FileURL)) { Request = WebRequest.Create(FileURL); Response = Request.GetResponse(); DataStream = Response.GetResponseStream(); DataReader = new StreamReader(DataStream); Content = DataReader.ReadToEnd(); } else if (!string.IsNullOrEmpty(WSURL)) { QueryElement = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, null, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.SeriesKeyOnly, DevInfo.Lib.DI_LibSDMX.Constants.AgencyId, null, null).DocumentElement; Service.Url = WSURL.ToString(); Service.GetStructureSpecificTimeSeriesData(ref QueryElement); Content = QueryElement.OuterXml; } ElementName = "Series"; AttributeName = DevInfo.Lib.DI_LibSDMX.Constants.Concept.INDICATOR.Id; } else { if (!string.IsNullOrEmpty(FileURL)) { Request = WebRequest.Create(FileURL); Response = Request.GetResponse(); DataStream = Response.GetResponseStream(); DataReader = new StreamReader(DataStream); Content = DataReader.ReadToEnd(); } ElementName = SDMXApi_2_0.Constants.Namespaces.Prefixes.DevInfo + ":" + "Series"; AttributeName = Constants.UNSD.Concept.Indicator.Id; } FileXML.LoadXml(Content); foreach (XmlNode Series in FileXML.GetElementsByTagName(ElementName)) { if (!RetVal.Contains(Series.Attributes[AttributeName].Value)) { RetVal.Add(Series.Attributes[AttributeName].Value); } } } else { if (Registration.ProvisionAgreement != null && Registration.ProvisionAgreement.Items != null && Registration.ProvisionAgreement.Items.Count > 0) { PAIdPrefixRemoved = ((ProvisionAgreementRefType)Registration.ProvisionAgreement.Items[0]).id.Replace(DevInfo.Lib.DI_LibSDMX.Constants.PA.Prefix, string.Empty); MFDId = PAIdPrefixRemoved.Substring(PAIdPrefixRemoved.IndexOf('_') + 1); RetVal.Add(MFDId); } } return RetVal; }
public string GetDataQueryResponseSDMXML(string requestParam) { string RetVal; string[] Params; int DBNId, SDMXFormat, RequestType; string Request; XmlDocument Query, SDMXML; XmlElement Element; DIConnection DIConnection; DIQueries DIQueries; Registry.RegistryService Service; string SOAPMethodName; WebRequest WebRequest; StreamReader ResponseReader; RetVal = string.Empty; Params = null; DBNId = -1; Request = string.Empty; Query = new XmlDocument(); SDMXML = new XmlDocument(); Element = null; DIConnection = null; DIQueries = null; Service = new Registry.RegistryService(); SOAPMethodName = string.Empty; WebRequest = null; ResponseReader = null; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); DBNId = Convert.ToInt32(Params[0].ToString().Trim()); RequestType = Convert.ToInt32(Params[1].ToString().Trim()); Request = this.Server.HtmlDecode(Params[2].ToString().Trim()); SDMXFormat = Convert.ToInt32(Params[3].ToString().Trim()); DIConnection = Global.GetDbConnection(DBNId); DIQueries = new DIQueries(DIConnection.DIDataSetDefault(), DIConnection.DILanguageCodeDefault(DIConnection.DIDataSetDefault())); switch (RequestType) { case 0://SOAP Query.LoadXml(Request); Element = Query.DocumentElement; //HttpContext.Current.RewritePath("~/libraries/ws/RegistryService.asmx"); //Service.Url = HttpContext.Current.Request.Url.ToString(); 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(); switch ((DataFormats)SDMXFormat) { case DataFormats.Generic: SOAPMethodName = "GetGenericData"; try { Service.GetGenericData(ref Element); SDMXML.LoadXml(Element.OuterXml); RetVal = this.Get_Formatted_XML(SDMXML); } catch (SoapException SOAPex) { SDMXML.LoadXml(SOAPex.Detail.InnerText); RetVal = this.Get_Formatted_XML(SDMXML); Global.CreateExceptionString(SOAPex, null); } break; case DataFormats.GenericTS: SOAPMethodName = "GetGenericTimeSeriesData"; try { Service.GetGenericTimeSeriesData(ref Element); SDMXML.LoadXml(Element.OuterXml); RetVal = this.Get_Formatted_XML(SDMXML); } catch (SoapException SOAPex) { SDMXML.LoadXml(SOAPex.Detail.InnerText); RetVal = this.Get_Formatted_XML(SDMXML); Global.CreateExceptionString(SOAPex, null); } break; case DataFormats.StructureSpecific: SOAPMethodName = "GetStructureSpecificData"; try { Service.GetStructureSpecificData(ref Element); SDMXML.LoadXml(Element.OuterXml); RetVal = this.Get_Formatted_XML(SDMXML); } catch (SoapException SOAPex) { SDMXML.LoadXml(SOAPex.Detail.InnerText); RetVal = this.Get_Formatted_XML(SDMXML); Global.CreateExceptionString(SOAPex, null); } break; case DataFormats.StructureSpecificTS: SOAPMethodName = "GetStructureSpecificTimeSeriesData"; try { Service.GetStructureSpecificTimeSeriesData(ref Element); SDMXML.LoadXml(Element.OuterXml); RetVal = this.Get_Formatted_XML(SDMXML); } catch (SoapException SOAPex) { SDMXML.LoadXml(SOAPex.Detail.InnerText); RetVal = this.Get_Formatted_XML(SDMXML); Global.CreateExceptionString(SOAPex, null); } break; } RetVal += Constants.Delimiters.ParamDelimiter + Service.Url; RetVal += Constants.Delimiters.ParamDelimiter + SOAPMethodName; break; case 1://REST WebRequest = WebRequest.Create(Request); switch ((DataFormats)SDMXFormat) { case DataFormats.Generic: WebRequest.ContentType = Constants.WSQueryStrings.SDMXContentTypes.Generic; break; case DataFormats.GenericTS: WebRequest.ContentType = Constants.WSQueryStrings.SDMXContentTypes.GenericTS; break; case DataFormats.StructureSpecific: WebRequest.ContentType = Constants.WSQueryStrings.SDMXContentTypes.StructureSpecific; break; case DataFormats.StructureSpecificTS: WebRequest.ContentType = Constants.WSQueryStrings.SDMXContentTypes.StructureSpecificTS; break; } ResponseReader = new StreamReader(WebRequest.GetResponse().GetResponseStream()); SDMXML.LoadXml(ResponseReader.ReadToEnd()); RetVal = this.Get_Formatted_XML(SDMXML); break; case 2://HTTP WebRequest = WebRequest.Create(Request); ResponseReader = new StreamReader(WebRequest.GetResponse().GetResponseStream()); SDMXML.LoadXml(ResponseReader.ReadToEnd()); RetVal = this.Get_Formatted_XML(SDMXML); break; default: break; } } catch (Exception ex) { RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }