Exemple #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            string TextIcon;

            SocialMediaTypeEnum SocialMedia = value is string?((string)value).ToEnum <SocialMediaTypeEnum>() : (SocialMediaTypeEnum)value;

            if (SocialMedia.Equals(SocialMediaTypeEnum.FACEBOOK))
            {
                TextIcon = FontAwesomeFont.Facebook;
            }
            else if (SocialMedia.Equals(SocialMediaTypeEnum.INSTAGRAM))
            {
                TextIcon = FontAwesomeFont.Instagram;
            }
            else
            {
                TextIcon = FontAwesomeFont.Youtube;
            }
            return(TextIcon);
        }
Exemple #2
0
        void prepareMappersForCharts(IMapperConfigurationExpression cfg)
        {
            // Sentiment Analysis Chart

            //Mapper for SentimentDTO to Microchart Entry
            cfg.CreateMap <SentimentDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Score))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Type))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Score))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.ResolveUsing(o =>
            {
                SkiaSharp.SKColor Color;
                SentimentEnum sentiment = o.Type.ToEnum <SentimentEnum>();
                if (sentiment.Equals(SentimentEnum.POSITIVE))
                {
                    Color = SKColor.Parse("#00FF00");
                }
                else if (sentiment.Equals(SentimentEnum.NEGATIVE))
                {
                    Color = SKColor.Parse("#FF0000");
                }
                else
                {
                    Color = SKColor.Parse("#9c9c9c");
                }
                return(Color);
            }));

            //Mapper for SentimentAnalysisStatisticsDTO to ChartModel
            cfg.CreateMap <SentimentAnalysisStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.SentimentData))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(DonutChart)));


            // Dimensions Chart

            //Mapper for DimensionDTO to Microchart Entry
            cfg.CreateMap <DimensionDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Value))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Type))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Value))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.UseValue(SKColor.Parse("#6BC7E0")));

            //Mapper for DimensionsStatisticsDTO to ChartModel
            cfg.CreateMap <DimensionsStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Dimensions))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(BarChart)));


            // Communities Chart

            //Mapper for CommunityDTO to Microchart Entry
            cfg.CreateMap <CommunityDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Value))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Type))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Value))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.UseValue(SKColor.Parse("#6BC7E0")));

            //Mapper for CommunitiesStatisticsDTO to ChartModel
            cfg.CreateMap <CommunitiesStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Communities))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(LineChart)));

            // Social Media Activities Chart

            //Mapper for ActivityDTO to Microchart Entry
            cfg.CreateMap <ActivityDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Value))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Type))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Value))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.ResolveUsing(o => {
                SkiaSharp.SKColor Color;
                SocialMediaTypeEnum socialMedia = o.Type.ToEnum <SocialMediaTypeEnum>();
                if (socialMedia.Equals(SocialMediaTypeEnum.FACEBOOK))
                {
                    Color = SKColor.Parse("#3b5998");
                }
                else if (socialMedia.Equals(SocialMediaTypeEnum.INSTAGRAM))
                {
                    Color = SKColor.Parse("#E03867");
                }
                else
                {
                    Color = SKColor.Parse("#cc181e");
                }
                return(Color);
            }));

            //Mapper for SocialMediaActivityStatisticsDTO to ChartModel
            cfg.CreateMap <SocialMediaActivityStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Activities))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(DonutChart)));


            // Comments Analyzed Chart

            //Mapper for CommentAnalyzedDTO  to Microchart Entry
            cfg.CreateMap <CommentsPerDateDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Total))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => String.Format("{0:d/M/yyyy HH:mm:ss}", o.Date)))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Total))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.UseValue(SKColor.Parse("#6BC7E0")));

            //Mapper for CommentsAnalyzedStatisticsDTO to ChartModel
            cfg.CreateMap <CommentsStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Data))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(BarChart)));


            // Social Media Likes Chart

            //Mapper for SocialMediaLikesDTO  to Microchart Entry
            cfg.CreateMap <SocialMediaLikesDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Likes))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Type))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Likes))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.ResolveUsing(o => {
                SkiaSharp.SKColor Color;
                SocialMediaTypeEnum socialMedia = o.Type.ToEnum <SocialMediaTypeEnum>();
                if (socialMedia.Equals(SocialMediaTypeEnum.FACEBOOK))
                {
                    Color = SKColor.Parse("#3b5998");
                }
                else if (socialMedia.Equals(SocialMediaTypeEnum.INSTAGRAM))
                {
                    Color = SKColor.Parse("#E03867");
                }
                else
                {
                    Color = SKColor.Parse("#cc181e");
                }
                return(Color);
            }));

            //Mapper for SocialMediaLikesStatisticsDTO to ChartModel
            cfg.CreateMap <SocialMediaLikesStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Data))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(BarChart)));

            // Alerts Statistics Chart

            //Mapper for AlertLevelDTO  to Microchart Entry
            cfg.CreateMap <AlertLevelDTO, Microcharts.Entry>()
            .ConstructUsing(s => new Microcharts.Entry(s.Total))
            .ForMember(s => s.Label, (obj) => obj.ResolveUsing(o => o.Level))
            .ForMember(s => s.Value, (obj) => obj.ResolveUsing(o => o.Total))
            .ForMember(s => s.ValueLabel, (obj) => obj.ResolveUsing(o => o.Label))
            .ForMember(s => s.Color, (obj) => obj.ResolveUsing(o => o.Level.ToEnum <AlertLevelEnum>().ToColor()));

            //Mapper for AlertsStatisticsDTO to ChartModel
            cfg.CreateMap <AlertsStatisticsDTO, ChartModel>()
            .ForMember(s => s.Entries, (obj) => obj.MapFrom((o) => o.Data))
            .ForMember(s => s.Type, (obj) => obj.UseValue(typeof(DonutChart)));
        }