private void Send_Notifications_For_Current_Subscription_For_Structural_Metadata_Changes(SubscriptionType Subscription, List<ArtefactRef> ListOfArtefactRefs) { string MessageContent; List<ArtefactInfo> Artefacts; DateTime CurrentDate; DateTime ValidityPeriodStartDate; DateTime ValidityPeriodEndDate; try { CurrentDate = DateTime.Now; ValidityPeriodStartDate = Subscription.ValidityPeriod.StartDate; ValidityPeriodEndDate = Subscription.ValidityPeriod.EndDate; if ((CurrentDate >= ValidityPeriodStartDate) && (CurrentDate <= ValidityPeriodEndDate)) { Artefacts = SDMXUtility.Get_Notification(SDMXSchemaType.Two_One, DateTime.Now, ListOfArtefactRefs, Subscription.RegistryURN, ActionType.Append, null); foreach (NotificationURLType NotificationMailId in Subscription.NotificationMailTo) { if (NotificationMailId.isSOAP == true) { MessageContent = Global.GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Global.Send_Notification_By_Email(MessageContent, NotificationMailId.Value); } foreach (NotificationURLType NotificationHTTP in Subscription.NotificationHTTP) { if (NotificationHTTP.isSOAP == true) { MessageContent = Global.GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Global.Send_Notification_By_HTTP_Post(MessageContent, NotificationHTTP.Value); } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } }
private static List<string> Get_Subscriptions_OverlapList(SubscriptionType Subscription, bool IsMetadata, bool IsAdminUploadedDSD, string DbNId) { List<string> RetVal; string CategoryId, CategorySchemeId, OutputFolder, FileName; Dictionary<string, List<string>> DictCategories; List<string> IndicatorGIds; RetVal = new List<string>(); CategoryId = string.Empty; CategorySchemeId = string.Empty; OutputFolder = string.Empty; FileName = string.Empty; DictCategories = new Dictionary<string, List<string>>(); IndicatorGIds = null; if (IsMetadata == false) { if (Subscription.EventSelector[0] is DataRegistrationEventsType) { foreach (CategoryReferenceType Category in ((DataRegistrationEventsType)Subscription.EventSelector[0]).Items) { if (Category.Items != null && Category.Items.Count > 0) { CategoryId = ((CategoryRefType)Category.Items[0]).id; CategorySchemeId = ((CategoryRefType)Category.Items[0]).maintainableParentID; if (!DictCategories.ContainsKey(CategorySchemeId)) { DictCategories.Add(CategorySchemeId, null); DictCategories[CategorySchemeId] = new List<string>(); DictCategories[CategorySchemeId].Add(CategoryId); } else { DictCategories[CategorySchemeId].Add(CategoryId); } } } OutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + DbNId + "\\" + Constants.FolderName.SDMX.Categories); foreach (string CategoryScheme in DictCategories.Keys) { switch (CategoryScheme) { case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Sector.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Sector.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Goal.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Goal.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Source.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Source.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Framework.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Framework.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Convention.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Convention.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Theme.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Theme.FileName); break; case DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Institution.Id: FileName = Path.Combine(OutputFolder, DevInfo.Lib.DI_LibSDMX.Constants.CategoryScheme.Institution.FileName); break; default: break; } IndicatorGIds = Get_IndicatorGIds_From_CategoryScheme(FileName, DictCategories[CategoryScheme]); foreach (string IndicatorGId in IndicatorGIds) { if (!RetVal.Contains(IndicatorGId)) { RetVal.Add(IndicatorGId); } } } } } else { if (Subscription.EventSelector[0] is MetadataRegistrationEventsType) { foreach (MaintainableEventType MaintainableEvent in ((MetadataRegistrationEventsType)Subscription.EventSelector[0]).Items) { RetVal.Add(((MaintainableQueryType)MaintainableEvent.Item).id); } } } return RetVal; }
private static void Send_Notifications_For_Current_Subscription(SubscriptionType Subscription, SDMXObjectModel.Registry.RegistrationType Registration, string HeaderFilePath = null) { string MessageContent; List<ArtefactInfo> Artefacts; DateTime CurrentDate; DateTime ValidityPeriodStartDate; DateTime ValidityPeriodEndDate; Header Header = new Header(); XmlDocument UploadedHeaderXml = new XmlDocument(); SDMXApi_2_0.Message.StructureType UploadedDSDStructure = new SDMXApi_2_0.Message.StructureType(); SDMXApi_2_0.Message.HeaderType Header_2_0 = new SDMXApi_2_0.Message.HeaderType(); if (File.Exists(HeaderFilePath)) { UploadedHeaderXml.Load(HeaderFilePath); UploadedDSDStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromXmlDocument(typeof(SDMXApi_2_0.Message.StructureType), UploadedHeaderXml); Header_2_0 = UploadedDSDStructure.Header; } try { if (string.IsNullOrEmpty(HeaderFilePath) == false) { Header.ID = Header_2_0.ID; Header.Name = Header_2_0.Name[0].Value.ToString(); foreach (SDMXApi_2_0.Message.PartyType Senders in Header_2_0.Sender) { Header.Sender.ID = Senders.id; Header.Sender.Name = !string.IsNullOrEmpty(Senders.Name[0].Value.ToString()) ? Senders.Name[0].Value.ToString() : string.Empty; foreach (SDMXApi_2_0.Message.ContactType Contacts in Senders.Contact) { Header.Sender.Contact.Department = !string.IsNullOrEmpty(Contacts.Department[0].Value.ToString()) ? Contacts.Department[0].Value.ToString() : string.Empty; Header.Sender.Contact.Email = !string.IsNullOrEmpty(Contacts.Items[1].ToString()) ? Contacts.Items[1].ToString() : string.Empty; Header.Sender.Contact.Fax = !string.IsNullOrEmpty(Contacts.Items[2].ToString()) ? Contacts.Items[2].ToString() : string.Empty; Header.Sender.Contact.Name = !string.IsNullOrEmpty(Contacts.Name[0].Value.ToString()) ? Contacts.Name[0].Value.ToString() : string.Empty; Header.Sender.Contact.Role = !string.IsNullOrEmpty(Contacts.Role[0].Value.ToString()) ? Contacts.Role[0].Value.ToString() : string.Empty; Header.Sender.Contact.Telephone = !string.IsNullOrEmpty(Contacts.Items[0].ToString()) ? Contacts.Items[0].ToString() : string.Empty; } } foreach (SDMXApi_2_0.Message.PartyType Receiver in Header_2_0.Receiver) { Header.Receiver.ID = Receiver.id; if (string.IsNullOrEmpty(Convert.ToString(Receiver.Name[0].Value)) == false) { Header.Receiver.Name = !string.IsNullOrEmpty(Receiver.Name[0].Value.ToString()) ? Receiver.Name[0].Value.ToString() : string.Empty; foreach (SDMXApi_2_0.Message.ContactType Contacts in Receiver.Contact) { Header.Receiver.Contact.Department = !string.IsNullOrEmpty(Convert.ToString(Contacts.Department[0].Value)) ? Convert.ToString(Contacts.Department[0].Value) : string.Empty; if (Contacts.Items.Length > 2) { Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[2])) ? Convert.ToString(Contacts.Items[2]) : string.Empty; } else { Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; } //Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[1])) ? Convert.ToString(Contacts.Items[1]) : string.Empty; //Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[2])) ? Convert.ToString(Contacts.Items[2]) : string.Empty; Header.Receiver.Contact.Name = !string.IsNullOrEmpty(Convert.ToString(Contacts.Name[0].Value)) ? Convert.ToString(Contacts.Name[0].Value) : string.Empty; Header.Receiver.Contact.Role = !string.IsNullOrEmpty(Convert.ToString(Contacts.Role[0].Value)) ? Convert.ToString(Contacts.Role[0].Value) : string.Empty; Header.Receiver.Contact.Telephone = !string.IsNullOrEmpty(Convert.ToString(Contacts.Items[0])) ? Convert.ToString(Contacts.Items[0]) : string.Empty; //Header.Receiver.Contact.Department = !string.IsNullOrEmpty(Contacts.Department[0].Value.ToString()) ? Contacts.Department[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Email = !string.IsNullOrEmpty(Contacts.Items[2].ToString()) ? Contacts.Items[2].ToString() : string.Empty; //Header.Receiver.Contact.Fax = !string.IsNullOrEmpty(Contacts.Items[1].ToString()) ? Contacts.Items[1].ToString() : string.Empty; //Header.Receiver.Contact.Name = !string.IsNullOrEmpty(Contacts.Name[0].Value.ToString()) ? Contacts.Name[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Role = !string.IsNullOrEmpty(Contacts.Role[0].Value.ToString()) ? Contacts.Role[0].Value.ToString() : string.Empty; //Header.Receiver.Contact.Telephone = !string.IsNullOrEmpty(Contacts.Items[0].ToString()) ? Contacts.Items[0].ToString() : string.Empty; } } } } CurrentDate = DateTime.Now; ValidityPeriodStartDate = Subscription.ValidityPeriod.StartDate; ValidityPeriodEndDate = Subscription.ValidityPeriod.EndDate; if ((CurrentDate >= ValidityPeriodStartDate) && (CurrentDate <= ValidityPeriodEndDate)) { if (string.IsNullOrEmpty(HeaderFilePath) == false) { Artefacts = SDMXUtility.Get_Notification(SDMXSchemaType.Two_One, DateTime.Now, Registration.id, Subscription.RegistryURN, ActionType.Append, Registration, Header); } else { Artefacts = SDMXUtility.Get_Notification(SDMXSchemaType.Two_One, DateTime.Now, Registration.id, Subscription.RegistryURN, ActionType.Append, Registration, null); } foreach (NotificationURLType NotificationMailId in Subscription.NotificationMailTo) { if (NotificationMailId.isSOAP == true) { MessageContent = GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Send_Notification_By_Email(MessageContent, NotificationMailId.Value); } foreach (NotificationURLType NotificationHTTP in Subscription.NotificationHTTP) { if (NotificationHTTP.isSOAP == true) { MessageContent = GetSoapWrappedXml(Artefacts[0].Content.OuterXml); } else { MessageContent = Artefacts[0].Content.OuterXml; } Send_Notification_By_HTTP_Post(MessageContent, NotificationHTTP.Value); } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } }
public SubscriptionRequestType(SubscriptionType subscription, ActionType action) { this.subscriptionField = subscription; this.actionField = action; }