//Returns the requires area levels public static DataTable GetAreaLevels(DIConnection dBConnection, DIQueries dBQueries) { DataTable dtAreaLevel = null; try { dtAreaLevel = dBConnection.ExecuteDataTable(dBQueries.Area.GetAreaLevel(FilterFieldType.None, string.Empty)); } catch (Exception) { } return dtAreaLevel; }
//Returns the all time periods public static DataTable GetAllTimePeriods(DIConnection dBConnection, DIQueries dBQueries) { DataTable dtTimePeriod=null; try { dtTimePeriod = dBConnection.ExecuteDataTable(dBQueries.Timeperiod.GetTimePeriod(FilterFieldType.None, string.Empty, Timeperiods.TimePeriod + " DESC")); } catch (Exception) { } return dtTimePeriod; }
/// <summary> /// Returns the instance of SubgroupInfo on the basis of Subgroup Nid /// </summary> /// <param name="sourceQuery"></param> /// <param name="sourceDBConnection"></param> /// <param name="subgroupNid"></param> /// <returns></returns> public static DI6SubgroupInfo GetSubgroupInfo(DIQueries queries, DIConnection dbConnection, FilterFieldType filterClause, string filterText) { string Query = string.Empty; DI6SubgroupInfo RetVal = new DI6SubgroupInfo(); DataTable SubgroupTable; DI6SubgroupTypeBuilder SGTypeBuilder; try { Query = queries.Subgroup.GetSubgroup(filterClause, filterText); SubgroupTable = dbConnection.ExecuteDataTable(Query); //set Subgroup info if (SubgroupTable != null) { if (SubgroupTable.Rows.Count > 0) { RetVal.GID = SubgroupTable.Rows[0][Subgroup.SubgroupGId].ToString(); RetVal.Global = Convert.ToBoolean(SubgroupTable.Rows[0][Subgroup.SubgroupGlobal]); RetVal.Name = SubgroupTable.Rows[0][Subgroup.SubgroupName].ToString(); RetVal.Nid = Convert.ToInt32(SubgroupTable.Rows[0][Subgroup.SubgroupNId].ToString()); RetVal.Type = Convert.ToInt32(SubgroupTable.Rows[0][Subgroup.SubgroupType].ToString()); // Get subgrouptype info if (RetVal.Type > 0) { SGTypeBuilder = new DI6SubgroupTypeBuilder(dbConnection, queries); RetVal.DISubgroupType = SGTypeBuilder.GetSubgroupTypeInfoByNid(RetVal.Type); } } } } catch (Exception) { RetVal = null; } return RetVal; }
/// <summary> /// Getting MetaData and writing them to Rtf file. /// </summary> public static string ExtractRtfMetadata(ICType ICType, int ICNId, DIConnection DIConnection, DIQueries DIQueries, String outputFolder, String outputFileName) { string RetVal = string.Empty; string RtfFilePath = System.IO.Path.Combine(outputFolder, outputFileName + ".rtf"); DataTable RtfDataTable = new DataTable(); try { if (System.IO.File.Exists(RtfFilePath)) { System.IO.File.Delete(RtfFilePath); } // getting metadata informationn from Database into DataTable RtfDataTable string sSql = DIQueries.IndicatorClassification.GetIC(FilterFieldType.NId, ICNId.ToString(), ICType, FieldSelection.Heavy); RtfDataTable = DIConnection.ExecuteDataTable(sSql); if (RtfDataTable != null & RtfDataTable.Rows.Count > 0) { RetVal = RtfDataTable.Rows[0][IndicatorClassifications.ICName].ToString(); if (!Convert.IsDBNull(RtfDataTable.Rows[0][IndicatorClassifications.ICInfo])) { string RtfString = RtfDataTable.Rows[0][IndicatorClassifications.ICInfo].ToString(); // Writng metadata into a rtf file in output directory if (RtfString.Trim().Length > 0) { WriteToFile(RtfString, RtfFilePath); } } } } catch (Exception) { //throw ex; } return RetVal; }
//Added to check gallery existence public int GalleryExistence(string requestParam) { int RetVal; DataTable dtPresentation; DIConnection DIConnection; string GetPresentationsQuery; string[] Params; int UserNId ; ; int AdminNId ; DIConnection = null; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); UserNId = Convert.ToInt32(Params[0].Trim()); AdminNId = Convert.ToInt32(this.Get_AdminNId()); DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); GetPresentationsQuery = "SELECT * FROM Presentations WHERE user_nid = " + UserNId + " OR user_nid = " + AdminNId + ""; dtPresentation = DIConnection.ExecuteDataTable(GetPresentationsQuery); RetVal = dtPresentation.Rows.Count; return RetVal; } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
public string GetIndicativeIdAgencyIdVersionValues(string requestParam) { string RetVal; string DBNId, SelectedFunction, FileName; string Id, AgencyId, Version; string[] Params; SDMXObjectModel.Message.StructureType Structure_Two_One; SDMXApi_2_0.Message.StructureType Structure_Two_Zero; DIConnection DIConnection; DataTable DtTable; RetVal = string.Empty; DBNId = string.Empty; SelectedFunction = string.Empty; FileName = string.Empty; Id = string.Empty; AgencyId = string.Empty; Version = string.Empty; Params = null; Structure_Two_One = null; Structure_Two_Zero = null; DIConnection = null; DtTable = null; try { Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); DBNId = Params[0].ToString().Trim(); SelectedFunction = Params[1].ToString().Trim(); DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); switch (SelectedFunction) { case "GetDataflow": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.DFD).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Dataflows != null && Structure_Two_One.Structures.Dataflows.Count > 0) { Id = Structure_Two_One.Structures.Dataflows[0].id; AgencyId = Structure_Two_One.Structures.Dataflows[0].agencyID; Version = Structure_Two_One.Structures.Dataflows[0].version; } break; case "GetMetadataflow": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.MFD).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Metadataflows != null && Structure_Two_One.Structures.Metadataflows.Count > 0) { Id = Structure_Two_One.Structures.Metadataflows[0].id; AgencyId = Structure_Two_One.Structures.Metadataflows[0].agencyID; Version = Structure_Two_One.Structures.Metadataflows[0].version; } break; case "GetDataStructure": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.DSD).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } if (Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DBNId)) == false) { Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.DataStructures != null && Structure_Two_One.Structures.DataStructures.Count > 0) { Id = Structure_Two_One.Structures.DataStructures[0].id; AgencyId = Structure_Two_One.Structures.DataStructures[0].agencyID; Version = Structure_Two_One.Structures.DataStructures[0].version; } } else { Structure_Two_Zero = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), FileName); if (Structure_Two_Zero != null && Structure_Two_Zero.KeyFamilies != null && Structure_Two_Zero.KeyFamilies.Count > 0) { Id = Structure_Two_Zero.KeyFamilies[0].id; AgencyId = Structure_Two_Zero.KeyFamilies[0].agencyID; Version = Structure_Two_Zero.KeyFamilies[0].version; } } break; case "GetMetadataStructure": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.MSD).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } if (Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DBNId)) == false) { Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.MetadataStructures != null && Structure_Two_One.Structures.MetadataStructures.Count > 0) { Id = Structure_Two_One.Structures.MetadataStructures[0].id; AgencyId = Structure_Two_One.Structures.MetadataStructures[0].agencyID; Version = Structure_Two_One.Structures.MetadataStructures[0].version; } } else { Structure_Two_Zero = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), FileName); if (Structure_Two_Zero != null && Structure_Two_Zero.MetadataStructureDefinitions != null && Structure_Two_Zero.MetadataStructureDefinitions.Count > 0) { Id = Structure_Two_Zero.MetadataStructureDefinitions[0].id; AgencyId = Structure_Two_Zero.MetadataStructureDefinitions[0].agencyID; Version = Structure_Two_Zero.MetadataStructureDefinitions[0].version; } } break; case "GetCategoryScheme": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.CategoryS).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.CategorySchemes != null && Structure_Two_One.Structures.CategorySchemes.Count > 0) { Id = Structure_Two_One.Structures.CategorySchemes[0].id; AgencyId = Structure_Two_One.Structures.CategorySchemes[0].agencyID; Version = Structure_Two_One.Structures.CategorySchemes[0].version; } break; case "GetCategorisation": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.Categorisation).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Categorisations != null && Structure_Two_One.Structures.Categorisations.Count > 0) { Id = Structure_Two_One.Structures.Categorisations[0].id; AgencyId = Structure_Two_One.Structures.Categorisations[0].agencyID; Version = Structure_Two_One.Structures.Categorisations[0].version; } break; case "GetConceptScheme": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.ConceptS).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } if (Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DBNId)) == false) { Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Concepts != null && Structure_Two_One.Structures.Concepts.Count > 0) { Id = Structure_Two_One.Structures.Concepts[0].id; AgencyId = Structure_Two_One.Structures.Concepts[0].agencyID; Version = Structure_Two_One.Structures.Concepts[0].version; } } else { Structure_Two_Zero = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), FileName); if (Structure_Two_Zero != null && Structure_Two_Zero.Concepts != null && Structure_Two_Zero.Concepts.ConceptScheme != null && Structure_Two_Zero.Concepts.ConceptScheme.Count > 0) { Id = Structure_Two_Zero.Concepts.ConceptScheme[0].id; AgencyId = Structure_Two_Zero.Concepts.ConceptScheme[0].agencyID; Version = Structure_Two_Zero.Concepts.ConceptScheme[0].version; } } break; case "GetCodelist": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.CL).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } if (Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DBNId)) == false) { Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Codelists != null && Structure_Two_One.Structures.Codelists.Count > 0) { Id = Structure_Two_One.Structures.Codelists[0].id; AgencyId = Structure_Two_One.Structures.Codelists[0].agencyID; Version = Structure_Two_One.Structures.Codelists[0].version; } } else { Structure_Two_Zero = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), FileName); if (Structure_Two_Zero != null && Structure_Two_Zero.CodeLists != null && Structure_Two_Zero.CodeLists.Count > 0) { Id = Structure_Two_Zero.CodeLists[0].id; AgencyId = Structure_Two_Zero.CodeLists[0].agencyID; Version = Structure_Two_Zero.CodeLists[0].version; } } break; case "GetOrganisationScheme": FileName = Path.Combine(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Users), DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.FileName); Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.OrganisationSchemes != null && Structure_Two_One.Structures.OrganisationSchemes.Count > 0) { Id = Structure_Two_One.Structures.OrganisationSchemes[0].id; AgencyId = Structure_Two_One.Structures.OrganisationSchemes[0].agencyID; Version = Structure_Two_One.Structures.OrganisationSchemes[0].version; } break; case "GetProvisionAgreement": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.PA).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.ProvisionAgreements != null && Structure_Two_One.Structures.ProvisionAgreements.Count > 0) { Id = Structure_Two_One.Structures.ProvisionAgreements[0].id; AgencyId = Structure_Two_One.Structures.ProvisionAgreements[0].agencyID; Version = Structure_Two_One.Structures.ProvisionAgreements[0].version; } break; case "GetConstraint": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.Constraint).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Constraints != null && Structure_Two_One.Structures.Constraints.Count > 0) { Id = Structure_Two_One.Structures.Constraints[0].id; AgencyId = Structure_Two_One.Structures.Constraints[0].agencyID; Version = Structure_Two_One.Structures.Constraints[0].version; } break; case "GetStructures": DtTable = DIConnection.ExecuteDataTable("SELECT FileLocation FROM Artefacts Where DBNId = " + DBNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.DFD).ToString()); if (DtTable != null && DtTable.Rows.Count > 0) { FileName = DtTable.Rows[0]["FileLocation"].ToString(); } Structure_Two_One = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), FileName); if (Structure_Two_One != null && Structure_Two_One.Structures != null && Structure_Two_One.Structures.Dataflows != null && Structure_Two_One.Structures.Dataflows.Count > 0) { Id = Structure_Two_One.Structures.Dataflows[0].id; AgencyId = Structure_Two_One.Structures.Dataflows[0].agencyID; Version = Structure_Two_One.Structures.Dataflows[0].version; } break; default: break; } RetVal = Id + "," + AgencyId + "," + Version; } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal; }
private XmlDocument Retrieve_Artefact(string Id, string AgencyId, string Version, string DbNId) { XmlDocument RetVal; string Query, FileNameWPath; DIConnection DIConnection; DataTable DtTable; RetVal = new XmlDocument(); Query = string.Empty; FileNameWPath = string.Empty; DIConnection = null; DtTable = null; try { if (!string.IsNullOrEmpty(Id) && !string.IsNullOrEmpty(Version)) { if (Id != DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Id && Id != DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Id && Id != DevInfo.Lib.DI_LibSDMX.Constants.DataConsumerScheme.Id) { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); if ((AgencyId == DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.AgencyId) || (AgencyId == DevInfo.Lib.DI_LibSDMX.Constants.DataConsumerScheme.AgencyId) || (AgencyId == DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.AgencyId)) { Query = "SELECT FileLocation FROM Artefacts WHERE Id = '" + Id; } else { Query = "SELECT FileLocation FROM Artefacts WHERE DBNId = " + DbNId + " AND Id = '" + Id; } if (!string.IsNullOrEmpty(AgencyId)) { Query += "' AND AgencyId = '" + AgencyId; } if (!string.IsNullOrEmpty(Version)) { Query += "' AND Version = '" + Version + "';"; } DtTable = DIConnection.ExecuteDataTable(Query); if (DtTable != null && DtTable.Rows.Count > 0) { FileNameWPath = DtTable.Rows[0]["FileLocation"].ToString(); RetVal.Load(FileNameWPath); } } else { switch (Id) { case DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.Id: FileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.MaintenanceAgencyScheme.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Id: FileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.DataConsumerScheme.Id: FileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Users + DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.FileName); break; default: break; } RetVal.Load(FileNameWPath); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal; }
public XmlDocument SubmitSubscription([XmlAnyElement] XmlDocument Input, string langPrefNid) { RegistryInterfaceType RegistryInterfaceRequest, RegistryInterfaceResponse; SubscriptionRequestType SubscriptionRequest; ActionType Action; DIConnection DIConnection; DataTable DtTable; string UserId, UserNId; string MaxNId, RegistryURN, SubscriberAssignedId; string FileNameWPath, Query; RegistryInterfaceRequest = null; RegistryInterfaceResponse = null; SubscriptionRequest = null; DIConnection = null; DtTable = null; UserId = string.Empty; UserNId = string.Empty; MaxNId = string.Empty; RegistryURN = string.Empty; SubscriberAssignedId = string.Empty; FileNameWPath = string.Empty; Query = string.Empty; try { try { RegistryInterfaceRequest = (RegistryInterfaceType)Deserializer.LoadFromXmlDocument(typeof(RegistryInterfaceType), Input); } catch (Exception) { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); if (RegistryInterfaceRequest.Item != null) { if (((SubmitSubscriptionsRequestType)RegistryInterfaceRequest.Item).SubscriptionRequest != null && ((SubmitSubscriptionsRequestType)RegistryInterfaceRequest.Item).SubscriptionRequest.Count > 0) { SubscriptionRequest = ((SubmitSubscriptionsRequestType)RegistryInterfaceRequest.Item).SubscriptionRequest[0]; if (SubscriptionRequest.Subscription != null) { if (SubscriptionRequest.Subscription.Organisation != null && SubscriptionRequest.Subscription.Organisation.Items != null && SubscriptionRequest.Subscription.Organisation.Items.Count > 0) { if (SubscriptionRequest.Subscription.Organisation.Items[0] is DataProviderRefType) { UserId = ((DataProviderRefType)SubscriptionRequest.Subscription.Organisation.Items[0]).id; } else { UserId = ((DataConsumerRefType)SubscriptionRequest.Subscription.Organisation.Items[0]).id; } UserNId = UserId.Split('_')[1]; Action = SubscriptionRequest.action; SubscriberAssignedId = SubscriptionRequest.Subscription.SubscriberAssignedID; RegistryInterfaceRequest.Footer = null; if (!string.IsNullOrEmpty(SubscriberAssignedId)) { switch (Action) { case ActionType.Append: if (UserId.Contains(DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix)) { Global.Create_Provider_In_DPScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); } else { Global.Create_Consumer_In_DCScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); } Query = "SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;"; DtTable = DIConnection.ExecuteDataTable(Query); MaxNId = (Convert.ToInt32(DtTable.Rows[0]["MaxNId"].ToString()) + 1).ToString(); RegistryURN = Guid.NewGuid().ToString(); SubscriptionRequest.Subscription.RegistryURN = RegistryURN; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Subscriptions/" + UserNId + "/" + RegistryURN + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); // validate Artefact schema for langPrefNid Global.BaselineAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation, LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistryURN + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ",'" + FileNameWPath + "', '" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); RegistryInterfaceResponse = this.Get_SubmitSubscriptions_Reponse(SubscriberAssignedId, RegistryURN, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Delete: RegistryURN = SubscriptionRequest.Subscription.RegistryURN; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Subscriptions/" + UserNId + "/" + RegistryURN + ".xml"); File.Delete(FileNameWPath); Query = "DELETE FROM Artefacts WHERE Id = '" + RegistryURN + "' AND Type = " + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ";"; DIConnection.ExecuteDataTable(Query); RegistryInterfaceResponse = this.Get_SubmitSubscriptions_Reponse(SubscriberAssignedId, RegistryURN, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Replace: RegistryURN = SubscriptionRequest.Subscription.RegistryURN; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Subscriptions/" + UserNId + "/" + RegistryURN + ".xml"); File.Delete(FileNameWPath); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Query = "DELETE FROM Artefacts WHERE Id = '" + RegistryURN + "' AND Type = " + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ";"; DIConnection.ExecuteDataTable(Query); // validate Artefact schema for langPrefNid Global.BaselineAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation, LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistryURN + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ",'" + FileNameWPath + "', '" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); RegistryInterfaceResponse = this.Get_SubmitSubscriptions_Reponse(SubscriberAssignedId, RegistryURN, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; default: break; } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); this.Handle_Exception(ex); } finally { } return Input; }
//public string AdminUpdateDatabaseForUploadedDSD(string requestParam) //{ // string RetVal = string.Empty; // string[] Params; // string DBConnectionsFile = string.Empty; // XmlDocument UploadedDSDXml = new XmlDocument(); // XmlDocument XmlDoc; // XmlNode xmlNode; // string UploadedDSDFileWPath = string.Empty; // string DbNId = string.Empty; // string AssosciatedDb = string.Empty; // string UploadedDSDFolderPath = Server.MapPath("../../stock/data"); // string UploadedDSDName = string.Empty; // string UserNId = string.Empty; // bool DefaultDB = false; // try // { // Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); // UploadedDSDFileWPath = Params[0]; // DbNId = Params[1]; // AssosciatedDb = Params[2]; // UserNId = Params[3]; // if (Params.Length > 4) // { // if (!bool.TryParse(Params[4], 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); // xmlNode = XmlDoc.SelectSingleNode("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "/" + Constants.XmlFile.Db.Tags.Database + "[@" + Constants.XmlFile.Db.Tags.DatabaseAttributes.Id + "=" + DbNId + "]"); // 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"; // } // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Name].Value = UploadedDSDName; // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId].Value = UploadedDSDStructure.KeyFamilies[0].id; // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId].Value = UploadedDSDStructure.KeyFamilies[0].agencyID; // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion].Value = UploadedDSDStructure.KeyFamilies[0].version; // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.AssosciatedDb].Value = AssosciatedDb; // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.LastModified].Value = string.Format("{0:yyyy-MM-dd}", DateTime.Today.Date); // xmlNode.Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DescriptionEnglish].Value = UploadedDSDName; // if (DefaultDB == true) // { // // XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.Default].Value = DbNId.ToString(); // 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, DbNId.ToString()); // } // else // { // XmlDoc.GetElementsByTagName(Constants.XmlFile.Db.Tags.Root)[0].Attributes[Constants.XmlFile.Db.Tags.RootAttributes.DefaultDSD].Value = DbNId.ToString(); // Session["hdbnid"] = Convert.ToString(DbNId); // } // } // 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); // this.Clean_SDMX_Folder_Structure(Convert.ToInt32(DbNId)); // //----------------------------------------------------------------------------------------------------------------- // //----------------------Updation of folder structure for uploaded DSD as per the DbNId alloted to Uploaded DSD in db.xml---- // UploadedDSDFolderPath = UploadedDSDFolderPath + "/" + DbNId; // RetVal = CreateFolderStructureForUploadedDSD(UploadedDSDFolderPath).ToString(); // this.Delete_SDMXArtefacts_Details_In_Database(DbNId, UserNId);//commented // //----------------------Updation of Complete File for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml--------- // RetVal = CreateCompleteFileForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", Convert.ToInt32(DbNId), UserNId).ToString(); // //----------------------Updation of Complete File for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml--------- // RetVal = CreateHeaderFileForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", Convert.ToInt32(DbNId), UserNId).ToString(); // //----------------------Updation of Codelists for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml--------- // RetVal = CreateCodelistsForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx" + "/" + "Codelists", Convert.ToInt32(DbNId)).ToString(); // //----------------------Updation of the Category Scheme for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml--------- // RetVal = CreateCategorySchemeForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", Convert.ToInt32(DbNId), Convert.ToInt32(AssosciatedDb), UserNId).ToString(); // //----------------------Updation of the Report for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml--------- // RetVal = CreateReportForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", Convert.ToInt32(DbNId), UserNId).ToString(); // //----------------------Updation of Other Artefacts for uploaded DSD as per the DbNId alloted to Uploaded DSD alloted to it in db.xml----------- // RetVal = CreateArtefactsForUploadedDSD(UploadedDSDStructure, UploadedDSDFolderPath + "/" + "sdmx", Convert.ToInt32(DbNId), UserNId).ToString(); // this.Send_Notifications_For_Subscriptions_For_Structural_Metadata_Changes(DbNId); // //AdminUpdateArtifactsWithHeaderForUploadedDSD(requestParam); // } // 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 string AdminGetAllTheUploadedDSDsTable(string requestParam) { string RetVal = string.Empty; string DBFile = string.Empty; string DSDPath = string.Empty; string DSDViewPath = string.Empty; string AssociatedDb = string.Empty; string Publisher = string.Empty; string UserNId = string.Empty; XmlDocument XmlDoc; XmlNodeList XmlNodes; DIConnection DIConnection = null; string Query = string.Empty; DataTable DtDFD; int i = 0; int DSDCount = 0; string HeaderFilePath = string.Empty; string DbNid = string.Empty; try { UserNId = requestParam; DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); 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\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Id\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_AgencyId\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Version\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Assosciated_Database\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Publisher_DSD\"></span></td>"; // RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Details\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Action\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Header\"></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)) { DSDCount = DSDCount + 1; RetVal = RetVal + "<tr class=\"DataRowStyle \">"; RetVal += "<td class=\"DataColumnStyle \">" + DSDCount + "</td>"; RetVal += "<td class=\"DataColumnStyle \">" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDId].Value + "</td>"; if (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId] != null) { RetVal += "<td class=\"DataColumnStyle \">" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDAgencyId].Value + "</td>"; } else { RetVal += "<td class=\"DataColumnStyle \"></td>"; } RetVal += "<td class=\"DataColumnStyle \">" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DSDVersion].Value + "</td>"; if (XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.AssosciatedDb] != null) { AssociatedDb = XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.AssosciatedDb].Value; RetVal += "<td class=\"DataColumnStyle \">" + Global.GetDbConnectionDetails(AssociatedDb)[0] + "</td>"; } else { RetVal += "<td class=\"DataColumnStyle \"></td>"; } DSDPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "\\sdmx\\DSD" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); DSDViewPath = "../../" + Constants.FolderName.Data + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "/sdmx/DSD" + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension; Query = "SELECT * FROM Artefacts WHERE Type=" + Convert.ToInt32(ArtefactTypes.DFD).ToString() + " And DbNId = " + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + ";"; DtDFD = DIConnection.ExecuteDataTable(Query); if (DtDFD.Rows.Count > 0) { Publisher = DtDFD.Rows[0]["AgencyId"].ToString(); RetVal += "<td class=\"DataColumnStyle \">" + Publisher + "</td>"; } else { RetVal += "<td class=\"DataColumnStyle \"></td>"; } // RetVal += "<td class=\"DataColumnStyle \">" + "<a style=\"cursor:pointer;\" href=\"" + DSDViewPath.Replace("\\", "/") + "\" target=\"_blank\" name=\"lang_View\"></a> | <a style=\"cursor:pointer;\" href='Download.aspx?fileId=" + DSDPath + "' name=\"lang_Download\"></a>" + "</td>"; if (string.IsNullOrEmpty(Publisher)) { RetVal += "<td class=\"DataColumnStyle \"></td>"; } else { if (this.isUserAdmin(UserNId) == true)//Global.SplitString(Publisher, "_")[1] == UserNId { RetVal += "<td class=\"DataColumnStyle \">" + "<a style=\"cursor:pointer;\" href=\"javascript:void(0);\" onclick=\"OpenUploadDSDPopup('U','" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "','" + AssociatedDb + "');\" name=\"lang_Edit\"></a> | <a style=\"cursor:pointer;\" href=\"javascript:void(0);\" onclick=\"OpenUploadDSDPopup('D','" + XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + "','" + AssociatedDb + "');\" name=\"lang_Delete\"></a>" + "</td>"; } else { RetVal += "<td class=\"DataColumnStyle \"></td>"; } } DbNid = XmlNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value; HeaderFilePath = "../../" + Constants.FolderName.Data + DbNid + "\\" + Constants.FolderName.SDMX.sdmx + Constants.FileName.HeaderFileName; RetVal += "<td class=\"DataColumnStyle \">" + "<a style=\"cursor:pointer;\" href=\"" + HeaderFilePath.Replace("\\", "/") + "\" target=\"_blank\" name=\"lang_View\"></a> | <a style=\"cursor:pointer;\" href=\"javascript:void(0);\" onclick=\"OpenHeaderUpdatePopup(false,'" + DbNid + "');\" name=\"lang_Edit\"></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 Dictionary<string, SubscriptionType> Get_Subscriptions_Dictionary_For_Structural_Metadata_Changes(string DbNId) { Dictionary<string, SubscriptionType> RetVal; string Query, FileNameWPath; DIConnection DIConnection; DataTable DtSubscriptions; SDMXObjectModel.Message.RegistryInterfaceType RegistryInterface; SDMXObjectModel.Registry.SubscriptionType Subscription; RetVal = new Dictionary<string, SubscriptionType>(); Query = string.Empty; FileNameWPath = string.Empty; DIConnection = null; 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 = " + DbNId + " AND Type = " + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ";"; DtSubscriptions = DIConnection.ExecuteDataTable(Query); foreach (DataRow DrSubscriptions in DtSubscriptions.Rows) { FileNameWPath = DrSubscriptions["FileLocation"].ToString(); RegistryInterface = (SDMXObjectModel.Message.RegistryInterfaceType)SDMXObjectModel.Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), FileNameWPath); Subscription = ((SDMXObjectModel.Registry.SubmitSubscriptionsRequestType)RegistryInterface.Item).SubscriptionRequest[0].Subscription; if (Subscription.EventSelector[0] is StructuralRepositoryEventsType) { RetVal.Add(Subscription.RegistryURN, Subscription); } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } return RetVal; }
private void Delete_SDMXArtefacts_Details_In_Database(string DbNId, string AdminNId) { string DeleteQuery; DIConnection DIConnection; DataTable DtTable; string RegistrationFolder = string.Empty; DeleteQuery = string.Empty; DIConnection = null; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); DtTable = DIConnection.ExecuteDataTable("SELECT * FROM Artefacts WHERE DBNId = " + DbNId + " AND Type = " + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ";"); foreach (DataRow DrTable in DtTable.Rows) { if (DrTable["FileLocation"].ToString().Contains(@"\" + DbNId + @"\" + Constants.FolderName.SDMX.Registrations + AdminNId + @"\")) { Global.Delete_Registration_Artefact(DbNId, AdminNId, DrTable["Id"].ToString()); Global.Delete_Constraint_Artefact(DbNId, AdminNId, DrTable["Id"].ToString()); } } DeleteQuery = "DELETE FROM Artefacts WHERE DBNId = " + DbNId + " AND (Type NOT IN (" + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + "," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + "," + Convert.ToInt32(ArtefactTypes.Constraint).ToString() + "," + Convert.ToInt32(ArtefactTypes.Mapping).ToString() + "));"; DIConnection.ExecuteDataTable(DeleteQuery); } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
private static DataTable Get_User(int UserNId) { DataTable RetVal; DIConnection DIConnection; string Query; RetVal = null; DIConnection = null; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT * FROM Users WHERE NId = " + UserNId.ToString() + ";"; RetVal = DIConnection.ExecuteDataTable(Query); } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } return RetVal; }
private static Dictionary<string, SubscriptionType> Get_Subscriptions_Dictionary(string DbNId, bool IsMetadata) { Dictionary<string, SubscriptionType> RetVal; string Query, FileNameWPath; DIConnection DIConnection; DataTable DtSubscriptions; SDMXObjectModel.Message.RegistryInterfaceType RegistryInterface; SDMXObjectModel.Registry.SubscriptionType Subscription; RetVal = new Dictionary<string, SubscriptionType>(); Query = string.Empty; FileNameWPath = string.Empty; DIConnection = null; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT * FROM Artefacts WHERE DBNId = " + DbNId + " AND Type = " + Convert.ToInt32(ArtefactTypes.Subscription).ToString() + ";"; DtSubscriptions = DIConnection.ExecuteDataTable(Query); foreach (DataRow DrSubscriptions in DtSubscriptions.Rows) { FileNameWPath = DrSubscriptions["FileLocation"].ToString(); RegistryInterface = (SDMXObjectModel.Message.RegistryInterfaceType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.RegistryInterfaceType), FileNameWPath); Subscription = ((SDMXObjectModel.Registry.SubmitSubscriptionsRequestType)RegistryInterface.Item).SubscriptionRequest[0].Subscription; if (Subscription.EventSelector != null && Subscription.EventSelector.Count > 0) { if (IsMetadata == false) { if (Subscription.EventSelector[0] is DataRegistrationEventsType) { RetVal.Add(Subscription.RegistryURN, Subscription); } } else { if (Subscription.EventSelector[0] is MetadataRegistrationEventsType) { RetVal.Add(Subscription.RegistryURN, Subscription); } } } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } return RetVal; }
private static void Create_Other_Artefacts_And_Update_Folder_Structures_For_Consumer_Per_Database(string UserNId) { DataTable DtRegisteredDatabases; DIConnection DIConnection; string OutputFolder; string Query; DtRegisteredDatabases = null; DIConnection = null; OutputFolder = string.Empty; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT DISTINCT DBNId FROM Artefacts WHERE DBNId <> -1;"; DtRegisteredDatabases = DIConnection.ExecuteDataTable(Query); foreach (DataRow DrRegisteredDatabases in DtRegisteredDatabases.Rows) { #region "--Subscription--" OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DrRegisteredDatabases["DBNId"].ToString() + "\\sdmx\\Subscriptions\\" + UserNId); Create_Directory_If_Not_Exists(OutputFolder); #endregion "--Subscription--" } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
public static void Create_Constraint_Artefact_For_Version_2_0_SDMLMLFile(string RegistrationId, string DbNId, string UserNId, string AgencyId, string FileURL) { string InsertQuery, OutputFolder; DIConnection DIConnection; XmlDocument SimpleDataFileXML; XmlNodeList ObjXmlNodeList; SDMXObjectModel.Message.StructureType ConstraintStructure; SDMXObjectModel.Structure.ContentConstraintType ContentConstraint; DataKeySetType DataKeySet; DataKeyValueType DataKeyValue; int KeyIndex; string SimpleDataFileUrl = string.Empty; string ConstraintFileName = string.Empty; string ConstraintFileLocation = string.Empty; InsertQuery = string.Empty; OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNId + "\\sdmx\\Constraints\\" + UserNId); ConstraintFileName = DevInfo.Lib.DI_LibSDMX.Constants.Constraint.Prefix + RegistrationId + ".xml"; ConstraintFileLocation = OutputFolder + "\\" + ConstraintFileName; DIConnection = null; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); SimpleDataFileXML = new XmlDocument(); if (!String.IsNullOrEmpty(FileURL)) { SimpleDataFileXML.Load(FileURL); } ObjXmlNodeList = SimpleDataFileXML.GetElementsByTagName("sts:Series"); ConstraintStructure = new SDMXObjectModel.Message.StructureType(); ConstraintStructure.Structures = new StructuresType(); ConstraintStructure.Structures.Constraints = new List<ConstraintType>(); ContentConstraint = new SDMXObjectModel.Structure.ContentConstraintType(); ContentConstraint.id = DevInfo.Lib.DI_LibSDMX.Constants.Constraint.Prefix + RegistrationId; ContentConstraint.Name.Add(new TextType(null, DevInfo.Lib.DI_LibSDMX.Constants.Constraint.Name + RegistrationId)); ContentConstraint.agencyID = AgencyId; ContentConstraint.version = DevInfo.Lib.DI_LibSDMX.Constants.Constraint.Version; ContentConstraint.Description.Add(new TextType(null, DevInfo.Lib.DI_LibSDMX.Constants.Constraint.Description)); ContentConstraint.Annotations = null; ContentConstraint.ReleaseCalendar = null; ContentConstraint.ConstraintAttachment = new ContentConstraintAttachmentType(); if (!String.IsNullOrEmpty(FileURL)) { ContentConstraint.ConstraintAttachment.Items = new object[1]; ContentConstraint.ConstraintAttachment.Items[0] = FileURL; ContentConstraint.ConstraintAttachment.ItemsElementName = new ConstraintAttachmentChoiceType[] { ConstraintAttachmentChoiceType.SimpleDataSource }; } DataKeySet = new DataKeySetType(); DataKeySet.isIncluded = true; ContentConstraint.Items.Add(DataKeySet); KeyIndex = 0; foreach (XmlNode SeriesNode in ObjXmlNodeList) { ((DataKeySetType)(ContentConstraint.Items[0])).Key.Add(new DataKeyType()); foreach (XmlAttribute SeriesAttribute in SeriesNode.Attributes) { DataKeyValue = new DataKeyValueType(); DataKeyValue.id = SeriesAttribute.Name; DataKeyValue.Items.Add(new SimpleKeyValueType()); ((SimpleKeyValueType)(DataKeyValue.Items[0])).Value = SeriesAttribute.Value; ((DataKeySetType)(ContentConstraint.Items[0])).Key[KeyIndex].KeyValue.Add(DataKeyValue); } KeyIndex = KeyIndex + 1; } ConstraintStructure.Structures.Constraints.Add(ContentConstraint); SDMXObjectModel.Serializer.SerializeToFile(typeof(SDMXObjectModel.Message.StructureType), ConstraintStructure, ConstraintFileLocation); InsertQuery = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DbNId + ",'" + ContentConstraint.id + "','" + ContentConstraint.agencyID + "','" + ContentConstraint.version + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Constraint).ToString() + ",'" + ConstraintFileLocation + "');"; DIConnection.ExecuteDataTable(InsertQuery); } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
private string Get_MFDId_From_DBNId(string DbNId) { string RetVal = string.Empty; DataTable DtTable; DIConnection DIConnection; DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); DtTable = DIConnection.ExecuteDataTable("SELECT Id FROM Artefacts WHERE DBNId = " + DbNId + " AND Type = " + Convert.ToInt32(ArtefactTypes.MFD).ToString() + ";"); if (DtTable != null && DtTable.Rows.Count > 0) { RetVal = DtTable.Rows[0]["Id"].ToString(); } return RetVal; }
private List<ArtefactInfo> Create_PAs_For_Database_Per_Provider(string DbNId, string AgencyId, string OutputFolder, string ProviderFileName, bool UploadedDSDFlag) { List<ArtefactInfo> RetVal; DataTable DtMFDs; DIConnection DIConnection; SDMXObjectModel.Message.StructureType Structure; string ProviderId; string MFDId; string Query; RetVal = new List<ArtefactInfo>(); DIConnection = null; Structure = null; ProviderId = string.Empty; MFDId = string.Empty; Query = string.Empty; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT * FROM Artefacts WHERE Type=" + Convert.ToInt32(ArtefactTypes.MFD).ToString() + " And DbNId = " + DbNId + ";"; DtMFDs = DIConnection.ExecuteDataTable(Query); 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) { ProviderId = DataProvider.id; RetVal.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, true, DevInfo.Lib.DI_LibSDMX.Constants.DFD.Id, ProviderId, AgencyId, null, OutputFolder)); if (UploadedDSDFlag == false) { RetVal.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Area.Id, ProviderId, AgencyId, null, OutputFolder)); RetVal.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Indicator.Id, ProviderId, AgencyId, null, OutputFolder)); RetVal.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Source.Id, ProviderId, AgencyId, null, OutputFolder)); } else { foreach (DataRow DrMFDs in DtMFDs.Rows) { MFDId = DrMFDs["Id"].ToString(); RetVal.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, MFDId, ProviderId, AgencyId, null, OutputFolder)); } } } } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } return RetVal; }
public static void Create_Other_Artefacts_And_Update_Folder_Structures_For_Provider_Per_Database(string UserNId) { DataTable DtRegisteredDatabases, DtTable; DIConnection DIConnection; string AgencyId, OutputFolder; string Query, InsertQuery; List<ArtefactInfo> PAArtefacts; DtRegisteredDatabases = null; DtTable = null; DIConnection = null; AgencyId = string.Empty; OutputFolder = string.Empty; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); Query = "SELECT DISTINCT DBNId FROM Artefacts WHERE DBNId <> -1;"; DtRegisteredDatabases = DIConnection.ExecuteDataTable(Query); foreach (DataRow DrRegisteredDatabases in DtRegisteredDatabases.Rows) { #region "--PA--" AgencyId = Get_AgencyId_From_DFD(DrRegisteredDatabases["DBNId"].ToString()); OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DrRegisteredDatabases["DBNId"].ToString() + "\\sdmx\\Provisioning Metadata\\PAs"); PAArtefacts = SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, true, DevInfo.Lib.DI_LibSDMX.Constants.DFD.Id, DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix + UserNId, AgencyId, null, OutputFolder); if (!Global.IsDSDUploadedFromAdmin(Convert.ToInt32(DrRegisteredDatabases["DBNId"].ToString()))) { PAArtefacts.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Area.Id, DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix + UserNId, AgencyId, null, OutputFolder)); PAArtefacts.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Indicator.Id, DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix + UserNId, AgencyId, null, OutputFolder)); PAArtefacts.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DevInfo.Lib.DI_LibSDMX.Constants.MFD.Source.Id, DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix + UserNId, AgencyId, null, OutputFolder)); } else { Query = "SELECT DISTINCT Id FROM Artefacts WHERE DBNId = " + DrRegisteredDatabases["DBNId"].ToString() + " AND Type = " + Convert.ToInt32(ArtefactTypes.MFD).ToString(); DtTable = DIConnection.ExecuteDataTable(Query); foreach (DataRow DrTable in DtTable.Rows) { PAArtefacts.AddRange(SDMXUtility.Generate_PA(SDMXSchemaType.Two_One, false, DrTable["Id"].ToString(), DevInfo.Lib.DI_LibSDMX.Constants.DataProviderScheme.Prefix + UserNId, AgencyId, null, OutputFolder)); } } foreach (ArtefactInfo PAArtefact in PAArtefacts) { InsertQuery = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation) VALUES(" + DrRegisteredDatabases["DBNId"].ToString() + ",'" + PAArtefact.Id + "','" + PAArtefact.AgencyId + "','" + PAArtefact.Version + "','" + string.Empty + "'," + Convert.ToInt32(PAArtefact.Type) + ",'" + Path.Combine(OutputFolder, PAArtefact.FileName) + "');"; DIConnection.ExecuteDataTable(InsertQuery); } #endregion "--PA--" #region "--Registration--" OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DrRegisteredDatabases["DBNId"].ToString() + "\\sdmx\\Registrations\\" + UserNId); Create_Directory_If_Not_Exists(OutputFolder); #endregion "--Registration--" #region "--Constraint--" OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DrRegisteredDatabases["DBNId"].ToString() + "\\sdmx\\Constraints\\" + UserNId); Create_Directory_If_Not_Exists(OutputFolder); #endregion "--Constraint--" #region "--Subscription--" OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DrRegisteredDatabases["DBNId"].ToString() + "\\sdmx\\Subscriptions\\" + UserNId); Create_Directory_If_Not_Exists(OutputFolder); #endregion "--Subscription--" } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
private string GetAllDbConnectionsWithPublishDetails(string CategoryName, string UseNId) { string RetVal = string.Empty; string DBFile = string.Empty; string DbNId = string.Empty; string ConnectionName = string.Empty; string DatabaseType = string.Empty; string CreatedOn = string.Empty; string Publisher = string.Empty; DIConnection DIConnection = null; string Query = string.Empty; DataTable DtDFD; XmlDocument XmlDoc; XmlNode xmlNode; int i = 0; string DefDbNId = string.Empty; string ConnStr = string.Empty; string DbType = string.Empty; try { DefDbNId = Global.GetDefaultDbNId(); DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); DBFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]); XmlDoc = new XmlDocument(); XmlDoc.Load(DBFile); xmlNode = XmlDoc.SelectSingleNode("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "[@" + Constants.XmlFile.Db.Tags.CategoryAttributes.Name + "='" + CategoryName + "']"); RetVal = "<table style=\"width:100%; \" border=\"0\" cellSpacing=\"0\" cellSpacing=\"0\">"; RetVal += "<tr class=\"HeaderRowStyle \">"; RetVal += "<td class=\"HeaderColumnStyle \"></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Connection_Name\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Database_Type\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Created_On\"></span></td>"; RetVal += "<td class=\"HeaderColumnStyle \"><span id=\"lang_Publisher\"></span></td>"; RetVal += "</tr>"; for (i = 0; i < xmlNode.ChildNodes.Count; i++) { if (xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.SDMXDb].Value.ToLower() == "false") { RetVal = RetVal + "<tr class=\"DataRowStyle \">"; DbNId = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value; ConnectionName = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Name].Value; ConnStr = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DatabaseConnection].Value; if (!string.IsNullOrEmpty(ConnStr)) { DbType = Global.SplitString(ConnStr, "||")[0]; } if (DbType == "0") { DatabaseType = "Sql Server"; } else if (DbType == "3") { DatabaseType = "My Sql"; } else if (DbType == "8") { DatabaseType = "Firebird"; } else { DatabaseType = ""; } CreatedOn = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.LastModified].Value; Query = "SELECT * FROM Artefacts WHERE Type=" + Convert.ToInt32(ArtefactTypes.DFD).ToString() + " And DbNId = " + xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value + ";"; DtDFD = DIConnection.ExecuteDataTable(Query); if (DtDFD.Rows.Count > 0) { Publisher = DtDFD.Rows[0]["AgencyId"].ToString(); // if (Global.SplitString(Publisher, "_")[1] == UseNId) /// { RetVal += "<td class=\"CheckBoxDataColumnStyle\"><input type=\"Radio\" id=\"db_" + DbNId + "\" name=\"group1\" style=\"display:none\" /></td>"; // } // else // { // RetVal += "<td class=\"CheckBoxDataColumnStyle\"></td>"; // } } else { Publisher = ""; RetVal += "<td class=\"CheckBoxDataColumnStyle\"><input type=\"Radio\" id=\"db_" + DbNId + "\" name=\"group1\" style=\"display:none\" /></td>"; } RetVal += "<td class=\"DataColumnStyle\">" + ConnectionName + "</td>"; RetVal += "<td class=\"DataColumnStyle\">" + DatabaseType + "</td>"; RetVal += "<td class=\"DataColumnStyle\">" + CreatedOn + "</td>"; RetVal += "<td class=\"DataColumnStyle\">" + Publisher + "</td>"; RetVal = RetVal + "</tr>"; } } RetVal = RetVal + "</table>"; } catch (Exception ex) { //Global.WriteErrorsInLog("Getting all database connection with Publish Details."); //Global.WriteErrorsInLog(ex.StackTrace); //Global.WriteErrorsInLog(ex.Message); Global.CreateExceptionString(ex, null); } return RetVal; }
public static void Delete_Registration_Artefact(string DbNId, string UserNId, string RegistrationId) { string Query, FileNameWPath; DIConnection DIConnection; Query = string.Empty; FileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNId + "\\sdmx\\Registrations\\" + UserNId + "\\" + RegistrationId + DevInfo.Lib.DI_LibSDMX.Constants.XmlExtension); DIConnection = null; try { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "stock//Database.mdb"), string.Empty, string.Empty); DIConnection.ExecuteDataTable("DELETE FROM Artefacts WHERE Id = '" + RegistrationId + "' AND DBNId = " + DbNId + " AND Type = " + Convert.ToInt32(DevInfo.Lib.DI_LibSDMX.ArtefactTypes.Registration).ToString() + ";"); if (File.Exists(FileNameWPath)) { File.Delete(FileNameWPath); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
private void Save_Artefacts_Details_In_Database(List<ArtefactInfo> Artefacts, int DbNid) { string InsertQuery; DIConnection DIConnection; System.Data.Common.DbParameter DbParam; List<System.Data.Common.DbParameter> DbParams; InsertQuery = string.Empty; DIConnection = null; string AppPhysicalPath = string.Empty; string DbFolder = string.Empty; try { AppPhysicalPath = HttpContext.Current.Request.PhysicalApplicationPath; DbFolder = Constants.FolderName.Data + DbNid.ToString() + "\\"; DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); DbParams = new List<System.Data.Common.DbParameter>(); foreach (ArtefactInfo Artefact in Artefacts) { InsertQuery = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(@DBNId, @Id, @AgencyId, @Version, @URN, @Type, @FileLocation);"; DbParams = new List<System.Data.Common.DbParameter>(); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "DBNId"; DbParam.DbType = DbType.Int32; DbParam.Value = DbNid; DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "Id"; DbParam.DbType = DbType.String; DbParam.Value = Artefact.Id; DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "AgencyId"; DbParam.DbType = DbType.String; DbParam.Value = Artefact.AgencyId; DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "Version"; DbParam.DbType = DbType.String; DbParam.Value = Artefact.Version; DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "URN"; DbParam.DbType = DbType.String; DbParam.Value = Artefact.URN; DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "Type"; DbParam.DbType = DbType.Int32; DbParam.Value = Convert.ToInt32(Artefact.Type); DbParams.Add(DbParam); DbParam = DIConnection.CreateDBParameter(); DbParam.ParameterName = "FileLocation"; DbParam.DbType = DbType.String; switch (Artefact.Type) { case ArtefactTypes.ConceptS: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Concepts + Artefact.FileName); break; case ArtefactTypes.DSD: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.sdmx + Artefact.FileName); break; case ArtefactTypes.CL: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Codelists + Artefact.FileName); break; case ArtefactTypes.CategoryS: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Categories + Artefact.FileName); break; //case ArtefactTypes.Categorisation: // DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Categorisations + Artefact.FileName); // break; case ArtefactTypes.DFD: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.ProvisioningMetadata + Artefact.FileName); break; case ArtefactTypes.Complete: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.sdmx + Artefact.FileName); break; case ArtefactTypes.Summary: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.sdmx + Artefact.FileName); break; case ArtefactTypes.Report: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.sdmx + Artefact.FileName); break; case ArtefactTypes.PA: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.PAs + Artefact.FileName); break; case ArtefactTypes.MSD: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.MSD + Artefact.FileName); break; case ArtefactTypes.MFD: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.ProvisioningMetadata + Artefact.FileName); break; case ArtefactTypes.Categorisation: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.Categorisations + Artefact.FileName); break; case ArtefactTypes.Header: DbParam.Value = Path.Combine(AppPhysicalPath, DbFolder + Constants.FolderName.SDMX.sdmx + Artefact.FileName); break; default: break; } DbParams.Add(DbParam); DIConnection.ExecuteDataTable(InsertQuery, CommandType.Text, DbParams); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { if (DIConnection != null) { DIConnection.Dispose(); } } }
/// <summary> /// Add PublishedFileName(Text) table to the Artefacts table in database.mdb /// </summary> /// <returns>bool</returns> public static bool ExistenceofColumnAccessDbSchema() { DIConnection diConnection; bool retVal = false; bool IsColumnExists = false; string query = string.Empty; using (diConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, @"stock\Database.mdb"), string.Empty, string.Empty)) { try { // Check if field exists to avoid exception try { //// MOD LOG //// Issue Id:BUG 7 Issue Date: 07-May-2014 //// Issue Fixed by:[email protected] //// Description: Exception capturing was used to figure out database colmun existance. Fixed to check for column exist before running the query to create column PublishedFileName. query = @" SELECT Top 1 * FROM Artefacts"; DataTable table = diConnection.ExecuteDataTable(query); if (table.Columns.IndexOf("PublishedFileName") < 0) { query = @" ALTER TABLE Artefacts ADD COLUMN PublishedFileName Text(225)"; var result = diConnection.ExecuteScalarSqlQuery(query); } IsColumnExists = true; } catch { IsColumnExists = true; } retVal = true; } catch (Exception ex) //catch specific exception by refering to the DIConnectino source. { Global.CreateExceptionString(ex, null); throw ex; } } return retVal; }
public XmlDocument SubmitRegistration([XmlAnyElement] XmlDocument Input, string SDMXFileName, string langPrefNid) { RegistryInterfaceType RegistryInterfaceRequest, RegistryInterfaceResponse; RegistrationRequestType RegistrationRequest; ActionType Action; DIConnection DIConnection; DataTable DtTable; string PAId, UserNId, DFDMFDId, AgencyId; string MaxNId, RegistrationId; string FileNameWPath, Query; string DataMetadataFile, CompleteFile; string ErrorMessage; XmlDocument DataDocument; List<ArtefactInfo> Artefacts; RegistryInterfaceRequest = null; RegistryInterfaceResponse = null; RegistrationRequest = null; DIConnection = null; DtTable = null; PAId = string.Empty; UserNId = string.Empty; DFDMFDId = string.Empty; AgencyId = string.Empty; MaxNId = string.Empty; RegistrationId = string.Empty; FileNameWPath = string.Empty; Query = string.Empty; DataMetadataFile = string.Empty; CompleteFile = string.Empty; ErrorMessage = string.Empty; DataDocument = new XmlDocument(); Artefacts = null; try { try { RegistryInterfaceRequest = (RegistryInterfaceType)Deserializer.LoadFromXmlDocument(typeof(RegistryInterfaceType), Input); RegistryInterfaceRequest.Footer = null; } catch (Exception) { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); AgencyId = Global.Get_AgencyId_From_DFD(DBNId.ToString()); if (!Global.IsDSDUploadedFromAdmin(DBNId)) { #region "--Schema 2.1--" if (RegistryInterfaceRequest.Item != null) { if (((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest != null && ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest.Count > 0) { RegistrationRequest = ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0]; if (RegistrationRequest.Registration != null) { if (RegistrationRequest.Registration.ProvisionAgreement != null && RegistrationRequest.Registration.ProvisionAgreement.Items != null && RegistrationRequest.Registration.ProvisionAgreement.Items.Count > 0) { PAId = ((ProvisionAgreementRefType)RegistrationRequest.Registration.ProvisionAgreement.Items[0]).id; UserNId = PAId.Split('_')[1]; DFDMFDId = PAId.Replace(DevInfo.Lib.DI_LibSDMX.Constants.PA.Prefix + UserNId + "_", ""); if (DFDMFDId == DevInfo.Lib.DI_LibSDMX.Constants.DFD.Id) { #region "--Data--" if (RegistrationRequest.Registration.Datasource != null) { CompleteFile = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Complete.xml"); Action = RegistrationRequest.action; switch (Action) { case ActionType.Append: Global.Create_Provider_In_DPScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, false, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Query = "SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;"; DtTable = DIConnection.ExecuteDataTable(Query); MaxNId = (Convert.ToInt32(DtTable.Rows[0]["MaxNId"].ToString()) + 1).ToString(); RegistrationId = Guid.NewGuid().ToString(); RegistrationRequest.Registration.id = RegistrationId; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Global.ExistenceofColumnAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation,PublishedFileName,LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "','" + SDMXFileName + "','" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); if (!string.IsNullOrEmpty(DataMetadataFile)) { DataDocument = new XmlDocument(); DataDocument.Load(DataMetadataFile); Artefacts = SDMXUtility.Create_Constraint(SDMXSchemaType.Two_One, DataDocument, RegistrationId, DataMetadataFile, AgencyId, null, Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Constraints/" + UserNId)); if (Artefacts.Count > 0) { Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + Artefacts[0].Id + "','" + Artefacts[0].AgencyId + "','" + Artefacts[0].Version + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Constraint).ToString() + ",'" + Path.Combine( Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Constraints/" + UserNId), Artefacts[0].FileName) + "');"; DIConnection.ExecuteDataTable(Query); } } Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, false); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; case ActionType.Delete: Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id, false, "true"); Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); Global.Delete_Constraint_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Replace: if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, false, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); Global.Delete_Constraint_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistrationId = RegistrationRequest.Registration.id; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "');"; DIConnection.ExecuteDataTable(Query); if (!string.IsNullOrEmpty(DataMetadataFile)) { DataDocument = new XmlDocument(); DataDocument.Load(DataMetadataFile); Artefacts = SDMXUtility.Create_Constraint(SDMXSchemaType.Two_One, DataDocument, RegistrationId, DataMetadataFile, AgencyId, null, Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Constraints/" + UserNId)); if (Artefacts.Count > 0) { Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + Artefacts[0].Id + "','" + Artefacts[0].AgencyId + "','" + Artefacts[0].Version + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Constraint).ToString() + ",'" + Path.Combine( Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Constraints/" + UserNId), Artefacts[0].FileName) + "');"; DIConnection.ExecuteDataTable(Query); } } Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, false); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; default: break; } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Data--" } else { #region "--Metadata--" if (RegistrationRequest.Registration.Datasource != null) { CompleteFile = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Complete.xml"); Action = RegistrationRequest.action; switch (Action) { case ActionType.Append: Global.Create_Provider_In_DPScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, true, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Query = "SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;"; DtTable = DIConnection.ExecuteDataTable(Query); MaxNId = (Convert.ToInt32(DtTable.Rows[0]["MaxNId"].ToString()) + 1).ToString(); RegistrationId = Guid.NewGuid().ToString(); RegistrationRequest.Registration.id = RegistrationId; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Global.ExistenceofColumnAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation,PublishedFileName,LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "','" + SDMXFileName + "','" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, true); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; case ActionType.Delete: Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id, false, "true"); Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Replace: if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, true, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistrationId = RegistrationRequest.Registration.id; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "');"; DIConnection.ExecuteDataTable(Query); Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, true); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; default: break; } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Metadata--" } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Schema 2.1--" } else { #region "--Schema 2.0--" if (RegistryInterfaceRequest.Item != null) { if (((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest != null && ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest.Count > 0) { RegistrationRequest = ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRequest.Item).RegistrationRequest[0]; if (RegistrationRequest.Registration != null) { if (RegistrationRequest.Registration.ProvisionAgreement != null && RegistrationRequest.Registration.ProvisionAgreement.Items != null && RegistrationRequest.Registration.ProvisionAgreement.Items.Count > 0) { PAId = ((ProvisionAgreementRefType)RegistrationRequest.Registration.ProvisionAgreement.Items[0]).id; UserNId = PAId.Split('_')[1]; DFDMFDId = PAId.Replace(DevInfo.Lib.DI_LibSDMX.Constants.PA.Prefix + UserNId + "_", ""); if (DFDMFDId == DevInfo.Lib.DI_LibSDMX.Constants.DFD.Id) { #region "--Data--" if (RegistrationRequest.Registration.Datasource != null) { CompleteFile = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Complete.xml"); Action = RegistrationRequest.action; switch (Action) { case ActionType.Append: Global.Create_Provider_In_DPScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, false, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Query = "SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;"; DtTable = DIConnection.ExecuteDataTable(Query); MaxNId = (Convert.ToInt32(DtTable.Rows[0]["MaxNId"].ToString()) + 1).ToString(); RegistrationId = Guid.NewGuid().ToString(); RegistrationRequest.Registration.id = RegistrationId; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Global.ExistenceofColumnAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation,PublishedFileName,LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "','" + SDMXFileName + "','" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); if (!string.IsNullOrEmpty(DataMetadataFile)) { Global.Create_Constraint_Artefact_For_Version_2_0_SDMLMLFile(RegistrationId, DBNId.ToString(), UserNId, AgencyId, DataMetadataFile); } Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, false); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; case ActionType.Delete: Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id, false, "true"); Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); Global.Delete_Constraint_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Replace: if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, false, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); Global.Delete_Constraint_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistrationId = RegistrationRequest.Registration.id; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "');"; DIConnection.ExecuteDataTable(Query); if (!string.IsNullOrEmpty(DataMetadataFile)) { Global.Create_Constraint_Artefact_For_Version_2_0_SDMLMLFile(RegistrationId, DBNId.ToString(), UserNId, AgencyId, DataMetadataFile); } Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, false); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; default: break; } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Data--" } else { #region "--Metadata--" if (RegistrationRequest.Registration.Datasource != null) { CompleteFile = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Complete.xml"); Action = RegistrationRequest.action; switch (Action) { case ActionType.Append: Global.Create_Provider_In_DPScheme_And_Update_Folder_Structures_Per_Database(UserNId, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, true, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Query = "SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;"; DtTable = DIConnection.ExecuteDataTable(Query); MaxNId = (Convert.ToInt32(DtTable.Rows[0]["MaxNId"].ToString()) + 1).ToString(); RegistrationId = Guid.NewGuid().ToString(); RegistrationRequest.Registration.id = RegistrationId; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Global.ExistenceofColumnAccessDbSchema(); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation,PublishedFileName,LangPrefNid)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "','" + SDMXFileName + "','" + Int32.Parse(langPrefNid) + "');"; DIConnection.ExecuteDataTable(Query); Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, true); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; case ActionType.Delete: Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id, true, "true"); Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); break; case ActionType.Replace: if (Global.Validate_DataSource(RegistrationRequest.Registration.Datasource, CompleteFile, DBNId, true, DFDMFDId, out ErrorMessage, out DataMetadataFile)) { Global.Delete_Registration_Artefact(DBNId.ToString(), UserNId, RegistrationRequest.Registration.id); RegistrationId = RegistrationRequest.Registration.id; FileNameWPath = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/" + UserNId + "/" + RegistrationId + ".xml"); Serializer.SerializeToFile(typeof(RegistryInterfaceType), RegistryInterfaceRequest, FileNameWPath); Query = "INSERT INTO Artefacts (DBNId, Id, AgencyId, Version, URN, Type, FileLocation)" + " VALUES(" + DBNId.ToString() + ",'" + RegistrationId + "','" + string.Empty + "','" + string.Empty + "','" + string.Empty + "'," + Convert.ToInt32(ArtefactTypes.Registration).ToString() + ",'" + FileNameWPath + "');"; DIConnection.ExecuteDataTable(Query); Global.Send_Notifications_For_Subscriptions(DBNId.ToString(), UserNId, RegistrationId, true); RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(RegistrationRequest.Registration, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { RegistryInterfaceResponse = this.Get_SubmitRegistrations_Reponse(null, StatusType.Failure, ErrorMessage, DevInfo.Lib.DI_LibSDMX.Constants.DefaultLanguage); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } break; default: break; } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Metadata--" } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } #endregion "--Schema 2.0--" } } catch (Exception ex) { Global.CreateExceptionString(ex, null); this.Handle_Exception(ex); } finally { } return Input; }
private void Add_Area_To_Dictionary(Dictionary<string, string> DictQuery, string AreaNIds, DIConnection DIConnection, DIQueries DIQueries) { DataTable DtAreas; string AreaID, AreaIDs; AreaIDs = string.Empty; try { if (!string.IsNullOrEmpty(AreaNIds)) { DtAreas = DIConnection.ExecuteDataTable(DIQueries.Area.GetArea(FilterFieldType.NId, AreaNIds)); foreach (DataRow DrArea in DtAreas.Rows) { AreaID = DrArea[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Area.AreaID].ToString(); AreaIDs += AreaID + ","; } } if (AreaIDs.Length > 0) { DictQuery.Add(DevInfo.Lib.DI_LibSDMX.Constants.Concept.AREA.Id, AreaIDs.Substring(0, AreaIDs.Length - 1)); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } }
/// <summary> /// Is user admin /// </summary> /// <param name="usernid">user nid</param> /// <returns>true if user is admin else false</returns> private bool isUserAdmin(string usernid) { bool isAdmin = false; string Query = string.Empty; DataTable dtUsers = null; DIConnection DIConnection = null; diworldwide_userinfo.UserLoginInformation Service; if (ConfigurationManager.AppSettings[Constants.WebConfigKey.IsGlobalAllow].ToLower() == "true") { Service = new diworldwide_userinfo.UserLoginInformation(); Service.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.UserLoginService; isAdmin = Service.IsUserAdmin(usernid, Global.GetAdaptationGUID()); } else { DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); Query = "Select user_is_admin from Users where nid =" + usernid + ";"; dtUsers = DIConnection.ExecuteDataTable(Query); if (dtUsers.Rows.Count > 0) { if (dtUsers.Rows[0][0].ToString().ToLower() == "true") { isAdmin = true; } } } return isAdmin; }
private void Add_IUS_To_Dictionary(Dictionary<string, string> DictQuery, string IndicatorNIds, DIConnection DIConnection, DIQueries DIQueries) { DataTable DtIUSConcise, DtIUSElaborate; string IndicatorGId, UnitGId, SubgroupValGId, IUSNIds, IUSGIds; IUSNIds = string.Empty; IUSGIds = string.Empty; try { DtIUSConcise = DIConnection.ExecuteDataTable(DIQueries.IUS.GetIUSFromIndicator(IndicatorNIds)); foreach (DataRow DrIUSConcise in DtIUSConcise.Rows) { IUSNIds += DrIUSConcise[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator_Unit_Subgroup.IUSNId].ToString() + ","; } if (IUSNIds.Length > 0) { IUSNIds = IUSNIds.Substring(0, IUSNIds.Length - 1); } DtIUSElaborate = DIConnection.ExecuteDataTable(DIQueries.IUS.GetIUS(FilterFieldType.NId, IUSNIds, FieldSelection.Light)); DtIUSElaborate = DtIUSElaborate.DefaultView.ToTable(true, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorGId, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Unit.UnitGId, DevInfo.Lib.DI_LibDAL.Queries.DIColumns.SubgroupVals.SubgroupValGId); foreach (DataRow DrIUSElaborate in DtIUSElaborate.Rows) { IndicatorGId = DrIUSElaborate[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Indicator.IndicatorGId].ToString(); UnitGId = DrIUSElaborate[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Unit.UnitGId].ToString(); SubgroupValGId = DrIUSElaborate[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.SubgroupVals.SubgroupValGId].ToString(); IUSGIds += IndicatorGId + DevInfo.Lib.DI_LibSDMX.Constants.AtTheRate + UnitGId + DevInfo.Lib.DI_LibSDMX.Constants.AtTheRate + SubgroupValGId + ","; } if (IUSGIds.Length > 0) { DictQuery.Add(DevInfo.Lib.DI_LibSDMX.Constants.Concept.INDICATOR.Id, IUSGIds.Substring(0, IUSGIds.Length - 1)); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } }
public XmlDocument QueryRegistration([XmlAnyElement] XmlDocument Input, string languageNid) { RegistryInterfaceType RegistryInterfaceRequest, RegistryInterfaceResponse, RegistryInterfaceRegistration; List<RegistrationType> Registrations; List<string> SortedFileNames; DIConnection DIConnection; DataTable DtTable; string UserId, UserNId; string FolderName; ArrayList AdFiles = new ArrayList(); RegistryInterfaceRequest = null; RegistryInterfaceResponse = null; RegistryInterfaceRegistration = null; Registrations = null; SortedFileNames = new List<string>(); UserId = string.Empty; UserNId = string.Empty; FolderName = string.Empty; try { try { RegistryInterfaceRequest = (RegistryInterfaceType)Deserializer.LoadFromXmlDocument(typeof(RegistryInterfaceType), Input); } catch (Exception) { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); FolderName = Path.Combine(Server.MapPath("~"), "stock/data/" + DBNId.ToString() + "/sdmx/Registrations/"); DtTable = new DataTable(); DtTable = DIConnection.ExecuteDataTable("SELECT * FROM Artefacts WHERE DBNId = " + DBNId.ToString() + " AND LangPrefNid=" + Int32.Parse(languageNid) + " AND Type = " + Convert.ToInt32(ArtefactTypes.Registration).ToString() + " ORDER BY PublishedFileName ;"); if (DtTable != null && DtTable.Rows.Count > 0) { foreach (DataRow dr in DtTable.Rows) { AdFiles.Add(Convert.ToString(dr["FileLocation"].ToString().Replace("<div>", "").Replace("</div>", ""))); } } if (RegistryInterfaceRequest.Item != null) { if (((SDMXObjectModel.Registry.QueryRegistrationRequestType)RegistryInterfaceRequest.Item).Item != null && ((DataProviderReferenceType)((SDMXObjectModel.Registry.QueryRegistrationRequestType)RegistryInterfaceRequest.Item).Item).Items != null && ((DataProviderReferenceType)((SDMXObjectModel.Registry.QueryRegistrationRequestType)RegistryInterfaceRequest.Item).Item).Items.Count > 0) { UserId = ((DataProviderRefType)((DataProviderReferenceType)((SDMXObjectModel.Registry.QueryRegistrationRequestType)RegistryInterfaceRequest.Item).Item).Items[0]).id; if (!string.IsNullOrEmpty(UserId) && UserId.Split('_').Length == 2) { UserNId = UserId.Split('_')[1]; FolderName += UserNId + "/"; Registrations = new List<RegistrationType>(); if (Directory.Exists(FolderName)) { SortedFileNames = new List<string>(Directory.GetFiles(FolderName)); SortedFileNames.Sort(); foreach (string File in AdFiles) { if (SortedFileNames.Contains(File)) { RegistryInterfaceRegistration = (RegistryInterfaceType)Deserializer.LoadFromFile(typeof(RegistryInterfaceType), File); if (RegistryInterfaceRegistration != null && RegistryInterfaceRegistration.Item != null && ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRegistration.Item).RegistrationRequest.Count > 0) { Registrations.Add(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)RegistryInterfaceRegistration.Item).RegistrationRequest[0].Registration); } } } RegistryInterfaceResponse = this.Get_QueryRegistrations_Reponse(Registrations, StatusType.Success, string.Empty, string.Empty); Input = Serializer.SerializeToXmlDocument(typeof(RegistryInterfaceType), RegistryInterfaceResponse); } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.NoResults.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } else { throw new Exception(DevInfo.Lib.DI_LibSDMX.Constants.SDMXWebServices.Exceptions.InvalidSyntax.Message); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); this.Handle_Exception(ex); } finally { } return Input; }
private void Add_Source_To_Dictionary(Dictionary<string, string> DictQuery, string SourceNIds, DIConnection DIConnection, DIQueries DIQueries) { DataTable DtSources; string Source, SourceTexts; SourceTexts = string.Empty; try { if (!string.IsNullOrEmpty(SourceNIds)) { DtSources = DIConnection.ExecuteDataTable(DIQueries.IndicatorClassification.GetIC(FilterFieldType.NId, SourceNIds, ICType.Source, FieldSelection.Light)); foreach (DataRow DrArea in DtSources.Rows) { Source = DrArea[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.IndicatorClassifications.ICName].ToString(); SourceTexts += Source + ","; } } if (SourceTexts.Length > 0) { DictQuery.Add(DevInfo.Lib.DI_LibSDMX.Constants.Concept.SOURCE.Id, SourceTexts.Substring(0, SourceTexts.Length - 1)); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } }
private XmlDocument GetQueryXmlDocumentForSubmitRegistration(string UserIdAndType, string AgencyId, string DFDOrMFDId, string WebServiceURL, bool IsREST, string WADLURL, bool IsSOAP, string WSDLURL, string FileURL) { XmlDocument RetVal; string id; string paId; SDMXObjectModel.Message.RegistryInterfaceType RegistryInterface; DIConnection DIConnection; string MaxNId; string UserId; RetVal = null; id = string.Empty; paId = string.Empty; MaxNId = string.Empty; UserId = string.Empty; try { UserId = UserIdAndType.Split('|')[0]; DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"), string.Empty, string.Empty); MaxNId = ((int)(Convert.ToInt32(DIConnection.ExecuteDataTable("SELECT MAX(ArtefactsNId) AS MaxNId FROM Artefacts;").Rows[0]["MaxNId"].ToString()) + 1)).ToString(); id = Guid.NewGuid().ToString(); paId = DevInfo.Lib.DI_LibSDMX.Constants.PA.Prefix + UserId + "_" + DFDOrMFDId; RegistryInterface = new RegistryInterfaceType(); RegistryInterface.Header = Global.Get_Appropriate_Header(); RegistryInterface.Item = new SDMXObjectModel.Registry.SubmitRegistrationsRequestType(); ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest = new List<RegistrationRequestType>(); ((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest.Add(new RegistrationRequestType()); ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration = new RegistrationType(id); ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.indexTimeSeries = true; ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.ProvisionAgreement = new ProvisionAgreementReferenceType(); ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.ProvisionAgreement.Items.Add(new ProvisionAgreementRefType(paId, AgencyId, DevInfo.Lib.DI_LibSDMX.Constants.PA.Version)); ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.Datasource = new List<object>(); //((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.Datasource.Add(new SDMXObjectModel.Registry.QueryableDataSourceType(WebServiceURL, IsREST, WADLURL, IsSOAP, WSDLURL)); ((RegistrationRequestType)(((SDMXObjectModel.Registry.SubmitRegistrationsRequestType)(RegistryInterface.Item)).RegistrationRequest[0])).Registration.Datasource.Add(FileURL); RetVal = Serializer.SerializeToXmlDocument(typeof(SDMXObjectModel.Message.RegistryInterfaceType), RegistryInterface); } catch (Exception ex) { Global.CreateExceptionString(ex, null); } finally { } return RetVal; }
private void Add_TP_To_Dictionary(Dictionary<string, string> DictQuery, string TPNIds, DIConnection DIConnection, DIQueries DIQueries) { DataTable DtTimePeriods; string TPText, TPTexts; TPTexts = string.Empty; try { if (!string.IsNullOrEmpty(TPNIds)) { DtTimePeriods = DIConnection.ExecuteDataTable(DIQueries.Timeperiod.GetTimePeriod(FilterFieldType.NId, TPNIds)); foreach (DataRow DrTimePeriod in DtTimePeriods.Rows) { TPText = DrTimePeriod[DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Timeperiods.TimePeriod].ToString(); TPTexts += TPText + ","; } } if (TPTexts.Length > 0) { DictQuery.Add(DevInfo.Lib.DI_LibSDMX.Constants.Concept.TIME_PERIOD.Id, TPTexts.Substring(0, TPTexts.Length - 1)); } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } }