public void ResolveTemplate(Core.Notification.Notification notification)
        {
            var parameters = ResolveNotificationParameters(notification);
            Dictionary <string, object> myDict = new Dictionary <string, object>();

            foreach (var parameter in parameters)
            {
                myDict.Add(parameter.ParameterName, notification.GetType().GetProperty(parameter.ParameterName).GetValue(notification));
            }

            Template templateSubject = Template.Parse(notification.NotificationTemplate.Subject);

            notification.Subject = templateSubject.Render(Hash.FromDictionary(myDict));

            Template templateBody = Template.Parse(notification.NotificationTemplate.Body);

            notification.Body = templateBody.Render(Hash.FromDictionary(myDict));
        }
        public NotificationParameter[] ResolveNotificationParameters(Core.Notification.Notification notification)
        {
            var retVal = new List <NotificationParameter>();

            List <PropertyInfo> properties = notification.GetType().GetProperties().Where(p => p.GetCustomAttributes(typeof(NotificationParameterAttribute), true).Any()).ToList();

            if (properties.Count > 0)
            {
                foreach (var property in properties)
                {
                    var attributes = property.GetCustomAttributes(typeof(NotificationParameterAttribute), true);
                    retVal.Add(new NotificationParameter
                    {
                        ParameterName        = property.Name,
                        ParameterDescription = attributes.Length > 0 ? ((NotificationParameterAttribute)(attributes[0])).Description : string.Empty,
                        ParameterCodeInView  = GetLiquidCodeOfParameter(property.Name)
                    });
                }
            }

            return(retVal.ToArray());
        }
Ejemplo n.º 3
0
 private void ResolveTemplate(Core.Notification.Notification notification)
 {
     GetNewNotification(notification.GetType().Name, notification.ObjectId, notification.ObjectTypeId, notification.Language);
     _resolver.ResolveTemplate(notification);
 }