Example #1
0
        public static DynamicPropertyName ToModel(this DynamicPropertyNameEntity entity)
        {
            var result = new DynamicPropertyName();

            result.InjectFrom(entity);
            return(result);
        }
Example #2
0
        public static DynamicPropertyNameEntity ToEntity(this DynamicPropertyName model)
        {
            var result = new DynamicPropertyNameEntity();

            result.InjectFrom(model);
            return(result);
        }
Example #3
0
        public virtual DynamicPropertyName ToModel(DynamicPropertyName propName)
        {
            if (propName == null)
            {
                throw new ArgumentNullException(nameof(propName));
            }

            propName.Locale = Locale;
            propName.Name   = Name;

            return(propName);
        }
Example #4
0
        public virtual DynamicPropertyNameEntity FromModel(DynamicPropertyName propName)
        {
            if (propName == null)
            {
                throw new ArgumentNullException(nameof(propName));
            }

            Locale = propName.Locale;
            Name   = propName.Name;

            return(this);
        }
Example #5
0
        protected override void ExecuteCommand()
        {
            if (!String.IsNullOrEmpty(OutputFolder) && !Directory.Exists(OutputFolder))
            {
                throw new Exception($"there is no such a folder {OutputFolder}");
            }

            this.Consume(ea =>
            {
                try
                {
                    var body         = ea.Body;
                    var message      = Encoding.UTF8.GetString(body);
                    dynamic uniqueId = String.Empty;

                    dynamic entity = Newtonsoft.Json.JsonConvert.DeserializeObject <ExpandoObject>(message);
                    if (entity != null)
                    {
                        try
                        {
                            if (!String.IsNullOrEmpty(DynamicPropertyName))
                            {
                                foreach (var item in DynamicPropertyName.Split(".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                                {
                                    entity = ((IDictionary <string, object>)entity)[item];
                                }
                                uniqueId = entity;
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception($"ReceivedMessage: {message}", ex);
                        }
                    }

                    if (!String.IsNullOrEmpty(OutputFolder))
                    {
                        //create file
                        var fileName = string.Format(OutputFileNameFormat, uniqueId);
                        var filePath = Path.Combine(OutputFolder, fileName);
                        FileManager.CreateFileWithData(filePath, message);
                    }
                    Notification.Notify($"Done:{DynamicPropertyName}:{uniqueId}");
                    if (ShowHeaders)
                    {
                        foreach (var item in ea.BasicProperties.Headers)
                        {
                            String value = item.Value?.ToString();
                            if (item.Value?.GetType() == typeof(byte[]))
                            {
                                value = Encoding.UTF8.GetString((byte[])item.Value);
                            }
                            Notification.Notify($"{item.Key} : {value}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Notification.Notify(ex, NotifyTo.CONSOLE);
                }
            });
        }