public static void SendTemplate(this IEmailService emailService, string from, IEnumerable<string> to, IEnumerable<string> bcc, string subject, IMcmRepository repository, MetadataIdentifier template, IList<MetadataIdentifier> datas)
		{
			var templateMetadata = GetMetadata(repository, template, "Failed to get template");

			var dataMetadatas = GetDatas(repository, datas);

			emailService.SendTemplate(from, to, bcc, subject, templateMetadata, dataMetadatas);
		}
		public static void SendFromEmailSchema(this IEmailService emailService, IEnumerable<string> to, IEnumerable<string> bcc, IMcmRepository repository, MetadataIdentifier template, IList<MetadataIdentifier> datas)
		{
			var templateMetadata = GetEmailTemplate(repository, template);

			var dataMetadatas = GetDatas(repository, datas);

			emailService.SendTemplate(templateMetadata.From, to, bcc, templateMetadata.Subject, templateMetadata.Body, dataMetadatas);
		}
// Build identifiers list (ISBNs + 902a yearbooks)
        private static List <MetadataIdentifier> getIdentifiersList(Metadata metadata)
        {
            List <MetadataIdentifier> Identifiers = new List <MetadataIdentifier>();

// No identifier (default value if union record not found)
            MetadataIdentifier nullIdentifier = new MetadataIdentifier();

            nullIdentifier.IdentifierType        = IdentifierType.ISBN;
            nullIdentifier.IdentifierCode        = null;
            nullIdentifier.IdentifierDescription = "nebylo nalezeno ISBN souborného záznamu";
            Identifiers.Add(nullIdentifier);

// MARC21 ISBNs
            foreach (var isbn in metadata.VariableFields.Where(vf => Settings.MetadataIsbnField.Item1.ToString("D3").Equals(vf.TagName)))
            {
                MetadataIdentifier identifierToInsert = new MetadataIdentifier();
                List <string>      subfDescription    = new List <string>();
                foreach (var subf in isbn.Subfields)
                {
                    if (subf.Key == "a")
                    {
                        identifierToInsert.IdentifierCode = subf.Value;
                    }
                    if (subf.Key == "q")
                    {
                        subfDescription.Add(subf.Value);
                    }
                }
                identifierToInsert.IdentifierType        = IdentifierType.ISBN;
                identifierToInsert.IdentifierDescription = string.Join(" ", subfDescription);
                Identifiers.Add(identifierToInsert);
            }

// ISBNs of yearbooks (902a)
            foreach (var isbn in metadata.VariableFields.Where(vf => Settings.MetadataIsbnYearbookField.Item1.ToString("D3").Equals(vf.TagName)))
            {
                MetadataIdentifier identifierToInsert = new MetadataIdentifier();
                List <string>      subfDescription    = new List <string>();
                foreach (var subf in isbn.Subfields)
                {
                    if (subf.Key == "a")
                    {
                        identifierToInsert.IdentifierCode = subf.Value;
                    }
                    if (subf.Key == "q")
                    {
                        subfDescription.Add(subf.Value);
                    }
                }
                identifierToInsert.IdentifierType        = IdentifierType.ISBN;
                identifierToInsert.IdentifierDescription = string.Join(" ", subfDescription);
                Identifiers.Add(identifierToInsert);
            }

            return(Identifiers);
        }
Example #4
0
        internal static IMetadataIdentifier CreatePuid(string value)
        {
            IMetadataIdentifier identifier = new MetadataIdentifier(value, ID_TYPE, version);

            return(identifier);
        }
		private static XElement GetMetadata(IMcmRepository repository, MetadataIdentifier metadata, string errorMessage = "Failed to get metadata")
		{
			var templateObject = repository.ObjectGet(metadata.ObjectGuid, true);

			if(templateObject == null)
				throw new System.Exception(string.Format("{0}, object not found. ObjectGuid: {1}", errorMessage, metadata.ObjectGuid));

			if (templateObject.Metadatas == null || templateObject.Metadatas.Count == 0)
				throw new System.Exception(string.Format("{0}, object has no metadata. ObjectGuid: {1}", errorMessage, metadata.ObjectGuid));

			var templateMetadata = templateObject.Metadatas.FirstOrDefault(m => m.MetadataSchemaGuid == metadata.MetadataSchemaGuid && m.LanguageCode == metadata.LanguageCode);

			if (templateMetadata == null)
				throw new System.Exception(string.Format("{0}, no matching schema and language code. ObjectGuid: {1} SchemaGuid: {2} LanguageCode: {3}", errorMessage, metadata.ObjectGuid, metadata.MetadataSchemaGuid, metadata.LanguageCode));

			return templateMetadata.MetadataXml.Root;
		}
		public static void SendFromEmailSchema(this IEmailService emailService, string to, IMcmRepository repository, MetadataIdentifier template, IList<XElement> datas)
		{
			emailService.SendFromEmailSchema(new List<string> { to }, null, repository, template, datas);
		}
		public static void SendFromEmailSchema(this IEmailService emailService, IList<string> to, IEnumerable<string> bcc, IMcmRepository repository, MetadataIdentifier template, XElement data)
		{
			emailService.SendFromEmailSchema(to, bcc, repository, template, new List<XElement> { data });
		}
		public static void SendTemplate(this IEmailService emailService, string from, string to, string subject, IMcmRepository repository, MetadataIdentifier template, IList<MetadataIdentifier> datas)
		{
			emailService.SendTemplate(from, new List<string> { to }, null, subject, repository, template, datas);
		}
		private static EmailTemplate GetEmailTemplate(IMcmRepository repository, MetadataIdentifier template)
		{
			var templateMetadata = GetMetadata(repository, template, "Failed to get template");

			var from = templateMetadata.Element("From");
			var subject = templateMetadata.Element("Subject");
			var body = templateMetadata.Element("Body");

			if (from == null || subject == null || body == null)
				throw new System.Exception(string.Format("Metadata did not match email template. ObjectGuid: {0} SchemaGuid: {1} LanguageCode: {2}", template.ObjectGuid, template.MetadataSchemaGuid, template.LanguageCode));

			return new EmailTemplate
			{
				From = from.Value,
				Subject = subject.Value,
				Body = body.Elements().First()
			};
		}
Example #10
0
 public MetadataDictionary GetMetadata(EphorteIdentity identity, MetadataIdentifier identifier)
 {
     throw new System.NotImplementedException();
 }