public string AdminCheckIfDSDAlreadyUploaded(string requestParam) { string RetVal = string.Empty; string DBFile = string.Empty; XmlDocument XmlDoc; XmlNodeList XmlNodes; int i = 0; bool ValidDSD = true; XmlDocument UploadedDSDXml = new XmlDocument(); string UploadedDSDFileWPath = string.Empty; string UploadedDSDId = string.Empty; string UploadedDSDAgencyId = string.Empty; string UploadedDSDVersion = string.Empty; string DbNId = string.Empty; string[] Params; string ErrorMessage = string.Empty; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); UploadedDSDFileWPath = Params[0]; DbNId = Params[1]; UploadedDSDXml.Load(UploadedDSDFileWPath); 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), UploadedDSDXml); if (UploadedDSDStructure.KeyFamilies.Count > 0) { UploadedDSDId = UploadedDSDStructure.KeyFamilies[0].id; UploadedDSDAgencyId = UploadedDSDStructure.KeyFamilies[0].agencyID; UploadedDSDVersion = UploadedDSDStructure.KeyFamilies[0].version; DBFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]); XmlDoc = new XmlDocument(); XmlDoc.Load(DBFile); XmlNodes = XmlDoc.GetElementsByTagName("db"); for (i = 0; i < XmlNodes.Count; i++) { if (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value != DbNId) { if ((XmlNodes[i].Attributes["sdmxdb"].Value == "true") && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId] != null) && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId] != null) && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion] != null)) { if ((UploadedDSDId == XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId].Value) && (UploadedDSDAgencyId == XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId].Value) && (UploadedDSDVersion == XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion].Value)) { ValidDSD = false; ErrorMessage = "A DSD with same Id, Agency Id, Version has been uploaded.Please upload different DSD."; } } } } } else { ValidDSD = false; ErrorMessage = "Invalid SDMX Artifact"; } RetVal = ValidDSD.ToString()+Constants.Delimiters.ParamDelimiter+ErrorMessage; } catch (Exception ex) { Global.CreateExceptionString(ex, null); RetVal = "false"; } return RetVal; }
private void Send_Notifications_For_Subscriptions_For_Structural_Metadata_Changes(string DbNId) { Dictionary<string, SubscriptionType> DictSubscriptions; List<ArtefactRef> ListOfArtefactRefs; bool IsAdminUploadedDSD; string ArtefactLanguage, ArtefactName, ArtefactDescription; ListOfArtefactRefs = new List<ArtefactRef>(); ArtefactLanguage = string.Empty; ArtefactName = string.Empty; ArtefactDescription = string.Empty; try { IsAdminUploadedDSD = Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DbNId)); if (IsAdminUploadedDSD) { SDMXApi_2_0.Message.StructureType Summary; Summary = new SDMXApi_2_0.Message.StructureType(); Summary = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNId + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); foreach (SDMXApi_2_0.Structure.KeyFamilyType DSD in Summary.KeyFamilies) { if ((DSD.Name != null) && (DSD.Name.Count > 0)) { ArtefactLanguage = DSD.Name[0].lang; ArtefactName = DSD.Name[0].Value; } if ((DSD.Description != null) && (DSD.Description.Count > 0)) { ArtefactDescription = DSD.Description[0].Value; } ListOfArtefactRefs.Add(new ArtefactRef(DSD.id, DSD.agencyID, DSD.version, ArtefactLanguage, ArtefactName, ArtefactDescription, ArtefactTypes.DSD)); } foreach (SDMXApi_2_0.Structure.MetadataStructureDefinitionType MSD in Summary.MetadataStructureDefinitions) { if ((MSD.Name != null) && (MSD.Name.Count > 0)) { ArtefactLanguage = MSD.Name[0].lang; ArtefactName = MSD.Name[0].Value; } if ((MSD.Description != null) && (MSD.Description.Count > 0)) { ArtefactDescription = MSD.Description[0].Value; } ListOfArtefactRefs.Add(new ArtefactRef(MSD.id, MSD.agencyID, MSD.version, ArtefactLanguage, ArtefactName, ArtefactDescription, ArtefactTypes.MSD)); } } else { SDMXObjectModel.Message.StructureType Summary; Summary = new SDMXObjectModel.Message.StructureType(); Summary = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNId + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); foreach (SDMXObjectModel.Structure.DataStructureType DSD in Summary.Structures.DataStructures) { if ((DSD.Name != null) && (DSD.Name.Count > 0)) { ArtefactLanguage = DSD.Name[0].lang; ArtefactName = DSD.Name[0].Value; } if ((DSD.Description != null) && (DSD.Description.Count > 0)) { ArtefactDescription = DSD.Description[0].Value; } ListOfArtefactRefs.Add(new ArtefactRef(DSD.id, DSD.agencyID, DSD.version, ArtefactLanguage, ArtefactName, ArtefactDescription, ArtefactTypes.DSD)); } foreach (SDMXObjectModel.Structure.MetadataStructureType MSD in Summary.Structures.MetadataStructures) { if ((MSD.Name != null) && (MSD.Name.Count > 0)) { ArtefactLanguage = MSD.Name[0].lang; ArtefactName = MSD.Name[0].Value; } if ((MSD.Description != null) && (MSD.Description.Count > 0)) { ArtefactDescription = MSD.Description[0].Value; } ListOfArtefactRefs.Add(new ArtefactRef(MSD.id, MSD.agencyID, MSD.version, ArtefactLanguage, ArtefactName, ArtefactDescription, ArtefactTypes.MSD)); } } DictSubscriptions = this.Get_Subscriptions_Dictionary_For_Structural_Metadata_Changes(DbNId); foreach (string RegistryURN in DictSubscriptions.Keys) { this.Send_Notifications_For_Current_Subscription_For_Structural_Metadata_Changes(DictSubscriptions[RegistryURN], ListOfArtefactRefs); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } }
public string BindDataProviders(string requestParam) { string RetVal; DIConnection DIConnection; int NoOfDPs; StringBuilder sb; string PAPath = string.Empty; string PAViewPath = string.Empty; DataTable dt = new DataTable(); bool IsAdminUploadedDSD; SDMXApi_2_0.Message.StructureType SummaryStructureFor2_0 = new SDMXApi_2_0.Message.StructureType(); SDMXObjectModel.Message.StructureType SummaryStructureFor2_1 = new SDMXObjectModel.Message.StructureType(); Dictionary<string, bool> DictColumns; DataTable DtDFD; DataTable DtMFDs; string Query = string.Empty; string DFDPath = string.Empty; string MFDPath = string.Empty; DIConnection = null; RetVal = string.Empty; string hdbnid = string.Empty; string hlngcodedb = string.Empty; string hlngcode = string.Empty; string[] Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); int i; hdbnid = Params[0]; hlngcodedb = Params[1]; hlngcode = Params[2]; IsAdminUploadedDSD = false; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT * FROM Artefacts WHERE DBNId = " + Convert.ToInt32(hdbnid) + " AND Type=4;"; DtDFD = DIConnection.ExecuteDataTable(Query); Query = "SELECT * FROM Artefacts WHERE DBNId = " + Convert.ToInt32(hdbnid) + " AND Type=16;"; DtMFDs = DIConnection.ExecuteDataTable(Query); IsAdminUploadedDSD = Global.IsDSDUploadedFromAdmin(Convert.ToInt32(hdbnid)); if (IsAdminUploadedDSD == false) { SummaryStructureFor2_1 = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); } sb = new StringBuilder(); sb.Append(GetlanguageBasedValueOfKey("langFirstName", hlngcode, "RegProviders.xml")); sb.Append("~"); sb.Append(GetlanguageBasedValueOfKey("langLastName", hlngcode, "RegProviders.xml")); sb.Append("~"); sb.Append(GetlanguageBasedValueOfKey("langCountry", hlngcode, "RegProviders.xml")); sb.Append("~"); sb.Append(GetlanguageBasedValueOfKey("langEmail", hlngcode, "RegProviders.xml")); sb.Append("~"); DictColumns = new Dictionary<string, bool>(); if (IsAdminUploadedDSD == true) { if (DtDFD != null && DtDFD.Rows.Count > 0) { DFDPath = DtDFD.Rows[0]["FileLocation"].ToString(); SDMXObjectModel.Message.StructureType DFD = new SDMXObjectModel.Message.StructureType(); DFD = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), DFDPath); DictColumns.Add(DFD.Structures.Dataflows[0].id, false); sb.Append(GetlanguageBasedValueOfKey("langProvisionAgreementFor", hlngcode, "RegProviders.xml") + GetLangSpecificValue_For_Version_2_1(DFD.Structures.Dataflows[0].Name, hlngcodedb)); sb.Append("~"); } if (DtMFDs != null && DtMFDs.Rows.Count > 0) { for (i = 0; i < DtMFDs.Rows.Count; i++) { MFDPath = DtMFDs.Rows[i]["FileLocation"].ToString(); SDMXObjectModel.Message.StructureType MFD = new SDMXObjectModel.Message.StructureType(); MFD = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), MFDPath); DictColumns.Add(MFD.Structures.Metadataflows[i].id, false); sb.Append(GetlanguageBasedValueOfKey("langProvisionAgreementFor", hlngcode, "RegProviders.xml") + GetLangSpecificValue_For_Version_2_1(MFD.Structures.Metadataflows[i].Name, hlngcodedb)); sb.Append("~"); } } } else { foreach (SDMXObjectModel.Structure.DataflowType DFD in SummaryStructureFor2_1.Structures.Dataflows) { DictColumns.Add(DFD.id, false); sb.Append(GetlanguageBasedValueOfKey("langProvisionAgreementFor", hlngcode, "RegProviders.xml") + GetLangSpecificValue_For_Version_2_1(DFD.Name, hlngcodedb)); sb.Append("~"); } foreach (SDMXObjectModel.Structure.MetadataflowType MFD in SummaryStructureFor2_1.Structures.Metadataflows) { DictColumns.Add(MFD.id, true); sb.Append(GetlanguageBasedValueOfKey("langProvisionAgreementFor", hlngcode, "RegProviders.xml") + GetLangSpecificValue_For_Version_2_1(MFD.Name, hlngcodedb)); sb.Append("~"); } } sb.Remove(sb.Length - 1, 1); sb.Append(Constants.Delimiters.ParamDelimiter); if (ConfigurationManager.AppSettings[Constants.WebConfigKey.IsGlobalAllow].ToLower() == "true") { diworldwide_userinfo.UserLoginInformation Service = new diworldwide_userinfo.UserLoginInformation(); Service.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.UserLoginService; dt = Service.GetAllDataProviders(Global.GetAdaptationGUID()); } else { Query = "Select NId,User_First_Name,User_Last_Name,User_Country as [User Country],User_Email_Id from Users where User_Is_Provider='True';"; dt = DIConnection.ExecuteDataTable(Query); } dt = this.Replace_AreaNIds_With_Names(dt); NoOfDPs = dt.Rows.Count; // Binding Data Providers for (i = 0; i < NoOfDPs; i++) { if (Global.Is_Already_Existing_Provider(dt.Rows[i]["NId"].ToString())) { sb.Append("" + dt.Rows[i]["User_First_Name"] + ""); sb.Append("~"); sb.Append("" + dt.Rows[i]["User_Last_Name"] + ""); sb.Append("~"); sb.Append("" + dt.Rows[i]["User Country"] + ""); sb.Append("~"); sb.Append("" + dt.Rows[i]["User_Email_Id"] + ""); sb.Append("~"); foreach (string Id in DictColumns.Keys) { PAPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\Provisioning Metadata\\PAs\\" + "PA_" + dt.Rows[i]["NId"] + "_" + Id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); PAViewPath = "../../" + PAPath.Substring(PAPath.LastIndexOf("stock")).Replace("\\", "/"); sb.Append("<a href=\" " + PAViewPath + "\" "); sb.Append(" target=\"_blank\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + PAPath + "' name=\"lang_Download\"></a>"); sb.Append("~"); } sb.Remove(sb.Length - 1, 1); sb.Append(Constants.Delimiters.PivotRowDelimiter); } } sb.Remove(sb.Length - 1, 1); RetVal = sb.ToString(); } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } return RetVal; }
private bool CreateCompleteFileForUploadedDSD(SDMXApi_2_0.Message.StructureType UploadedDSDStructure, string sdmxFolderPath, int DbNId, string UserNId) { bool RetVal; SDMXApi_2_0.Message.StructureType Complete; string AgencyId; string AppPhysicalPath; string DbFolder; RetVal = true; AgencyId = string.Empty; try { AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + UserNId; AppPhysicalPath = HttpContext.Current.Request.PhysicalApplicationPath; DbFolder = Constants.FolderName.Data + DbNId.ToString() + "\\"; Complete = new SDMXApi_2_0.Message.StructureType(); Complete.Header = UploadedDSDStructure.Header; Complete.Concepts = UploadedDSDStructure.Concepts; Complete.KeyFamilies = UploadedDSDStructure.KeyFamilies; Complete.CodeLists = UploadedDSDStructure.CodeLists; Complete.MetadataStructureDefinitions = UploadedDSDStructure.MetadataStructureDefinitions; Complete.OrganisationSchemes = null; Complete.HierarchicalCodelists = null; Complete.Metadataflows = null; Complete.Processes = null; Complete.ReportingTaxonomies = null; Complete.StructureSets = null; Complete.CategorySchemes = null; Complete.Dataflows = null; foreach (SDMXApi_2_0.Structure.CodeListType CodeList in Complete.CodeLists) { foreach (SDMXApi_2_0.Structure.CodeType Code in CodeList.Code) { Code.Annotations = null; } } //Creating Complete file and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), Complete, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Complete_XML.FileName); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, DevInfo.Lib.DI_LibSDMX.Constants.Complete_XML.Id, AgencyId, DevInfo.Lib.DI_LibSDMX.Constants.Complete_XML.Version, string.Empty, ArtefactTypes.Complete, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Complete_XML.FileName, DevInfo.Lib.DI_LibSDMX.Constants.Complete_XML.FileName); } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Artefacts For Uploaded DSD From Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
public string AdminRegisterDatabaseForUploadedDSD(string requestParam) { string RetVal = string.Empty; string AssosciatedDb = string.Empty; string[] Params; string DBConnectionsFile = string.Empty; XmlDocument UploadedDSDXml = new XmlDocument(); XmlDocument XmlDoc; XmlNode xmlNode; string UploadedDSDFileWPath = string.Empty; string UploadedDSDFolderPath = Server.MapPath("../../stock/data"); string UploadedDSDName = string.Empty; string UserNId = string.Empty; bool DefaultDB = false; XmlElement NewNode; int NewId = 0; XmlNodeList ObjXmlNodeList; XmlNodeList CategoryNodeList; int CategoryId = 0; string CategoryName = string.Empty; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); UploadedDSDFileWPath = Params[0]; AssosciatedDb = Params[1]; UserNId = Params[2]; if (Params.Length > 3) { if (!bool.TryParse(Params[3], out DefaultDB)) { DefaultDB = false; } } UploadedDSDXml.Load(UploadedDSDFileWPath); 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), UploadedDSDXml); if ((UploadedDSDStructure.CodeLists.Count > 0) && (UploadedDSDStructure.KeyFamilies.Count > 0)) { //&& (UploadedDSDStructure.Concepts.Concept.Count > 0) //------------------------ Updating db.xml by creating new entry for Uploaded DSD-------------------------------------- DBConnectionsFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]); XmlDoc = new XmlDocument(); XmlDoc.Load(DBConnectionsFile); CategoryNodeList = XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Category); CategoryName = CategoryNodeList[0].Attributes[Constants.XmlFile.Db.Tags.CategoryAttributes.Name].Value; xmlNode = XmlDoc.SelectSingleNode("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "[@" + Constants.XmlFile.Db.Tags.CategoryAttributes.Name + "='" + CategoryName + "']"); // Get old higher id ObjXmlNodeList = XmlDoc.SelectNodes("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "/" + "child::node()"); foreach (XmlNode data in ObjXmlNodeList) { CategoryId = int.Parse(data.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value); if (NewId < CategoryId) { NewId = CategoryId; } } // Increase 1 for new id NewId++; if (UploadedDSDStructure.KeyFamilies[0].Name.Count > 0) { UploadedDSDName = GetLangSpecificValueFor_Version_2_0(UploadedDSDStructure.KeyFamilies[0].Name, "en"); if (string.IsNullOrEmpty(UploadedDSDName)) { UploadedDSDName = "DSD"; } } else { UploadedDSDName = "DSD"; } //Create new element node and set its attributes NewNode = XmlDoc.CreateElement(Constants.XmlFile.Db.Tags.Database); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.Id, NewId.ToString()); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.Name, UploadedDSDName); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.SDMXDb, "true"); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId, UploadedDSDStructure.KeyFamilies[0].id); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId, UploadedDSDStructure.KeyFamilies[0].agencyID); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion, UploadedDSDStructure.KeyFamilies[0].version); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.AssosciatedDb, AssosciatedDb); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.Count, ""); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DefaultLanguage, "en"); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DefaultArea, ""); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DefaultAreaJSON, ""); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DefaultAreaCount, ""); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DatabaseConnection, ""); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.AvailableLanguage, "en"); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.LastModified, string.Format("{0:yyyy-MM-dd}", DateTime.Today.Date)); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.DescriptionEnglish, UploadedDSDName); NewNode.SetAttribute(Constants.XmlFile.Db.Tags.DatabaseAttributes.IsSDMXHeaderCreated, "true"); xmlNode.AppendChild(NewNode); //Now the defDSD attribute of Category will consume default dsd id. if (DefaultDB == true) { if (XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD] == null) { XmlElement root = XmlDoc.DocumentElement; // Add a new attribute. root.SetAttribute(Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD, NewId.ToString()); } else { XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD].Value = NewId.ToString(); } } //else //{ // if (XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD] != null) // { // XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD].Value = ""; // } //} File.SetAttributes(DBConnectionsFile, FileAttributes.Normal); XmlDoc.Save(DBConnectionsFile); //----------------------------------------------------------------------------------------------------------------- //----------------------Creation of folder structure for uploaded DSD as per the New Id alloted to it in db.xml---- UploadedDSDFolderPath = UploadedDSDFolderPath + "/" + NewId.ToString(); RetVal = CreateFolderStructureForUploadedDSD(UploadedDSDFolderPath).ToString(); //----------------------Creation of Complete File for uploaded DSD as per the New Id alloted to it in db.xml--------- RetVal = CreateCompleteFileForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", NewId, UserNId).ToString(); //----------------------Creation of Header File for uploaded DSD as per the New Id alloted to it in db.xml--------- RetVal = CreateHeaderFileForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", NewId, UserNId).ToString(); //----------------------Creation of Codelists for uploaded DSD as per the New Id alloted to it in db.xml--------- RetVal = CreateCodelistsForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx" + "/" + "Codelists", NewId).ToString(); //----------------------Creation of a Category Scheme for uploaded DSD as per the New Id alloted to it in db.xml--------- RetVal = CreateCategorySchemeForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", NewId, Convert.ToInt32(AssosciatedDb), UserNId).ToString(); //----------------------Creation of a Report for uploaded DSD as per the New Id alloted to it in db.xml--------- RetVal = CreateReportForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", NewId, UserNId).ToString(); //----------------------Creation of Other Artefacts for uploaded DSD as per the New Id alloted to it in db.xml----------- RetVal = CreateArtefactsForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", NewId, UserNId).ToString(); Session["hdbnid"] = Convert.ToString(NewId); } else { RetVal = "DSD does not contains codelists or concepts of key family listing."; } if (RetVal == "true") { File.Delete(UploadedDSDFileWPath); } } catch (Exception ex) { //Global.WriteErrorsInLog("Uploading DSD from Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = ex.Message; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
public bool CreateHeaderFileForUploadedDSD(SDMXApi_2_0.Message.StructureType UploadedDSDStructure, string sdmxFolderPath, int DbNId, string UserNId) { bool RetVal; SDMXApi_2_0.Message.StructureType Header; // SDMXApi_2_0.Message.HeaderType Header; string AgencyId; string AppPhysicalPath; string DbFolder; RetVal = true; AgencyId = string.Empty; try { AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + UserNId; AppPhysicalPath = HttpContext.Current.Request.PhysicalApplicationPath; DbFolder = Constants.FolderName.Data + DbNId.ToString() + "\\"; Header = new SDMXApi_2_0.Message.StructureType(); //Header.ID = UploadedDSDStructure.Header.ID; //Header.Name = UploadedDSDStructure.Header.na; //Header.Test = UploadedDSDStructure.Header.Sender; //Header.Prepared = UploadedDSDStructure.Header.Sender; //Header.Sender = UploadedDSDStructure.Header.Sender; //Header.Receiver = UploadedDSDStructure.Header.Receiver; Header.Header = UploadedDSDStructure.Header; Header.Concepts = null; Header.KeyFamilies = null; Header.CodeLists = null; Header.MetadataStructureDefinitions = null; Header.OrganisationSchemes = null; Header.HierarchicalCodelists = null; Header.Metadataflows = null; Header.Processes = null; Header.ReportingTaxonomies = null; Header.StructureSets = null; Header.CategorySchemes = null; Header.Dataflows = null; Remove_Extra_Annotations(Header); //Creating Header file and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), Header, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, DevInfo.Lib.DI_LibSDMX.Constants.Header.Id, string.Empty, string.Empty, string.Empty, ArtefactTypes.Header, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName, DevInfo.Lib.DI_LibSDMX.Constants.Header.FileName); } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Artefacts For Uploaded DSD From Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
private void BindDimensionsAttributesMeasure_For_Version_2_0() { XmlDocument SummaryXml; string DSDViewPath, DSDPath; SummaryXml = new XmlDocument(); int i, j; StringBuilder sb; SDMXApi_2_0.Message.StructureType SummaryStructure = new SDMXApi_2_0.Message.StructureType(); string AttributeImportance = string.Empty; //Providing the Path of the Summary.xml SummaryXml.Load(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); //Loading Summary objects from its XML document into 'DataStructuresType' Summary object SummaryStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), SummaryXml); DSDViewPath = "../../" + Constants.FolderName.Data + hdbnid + "\\sdmx\\DSD" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension; DSDPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\DSD" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); //Binding DSD sb = new StringBuilder(); sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("<b>"); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.KeyFamilies[0].Name, hlngcodedb)); sb.Append("</b>"); if (SummaryStructure.KeyFamilies[0].Description.Count > 0) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.KeyFamilies[0].Description, hlngcodedb)); sb.Append(")</span> "); } sb.Append("</div>"); sb.Append("<div>"); sb.Append("<a href=\" " + DSDViewPath.Replace("\\", "/") + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + DSDPath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("<br/>"); //Binding Dimensions sb.Append("<h4 id=\"lang_Dimensions\"></h4>"); sb.Append("<ul>"); for (i = 0; i < SummaryStructure.KeyFamilies[0].Components.Dimension.Count; i++) { sb.Append("<li>"); for (j = 0; j < SummaryStructure.Concepts.Concept.Count; j++) { if (SummaryStructure.Concepts.Concept[j].id == SummaryStructure.KeyFamilies[0].Components.Dimension[i].conceptRef) { sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Name, hlngcodedb)); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Description, hlngcodedb)); sb.Append(")</span> "); break; } } sb.Append("</li>"); } //Binding Time Dimension for (j = 0; j < SummaryStructure.Concepts.Concept.Count; j++) { if (SummaryStructure.Concepts.Concept[j].id == SummaryStructure.KeyFamilies[0].Components.TimeDimension.conceptRef) { sb.Append("<li>"); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Name, hlngcodedb)); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Description, hlngcodedb)); sb.Append(")</span> "); sb.Append("</li>"); break; } } sb.Append("</ul>"); divDimensions.InnerHtml = sb.ToString(); //Binding Attributes sb = new StringBuilder(); sb.Append("<h4 id=\"lang_Attributes\"></h4>"); sb.Append("<ul>"); for (i = 0; i < SummaryStructure.KeyFamilies[0].Components.Attribute.Count; i++) { sb.Append("<li>"); for (j = 0; j < SummaryStructure.Concepts.Concept.Count; j++) { if (SummaryStructure.Concepts.Concept[j].id == SummaryStructure.KeyFamilies[0].Components.Attribute[i].conceptRef) { sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Name, hlngcodedb)); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Description, hlngcodedb)); sb.Append(")</span>"); break; } } sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("Attachment Level : "); sb.Append(SummaryStructure.KeyFamilies[0].Components.Attribute[i].attachmentLevel); sb.Append(" , Mandatory : "); if (SummaryStructure.KeyFamilies[0].Components.Attribute[i].assignmentStatus == SDMXApi_2_0.Structure.AssignmentStatusType.Mandatory) { sb.Append("Yes"); } else { sb.Append("No"); } sb.Append("</div>"); sb.Append("</li>"); } sb.Append("</ul>"); divAttributes.InnerHtml = sb.ToString(); //Binding Measure sb = new StringBuilder(); sb.Append("<h4 id=\"lang_Measure\"></h4>"); sb.Append("<ul>"); for (j = 0; j < SummaryStructure.Concepts.Concept.Count; j++) { if (SummaryStructure.Concepts.Concept[j].id == SummaryStructure.KeyFamilies[0].Components.PrimaryMeasure.conceptRef) { sb.Append("<li>"); sb.Append( GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Name, hlngcodedb)); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(SummaryStructure.Concepts.Concept[j].Description, hlngcodedb)); sb.Append(")</span>"); sb.Append("</li>"); break; } } sb.Append("</ul>"); divMeasure.InnerHtml = sb.ToString(); }
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; }
private void BindCodelists_For_Version_2_0() { XmlDocument SummaryXml; SummaryXml = new XmlDocument(); string CodelistPath; string CodelistViewPath; int i; string CodelistName; StringBuilder sb; //Providing the Path of the Summary XML SummaryXml.Load(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); SDMXApi_2_0.Message.StructureType Summary = new SDMXApi_2_0.Message.StructureType(); //Loading Summary Xml into 'StructureType' Composite object Summary = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), SummaryXml); //Binding Codelists sb = new StringBuilder(); sb.Append("<ul>"); for (i = 0; i < Summary.CodeLists.Count; i++) { sb.Append("<li>"); CodelistName = GetLangSpecificValue_For_Version_2_0(Summary.CodeLists[i].Name, hlngcodedb); sb.Append(CodelistName); if (Summary.CodeLists[i].Description.Count > 0) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(Summary.CodeLists[i].Description, hlngcodedb)); sb.Append(")</span>"); } CodelistViewPath = "/data/" + hdbnid + "/sdmx/Codelists/" + Summary.CodeLists[i].Name[0].Value + ".xml"; CodelistPath = "stock/data/" + hdbnid + "/sdmx/Codelists/" + Summary.CodeLists[i].Name[0].Value + ".xml"; sb.Append("<div>"); sb.Append("<a href=\"javascript:void(0);\" "); sb.Append(" onclick=\"ViewCodelist('" + CodelistViewPath + "');\""); sb.Append(" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); //Download Codelist sb.Append("<a class=\"reg_li_link_txt\" href='Download.aspx?fileId=" + CodelistPath + "' name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("</li>"); } sb.Append("</ul>"); divCodelists.InnerHtml = sb.ToString(); }
private void BindDFDAndConceptScheme_For_Version_2_0() { string DFDViewPath, DFDPath; string ConceptSchemeViewPath, ConceptSchemePath; DIConnection DIConnection; string Query; DataTable DtDFD; StringBuilder sb; int i; DIConnection = null; DFDViewPath = string.Empty; DFDPath = string.Empty; ConceptSchemeViewPath = string.Empty; ConceptSchemePath = string.Empty; sb = new StringBuilder(); DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT * FROM Artefacts WHERE DBNId = " + Convert.ToInt32(hdbnid) + " AND Type=4;"; DtDFD = DIConnection.ExecuteDataTable(Query); if (DtDFD != null && DtDFD.Rows.Count > 0) { DFDPath = DtDFD.Rows[0]["FileLocation"].ToString(); DFDViewPath = "../../" + DFDPath.Substring(DFDPath.LastIndexOf("stock")).Replace("\\", "/"); } else { DFDPath = string.Empty; DFDViewPath = string.Empty; } SDMXObjectModel.Message.StructureType DFD = new SDMXObjectModel.Message.StructureType(); DFD = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), DFDPath); sb = new StringBuilder(); sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("<b>"); sb.Append(GetLangSpecificValue_For_Version_2_1(DFD.Structures.Dataflows[0].Name, hlngcodedb)); sb.Append("</b>"); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_1(DFD.Structures.Dataflows[0].Description, hlngcodedb)); sb.Append(")</span> "); sb.Append("</div>"); sb.Append("<div>"); sb.Append("<a href=\" " + DFDViewPath + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + DFDPath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); divDFD.InnerHtml = sb.ToString(); ConceptSchemeViewPath = "../../" + Constants.FolderName.Data + hdbnid + "\\sdmx\\Concepts\\DSD_Concepts" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension; ConceptSchemePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + hdbnid + "\\sdmx\\Concepts\\DSD_Concepts" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); SDMXApi_2_0.Message.StructureType ConceptScheme = new SDMXApi_2_0.Message.StructureType(); ConceptScheme = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), ConceptSchemePath); sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<a href=\" " + ConceptSchemeViewPath.Replace("\\", "/") + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + ConceptSchemePath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("<br/>"); sb.Append("<ul id=\"ulConceptScheme\">"); for (i = 0; i < ConceptScheme.Concepts.Concept.Count; i++) { sb.Append("<li>"); sb.Append("<span>"); sb.Append(GetLangSpecificValue_For_Version_2_0(ConceptScheme.Concepts.Concept[i].Name, hlngcodedb)); sb.Append("</span>"); sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_0(ConceptScheme.Concepts.Concept[i].Description, hlngcodedb)); sb.Append(")</span>"); sb.Append("</li>"); } sb.Append("</ul>"); divConceptScheme.InnerHtml = sb.ToString(); }
private bool InstallPatch7_0_0_10(string DbConnectionstring) { bool RetVal = false; //Step 1. Iterate all dbnids in db.xml //Step 2. Check existence of Header.xml in each \dbnid\sdmx //Step 3. If Header.xml does not exists then create Header.xml using “GenerateHeader()” function (use appropriate function for 2.0 (dbnid > 1)and 2.1 (dbnid=1)) //Step 4. Generate “DataPublishedUserSelection.xml” based on existing mapping using function “()” for each dbnid //Step 5. GenerateandRegister SDMX-ML data file using function “()” //Step 6. Set <item n="IsSDMXHeaderCreated" v="true" /> in appsettings.xml try { Dictionary<string, string> DictConnections = new Dictionary<string, string>(); Dictionary<string, string> DBConnections = Global.GetAllConnections("DevInfo"); string DBConnectionsFile = HttpContext.Current.Server.MapPath("..\\..\\" + ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]); XmlDocument XmlDoc = new XmlDocument(); XmlDoc.Load(DBConnectionsFile); XmlNode xmlNode; XmlDocument UploadedDSDXml = new XmlDocument(); string UploadedDSDFileWPath = string.Empty; bool delCondition = false; SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); Callback objCallback = new Callback(); foreach (var item in DBConnections.Keys) { // Remove all the artifacts of type=10 regardless of its DBNid . IF two columns 'publishedfilename and LangPrefNid' exists using (var diConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, @"stock\Database.mdb"), string.Empty, string.Empty)) { var dataTable = diConnection.ExecuteDataTable(@"SELECT * FROM Artefacts"); delCondition = dataTable.Columns.Contains("PublishedFileName"); if (!delCondition) { diConnection.ExecuteNonQuery(string.Format(@"DELETE FROM Artefacts where DBNId = {0} and Type={1}", item, 10)); foreach (var folder in System.IO.Directory.GetDirectories(HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item + "\\" + Constants.FolderName.SDMX.Registrations))) { foreach (var file in System.IO.Directory.GetFiles(folder)) System.IO.File.Delete(file); } } } //check folder if (Directory.Exists(HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item))) { //check file if (!File.Exists(HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item + "\\sdmx\\" + Constants.FileName.HeaderFileName))) { //create file xmlNode = XmlDoc.SelectSingleNode("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "/" + Constants.XmlFile.Db.Tags.Database + "[@" + Constants.XmlFile.Db.Tags.DatabaseAttributes.Id + "=" + item + "]"); if (Convert.ToBoolean(xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.SDMXDb].Value) == true) { UploadedDSDFileWPath = HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item) + "\\sdmx\\DSD.xml"; UploadedDSDXml.Load(UploadedDSDFileWPath); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedDSDXml); objCallback.CreateHeaderFileForUploadedDSD(UploadedDSDStructure, HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item) + "\\" + "sdmx", Convert.ToInt32(item), string.Empty).ToString(); Global.SetDBXmlAttributes(item, Constants.XmlFile.Db.Tags.DatabaseAttributes.IsSDMXHeaderCreated, "true"); } else { SDMXUtility.Generate_Header(string.Empty, string.Empty, null, HttpContext.Current.Server.MapPath("..\\..\\stock\\data\\" + item + "\\sdmx")); Global.SetDBXmlAttributes(item, Constants.XmlFile.Db.Tags.DatabaseAttributes.IsSDMXHeaderCreated, "true"); } } } } RetVal = true; } catch (Exception) { } return RetVal; }
internal static bool Generate_MetadataReport(string SummaryFileName, string CodelistMappingFileName, string MetadataMappingFileName, string IndicatorNIds, string TargetAreaId, DIConnection DIConnection, DIQueries DIQueries, string OutputFolder, out string ErrorMessage, out List<string> GeneratedMetadataFiles, string HeaderfilePath, string xmlMetaFilePath) { bool RetVal; SDMXApi_2_0.Message.StructureType Summary; SDMXApi_2_0.Message.GenericMetadataType GenericMetadata; string MetadataSetName, MetadataStructureRef, MetadataStructureAgencyRef, ReportRef, TargetRef; string IndicatorNId, IndicatorGId,AreaId; Dictionary<string, string> DictIndicatorMapping, DictMetadataMapping,DictAreaMapping; DataTable DtIndicator,DtArea; ReportedAttributeType ReportedAttribute; DateTime CurrentTime; ErrorMessage = string.Empty; RetVal = false; CurrentTime = DateTime.Now; GeneratedMetadataFiles = new List<string>(); XmlDocument UploadedHeaderXml = new XmlDocument(); string AppSettingFile = string.Empty; XmlDocument XmlDoc; SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); SDMXApi_2_0.Message.HeaderType Header = new SDMXApi_2_0.Message.HeaderType(); DataSet ds = new DataSet(); Callback objCallBack = new Callback(); AppSettingFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.AppSettingFile]); if (File.Exists(HeaderfilePath)) { UploadedHeaderXml.Load(HeaderfilePath); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml); Header = UploadedDSDStructure.Header; } if (File.Exists(xmlMetaFilePath)) { ds.ReadXml(xmlMetaFilePath); } try { Summary = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), SummaryFileName); MetadataSetName = "CountryData Metadata"; if (Summary.MetadataStructureDefinitions.Count > 0) { MetadataStructureRef = Summary.MetadataStructureDefinitions[0].id; MetadataStructureAgencyRef = Summary.MetadataStructureDefinitions[0].agencyID; ReportRef = Summary.MetadataStructureDefinitions[0].ReportStructure[0].id; TargetRef = Summary.MetadataStructureDefinitions[0].ReportStructure[0].target; DtIndicator = DIConnection.ExecuteDataTable(DIQueries.Indicators.GetIndicator(FilterFieldType.NId, IndicatorNIds, FieldSelection.Light)); DtIndicator = DtIndicator.DefaultView.ToTable(true, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorNId, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorGId); DtArea = DIConnection.ExecuteDataTable(DIQueries.Area.GetAreaByAreaLevel(Global.registryAreaLevel)); DtArea = DtArea.DefaultView.ToTable(true, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaGId); DictIndicatorMapping = RegTwoZeroFunctionality.Get_Indicator_Mapping_Dict(CodelistMappingFileName, string.Empty); DictAreaMapping = RegTwoZeroFunctionality.Get_Area_Mapping_Dict(CodelistMappingFileName); foreach (DataRow DrArea in DtArea.Rows) { AreaId = DrArea[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID].ToString(); if (DictAreaMapping.ContainsKey(AreaId)) { if (DictAreaMapping.Count == 1) { TargetAreaId = DictAreaMapping[AreaId].ToString();//DrArea[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID].ToString(); } } } if (TargetAreaId != Global.registryMSDAreaId) { XmlDoc = new XmlDocument(); XmlDoc.Load(AppSettingFile); objCallBack.SaveAppSettingValue(XmlDoc, Constants.AppSettingKeys.registryMSDAreaId, TargetAreaId); XmlDoc.Save(AppSettingFile); } if (File.Exists(MetadataMappingFileName)) { DictMetadataMapping = Get_Metadata_Mapping_Dict(MetadataMappingFileName); foreach (DataRow DrIndicator in DtIndicator.Rows) { IndicatorNId = DrIndicator[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorNId].ToString(); IndicatorGId = DrIndicator[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorGId].ToString(); if (DictIndicatorMapping.ContainsKey(IndicatorGId)) { if (File.Exists(xmlMetaFilePath)) { foreach (DataRow DSRow in ds.Tables["Data"].Select("Ind=" + IndicatorNId)) { IndicatorNId = DSRow["Ind"].ToString(); } } GenericMetadata = new SDMXApi_2_0.Message.GenericMetadataType(); // GenericMetadata.Header = RegTwoZeroFunctionality.Get_Appropriate_Header(); if (!File.Exists(HeaderfilePath)) { GenericMetadata.Header = RegTwoZeroFunctionality.Get_Appropriate_Header(); } else { GenericMetadata.Header = Header; } GenericMetadata.MetadataSet = new SDMXApi_2_0.GenericMetadata.MetadataSetType(); GenericMetadata.MetadataSet.Annotations = null; GenericMetadata.MetadataSet.Name = new List<SDMXApi_2_0.Common.TextType>(); GenericMetadata.MetadataSet.Name.Add(new SDMXApi_2_0.Common.TextType()); GenericMetadata.MetadataSet.Name[0].Value = MetadataSetName; GenericMetadata.MetadataSet.MetadataStructureRef = MetadataStructureRef; GenericMetadata.MetadataSet.MetadataStructureAgencyRef = MetadataStructureAgencyRef; GenericMetadata.MetadataSet.ReportRef = ReportRef; GenericMetadata.MetadataSet.AttributeValueSet = new List<SDMXApi_2_0.GenericMetadata.AttributeValueSetType>(); GenericMetadata.MetadataSet.AttributeValueSet.Add(new SDMXApi_2_0.GenericMetadata.AttributeValueSetType()); GenericMetadata.MetadataSet.AttributeValueSet[0].TargetRef = TargetRef; GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues = new List<SDMXApi_2_0.GenericMetadata.ComponentValueType>(); GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues.Add(new SDMXApi_2_0.GenericMetadata.ComponentValueType()); GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[0].@object = SDMXApi_2_0.GenericMetadata.ObjectIDType.Dimension; GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[0].component = "SERIES"; GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[0].Value = DictIndicatorMapping[IndicatorGId].ToString(); GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues.Add(new SDMXApi_2_0.GenericMetadata.ComponentValueType()); GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[1].@object = SDMXApi_2_0.GenericMetadata.ObjectIDType.Dimension; GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[1].component = "REF_AREA"; GenericMetadata.MetadataSet.AttributeValueSet[0].TargetValues[1].Value = TargetAreaId; if (Summary.MetadataStructureDefinitions[0].ReportStructure[0].MetadataAttribute != null && Summary.MetadataStructureDefinitions[0].ReportStructure[0].MetadataAttribute.Count > 0) { GenericMetadata.MetadataSet.AttributeValueSet[0].ReportedAttribute = new List<ReportedAttributeType>(); foreach (MetadataAttributeType MetadataAttribute in Summary.MetadataStructureDefinitions[0].ReportStructure[0].MetadataAttribute) { ReportedAttribute = new ReportedAttributeType(); ReportedAttribute.Annotations = null; ReportedAttribute.conceptID = MetadataAttribute.conceptRef; Fill_Reported_Attribute_Value(ReportedAttribute, IndicatorNId, DictMetadataMapping, DIConnection, DIQueries); Fill_Reported_Attribute_ChildAttributes(ReportedAttribute, MetadataAttribute, IndicatorNId, DictMetadataMapping, DIConnection, DIQueries); GenericMetadata.MetadataSet.AttributeValueSet[0].ReportedAttribute.Add(ReportedAttribute); } } //SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.GenericMetadataType), GenericMetadata, Path.Combine(OutputFolder, DictIndicatorMapping[IndicatorGId].ToString() + "_" + CurrentTime.ToString("yyyy-MM-dd HHmmss") + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); //GeneratedMetadataFiles.Add(Convert.ToString(DictIndicatorMapping[IndicatorGId].ToString() + "_" + CurrentTime.ToString("yyyy-MM-dd HHmmss"))); SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.GenericMetadataType), GenericMetadata, Path.Combine(OutputFolder, DictIndicatorMapping[IndicatorGId].ToString() + "_DIMD_" + IndicatorGId + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); GeneratedMetadataFiles.Add(Convert.ToString(DictIndicatorMapping[IndicatorGId].ToString() + "_DIMD_" + IndicatorGId)); RetVal = true; } } } else { RetVal = false; ErrorMessage = "MNF"; return RetVal; } } else { RetVal = false; ErrorMessage = "ANF"; return RetVal; } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal; }
private string BindMSDAttributes_For_MSD_2_0(string DBNId, string MSDId, string lngcodedb) { string RetVal = string.Empty; string ConceptName = string.Empty; string ConceptDescription = string.Empty; string CategorySchemeName = string.Empty; string CategorySchemeDescription = string.Empty; string CodelistName = string.Empty; string CodelistDescription = string.Empty; string ObjectType = string.Empty; XmlDocument MSDXml; StringBuilder sb; StringBuilder sbChild; int i, j, k, l; try { string MSDPath = ""; string MSDViewPath = ""; string MFDPath = ""; string MFDViewPath = ""; string ConceptSchemePath = ""; string ConceptSchemeViewPath = ""; string MFDId = ""; string ConceptSchemeId = ""; MSDPath = Server.MapPath(System.IO.Path.Combine("~", @"stock\\data\\" + DBNId + "\\sdmx\\MSD\\" + MSDId + ".xml")); MSDViewPath = "../../stock/data/" + DBNId + "/sdmx/MSD/" + MSDId + ".xml"; MSDXml = new XmlDocument(); MSDXml.Load(MSDPath); MFDId = "MF_" + MSDId; MFDPath = Server.MapPath(System.IO.Path.Combine("~", @"stock\\data\\" + DBNId + "\\sdmx\\Provisioning Metadata\\" + MFDId + ".xml")); MFDViewPath = "../../stock/data/" + DBNId + "/sdmx/Provisioning Metadata/" + MFDId + ".xml"; SDMXApi_2_0.Message.StructureType SummaryStructure = new SDMXApi_2_0.Message.StructureType(); SummaryStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DBNId + "\\sdmx\\Summary" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<img id=\"imgdivMSD\" src=\"../../stock/themes/default/images/collapse.png\" alt=\"Expand and Collapse\" onclick=\"ExpandCollapseList('imgdivMSD','divMSD')\" style=\"margin-top: 10px;margin-right: 4px\" class=\"flt_lft\"/>"); sb.Append("<h3 id=\"lang_Metadata_Structure_Definition\" class=\"flt_lft\"></h3>"); sb.Append(" <img id=\"imghelpMSD\" src=\"../../stock/themes/default/images/help.gif\" alt=\"Help\" onclick=\"ToggleCallout('divCallout', event, 'divHelpMSD')\" style=\"margin-top:10px;cursor:pointer;\" onmouseout=\"HideCallout('divCallout')\";/>"); sb.Append("</div>"); sb.Append("<div id=\"divMSD\" style=\"display:block\">"); for (i = 0; i < SummaryStructure.MetadataStructureDefinitions.Count; i++) { if (SummaryStructure.MetadataStructureDefinitions[i].id == MSDId) { sb.Append("<br/>"); sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("<b>"); sb.Append(GetLangSpecificValueFor_Version_2_0(SummaryStructure.MetadataStructureDefinitions[i].Name, lngcodedb)); sb.Append("</b>"); if (SummaryStructure.MetadataStructureDefinitions[i].Description.Count > 0) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValueFor_Version_2_0(SummaryStructure.MetadataStructureDefinitions[i].Description, lngcodedb)); sb.Append(")</span> "); } sb.Append("</div>"); sb.Append("<div>"); sb.Append("<a href=\" " + MSDViewPath + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + MSDPath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("<br/>"); sb.Append("<h4 id=\"lang_Target\"></h4>"); sb.Append("<div id=\"divTarget\" class=\"reg_li_sub_txt\">"); sb.Append("<ul class=\"reg_nonlst_txt\">"); foreach (IdentifierComponentType IdentifierComponent in SummaryStructure.MetadataStructureDefinitions[i].TargetIdentifiers.FullTargetIdentifier.IdentifierComponent) { if (IdentifierComponent.RepresentationScheme.representationSchemeType == RepresentationSchemeTypeType.Codelist) { sb.Append("<li>"); for (j = 0; j < SummaryStructure.KeyFamilies[0].Components.Dimension.Count; j++) { if (IdentifierComponent.id == SummaryStructure.KeyFamilies[0].Components.Dimension[j].conceptRef) { for (k = 0; k < SummaryStructure.CodeLists.Count; k++) { if (SummaryStructure.KeyFamilies[0].Components.Dimension[j].codelist == SummaryStructure.CodeLists[k].id) { CodelistName = GetLangSpecificValueFor_Version_2_0(SummaryStructure.CodeLists[k].Name, lngcodedb).ToUpper(); CodelistDescription = GetLangSpecificValueFor_Version_2_0(SummaryStructure.CodeLists[k].Description, lngcodedb); if (CodelistName != string.Empty) { sb.Append(CodelistName); } if (CodelistDescription != string.Empty) { sb.Append("<span class=\"reg_li_brac_txt\" >("); sb.Append(CodelistDescription); sb.Append(")</span> "); } sb.Append(" - "); sb.Append("<span id=\"lang_Object_Type" + i + "\" ></span>"); sb.Append("<span class=\"reg_li_brac_txt\" >"); sb.Append(IdentifierComponent.RepresentationScheme.representationSchemeType.ToString()); sb.Append("</span> "); break; } } break; } } sb.Append("</li>"); } else if (IdentifierComponent.RepresentationScheme.representationSchemeType == RepresentationSchemeTypeType.Category) { sb.Append("<li>"); for (j = 0; j < SummaryStructure.KeyFamilies[0].Components.Dimension.Count; j++) { if (IdentifierComponent.id == SummaryStructure.KeyFamilies[0].Components.Dimension[j].conceptRef) { for (k = 0; k < SummaryStructure.CategorySchemes.Count; k++) { if (SummaryStructure.KeyFamilies[0].Components.Dimension[j].conceptSchemeRef == SummaryStructure.CategorySchemes[k].id) { CategorySchemeName = GetLangSpecificValueFor_Version_2_0(SummaryStructure.CategorySchemes[k].Name, lngcodedb).ToUpper(); CategorySchemeDescription = GetLangSpecificValueFor_Version_2_0(SummaryStructure.CategorySchemes[k].Description, lngcodedb); if (CategorySchemeName != string.Empty) { sb.Append(CategorySchemeName); } if (CategorySchemeDescription != string.Empty) { sb.Append("<span class=\"reg_li_brac_txt\" >("); sb.Append(CategorySchemeDescription); sb.Append(")</span> "); } sb.Append(" - "); sb.Append("<span id=\"lang_Object_Type" + i + "\" ></span>"); sb.Append("<span class=\"reg_li_brac_txt\" >"); sb.Append(IdentifierComponent.RepresentationScheme.representationSchemeType.ToString()); sb.Append("</span> "); break; } } break; } } sb.Append("</li>"); } } sb.Append("</ul>"); sb.Append("</div>"); break; } } for (i = 0; i < SummaryStructure.MetadataStructureDefinitions.Count; i++) { if (SummaryStructure.MetadataStructureDefinitions[i].id == MSDId) { sb.Append("<h4 id=\"lang_Report_Structure\"></h4>"); sb.Append("<ul id=\"ulRS\">"); for (j = 0; j < SummaryStructure.MetadataStructureDefinitions[i].ReportStructure[0].MetadataAttribute.Count; j++) { sb.Append("<li>"); for (k = 0; k < SummaryStructure.Concepts.ConceptScheme.Count; k++) { if (SummaryStructure.MetadataStructureDefinitions[i].ReportStructure[0].MetadataAttribute[j].conceptSchemeRef == SummaryStructure.Concepts.ConceptScheme[k].id) { ConceptSchemeId = SummaryStructure.MetadataStructureDefinitions[i].ReportStructure[0].MetadataAttribute[j].conceptSchemeRef; for (l = 0; l < SummaryStructure.Concepts.ConceptScheme[k].Concept.Count; l++) { if (SummaryStructure.MetadataStructureDefinitions[i].ReportStructure[0].MetadataAttribute[j].conceptRef == SummaryStructure.Concepts.ConceptScheme[k].Concept[l].id) { ConceptName = GetLangSpecificValueFor_Version_2_0(SummaryStructure.Concepts.ConceptScheme[k].Concept[l].Name, lngcodedb).ToUpper(); ConceptDescription = GetLangSpecificValueFor_Version_2_0(SummaryStructure.Concepts.ConceptScheme[k].Concept[l].Description, lngcodedb); if (ConceptName != string.Empty) { sb.Append(ConceptName); } if (ConceptDescription != string.Empty) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(ConceptDescription); sb.Append(")</span> "); } break; } } break; } } sbChild = new StringBuilder(); sb.Append(BindChildMetadatAttributes_For_Version_2_0(sbChild, SummaryStructure.MetadataStructureDefinitions[i].ReportStructure[0].MetadataAttribute[j], SummaryStructure, lngcodedb)); sb.Append("</li>"); } sb.Append("</ul>"); } } sb.Append("</div>"); sb.Append("<br/>"); sb.Append("<div>"); sb.Append("<img id=\"imgdivMFD\" src=\"../../stock/themes/default/images/collapse.png\" alt=\"Expand and Collapse\" onclick=\"ExpandCollapseList('imgdivMFD','divMFD')\" style=\"margin-top: 10px;margin-right: 4px\" class=\"flt_lft\"/>"); sb.Append("<h3 id=\"lang_Metadata_Flow_Definition\" class=\"flt_lft\"></h3>"); sb.Append(" <img id=\"imghelpMFD\" src=\"../../stock/themes/default/images/help.gif\" alt=\"Help\" onclick=\"ToggleCallout('divCallout', event, 'divHelpMFD')\" style=\"margin-top:10px;cursor:pointer;\" onmouseout=\"HideCallout('divCallout')\";/>"); sb.Append("</div>"); sb.Append("<br/>"); SDMXObjectModel.Message.StructureType MFDStructure = new SDMXObjectModel.Message.StructureType(); MFDStructure = (SDMXObjectModel.Message.StructureType)SDMXObjectModel.Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), MFDPath); sb.Append("<div id=\"divMFD\" style=\"display:block\">"); sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("<b>"); sb.Append(GetLangSpecificValue_For_Version_2_1(MFDStructure.Structures.Metadataflows[0].Name, lngcodedb)); sb.Append("</b>"); if (MFDStructure.Structures.Metadataflows[0].Description.Count > 0) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValue_For_Version_2_1(MFDStructure.Structures.Metadataflows[0].Description, lngcodedb)); sb.Append(")</span> "); } sb.Append("</div>"); sb.Append("<div>"); sb.Append("<a href=\" " + MFDViewPath + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + MFDPath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("</div>"); ConceptSchemePath = Server.MapPath(System.IO.Path.Combine("~", @"stock\\data\\" + DBNId + "\\sdmx\\Concepts\\" + ConceptSchemeId + ".xml")); ConceptSchemeViewPath = "../../stock/data/" + DBNId + "/sdmx/Concepts/" + ConceptSchemeId + ".xml"; SDMXApi_2_0.Message.StructureType ConceptSchemeStructure = new SDMXApi_2_0.Message.StructureType(); ConceptSchemeStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), ConceptSchemePath); sb.Append("<div>"); sb.Append("<img id=\"imgdivCS\" src=\"../../stock/themes/default/images/collapse.png\" alt=\"Expand and Collapse\" onclick=\"ExpandCollapseList('imgdivCS','divCS')\" style=\"margin-top: 10px;margin-right: 4px\" class=\"flt_lft\"/>"); sb.Append("<h3 id=\"lang_Concept_Scheme_MSD\" class=\"flt_lft\"></h3>"); sb.Append(" <img id=\"imghelpConceptScheme\" src=\"../../stock/themes/default/images/help.gif\" alt=\"Help\" onclick=\"ToggleCallout('divCallout', event, 'divHelpCS')\" style=\"margin-top:10px;cursor:pointer;\" onmouseout=\"HideCallout('divCallout')\";/>"); sb.Append("</div>"); sb.Append("<br/>"); sb.Append("<div id=\"divCS\" style=\"display:block\">"); sb.Append("<div class=\"reg_li_sub_txt\">"); sb.Append("<b>"); sb.Append(GetLangSpecificValueFor_Version_2_0(ConceptSchemeStructure.Concepts.ConceptScheme[0].Name, lngcodedb)); sb.Append("</b>"); if (ConceptSchemeStructure.Concepts.ConceptScheme[0].Description.Count > 0) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValueFor_Version_2_0(ConceptSchemeStructure.Concepts.ConceptScheme[0].Description, lngcodedb)); sb.Append(")</span> "); } sb.Append("</div>"); sb.Append("<div>"); sb.Append("<a href=\" " + ConceptSchemeViewPath + "\" "); sb.Append(" target=\"_blank\" class=\"reg_li_link_txt\" name=\"lang_View\"></a> | "); sb.Append("<a href='Download.aspx?fileId=" + ConceptSchemePath + "' class=\"reg_li_link_txt\" name=\"lang_Download\"></a>"); sb.Append("</div>"); sb.Append("<br/>"); sb.Append("<ul>"); for (i = 0; i < ConceptSchemeStructure.Concepts.ConceptScheme[0].Concept.Count; i++) { sb.Append("<li>"); sb.Append("<span>"); sb.Append(GetLangSpecificValueFor_Version_2_0(ConceptSchemeStructure.Concepts.ConceptScheme[0].Concept[i].Name, lngcodedb)); sb.Append("</span>"); if (!string.IsNullOrEmpty(GetLangSpecificValueFor_Version_2_0(ConceptSchemeStructure.Concepts.ConceptScheme[0].Concept[i].Description, lngcodedb))) { sb.Append("<span class=\"reg_li_brac_txt\">("); sb.Append(GetLangSpecificValueFor_Version_2_0(ConceptSchemeStructure.Concepts.ConceptScheme[0].Concept[i].Description, lngcodedb)); sb.Append(")</span>"); } sb.Append("</li>"); } sb.Append("</ul>"); sb.Append("</div>"); RetVal = sb.ToString(); } catch (Exception ex) { RetVal = string.Empty; Global.CreateExceptionString(ex, null); } return RetVal; }
private bool UpdateArtefactsForUploadedDSDWithHeader(SDMXApi_2_0.Message.HeaderType Header, string DbNId, string UserNId, string sdmxFolderPath, string DatabaseNIDVersion2_1) { bool RetVal; SDMXApi_2_0.Message.StructureType DSD; SDMXApi_2_0.Message.StructureType MSD; SDMXApi_2_0.Message.StructureType MSDConcepts; SDMXApi_2_0.Message.StructureType Summary; string AgencyId, AgencyName, Language, MFDDFolderPathInMetadataFolder; string AppPhysicalPath; string SummaryFile; string DSDFile; string DbFolder; string ConsumerFileName, ProviderFileName; string ConceptSchemeFolder; string MSDFolder; string[] conceptSchemes; string[] MSDS; RetVal = true; AgencyId = string.Empty; AgencyName = string.Empty; Language = string.Empty; MFDDFolderPathInMetadataFolder = string.Empty; ConsumerFileName = string.Empty; ProviderFileName = string.Empty; ConceptSchemeFolder = string.Empty; MSDFolder = string.Empty; try { AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + UserNId; AgencyName = Global.GetDbDetails(DbNId.ToString(), Language)[0]; AppPhysicalPath = HttpContext.Current.Request.PhysicalApplicationPath; DbFolder = Constants.FolderName.Data + DbNId.ToString() + "\\"; DSD = new SDMXApi_2_0.Message.StructureType(); DSDFile = sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.DSD.FileName; DSD = (SDMXApi_2_0.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), DSDFile); DSD.Header = Header; DSD.OrganisationSchemes = null; DSD.HierarchicalCodelists = null; DSD.Concepts = null; DSD.Metadataflows = null; DSD.MetadataStructureDefinitions = null; DSD.Processes = null; DSD.ReportingTaxonomies = null; DSD.StructureSets = null; DSD.CategorySchemes = null; DSD.CodeLists = null; DSD.Dataflows = null; Remove_Extra_Annotations(DSD); //Creating DSD and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), DSD, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.DSD.FileName); SummaryFile = sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.FileName; Summary = new SDMXApi_2_0.Message.StructureType(); Summary = (SDMXApi_2_0.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), SummaryFile); ConceptSchemeFolder = sdmxFolderPath + "/" + "Concepts"; MSDFolder = sdmxFolderPath + "/" + "MSD"; Summary.Header = Header; Summary.OrganisationSchemes = null; Summary.HierarchicalCodelists = null; Summary.Metadataflows = null; Summary.Processes = null; Summary.ReportingTaxonomies = null; Summary.StructureSets = null; Summary.CategorySchemes = null; Summary.Dataflows = null; //Creating Summary file and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), Summary, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.FileName); MSDS = Directory.GetFiles(MSDFolder); foreach (string msdfile in MSDS) { MSD = new SDMXApi_2_0.Message.StructureType(); MSD = (SDMXApi_2_0.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), msdfile); MSD.Header = Header; MSD.OrganisationSchemes = null; MSD.HierarchicalCodelists = null; MSD.Concepts = null; MSD.Metadataflows = null; MSD.KeyFamilies = null; MSD.Processes = null; MSD.ReportingTaxonomies = null; MSD.StructureSets = null; MSD.CategorySchemes = null; MSD.CodeLists = null; MSD.Dataflows = null; //Creating MSD and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), MSD, msdfile);//sdmxFolderPath + "\\MSD\\" } conceptSchemes = Directory.GetFiles(ConceptSchemeFolder); foreach (string conceptSchemeFile in conceptSchemes) { MSDConcepts = new SDMXApi_2_0.Message.StructureType(); MSDConcepts = (SDMXApi_2_0.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), conceptSchemeFile); MSDConcepts.Header = Header; MSDConcepts.MetadataStructureDefinitions = null; MSDConcepts.OrganisationSchemes = null; MSDConcepts.HierarchicalCodelists = null; MSDConcepts.Metadataflows = null; MSDConcepts.KeyFamilies = null; MSDConcepts.Processes = null; MSDConcepts.ReportingTaxonomies = null; MSDConcepts.StructureSets = null; MSDConcepts.CategorySchemes = null; MSDConcepts.CodeLists = null; MSDConcepts.Dataflows = null; //Creating MSDConcepts and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), MSDConcepts, conceptSchemeFile);//sdmxFolderPath + "\\Concepts\\" + } } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Artefacts For Uploaded DSD From Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
/// <summary> /// Generate_Data for Country DSD SDMX-ML v2.0 /// </summary> /// <param name="DictMapping">Key - DevInfo GId; Value - UNSD GID</param> /// <param name="OutputFolder">SDMX-ML folder path</param> /// <param name="DIConnection"></param> /// <param name="DIQueries"></param> /// <param name="fileCount">Return Count of SDMX-ML files generated for all language</param> /// <param name="AreaId"></param> /// <param name="DBOrDSDDBId">dbnid of devinfo database / country dsd</param> /// <param name="GeneratedFiles">list unique SDMX-ML file generated (single file name for multiple language)</param> /// <param name="HeaderfilePath"></param> /// <param name="xml">In case of optimize database - user selection through databuplish xml</param> /// <param name="DuplicateKey">Return knowldege of Duplicate key for indicator and time</param> /// <param name="dtSelections">In case of Register - user selection in form of datatable [ind, Area]</param> /// <param name="ErrorLogs">Return indicator@@Timeperiod}} </param> /// <param name="GeneratedIndicatorCountryGIDS">Return list of Country GUID for which files have been generated</param> /// <returns></returns> internal static bool Generate_Data(Dictionary<string, string> DictMapping, string OutputFolder, DIConnection DIConnection, DIQueries DIQueries, string AreaId, string DBOrDSDDBId, string HeaderfilePath, string xml, DataTable dtSelections, out int fileCount, out List<string> GeneratedFiles, out string ErrorLogs, out string DuplicateKey) { bool RetVal; string Language; string IndicatorGId, UnitGId, SGVGId, AreaID; string AreaNIds, TPNIds, SourceNIds; string SeriesValue, Unit, Age, Sex, Location, Frequency, SourceType, Nature, UnitMult, TimePeriod, ObsVal, TimeDetail, SourceDetail, Footnotes, IndicatorName; ErrorLogs = string.Empty; List<string> ProcessedIUSA; DataTable DtData; DataRow[] IUSARows; DataRow[] CheckDuplicateKeys; XmlDocument AttributesDoc; System.Xml.XmlAttribute Attribute; CompactDataType CompactData; SDMXApi_2_0.CompactData.SeriesType Series; SDMXApi_2_0.CompactData.ObsType Obs; Dictionary<string, string> DictAreaMapping; DateTime CurrentTime; RetVal = true; fileCount = 0; Language = string.Empty; IndicatorGId = string.Empty; UnitGId = string.Empty; SGVGId = string.Empty; AreaID = string.Empty; SeriesValue = string.Empty; Unit = string.Empty; Age = string.Empty; Sex = string.Empty; Location = string.Empty; Frequency = string.Empty; SourceType = string.Empty; Nature = string.Empty; UnitMult = string.Empty; TimePeriod = string.Empty; ObsVal = string.Empty; TimeDetail = string.Empty; SourceDetail = string.Empty; Footnotes = string.Empty; int RowCount = 0; ProcessedIUSA = new List<string>(); DtData = null; IUSARows = null; CheckDuplicateKeys = null; AttributesDoc = null; Attribute = null; CompactData = null; Series = null; Obs = null; DictAreaMapping = null; CurrentTime = DateTime.Now; IndicatorName = string.Empty; XmlDocument UploadedHeaderXml = new XmlDocument(); DataSet ds = new DataSet(); SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); SDMXApi_2_0.Message.HeaderType Header = new SDMXApi_2_0.Message.HeaderType(); DuplicateKey = string.Empty; DataTable dtIndicator = new DataTable(); if (File.Exists(HeaderfilePath)) { UploadedHeaderXml.Load(HeaderfilePath); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml); Header = UploadedDSDStructure.Header; } GeneratedFiles = new List<string>(); if (dtSelections != null && dtSelections.Rows.Count > 0) { // register tab ds.Tables.Add(dtSelections); } else { // Admin if (File.Exists(xml)) { ds.ReadXml(xml); } } string IndicatorNId = string.Empty; // for each language in database foreach (DataRow LanguageRow in DIConnection.DILanguages(DIQueries.DataPrefix).Rows) { // Language = LanguageRow[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Language.LanguageCode].ToString(); int dsRowCount = ds.Tables["Data"].Rows.Count; RowCount = 0; // consider only those indiactors which are selected foreach (DataRow DSRow in ds.Tables["Data"].Select("selectedState=true")) { if (RowCount > dsRowCount) { break; } IndicatorNId = DSRow["Ind"].ToString(); AreaNIds = DSRow["areas"].ToString(); TPNIds = DSRow["timeperiods"].ToString(); SourceNIds = DSRow["source"].ToString(); // Get data based on Indiactor and associated fileters DtData = Get_Language_Specific_Data_Table(Language, IndicatorNId, AreaNIds, TPNIds, SourceNIds, DIConnection); dtIndicator = DIConnection.ExecuteDataTable(DIQueries.Indicators.GetIndicator(FilterFieldType.NId, IndicatorNId, FieldSelection.Heavy)); foreach (DataRow drIndicator in dtIndicator.Rows) { IndicatorName = drIndicator[Indicator.IndicatorName].ToString(); } ProcessedIUSA = new List<string>(); DictAreaMapping = RegTwoZeroFunctionality.Get_Area_Mapping_Dict(Convert.ToInt32(DBOrDSDDBId)); if ((DtData != null) && (DtData.Rows.Count > 0)) { fileCount += 1; CompactData = new CompactDataType(); if (!File.Exists(HeaderfilePath)) { CompactData.Header = RegTwoZeroFunctionality.Get_Appropriate_Header(); } else { CompactData.Header = Header; } CompactData.DataSet = new SDMXApi_2_0.CompactData.DataSetType(); CompactData.DataSet.ListSeries = new List<SDMXApi_2_0.CompactData.SeriesType>(); // for each data value for indicator foreach (DataRow DrData in DtData.Rows) { IndicatorGId = DrData[Indicator.IndicatorGId].ToString(); UnitGId = DrData[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Unit.UnitGId].ToString(); SGVGId = DrData[SubgroupVals.SubgroupValGId].ToString(); if (DictAreaMapping.ContainsKey(DrData[Area.AreaID].ToString())) { AreaId = DictAreaMapping[DrData[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID].ToString()]; } else { AreaId = DrData[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID].ToString(); } // AreaID = DrData[Area.AreaID].ToString(); AreaID = AreaId; if (string.IsNullOrEmpty(AreaID) == true) { AreaID = Global.registryMSDAreaId; } if (!DictMapping.ContainsKey(IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId)) { continue; } // Replace DI GUIDs with Coutry data GIDs based on mapping SeriesValue = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[0]; Unit = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[1]; Age = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[2]; Sex = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[3]; Location = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[4]; Frequency = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[5]; SourceType = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[6]; Nature = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[7]; UnitMult = DictMapping[IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId].Split(new string[] { "@__@" }, StringSplitOptions.None)[8]; // If series item already exists if (ProcessedIUSA.Contains(IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId + "@__@" + AreaID)) { continue; } else { ProcessedIUSA.Add(IndicatorGId + "@__@" + UnitGId + "@__@" + SGVGId + "@__@" + AreaID); Series = new SDMXApi_2_0.CompactData.SeriesType(); Series.AnyAttr = new List<XmlAttribute>(); AttributesDoc = new XmlDocument(); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Indicator.Id); Attribute.Value = SeriesValue; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Unit.Id); Attribute.Value = Unit; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Age.Id); Attribute.Value = Age; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Sex.Id); Attribute.Value = Sex; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Location.Id); Attribute.Value = Location; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Frequency.Id); Attribute.Value = Frequency; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.SourceType.Id); Attribute.Value = SourceType; Series.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Area.Id); Attribute.Value = AreaID; Series.AnyAttr.Add(Attribute); IUSARows = DtData.Select(Indicator.IndicatorGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + IndicatorGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Unit.UnitGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + UnitGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + SubgroupVals.SubgroupValGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + SGVGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + Area.AreaID + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + DrData[Area.AreaID].ToString() + SDMXLibrary.Constants.Apostophe); Series.ListObs = new List<SDMXApi_2_0.CompactData.ObsType>(); foreach (DataRow IUSARow in IUSARows) { TimePeriod = Get_Time_Period_Start_Year(Convert.ToString(IUSARow[Timeperiods.TimePeriod])); CheckDuplicateKeys = DtData.Select(Indicator.IndicatorGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + IndicatorGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Unit.UnitGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + UnitGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + SubgroupVals.SubgroupValGId + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + SGVGId + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + Area.AreaID + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + DrData[Area.AreaID].ToString() + SDMXLibrary.Constants.Apostophe + SDMXLibrary.Constants.AND + Timeperiods.TimePeriod + SDMXLibrary.Constants.EqualsTo + SDMXLibrary.Constants.Apostophe + TimePeriod + SDMXLibrary.Constants.Apostophe); ObsVal = IUSARow[Data.DataValue].ToString(); TimeDetail = IUSARow[Timeperiods.TimePeriod].ToString(); SourceDetail = IUSARow[IndicatorClassifications.ICName].ToString(); Footnotes = IUSARow[FootNotes.FootNote].ToString(); Obs = new SDMXApi_2_0.CompactData.ObsType(); Obs.AnyAttr = new List<XmlAttribute>(); AttributesDoc = new XmlDocument(); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Nature.Id); Attribute.Value = Nature; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.UnitMult.Id); Attribute.Value = UnitMult; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.TimePeriod.Id); Attribute.Value = TimePeriod; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.ObsVal.Id); Attribute.Value = ObsVal; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.TimeDetail.Id); Attribute.Value = TimeDetail; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.SourceDetail.Id); Attribute.Value = SourceDetail; Obs.AnyAttr.Add(Attribute); Attribute = AttributesDoc.CreateAttribute(Constants.UNSD.Concept.Footnotes.Id); Attribute.Value = Footnotes; Obs.AnyAttr.Add(Attribute); Series.ListObs.Add(Obs); } CompactData.DataSet.ListSeries.Add(Series); } } if (CheckDuplicateKeys.Count() <= 1) { SDMXApi_2_0.Serializer.SerializeToFile(typeof(CompactDataType), CompactData, Path.Combine(Path.Combine(OutputFolder, Language), Convert.ToString(SeriesValue + "_DI_" + IndicatorGId) + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension)); GeneratedFiles.Add(Convert.ToString(SeriesValue + "_DI_" + IndicatorGId)); } else { fileCount -= 1; if (string.IsNullOrEmpty(DuplicateKey)) { DuplicateKey += "DK" + Constants.Delimiters.ParamDelimiter + "INDICATOR: " + IndicatorName + "__@@@@__" + "TIMEPERIOD: " + TimePeriod + Constants.Delimiters.ParamDelimiter; } else { DuplicateKey += "DK" + Constants.Delimiters.ParamDelimiter + "INDICATOR: " + IndicatorName + "__@@@@__" + "TIMEPERIOD: " + TimePeriod + Constants.Delimiters.ParamDelimiter; } XLSLogGenerator.WriteCSVLogForMailStatus("Error found while publishing data", IndicatorName, "File not published for the given IndicatorGId and Timeperiod", DuplicateKey); } } else { // to find indicator gid DtData = Get_Language_Specific_Data_Table(Language, IndicatorNId, string.Empty, string.Empty, string.Empty, DIConnection); if (string.IsNullOrEmpty(IndicatorName)) { ErrorLogs += "NDF" + Constants.Delimiters.ParamDelimiter + IndicatorName + Constants.Delimiters.ParamDelimiter; XLSLogGenerator.WriteCSVLogForMailStatus("No data found", IndicatorName, "File not published", IndicatorName); } else { if (ErrorLogs.Contains(IndicatorName)) { continue; } else { if (string.IsNullOrEmpty(ErrorLogs)) { ErrorLogs += "NDF" + Constants.Delimiters.ParamDelimiter + IndicatorName + Constants.Delimiters.ParamDelimiter; } else { ErrorLogs += "NDF" + Constants.Delimiters.ParamDelimiter + IndicatorName + Constants.Delimiters.ParamDelimiter; } XLSLogGenerator.WriteCSVLogForMailStatus("No data found for ", IndicatorName, "File not published for the given IndicatorGId", IndicatorName); } } } RowCount += 1; } } RetVal = true; return RetVal; }
private bool UpdateCodelistsForUploadedDSDWithHeader(SDMXApi_2_0.Message.HeaderType Header, string DbNId, string UserNId, string CodelistsFolderPath) { bool RetVal; SDMXApi_2_0.Message.StructureType CodelistStructure; RetVal = true; try { string[] Files = Directory.GetFiles(CodelistsFolderPath); foreach (string codilistFile in Files) { CodelistStructure = new SDMXApi_2_0.Message.StructureType(); CodelistStructure = (SDMXApi_2_0.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), codilistFile); CodelistStructure.Header = Header; CodelistStructure.OrganisationSchemes = null; CodelistStructure.HierarchicalCodelists = null; CodelistStructure.Concepts = null; CodelistStructure.Metadataflows = null; CodelistStructure.MetadataStructureDefinitions = null; CodelistStructure.Processes = null; CodelistStructure.ReportingTaxonomies = null; CodelistStructure.StructureSets = null; CodelistStructure.CategorySchemes = null; CodelistStructure.KeyFamilies = null; CodelistStructure.Dataflows = null; // Global.deleteFiles(codilistFile); Remove_Extra_Annotations(CodelistStructure); SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), CodelistStructure, codilistFile); } } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Codelists For Uploaded DSD from Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
private static void Send_Notifications_For_Current_Subscription(SubscriptionType Subscription, SDMXObjectModel.Registry.RegistrationType Registration, string HeaderFilePath = null) { string MessageContent; List<ArtefactInfo> Artefacts; DateTime CurrentDate; DateTime ValidityPeriodStartDate; DateTime ValidityPeriodEndDate; Header Header = new Header(); XmlDocument UploadedHeaderXml = new XmlDocument(); SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); SDMXApi_2_0.Message.HeaderType Header_2_0 = new SDMXApi_2_0.Message.HeaderType(); if (File.Exists(HeaderFilePath)) { UploadedHeaderXml.Load(HeaderFilePath); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml); Header_2_0 = UploadedDSDStructure.Header; } try { if (string.IsNullOrEmpty(HeaderFilePath) == false) { Header.ID = Header_2_0.ID; Header.Name = Header_2_0.Name[0].Value.ToString(); foreach (SDMXApi_2_0.Message.PartyType Senders in Header_2_0.Sender) { Header.Sender.ID = Senders.id; Header.Sender.Name = !string.IsNullOrEmpty(Senders.Name[0].Value.ToString()) ? Senders.Name[0].Value.ToString() : string.Empty; foreach (SDMXApi_2_0.Message.ContactType Contacts in Senders.Contact) { Header.Sender.Contact.Department = !string.IsNullOrEmpty(Contacts.Department[0].Value.ToString()) ? Contacts.Department[0].Value.ToString() : string.Empty; Header.Sender.Contact.Email = !string.IsNullOrEmpty(Contacts.Items[1].ToString()) ? Contacts.Items[1].ToString() : string.Empty; Header.Sender.Contact.Fax = !string.IsNullOrEmpty(Contacts.Items[2].ToString()) ? Contacts.Items[2].ToString() : string.Empty; Header.Sender.Contact.Name = !string.IsNullOrEmpty(Contacts.Name[0].Value.ToString()) ? Contacts.Name[0].Value.ToString() : string.Empty; Header.Sender.Contact.Role = !string.IsNullOrEmpty(Contacts.Role[0].Value.ToString()) ? Contacts.Role[0].Value.ToString() : string.Empty; Header.Sender.Contact.Telephone = !string.IsNullOrEmpty(Contacts.Items[0].ToString()) ? Contacts.Items[0].ToString() : string.Empty; } } foreach (SDMXApi_2_0.Message.PartyType Receiver in Header_2_0.Receiver) { Header.Receiver.ID = Receiver.id; if (string.IsNullOrEmpty(Convert.ToString(Receiver.Name[0].Value)) == false) { Header.Receiver.Name = !string.IsNullOrEmpty(Receiver.Name[0].Value.ToString()) ? Receiver.Name[0].Value.ToString() : string.Empty; foreach (SDMXApi_2_0.Message.ContactType Contacts in Receiver.Contact) { Header.Receiver.Contact.Department = !string.IsNullOrEmpty(Convert.ToString(Contacts.Department[0].Value)) ? Convert.ToString(Contacts.Department[0].Value) : string.Empty; if (Contacts.Items.Length > 2) { Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[2])) ? Convert.ToString(Contacts.Items[2]) : string.Empty; } else { Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; } //Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; //Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[2])) ? Convert.ToString(Contacts.Items[2]) : string.Empty; Header.Receiver.Contact.Name = !string.IsNullOrEmpty(Convert.ToString(Contacts.Name[0].Value)) ? Convert.ToString(Contacts.Name[0].Value) : string.Empty; Header.Receiver.Contact.Role = !string.IsNullOrEmpty(Convert.ToString(Contacts.Role[0].Value)) ? Convert.ToString(Contacts.Role[0].Value) : string.Empty; Header.Receiver.Contact.Telephone = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[0])) ? Convert.ToString(Contacts.Items[0]) : string.Empty; //Header.Receiver.Contact.Department = !string.IsNullOrEmpty(Contacts.Department[0].Value.ToString()) ? Contacts.Department[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Contacts.Items[2].ToString()) ? Contacts.Items[2].ToString() : string.Empty; //Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Contacts.Items[1].ToString()) ? Contacts.Items[1].ToString() : string.Empty; //Header.Receiver.Contact.Name = !string.IsNullOrEmpty(Contacts.Name[0].Value.ToString()) ? Contacts.Name[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Role = !string.IsNullOrEmpty(Contacts.Role[0].Value.ToString()) ? Contacts.Role[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Telephone = !string.IsNullOrEmpty(Contacts.Items[0].ToString()) ? Contacts.Items[0].ToString() : string.Empty; } } } } CurrentDate = DateTime.Now; ValidityPeriodStartDate = Subscription.ValidityPeriod.StartDate; ValidityPeriodEndDate = Subscription.ValidityPeriod.EndDate; if ((CurrentDate >= ValidityPeriodStartDate) && (CurrentDate <= ValidityPeriodEndDate)) { if (string.IsNullOrEmpty(HeaderFilePath) == false) { Artefacts = SDMXUtility.Get_Notification(SDMXSchemaType.Two_One, DateTime.Now, Registration.id, Subscription.RegistryURN, ActionType.Append, Registration, Header); } else { Artefacts = SDMXUtility.Get_Notification(SDMXSchemaType.Two_One, DateTime.Now, Registration.id, Subscription.RegistryURN, ActionType.Append, Registration, null); } foreach (NotificationURLType NotificationMailId in Subscription.NotificationMailTo) { if (NotificationMailId.isSOAP == true) { MessageContent = GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Send_Notification_By_Email(MessageContent, NotificationMailId.Value); } foreach (NotificationURLType NotificationHTTP in Subscription.NotificationHTTP) { if (NotificationHTTP.isSOAP == true) { MessageContent = GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Send_Notification_By_HTTP_Post(MessageContent, NotificationHTTP.Value); } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } }
public string AdminGetAllTheUploadedMSDsTable() { string RetVal = string.Empty; string DBFile = string.Empty; string CompleteXmlPath = string.Empty; string MSDPath = string.Empty; string MSDViewPath = string.Empty; string AgencyId = string.Empty; XmlDocument XmlDoc; XmlNodeList XmlNodes; int i = 0; int MSDCount = 0; int j = 0; SDMXApi_2_0.Message.StructureType CompleteStructure = new SDMXApi_2_0.Message.StructureType(); try { DBFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]); XmlDoc = new XmlDocument(); XmlDoc.Load(DBFile); XmlNodes = XmlDoc.GetElementsByTagName("db"); if (XmlNodes.Count > 0) { RetVal = "<table style=\"width:100%; \" border=\"0\" cellSpacing=\"0\" cellSpacing=\"0\">"; RetVal += "<tr class=\"HeaderRowStyle \">"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_SNo_MSD\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Id_MSD\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Agency_Id_MSD\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Version_MSD\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Assosciated_DSD_MSD\"></span></td>"; // RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Details_MSD\"></span></td>"; RetVal += "</tr>"; for (i = 0; i < XmlNodes.Count; i++) { if ((XmlNodes[i].Attributes["sdmxdb"].Value == "true") && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId] != null) && (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion] != null)) { CompleteXmlPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "\\sdmx\\Complete" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); CompleteStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), CompleteXmlPath); for (j = 0; j < CompleteStructure.MetadataStructureDefinitions.Count; j++) { MSDCount = MSDCount + 1; MSDPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "\\sdmx\\MSD\\" + CompleteStructure.MetadataStructureDefinitions[j].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); MSDViewPath = "../../" + Constants.FolderName.Data + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "/sdmx/MSD/" + CompleteStructure.MetadataStructureDefinitions[j].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension; RetVal = RetVal + "<tr class=\"DataRowStyle \">"; RetVal += "<td class=\"DataRowStyle \">" + MSDCount + "</td>"; RetVal += "<td class=\"DataRowStyle \">" + CompleteStructure.MetadataStructureDefinitions[j].id + "</td>"; RetVal += "<td class=\"DataRowStyle \">" + CompleteStructure.MetadataStructureDefinitions[j].agencyID + "</td>"; RetVal += "<td class=\"DataRowStyle \">" + CompleteStructure.MetadataStructureDefinitions[j].version + "</td>"; RetVal += "<td class=\"DataRowStyle \">" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId].Value + "-" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId].Value + "-" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion].Value + "</td>"; ///RetVal += "<td class=\"DataColumnStyle \">" + "<a style=\"cursor:pointer;\" href=\"" + MSDViewPath.Replace("\\", "/") + "\" target=\"_blank\" name=\"lang_View\"></a> | <a style=\"cursor:pointer;\" href='Download.aspx?fileId=" + MSDPath + "' name=\"lang_Download\"></a>" + "</td>"; RetVal = RetVal + "</tr>"; } } } RetVal = RetVal + "</table>"; } if (RetVal.Length > 0) { RetVal = RetVal.Remove(RetVal.Length - 1); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); } return RetVal; }
private bool CreateArtefactsForUploadedDSD(SDMXApi_2_0.Message.StructureType UploadedDSDStructure, string sdmxFolderPath, int DbNId, string UserNId) { bool RetVal; SDMXApi_2_0.Message.StructureType Concepts; SDMXApi_2_0.Message.StructureType DSD; SDMXApi_2_0.Message.StructureType MSD; SDMXApi_2_0.Message.StructureType MSDConcepts; SDMXApi_2_0.Message.StructureType Summary; List<ArtefactInfo> Artefacts, PAArtefacts; string AgencyId, AgencyName, Language, MFDDFolderPathInMetadataFolder; string AppPhysicalPath; string DbFolder; string FolderName; string ConsumerFileName, ProviderFileName; SDMXObjectModel.Message.StructureType Structure; RetVal = true; AgencyId = string.Empty; AgencyName = string.Empty; Language = string.Empty; MFDDFolderPathInMetadataFolder = string.Empty; ConsumerFileName = string.Empty; ProviderFileName = string.Empty; Structure = null; try { //Language = UploadedDSDStructure.Concepts.Concept[0].Name[0].lang; Language = UploadedDSDStructure.CodeLists[0].Name[0].lang; AgencyId = DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Prefix + UserNId; AgencyName = Global.GetDbDetails(DbNId.ToString(), Language)[0]; AppPhysicalPath = HttpContext.Current.Request.PhysicalApplicationPath; DbFolder = Constants.FolderName.Data + DbNId.ToString() + "\\"; Concepts = new SDMXApi_2_0.Message.StructureType(); DSD = new SDMXApi_2_0.Message.StructureType(); Summary = new SDMXApi_2_0.Message.StructureType(); if (UploadedDSDStructure.Concepts != null) { Concepts.Header = UploadedDSDStructure.Header; Concepts.Concepts = UploadedDSDStructure.Concepts; Summary.Concepts = UploadedDSDStructure.Concepts; } DSD.Header = UploadedDSDStructure.Header; Summary.Header = UploadedDSDStructure.Header; DSD.KeyFamilies = UploadedDSDStructure.KeyFamilies; Summary.KeyFamilies = UploadedDSDStructure.KeyFamilies; Summary.MetadataStructureDefinitions = UploadedDSDStructure.MetadataStructureDefinitions; Summary.CodeLists = UploadedDSDStructure.CodeLists; foreach (SDMXApi_2_0.Structure.CodeListType CodeList in Summary.CodeLists) { CodeList.Code = null; } Summary.OrganisationSchemes = null; Summary.HierarchicalCodelists = null; Summary.Metadataflows = null; Summary.Processes = null; Summary.ReportingTaxonomies = null; Summary.StructureSets = null; Summary.CategorySchemes = null; Summary.Dataflows = null; //Creating Summary file and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), Summary, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.FileName); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.Id, AgencyId, DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.Version, string.Empty, ArtefactTypes.Summary, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.FileName, DevInfo.Lib.DI_LibSDMX.Constants.Summary_XML.FileName); DSD.OrganisationSchemes = null; DSD.HierarchicalCodelists = null; DSD.Concepts = null; DSD.Metadataflows = null; DSD.MetadataStructureDefinitions = null; DSD.Processes = null; DSD.ReportingTaxonomies = null; DSD.StructureSets = null; DSD.CategorySchemes = null; DSD.CodeLists = null; DSD.Dataflows = null; if (UploadedDSDStructure.MetadataStructureDefinitions != null) { if (UploadedDSDStructure.MetadataStructureDefinitions.Count > 0) { foreach (SDMXApi_2_0.Structure.MetadataStructureDefinitionType MetadataStructureDefinition in UploadedDSDStructure.MetadataStructureDefinitions) { MSD = new SDMXApi_2_0.Message.StructureType(); MSD.Header = UploadedDSDStructure.Header; MSD.MetadataStructureDefinitions = new List<SDMXApi_2_0.Structure.MetadataStructureDefinitionType>(); MSD.MetadataStructureDefinitions.Add(new SDMXApi_2_0.Structure.MetadataStructureDefinitionType()); MSD.MetadataStructureDefinitions[0] = MetadataStructureDefinition; MSD.OrganisationSchemes = null; MSD.HierarchicalCodelists = null; MSD.Concepts = null; MSD.Metadataflows = null; MSD.KeyFamilies = null; MSD.Processes = null; MSD.ReportingTaxonomies = null; MSD.StructureSets = null; MSD.CategorySchemes = null; MSD.CodeLists = null; MSD.Dataflows = null; //Creating MSD and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), MSD, sdmxFolderPath + "\\MSD\\" + MSD.MetadataStructureDefinitions[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, MSD.MetadataStructureDefinitions[0].id, MSD.MetadataStructureDefinitions[0].agencyID, MSD.MetadataStructureDefinitions[0].version, string.Empty, ArtefactTypes.MSD, sdmxFolderPath + "\\" + MSD.MetadataStructureDefinitions[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension, MSD.MetadataStructureDefinitions[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); //Creating MFD and saving its information in the Database.mdb this.Generate_MFD("MF_" + MetadataStructureDefinition.id, AgencyId, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Area.Version, "DevInfo Metadata Flow for " + GetLangSpecificValueFor_Version_2_0(MetadataStructureDefinition.Name, Language), DevInfo.Lib.DI_LibSDMX.Constants.MFD.Area.Description, Language, MetadataStructureDefinition.id, MetadataStructureDefinition.agencyID, MetadataStructureDefinition.version, sdmxFolderPath, DbNId); //----------------------Creation of a MSD folder for uploaded DSD ----------------------------------------------- MFDDFolderPathInMetadataFolder = sdmxFolderPath + "\\" + "Metadata" + "\\" + "MF_" + MetadataStructureDefinition.id; if (!(Directory.Exists(MFDDFolderPathInMetadataFolder))) { Directory.CreateDirectory(MFDDFolderPathInMetadataFolder); } } } } if (UploadedDSDStructure.Concepts.ConceptScheme != null) { if (UploadedDSDStructure.Concepts.ConceptScheme.Count > 0) { foreach (SDMXApi_2_0.Structure.ConceptSchemeType ConceptScheme in UploadedDSDStructure.Concepts.ConceptScheme) { MSDConcepts = new SDMXApi_2_0.Message.StructureType(); MSDConcepts.Header = UploadedDSDStructure.Header; MSDConcepts.Concepts.ConceptScheme = new List<SDMXApi_2_0.Structure.ConceptSchemeType>(); MSDConcepts.Concepts.ConceptScheme.Add(new SDMXApi_2_0.Structure.ConceptSchemeType()); MSDConcepts.Concepts.ConceptScheme[0] = ConceptScheme; MSDConcepts.Concepts.Concept = null; MSDConcepts.MetadataStructureDefinitions = null; MSDConcepts.OrganisationSchemes = null; MSDConcepts.HierarchicalCodelists = null; MSDConcepts.Metadataflows = null; MSDConcepts.KeyFamilies = null; MSDConcepts.Processes = null; MSDConcepts.ReportingTaxonomies = null; MSDConcepts.StructureSets = null; MSDConcepts.CategorySchemes = null; MSDConcepts.CodeLists = null; MSDConcepts.Dataflows = null; //Creating MSDConcepts and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), MSDConcepts, sdmxFolderPath + "\\Concepts\\" + MSDConcepts.Concepts.ConceptScheme[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, string.Empty, MSDConcepts.Concepts.ConceptScheme[0].agencyID, MSDConcepts.Concepts.ConceptScheme[0].version, string.Empty, ArtefactTypes.ConceptS, sdmxFolderPath + "\\Concepts\\" + MSDConcepts.Concepts.ConceptScheme[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension, MSDConcepts.Concepts.ConceptScheme[0].id + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); } } } if (UploadedDSDStructure.Concepts != null) { if (UploadedDSDStructure.Concepts.Concept.Count > 0) { Concepts.OrganisationSchemes = null; Concepts.HierarchicalCodelists = null; Concepts.KeyFamilies = null; Concepts.Metadataflows = null; Concepts.MetadataStructureDefinitions = null; Concepts.Processes = null; Concepts.ReportingTaxonomies = null; Concepts.StructureSets = null; Concepts.CategorySchemes = null; Concepts.CodeLists = null; Concepts.Dataflows = null; Concepts.Concepts.ConceptScheme = null; //Creating Concepts and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), Concepts, sdmxFolderPath + "\\Concepts\\" + DevInfo.Lib.DI_LibSDMX.Constants.ConceptScheme.DSD.FileName); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, string.Empty, Concepts.Concepts.Concept[0].agencyID, Concepts.Concepts.Concept[0].version, string.Empty, ArtefactTypes.ConceptS, sdmxFolderPath + "\\Concepts\\" + DevInfo.Lib.DI_LibSDMX.Constants.ConceptScheme.DSD.FileName, DevInfo.Lib.DI_LibSDMX.Constants.ConceptScheme.DSD.FileName); } } //Creating DSD and saving its information in the Database.mdb SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), DSD, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.DSD.FileName); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, DSD.KeyFamilies[0].id, DSD.KeyFamilies[0].agencyID, DSD.KeyFamilies[0].version, string.Empty, ArtefactTypes.DSD, sdmxFolderPath + "\\" + DevInfo.Lib.DI_LibSDMX.Constants.DSD.FileName, DevInfo.Lib.DI_LibSDMX.Constants.DSD.FileName); //Creating DFD and saving its information in the Database.mdb Artefacts = SDMXUtility.Generate_DFD(SDMXSchemaType.Two_One, UploadedDSDStructure.KeyFamilies[0].id, AgencyId, null, sdmxFolderPath + "\\Provisioning Metadata"); //Creating PA per user and saving its information in the Database.mdb PAArtefacts = this.Create_PAs_For_Database_Per_Provider(DbNId.ToString(), AgencyId, sdmxFolderPath + "\\Provisioning Metadata\\PAs", Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.FileName), true); if (PAArtefacts != null && PAArtefacts.Count > 0) { Artefacts.AddRange(PAArtefacts); } this.Save_Artefacts_Details_In_Database(Artefacts, DbNId); ConsumerFileName = Path.Combine(AppPhysicalPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.DataConsumerScheme.FileName); if (File.Exists(ConsumerFileName)) { Structure = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), ConsumerFileName); if (Structure != null && Structure.Structures != null && Structure.Structures.OrganisationSchemes != null && Structure.Structures.OrganisationSchemes.Count > 0 && Structure.Structures.OrganisationSchemes[0] is SDMXObjectModel.Structure.DataConsumerSchemeType && Structure.Structures.OrganisationSchemes[0].Organisation != null && Structure.Structures.OrganisationSchemes[0].Organisation.Count > 0) { foreach (DataConsumerType DataConsumer in Structure.Structures.OrganisationSchemes[0].Organisation) { FolderName = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Subscriptions + DataConsumer.id.Replace(DevInfo.Lib.DI_LibSDMX.Constants.DataConsumerScheme.Prefix, string.Empty)); this.Create_Directory_If_Not_Exists(FolderName); } } } ProviderFileName = Path.Combine(AppPhysicalPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.FileName); if (File.Exists(ProviderFileName)) { Structure = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), ProviderFileName); if (Structure != null && Structure.Structures != null && Structure.Structures.OrganisationSchemes != null && Structure.Structures.OrganisationSchemes.Count > 0 && Structure.Structures.OrganisationSchemes[0] is SDMXObjectModel.Structure.DataProviderSchemeType && Structure.Structures.OrganisationSchemes[0].Organisation != null && Structure.Structures.OrganisationSchemes[0].Organisation.Count > 0) { foreach (DataProviderType DataProvider in Structure.Structures.OrganisationSchemes[0].Organisation) { FolderName = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Subscriptions + DataProvider.id.Replace(DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix, string.Empty)); this.Create_Directory_If_Not_Exists(FolderName); FolderName = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Registrations + DataProvider.id.Replace(DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix, string.Empty)); this.Create_Directory_If_Not_Exists(FolderName); FolderName = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Constraints + DataProvider.id.Replace(DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix, string.Empty)); this.Create_Directory_If_Not_Exists(FolderName); } } } } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Artefacts For Uploaded DSD From Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
public bool AdminUpdateArtifactsWithHeaderForUploadedDSD(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); SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); SDMXApi_2_0.Message.HeaderType Header = new SDMXApi_2_0.Message.HeaderType(); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml); Header = UploadedDSDStructure.Header; UploadedHeaderFolderPath = UploadedHeaderFolderPath + "/" + DbNId; RetVal = UpdateCompleteWithHeader(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx"); RetVal = UpdateCodelistsForUploadedDSDWithHeader(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx" + "/" + "Codelists"); RetVal = UpdateCategorySchemeForUploadedDSDWithHeader(DbNId, UserNId, DatabaseNIdfor2_1); RetVal = UpdateArtefactsForUploadedDSDWithHeader(Header, DbNId, UserNId, UploadedHeaderFolderPath + "/" + "sdmx", DatabaseNIdfor2_1); RetVal = UpdateNonMAForUploadedDSDWithHeader(DbNId, UserNId, DatabaseNIdfor2_1); } catch (Exception ex) { RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
private bool CreateCodelistsForUploadedDSD(SDMXApi_2_0.Message.StructureType UploadedDSDStructure, string CodelistsFolderPath, int DbNId) { bool RetVal; SDMXApi_2_0.Message.StructureType CodelistStructure; int CodelistIndex; string CodelistName; string CodelistId; string CodelistAgencyId; string CodelistVersion; RetVal = true; CodelistIndex = 0; CodelistName = string.Empty; CodelistId = string.Empty; CodelistAgencyId = string.Empty; CodelistVersion = string.Empty; try { foreach (SDMXApi_2_0.Structure.CodeListType CodeList in UploadedDSDStructure.CodeLists) { CodelistStructure = new SDMXApi_2_0.Message.StructureType(); CodelistStructure.CodeLists = new List<SDMXApi_2_0.Structure.CodeListType>(); CodelistStructure.CodeLists.Add(UploadedDSDStructure.CodeLists[CodelistIndex]); CodelistId = UploadedDSDStructure.CodeLists[CodelistIndex].id; CodelistAgencyId = UploadedDSDStructure.CodeLists[CodelistIndex].agencyID; CodelistVersion = UploadedDSDStructure.CodeLists[CodelistIndex].version; CodelistName = UploadedDSDStructure.CodeLists[CodelistIndex].Name[0].Value.ToString(); CodelistStructure.Header = UploadedDSDStructure.Header; CodelistStructure.OrganisationSchemes = null; CodelistStructure.HierarchicalCodelists = null; CodelistStructure.Concepts = null; CodelistStructure.Metadataflows = null; CodelistStructure.MetadataStructureDefinitions = null; CodelistStructure.Processes = null; CodelistStructure.ReportingTaxonomies = null; CodelistStructure.StructureSets = null; CodelistStructure.CategorySchemes = null; CodelistStructure.KeyFamilies = null; CodelistStructure.Dataflows = null; SDMXApi_2_0.Serializer.SerializeToFile(typeof(SDMXApi_2_0.Message.StructureType), CodelistStructure, CodelistsFolderPath + "\\" + CodelistName + ".xml"); this.Save_Artefacts_Details_For_Uploaded_DSD_In_Database(DbNId, CodelistId, CodelistAgencyId, CodelistVersion, string.Empty, ArtefactTypes.CL, CodelistsFolderPath + "\\" + CodelistName + ".xml", CodelistName + ".xml"); CodelistIndex = CodelistIndex + 1; } } catch (Exception ex) { //Global.WriteErrorsInLog("Creating Codelists For Uploaded DSD from Admin"); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); RetVal = false; Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
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; }
/// <summary> /// Generate and save header.xml file based passed input parameters /// </summary> /// <param name="requestParam">input parameters for generating header Xml file</param> /// <returns>True if header file created successfuly, else return false</returns> public bool SaveHeaderDetails(string requestParam) { Boolean RetVal = false; string[] Params; string DbNid = string.Empty; bool IsDIDatabase = false; HeaderDetailsTemplate ObjHeaderDet; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); DbNid = Params[0]; ObjHeaderDet = new HeaderDetailsTemplate(); ObjHeaderDet.LanguageCode = Params[1]; IsDIDatabase = Convert.ToBoolean(Params[2]); ObjHeaderDet.HeaderId = Params[3]; ObjHeaderDet.HeaderDsdName = Params[4]; ObjHeaderDet.SenderId = Params[5]; ObjHeaderDet.RecieverId = Params[6]; ObjHeaderDet.SenderName = Params[7]; ObjHeaderDet.SenderContactName = Params[8]; ObjHeaderDet.SenderDepartment = Params[9]; ObjHeaderDet.SenderRole = Params[10]; ObjHeaderDet.SenderFax = Params[11]; ObjHeaderDet.SenderTelephone = Params[12]; ObjHeaderDet.SenderEmail = Params[13]; ObjHeaderDet.RecieverName = Params[14]; ObjHeaderDet.RecieverContactName = Params[15]; ObjHeaderDet.RecieverDepartment = Params[16]; ObjHeaderDet.RecieverRole = Params[17]; ObjHeaderDet.RecieverFax = Params[18]; ObjHeaderDet.RecieverTelephone = Params[19]; ObjHeaderDet.RecieverEmail = Params[20]; ObjHeaderDet.Prepared = Params[22]; // Check if to save header for di adaptation--2.1 if (IsDIDatabase) { // Create StructureType object of SDMXObjectModel--2.1 SDMXObjectModel.Message.StructureType ObjStructure = new StructureType(); // Set header field of structure object, by calling method ObjStructure.Header = GetDiMessageHeaderStructure(ObjHeaderDet); ObjStructure.Footer = null; // Call method to save header xml RetVal = SaveDIHeaderStructure(DbNid, ObjStructure); } else// if to save header for unsd--2.0 { // create StructureType object of SDMXApi_2_0 SDMXApi_2_0.Message.StructureType ObjSdxmStructure = new SDMXApi_2_0.Message.StructureType(); // set header field of structure object ObjSdxmStructure.Header = GetSdmxMessageHeaderStructure(ObjHeaderDet); ObjSdxmStructure.Concepts = null; ObjSdxmStructure.KeyFamilies = null; ObjSdxmStructure.CodeLists = null; ObjSdxmStructure.MetadataStructureDefinitions = null; ObjSdxmStructure.OrganisationSchemes = null; ObjSdxmStructure.HierarchicalCodelists = null; ObjSdxmStructure.Metadataflows = null; ObjSdxmStructure.Processes = null; ObjSdxmStructure.ReportingTaxonomies = null; ObjSdxmStructure.StructureSets = null; ObjSdxmStructure.CategorySchemes = null; ObjSdxmStructure.Dataflows = null; // Call method to save header xml RetVal = SaveUNSDHeaderStructure(DbNid, ObjSdxmStructure); } } catch (Exception Ex) { Global.CreateExceptionString(Ex, null); RetVal = false; } return RetVal; }