Пример #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //var dummyData = new Measurment
            //{
            //    ServiceUserID = new Guid("19E78A2C-4207-4C4B-907F-1A13F72266CD"),
            //    Id = new Guid("EB5C3B06-11C4-49AD-862E-2191148D2504"),
            //    MeasurmentDate = DateTime.Now,
            //    MeasurmentType = MeasurmentType.Weight,
            //    MeasurmentValue = 75
            //};

            System.Data.Entity.Database.SetInitializer(new ChartInitializer());
            var chartContext = new ChartContext();
            chartContext.Database.Initialize(true);
        }
Пример #2
0
 public ChartService(ChartContext context) : base(context)
 {
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string customerId = this.ddlCustomer.SelectedValue;
            string filePath   = Server.MapPath("~/template_files/template_workbook.xlsx");
            string chartTitle = this.txtChartTitle.Text.Replace("#", "");

            using (var context = new ChartContext())
            {
                DataTable table  = (DataTable)ViewState["table"];
                DataTable table1 = (DataTable)ViewState["table1"];
                if (this.ddlChartType.SelectedValue == "1")
                {
                    var rows = table.Select("Quantity <> '0'");
                    if (rows.Count() == 0)
                    {
                        MessageBox.Show(this, "图表数据不能为空");
                        return;
                    }
                }
                if (this.ddlChartType.SelectedValue == "2")
                {
                    var rows = table1.Rows;
                    if (rows.Count == 0)
                    {
                        MessageBox.Show(this, "图表数据不能为空");
                        return;
                    }
                }

                try
                {
                    var               missing     = Type.Missing;
                    string            fileName    = Server.MapPath("~/template_files/template_workbook.xlsx");
                    Excel.Application application = new Excel.Application();
                    application.Visible       = false;
                    application.DisplayAlerts = false;

                    Excel.Workbook   workbook  = application.Workbooks.Open(fileName);
                    string           sheetname = "sheet1";
                    Excel._Worksheet worksheet = workbook.Sheets[sheetname];
                    worksheet.Activate();
                    List <GatherTrend> gatherTrends = new List <GatherTrend>();
                    List <int>         listElements = new List <int>();
                    int    i             = 0;
                    string chartCategory = this.ddlChartType.SelectedValue;
                    switch (chartCategory)
                    {
                    case "1":
                        table = (DataTable)ViewState["table"];
                        string dateString = string.Empty;
                        foreach (DataRow row in table.Rows)
                        {
                            if (row["Quantity"].ToString() != "0")
                            {
                                if (this.rbYearMonth.Checked == true)
                                {
                                    dateString = DateTime.Parse(row["Date"].ToString()).ToString("yyyy年M月");
                                }
                                else if (this.rbMonthDay.Checked == true)
                                {
                                    dateString = DateTime.Parse(row["Date"].ToString()).ToString("M月d日");
                                }
                                i++;
                                Excel.Range rangeA = worksheet.get_Range("A" + i);
                                rangeA.Value = dateString;
                                Excel.Range rangeB = worksheet.get_Range("B" + i);
                                rangeB.Value = row["Quantity"].ToString();
                                listElements.Add(row["Quantity"].ToInt32());
                                GatherTrend trend = new GatherTrend
                                {
                                    Name   = dateString,
                                    Number = row["Quantity"].ToInt32()
                                };
                                gatherTrends.Add(trend);
                            }
                        }
                        break;

                    case "2":
                        table1 = (DataTable)ViewState["table1"];
                        foreach (DataRow row in table1.Rows)
                        {
                            i++;
                            Excel.Range rangeA = worksheet.get_Range("A" + i);
                            rangeA.Value = row["Issue"];
                            Excel.Range rangeB = worksheet.get_Range("B" + i);
                            rangeB.Value = row["Quantity"].ToString();
                            listElements.Add(row["Quantity"].ToInt32());
                        }
                        break;
                    }

                    Excel.Range dataSourceRange = worksheet.get_Range("A1", "B" + i);
                    Excel.Shape shape1          = worksheet.Shapes.AddChart(Excel.XlChartType.xlLineMarkers, missing, missing, missing, missing);

                    //设置数据源
                    shape1.Chart.SetSourceData(dataSourceRange, missing);

                    //设置标题
                    shape1.Chart.HasTitle        = true;
                    shape1.Chart.ChartTitle.Text = chartTitle.Replace("#", "");
                    shape1.Chart.ChartTitle.Format.TextFrame2.TextRange.Font.Size = 16;

                    //设置Legend
                    if (this.rblDataLabels.SelectedValue == "1")
                    {
                        shape1.Chart.ApplyDataLabels();
                    }
                    else if (this.rblDataLabels.SelectedValue == "2")
                    {
                        int maxIndex = listElements.IndexOf(listElements.Max()) + 1;
                        int minIndex = listElements.IndexOf(listElements.Min()) + 1;
                        shape1.Chart.SeriesCollection(1).Points(maxIndex).ApplyDataLabels();
                        shape1.Chart.SeriesCollection(1).Points(minIndex).ApplyDataLabels();
                    }


                    shape1.Left               = (float)worksheet.get_Range("G1").Left;
                    shape1.Top                = (float)worksheet.get_Range("G6").Top;
                    shape1.Fill.Visible       = MsoTriState.msoTrue;
                    shape1.Fill.ForeColor.RGB = Color.FromArgb(225, 236, 238).ToArgb();
                    shape1.Fill.Transparency  = 0;
                    shape1.Fill.Solid();
                    shape1.Chart.PlotArea.Format.Fill.Visible       = MsoTriState.msoTrue;
                    shape1.Chart.PlotArea.Format.Fill.ForeColor.RGB = Color.FromArgb(218, 234, 253).ToArgb();
                    shape1.Chart.PlotArea.Format.Fill.Transparency  = 0;
                    shape1.Chart.PlotArea.Format.Fill.Solid();
                    //shape1.Chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom;
                    shape1.Chart.HasLegend = false;

                    DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("~/Download/" + this.ddlCustomer.SelectedItem.Text));
                    if (!directoryInfo.Exists)
                    {
                        directoryInfo.Create();
                    }
                    String ymd = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                    string saveExcelFileName = String.Format("{0}_{1}.xlsx", chartTitle, ymd);
                    string saveExcelFilePath = Path.Combine(directoryInfo.FullName, saveExcelFileName);
                    string savePngFileName   = String.Format("{0}_{1}.png", chartTitle, ymd);
                    string savePngFilePath   = Path.Combine(directoryInfo.FullName, savePngFileName);
                    string excelFileName     = "/Download/" + this.ddlCustomer.SelectedItem.Text + "/" + saveExcelFileName;
                    string pngFileName       = "/Download/" + this.ddlCustomer.SelectedItem.Text + "/" + savePngFileName;
                    worksheet.SaveAs(saveExcelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    shape1.Chart.Export(savePngFilePath, missing, missing);
                    application.Quit();
                    worksheet   = null;
                    workbook    = null;
                    application = null;
                    GC.GetTotalMemory(false);
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                    GC.GetTotalMemory(true);

                    var entity = new Gather
                    {
                        CustomerID    = int.Parse(customerId),
                        TimeRange     = "",
                        ChartTitle    = chartTitle,
                        ExcelFilePath = excelFileName,
                        PngFilePath   = pngFileName,
                        AddDate       = DateTime.Now,
                        Flag          = "trend"
                    };
                    gatherTrends.ForEach(item =>
                    {
                        entity.GatherTrends.Add(item);
                    });
                    context.Gathers.Add(entity);
                    context.SaveChanges();
                    using (FileStream fileStream = new FileStream(saveExcelFilePath, FileMode.Open))
                    {
                        byte[] bytes = fileStream.ToByteArray();
                        Response.Clear();
                        Response.AddHeader("Content-Length", fileStream.Length.ToString());
                        Response.ContentType = "application/ms-excel";
                        Response.AddHeader("Content-Disposition", "inline;FileName=" + saveExcelFileName);
                        fileStream.Close();
                        fileStream.Dispose();
                        Response.BinaryWrite(bytes);
                        Response.End();
                    }
                    InitRepeater3();
                }
                catch (Exception ex)
                {
                    MessageBox.ShowAndRedirect(this, "生成图表是出错:" + ex.Message, Request.RawUrl);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 生成图表
        /// </summary>
        /// <param name="queryId">视图记录</param>
        /// <param name="chartId">图表记录</param>
        /// <param name="filter">附加过滤条件</param>
        /// <returns></returns>
        public ChartContext Build(QueryView.Domain.QueryView queryView, Chart chartEntity, FilterExpression filter = null, string drillGroup = "")
        {
            ChartContext context = new ChartContext();
            //图表对象
            ChartDescriptor chart = new ChartDescriptor();

            chart       = chart.DeserializeFromJson(chartEntity.PresentationConfig);
            chart.Title = chartEntity.Name;
            //引用视图查询数据
            _fetchDataService.GetMetaDatas(queryView.FetchConfig);
            if (filter != null)
            {
                _fetchDataService.QueryExpression.Criteria.AddFilter(filter);
            }

            //图表数据描述
            ChartDataDescriptor chartData = new ChartDataDescriptor();

            chartData = chartData.DeserializeFromJson(chartEntity.DataConfig);
            if (drillGroup.IsNotEmpty())
            {
                var categoryChartData = chartData.Fetch.Find(n => n.Type == ChartItemType.Category);
                categoryChartData.Attribute = drillGroup;
            }
            var dataSource = _chartRepository.GetChartDataSource(chartData, _fetchDataService.QueryExpression, _fetchDataService.QueryResolver);

            chart.Legend = new List <string>();
            var categories = new List <string>();//分类标签
            var emptyStr   = _loc["chart_nodata"];

            foreach (var item in chartData.Fetch)
            {
                var attr = _fetchDataService.QueryResolver.AttributeList.Find(n => n.EntityId == chartEntity.EntityId && n.Name.IsCaseInsensitiveEqual(item.Attribute));
                var name = item.Attribute;
                if (item.Type == ChartItemType.Series)
                {
                    //legend
                    chart.Legend.Add(attr.LocalizedName);
                    var seriesData = new List <string>();
                    var seriesName = name + Enum.GetName(typeof(AggregateType), item.Aggregate);
                    foreach (var d in dataSource)
                    {
                        var line = d as IDictionary <string, object>;
                        seriesData.Add(line[seriesName] != null ? line[seriesName].ToString() : "0");
                    }
                    var s = chart.Series.Find(n => n.Name.IsCaseInsensitiveEqual(item.Attribute));
                    s.Name = attr.LocalizedName;
                    s.Data = seriesData;
                }
                else if (item.Type == ChartItemType.Category)
                {
                    if (attr.TypeIsLookUp() || attr.TypeIsOwner() || attr.TypeIsCustomer())
                    {
                        name += "name";
                    }
                    else if (attr.TypeIsPrimaryKey())
                    {
                        name = attr.Name + "name";
                    }
                    foreach (var d in dataSource)
                    {
                        var line = d as IDictionary <string, object>;
                        //选项类型,获取选项显示名称
                        if (line[name] != null && (attr.TypeIsPickList() || attr.TypeIsStatus()))
                        {
                            var oname = _optionSetDetailFinder.GetOptionName(attr.OptionSetId.Value, int.Parse(line[name].ToString()));
                            categories.Add(oname.IfEmpty(emptyStr));
                        }
                        //是否类型,获取选项显示名称
                        else if (line[name] != null && (attr.TypeIsBit() || attr.TypeIsState()))
                        {
                            var oname = _stringMapFinder.GetOptionName(attr.AttributeId, int.Parse(line[name].ToString()));
                            categories.Add(oname.IfEmpty(emptyStr));
                        }
                        else
                        {
                            categories.Add(line[name] != null ? line[name].ToString() : emptyStr);
                        }
                    }
                    chart.XAxis = new XAxis()
                    {
                        Type = AxisType.Category,
                        Data = categories
                    };
                }
                chart.SubTitle = queryView.Name;

                context.Chart      = chart;
                context.ChartData  = chartData;
                context.Attributes = _fetchDataService.QueryResolver.AttributeList;
                context.DataSource = dataSource;
            }
            return(context);
        }
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is LineSeriesView view)
            {
                view.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

                if (MarkerKind.HasValue)
                {
                    view.LineMarkerOptions.Kind = MarkerKind.Value;
                }
                if (MarkerSize.HasValue)
                {
                    view.LineMarkerOptions.Size = MarkerSize.Value;
                }
                if (MarkerStarPointCount.HasValue)
                {
                    view.LineMarkerOptions.StarPointCount = MarkerStarPointCount.Value;
                }
                var markerBorderColor = Utils.ColorFromString(MarkerBorderColor);
                if (markerBorderColor != System.Drawing.Color.Empty)
                {
                    view.LineMarkerOptions.BorderColor = markerBorderColor;
                }
                if (HideMarkerBorder)
                {
                    view.LineMarkerOptions.BorderVisible = false;
                }

                if (MarkerFillMode.HasValue)
                {
                    switch (MarkerFillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.LineMarkerOptions.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (MarkerGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = MarkerGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.LineMarkerOptions.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (MarkerHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = MarkerHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }

                if (MarkerVisibility.HasValue)
                {
                    view.MarkerVisibility = MarkerVisibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }

                if (LineDashStyle.HasValue)
                {
                    view.LineStyle.DashStyle = LineDashStyle.Value;
                }
                if (LineJoin.HasValue)
                {
                    view.LineStyle.LineJoin = LineJoin.Value;
                }
                if (LineThickness.HasValue)
                {
                    view.LineStyle.Thickness = LineThickness.Value;
                }
            }
        }
Пример #6
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is BoxPlotSeriesView view)
            {
                var borderColor = Utils.ColorFromString(BorderColor);
                if (borderColor != System.Drawing.Color.Empty)
                {
                    view.Border.Color      = borderColor;
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                }

                if (BorderThickness.HasValue)
                {
                    view.Border.Thickness  = BorderThickness.Value;
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                }

                if (BoxDistance.HasValue)
                {
                    view.BoxDistance = BoxDistance.Value;
                }

                if (BoxDistanceFixed.HasValue)
                {
                    view.BoxDistanceFixed = BoxDistanceFixed.Value;
                }

                if (BoxWidth.HasValue)
                {
                    view.BoxWidth = BoxWidth.Value;
                }

                if (CapWidthPercentage.HasValue)
                {
                    view.CapWidthPercentage = CapWidthPercentage.Value;
                }

                view.EqualBoxWidth = EqualBoxWidth;

                if (FillMode.HasValue)
                {
                    view.FillStyle.FillMode = FillMode.Value;
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                        {
                            var backColor2 = Utils.ColorFromString(BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientOptions.Color2 = backColor2;
                            }
                            if (FillGradientMode.HasValue)
                            {
                                gradientOptions.GradientMode = FillGradientMode.Value;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.FillStyle.Options is HatchFillOptions hatchOptions)
                        {
                            var backColor2 = Utils.ColorFromString(BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchOptions.Color2 = backColor2;
                            }
                            if (FillHatchStyle.HasValue)
                            {
                                hatchOptions.HatchStyle = FillHatchStyle.Value;
                            }
                        }
                        break;
                    }
                }

                if (LineThickness.HasValue)
                {
                    view.LineThickness = LineThickness.Value;
                }

                var meanAndMedianColor = Utils.ColorFromString(MeanAndMedianColor);
                if (meanAndMedianColor != System.Drawing.Color.Empty)
                {
                    view.MeanAndMedianColor = meanAndMedianColor;
                }

                if (MeanMarkerKind.HasValue)
                {
                    view.MeanMarkerKind = MeanMarkerKind.Value;
                }

                if (MeanMarkerSize.HasValue)
                {
                    view.MeanMarkerSize = MeanMarkerSize.Value;
                }

                if (OutlierMarkerKind.HasValue)
                {
                    view.OutlierMarkerKind = OutlierMarkerKind.Value;
                }

                if (OutlierMarkerSize.HasValue)
                {
                    view.OutlierMarkerSize = OutlierMarkerSize.Value;
                }

                if (Transparency.HasValue)
                {
                    view.Transparency = Transparency.Value;
                }
            }
        }
Пример #7
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is WaterfallSeriesView view)
            {
                var connectorColor = Utils.ColorFromString(ConnectorColor);
                if (connectorColor != System.Drawing.Color.Empty)
                {
                    view.ConnectorColor = connectorColor;
                }

                if (ConnectorLineDashStyle.HasValue)
                {
                    view.ConnectorStyle.DashStyle = ConnectorLineDashStyle.Value;
                }

                if (ConnectorLineJoin.HasValue)
                {
                    view.ConnectorStyle.LineJoin = ConnectorLineJoin.Value;
                }

                if (ConnectorThickness.HasValue)
                {
                    view.ConnectorStyle.Thickness = ConnectorThickness.Value;
                }

                var fallingBarColor = Utils.ColorFromString(FallingBarColor);
                if (fallingBarColor != System.Drawing.Color.Empty)
                {
                    view.FallingBarColor = fallingBarColor;
                }

                var risingBarColor = Utils.ColorFromString(RisingBarColor);
                if (risingBarColor != System.Drawing.Color.Empty)
                {
                    view.RisingBarColor = risingBarColor;
                }

                var startBarColor = Utils.ColorFromString(StartBarColor);
                if (startBarColor != System.Drawing.Color.Empty)
                {
                    view.StartBarColor = startBarColor;
                }

                var subtotalBarColor = Utils.ColorFromString(SubtotalBarColor);
                if (subtotalBarColor != System.Drawing.Color.Empty)
                {
                    view.SubtotalBarColor = subtotalBarColor;
                }

                var totalBarColor = Utils.ColorFromString(TotalBarColor);
                if (totalBarColor != System.Drawing.Color.Empty)
                {
                    view.TotalBarColor = totalBarColor;
                }

                if (RelativeValues)
                {
                    var valueOptions = new WaterfallRelativeValueOptions()
                    {
                        ShowTotal = this.ShowTotal
                    };

                    if (!string.IsNullOrWhiteSpace(StartBarLabel))
                    {
                        valueOptions.StartBarLabel = StartBarLabel;
                    }

                    if (StartBarValue.HasValue)
                    {
                        valueOptions.StartBarValue = StartBarValue.Value;
                    }

                    if (!string.IsNullOrWhiteSpace(TotalLabel))
                    {
                        valueOptions.TotalLabel = TotalLabel;
                    }

                    if (Subtotals != null && Subtotals.Length > 0)
                    {
                        foreach (var subtotal in Subtotals)
                        {
                            valueOptions.Subtotals.Add(new DevExpress.XtraCharts.Subtotal(subtotal.PointIndex, subtotal.Label));
                        }
                    }

                    view.ValueOptions = valueOptions;
                }
                else
                {
                    var valueOptions = new WaterfallAbsoluteValueOptions()
                    {
                        ShowTotal = this.ShowTotal
                    };

                    if (!string.IsNullOrWhiteSpace(TotalLabel))
                    {
                        valueOptions.TotalLabel = TotalLabel;
                    }

                    if (Subtotals != null && Subtotals.Length > 0)
                    {
                        foreach (var subtotal in Subtotals)
                        {
                            valueOptions.Subtotals.Add(new DevExpress.XtraCharts.Subtotal(subtotal.PointIndex, subtotal.Label));
                        }
                    }

                    view.ValueOptions = valueOptions;
                }
            }
        }
 public override void SetupXtraChartColorizer(ChartContext chartContext, ChartColorizerBase colorizer)
 {
     //Do nothing
 }
 public EFUnitOfWork(string connectionString)
 {
     db = ChartContext.getInstance(connectionString);
 }
 public PointRepository(ChartContext context)
 {
     this.db = context;
 }
Пример #11
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is RadarRangeAreaSeriesView view)
            {
                if (AggregateFunction != SCSeriesAggregateFunction.Default)
                {
                    view.AggregateFunction = (SeriesAggregateFunction)(int)AggregateFunction;
                }

                var border1Color = Utils.ColorFromString(Border1Color);
                if (border1Color != System.Drawing.Color.Empty)
                {
                    view.Border1.Visibility = DevExpress.Utils.DefaultBoolean.True;
                    view.Border1.Color      = border1Color;
                }
                if (Border1Thickness.HasValue)
                {
                    view.Border1.Thickness = Border1Thickness.Value;
                }

                var border2Color = Utils.ColorFromString(Border1Color);
                if (border2Color != System.Drawing.Color.Empty)
                {
                    view.Border2.Visibility = DevExpress.Utils.DefaultBoolean.True;
                    view.Border2.Color      = border2Color;
                }
                if (Border2Thickness.HasValue)
                {
                    view.Border2.Thickness = Border2Thickness.Value;
                }

                var color = Utils.ColorFromString(Color);
                if (color != System.Drawing.Color.Empty)
                {
                    view.Color = color;
                }

                view.ColorEach = ColorEach;

                if (FillMode.HasValue)
                {
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (FillGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = FillGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Color2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (FillHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = FillHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Color2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }

                if (Marker1Kind.HasValue)
                {
                    view.Marker1.Kind = Marker1Kind.Value;
                }
                if (Marker1Size.HasValue)
                {
                    view.Marker1.Size = Marker1Size.Value;
                }
                if (Marker1StarPointCount.HasValue)
                {
                    view.Marker1.StarPointCount = Marker1StarPointCount.Value;
                }
                if (!string.IsNullOrWhiteSpace(Marker1BorderColor))
                {
                    var marker1BorderColor = Utils.ColorFromString(Marker1BorderColor);
                    if (marker1BorderColor != System.Drawing.Color.Empty)
                    {
                        view.Marker1.BorderVisible = true;
                        view.Marker1.BorderColor   = marker1BorderColor;
                    }
                }

                var marker1Color = Utils.ColorFromString(Marker1Color);
                if (marker1Color != System.Drawing.Color.Empty)
                {
                    view.Marker1.Color = marker1Color;
                }

                if (Marker1Visibility.HasValue)
                {
                    view.Marker1Visibility = Marker1Visibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }

                if (HideMarker1Border)
                {
                    view.Marker1.BorderVisible = false;
                }
                if (Marker1FillMode.HasValue)
                {
                    switch (Marker1FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.Marker1.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (Marker1GradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = Marker1GradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Marker1BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.Marker1.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (Marker1HatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = Marker1HatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Marker1BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }

                if (Marker2Kind.HasValue)
                {
                    view.Marker2.Kind = Marker2Kind.Value;
                }
                if (Marker2Size.HasValue)
                {
                    view.Marker2.Size = Marker2Size.Value;
                }
                if (Marker2StarPointCount.HasValue)
                {
                    view.Marker2.StarPointCount = Marker2StarPointCount.Value;
                }
                if (!string.IsNullOrWhiteSpace(Marker2BorderColor))
                {
                    var marker2BorderColor = Utils.ColorFromString(Marker2BorderColor);
                    if (marker2BorderColor != System.Drawing.Color.Empty)
                    {
                        view.Marker2.BorderVisible = true;
                        view.Marker2.BorderColor   = marker2BorderColor;
                    }
                }

                var marker2Color = Utils.ColorFromString(Marker2Color);
                if (marker2Color != System.Drawing.Color.Empty)
                {
                    view.Marker2.Color = marker2Color;
                }

                if (Marker2Visibility.HasValue)
                {
                    view.Marker2Visibility = Marker2Visibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }

                if (HideMarker2Border)
                {
                    view.Marker2.BorderVisible = false;
                }
                if (Marker2FillMode.HasValue)
                {
                    switch (Marker2FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.Marker2.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (Marker2GradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = Marker2GradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Marker2BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.Marker2.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (Marker2HatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = Marker2HatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(Marker2BackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }

                if (!string.IsNullOrWhiteSpace(ShadowColor))
                {
                    var shadowColor = Utils.ColorFromString(ShadowColor);
                    if (shadowColor != System.Drawing.Color.Empty)
                    {
                        view.Shadow.Visible = true;
                        view.Shadow.Color   = shadowColor;
                    }
                }
                if (ShadowSize.HasValue)
                {
                    view.Shadow.Size    = ShadowSize.Value;
                    view.Shadow.Visible = true;
                }
            }
        }
Пример #12
0
 public DashboardController(ChartContext context)
 {
     _Context = context;
 }
Пример #13
0
 public AccountController(ChartContext context)
 {
     _Context = context;
 }
Пример #14
0
 public virtual void SetupXtraChartColorizer(ChartContext chartContext, SegmentColorizerBase colorizer)
 {
 }
Пример #15
0
 public ChartDataRepository(ChartContext context)
 {
     this.db = context;
 }
Пример #16
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is RadarPointSeriesView view)
            {
                if (AggregateFunction != SCSeriesAggregateFunction.Default)
                {
                    view.AggregateFunction = (SeriesAggregateFunction)(int)AggregateFunction;
                }
                view.ColorEach = ColorEach;

                if (view is RadarLineSeriesView viewLine)
                {
                    if (MarkerKind.HasValue)
                    {
                        viewLine.LineMarkerOptions.Kind = MarkerKind.Value;
                    }
                    if (MarkerSize.HasValue)
                    {
                        viewLine.LineMarkerOptions.Size = MarkerSize.Value;
                    }
                    if (MarkerStarPointCount.HasValue)
                    {
                        viewLine.LineMarkerOptions.StarPointCount = MarkerStarPointCount.Value;
                    }
                    if (!string.IsNullOrWhiteSpace(MarkerBorderColor))
                    {
                        var borderColor = Utils.ColorFromString(MarkerBorderColor);
                        if (borderColor != Color.Empty)
                        {
                            viewLine.LineMarkerOptions.BorderVisible = true;
                            viewLine.LineMarkerOptions.BorderColor   = borderColor;
                        }
                    }

                    if (HideMarkerBorder)
                    {
                        viewLine.LineMarkerOptions.BorderVisible = false;
                    }
                    if (MarkerFillMode.HasValue)
                    {
                        switch (MarkerFillMode.Value)
                        {
                        case DevExpress.XtraCharts.FillMode.Empty:
                            break;

                        case DevExpress.XtraCharts.FillMode.Solid:
                            break;

                        case DevExpress.XtraCharts.FillMode.Gradient:
                            if (viewLine.LineMarkerOptions.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                            {
                                if (MarkerGradientMode.HasValue)
                                {
                                    gradientFillOptions.GradientMode = MarkerGradientMode.Value;
                                }
                                var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                                if (backColor2 != Color.Empty)
                                {
                                    gradientFillOptions.Color2 = backColor2;
                                }
                            }
                            break;

                        case DevExpress.XtraCharts.FillMode.Hatch:
                            if (viewLine.LineMarkerOptions.FillStyle.Options is HatchFillOptions hatchFillOptions)
                            {
                                if (MarkerHatchStyle.HasValue)
                                {
                                    hatchFillOptions.HatchStyle = MarkerHatchStyle.Value;
                                }
                                var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                                if (backColor2 != Color.Empty)
                                {
                                    hatchFillOptions.Color2 = backColor2;
                                }
                            }
                            break;
                        }
                    }
                }
                else
                {
                    if (MarkerKind.HasValue)
                    {
                        view.PointMarkerOptions.Kind = MarkerKind.Value;
                    }
                    if (MarkerSize.HasValue)
                    {
                        view.PointMarkerOptions.Size = MarkerSize.Value;
                    }
                    if (MarkerStarPointCount.HasValue)
                    {
                        view.PointMarkerOptions.StarPointCount = MarkerStarPointCount.Value;
                    }
                    if (!string.IsNullOrWhiteSpace(MarkerBorderColor))
                    {
                        var borderColor = Utils.ColorFromString(MarkerBorderColor);
                        if (borderColor != Color.Empty)
                        {
                            view.PointMarkerOptions.BorderVisible = true;
                            view.PointMarkerOptions.BorderColor   = borderColor;
                        }
                    }

                    if (HideMarkerBorder)
                    {
                        view.PointMarkerOptions.BorderVisible = false;
                    }
                    if (MarkerFillMode.HasValue)
                    {
                        switch (MarkerFillMode.Value)
                        {
                        case DevExpress.XtraCharts.FillMode.Empty:
                            break;

                        case DevExpress.XtraCharts.FillMode.Solid:
                            break;

                        case DevExpress.XtraCharts.FillMode.Gradient:
                            if (view.PointMarkerOptions.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                            {
                                if (MarkerGradientMode.HasValue)
                                {
                                    gradientFillOptions.GradientMode = MarkerGradientMode.Value;
                                }
                                var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                                if (backColor2 != Color.Empty)
                                {
                                    gradientFillOptions.Color2 = backColor2;
                                }
                            }
                            break;

                        case DevExpress.XtraCharts.FillMode.Hatch:
                            if (view.PointMarkerOptions.FillStyle.Options is HatchFillOptions hatchFillOptions)
                            {
                                if (MarkerHatchStyle.HasValue)
                                {
                                    hatchFillOptions.HatchStyle = MarkerHatchStyle.Value;
                                }
                                var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                                if (backColor2 != Color.Empty)
                                {
                                    hatchFillOptions.Color2 = backColor2;
                                }
                            }
                            break;
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(ShadowColor))
                {
                    var shadowColor = Utils.ColorFromString(ShadowColor);
                    if (shadowColor != Color.Empty)
                    {
                        view.Shadow.Visible = true;
                        view.Shadow.Color   = shadowColor;
                    }
                }
                if (ShadowSize.HasValue)
                {
                    view.Shadow.Size    = ShadowSize.Value;
                    view.Shadow.Visible = true;
                }
            }
        }
Пример #17
0
 public DashboardRepository(ChartContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is RangeBarSeriesView view)
            {
                if (MaxMarkerKind.HasValue)
                {
                    view.MaxValueMarker.Kind = MaxMarkerKind.Value;
                }
                if (MaxMarkerSize.HasValue)
                {
                    view.MaxValueMarker.Size = MaxMarkerSize.Value;
                }
                if (MaxMarkerStarPointCount.HasValue)
                {
                    view.MaxValueMarker.StarPointCount = MaxMarkerStarPointCount.Value;
                }
                if (!string.IsNullOrWhiteSpace(MaxMarkerBorderColor))
                {
                    var markerBorderColor = Utils.ColorFromString(MaxMarkerBorderColor);
                    if (markerBorderColor != System.Drawing.Color.Empty)
                    {
                        view.MaxValueMarker.BorderVisible = true;
                        view.MaxValueMarker.BorderColor   = markerBorderColor;
                    }
                }

                var maxMarkerColor = Utils.ColorFromString(MaxMarkerColor);
                if (maxMarkerColor != System.Drawing.Color.Empty)
                {
                    view.MaxValueMarker.Color = maxMarkerColor;
                }

                if (MaxMarkerVisibility.HasValue)
                {
                    view.MaxValueMarkerVisibility = MaxMarkerVisibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }

                if (MaxHideMarkerBorder)
                {
                    view.MaxValueMarker.BorderVisible = false;
                }
                if (MaxMarkerFillMode.HasValue)
                {
                    switch (MaxMarkerFillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.MaxValueMarker.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (MaxMarkerGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = MaxMarkerGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MaxMarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.MaxValueMarker.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (MaxMarkerHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = MaxMarkerHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MaxMarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }


                if (MinMarkerKind.HasValue)
                {
                    view.MinValueMarker.Kind = MinMarkerKind.Value;
                }
                if (MinMarkerSize.HasValue)
                {
                    view.MinValueMarker.Size = MinMarkerSize.Value;
                }
                if (MinMarkerStarPointCount.HasValue)
                {
                    view.MinValueMarker.StarPointCount = MinMarkerStarPointCount.Value;
                }
                if (!string.IsNullOrWhiteSpace(MinMarkerBorderColor))
                {
                    var markerBorderColor = Utils.ColorFromString(MinMarkerBorderColor);
                    if (markerBorderColor != System.Drawing.Color.Empty)
                    {
                        view.MinValueMarker.BorderVisible = true;
                        view.MinValueMarker.BorderColor   = markerBorderColor;
                    }
                }

                var minMarkerColor = Utils.ColorFromString(MinMarkerColor);
                if (minMarkerColor != System.Drawing.Color.Empty)
                {
                    view.MinValueMarker.Color = minMarkerColor;
                }

                if (MinMarkerVisibility.HasValue)
                {
                    view.MinValueMarkerVisibility = MinMarkerVisibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }

                if (MinHideMarkerBorder)
                {
                    view.MinValueMarker.BorderVisible = false;
                }
                if (MinMarkerFillMode.HasValue)
                {
                    switch (MinMarkerFillMode)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.MinValueMarker.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (MinMarkerGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = MinMarkerGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MinMarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.MinValueMarker.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (MinMarkerHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = MinMarkerHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MinMarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }
            }
        }
Пример #19
0
 public EFUnitOfWork(string connectionString)
 {
     db = new ChartContext(connectionString);
 }
Пример #20
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is BubbleSeriesView view)
            {
                if (SizeUnit.HasValue)
                {
                    view.SizeUnit = SizeUnit.Value;
                }
                if (MinSize.HasValue)
                {
                    view.MinSize  = MinSize.Value;
                    view.AutoSize = false;
                }
                if (MaxSize.HasValue)
                {
                    view.MaxSize  = MaxSize.Value;
                    view.AutoSize = false;
                }

                if (MarkerKind.HasValue)
                {
                    view.BubbleMarkerOptions.Kind = MarkerKind.Value;
                }
                if (MarkerStarPointCount.HasValue)
                {
                    view.BubbleMarkerOptions.StarPointCount = MarkerStarPointCount.Value;
                }
                var markerBorderColor = Utils.ColorFromString(MarkerBorderColor);
                if (markerBorderColor != System.Drawing.Color.Empty)
                {
                    view.BubbleMarkerOptions.BorderColor = markerBorderColor;
                }
                if (HideMarkerBorder)
                {
                    view.BubbleMarkerOptions.BorderVisible = false;
                }

                if (MarkerFillMode.HasValue)
                {
                    switch (MarkerFillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.BubbleMarkerOptions.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (MarkerGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = MarkerGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.BubbleMarkerOptions.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (MarkerHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = MarkerHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }
            }
        }
Пример #21
0
 public UserVoteRepository(ChartContext context) :
     base(context)
 {
 }
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is PieSeriesView view)
            {
                if (ExplodeMode.HasValue)
                {
                    view.ExplodeMode = (PieExplodeMode)ExplodeMode.Value;
                }
                if (HeightToWidthRatio.HasValue)
                {
                    view.HeightToWidthRatio = HeightToWidthRatio.Value;
                }
                if (Rotation.HasValue)
                {
                    view.Rotation = Rotation.Value;
                }
                if (SweepDirection.HasValue)
                {
                    view.SweepDirection = SweepDirection.Value;
                }
                if (MinAllowedSizePercentage.HasValue)
                {
                    view.MinAllowedSizePercentage = MinAllowedSizePercentage.Value;
                }

                if (ExplodedPoints != null && ExplodedPoints.Length > 0)
                {
                    view.ExplodeMode = PieExplodeMode.UseFilters;
                    view.ExplodedPointsFilters.ConjunctionMode = ConjunctionTypes.Or;

                    foreach (var explodedPoint in ExplodedPoints)
                    {
                        view.ExplodedPointsFilters.Add(new SeriesPointFilter(SeriesPointKey.Argument, DataFilterCondition.Equal, explodedPoint));
                    }
                }

                if (FillMode.HasValue)
                {
                    view.FillStyle.FillMode = FillMode.Value;
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                        {
                            var backColor2 = Utils.ColorFromString(BackColor2);
                            if (backColor2 != Color.Empty)
                            {
                                gradientOptions.Color2 = backColor2;
                            }
                            if (FillGradientMode.HasValue)
                            {
                                gradientOptions.GradientMode = FillGradientMode.Value;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.FillStyle.Options is HatchFillOptions hatchOptions)
                        {
                            var backColor2 = Utils.ColorFromString(BackColor2);
                            if (backColor2 != Color.Empty)
                            {
                                hatchOptions.Color2 = backColor2;
                            }
                            if (FillHatchStyle.HasValue)
                            {
                                hatchOptions.HatchStyle = FillHatchStyle.Value;
                            }
                        }
                        break;
                    }
                }
            }
            else if (series.View is Pie3DSeriesView view3D)
            {
                if (ExplodeMode.HasValue)
                {
                    view3D.ExplodeMode = (PieExplodeMode)ExplodeMode.Value;
                }
                if (SweepDirection.HasValue)
                {
                    view3D.SweepDirection = SweepDirection.Value;
                }
                if (MinAllowedSizePercentage.HasValue)
                {
                    view3D.SizeAsPercentage = MinAllowedSizePercentage.Value;
                }

                if (ExplodedPoints != null && ExplodedPoints.Length > 0)
                {
                    view3D.ExplodeMode = PieExplodeMode.UseFilters;
                    view3D.ExplodedPointsFilters.ConjunctionMode = ConjunctionTypes.Or;

                    foreach (var explodedPoint in ExplodedPoints)
                    {
                        view3D.ExplodedPointsFilters.Add(new SeriesPointFilter(SeriesPointKey.Argument, DataFilterCondition.Equal, explodedPoint));
                    }
                }

                if (FillMode.HasValue)
                {
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        view3D.PieFillStyle.FillMode = FillMode3D.Solid;
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        view3D.PieFillStyle.FillMode = FillMode3D.Gradient;
                        if (view3D.PieFillStyle.Options is RectangleGradientFillOptions gradientOptions)
                        {
                            var backColor2 = Utils.ColorFromString(BackColor2);
                            if (backColor2 != Color.Empty)
                            {
                                gradientOptions.Color2 = backColor2;
                            }
                            if (FillGradientMode.HasValue)
                            {
                                gradientOptions.GradientMode = FillGradientMode.Value;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        //Ignore, cannot be applied to 3D series
                        break;
                    }
                }

                if (Depth.HasValue)
                {
                    view3D.Depth = Depth.Value;
                }
            }
        }
Пример #23
0
 public GenericRepository(ChartContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Пример #24
0
 public ParamRepository(ChartContext context)
 {
     this.db = context;
 }
Пример #25
0
        protected void btnGenerateReport_Click(object sender, EventArgs e)
        {
            DateTime startDate     = DateTime.Now;
            DateTime endDate       = DateTime.Now;
            ListItem customerItem  = this.ddlCustomerID.SelectedItem;
            ListItem reportItem    = this.ddlReportType.SelectedItem;
            int      customerId    = int.Parse(customerItem.Value);
            int      currentNumber = 0;
            int      totalNumber   = 0;
            string   reportType    = this.ddlReportType.SelectedValue;
            string   news_ids      = this.hideSelectedIDs.Value;

            using (var context = new ReportContext())
            {
                int reportTypeId = int.Parse(reportType);
                var entity       = context.ReportNumbers.FirstOrDefault(a => a.CustomerID == customerId && a.ReportTypeId == reportTypeId);
                if (entity != null)
                {
                    currentNumber = entity.CurrentNumber.Value;
                    totalNumber   = entity.TotalNumber.Value;
                }
            }
            switch (reportItem.Value)
            {
            case "1":     //日报
                startDate = DateTime.Now;
                break;

            case "2":     //周报
                startDate = DateTime.Now.AddDays(-7);
                break;

            case "3":     //旬报
                startDate = DateTime.Now.AddDays(-10);
                break;

            case "4":     //半月报
                startDate = DateTime.Now.AddDays(-15);
                break;

            case "5":     //月报
                startDate = DateTime.Now.AddDays(-30);
                break;

            case "6":     //季度报
                startDate = DateTime.Now.AddDays(-90);
                break;

            case "7":     //年报
                startDate = DateTime.Now.AddYears(-1);
                break;
            }
            string reportType1 = string.Empty;

            switch (reportItem.Text)
            {
            case "日报":
                reportType1 = "一日";
                break;

            case "周报":
                reportType1 = "一周";
                break;

            case "旬报":
                reportType1 = "旬度";
                break;

            case "半月报":
                reportType1 = "半月";
                break;

            case "月报":
                reportType1 = "月度";
                break;
            }
            string Subsidiary = string.Empty;

            using (var context = new ReportContext())
            {
                var yesExists = context.Subsidiaries.Any(s => s.CustomerID == customerId);
                if (yesExists == true)
                {
                    Subsidiary = "及其权属企业";
                }
            }
            StringBuilder areaBuilder = new StringBuilder();

            using (var context = new ChartContext())
            {
                string pngPath = this.txtPath0.Text.Trim();
                if (!string.IsNullOrEmpty(pngPath))
                {
                    var gather = context.Gathers.FirstOrDefault(a => a.PngFilePath == pngPath);
                    if (gather != null)
                    {
                        var entities   = gather.GatherQuantities;
                        var sensitives = entities.Where(a => a.SensitiveNumber > 0).Select(a => a.ChannelName);
                        int i          = 0;
                        foreach (var entity in sensitives)
                        {
                            i++;
                            if (i == sensitives.Count())
                            {
                                areaBuilder.AppendFormat("和{0}", entity);
                            }
                            else
                            {
                                areaBuilder.AppendFormat("、{0}", entity);
                            }
                        }
                    }
                }
            }
            string          area       = areaBuilder.ToString().TrimStart('、');
            Document        document   = new Document(Server.MapPath("~/template_files/week_report.doc"));
            DocumentBuilder docBuilder = new DocumentBuilder(document);

            document.Range.Replace("{Company}", customerItem.Text, false, false);
            document.Range.Replace("{Subsidiary}", Subsidiary, false, false);
            document.Range.Replace("{ReportType}", reportItem.Text, false, false);
            document.Range.Replace("{area}", area, false, false);
            document.Range.Replace("{year}", DateTime.Now.ToString("yyyy"), false, false);
            document.Range.Replace("{month}", DateTime.Now.ToString("MM"), false, false);
            document.Range.Replace("{day}", DateTime.Now.ToString("dd"), false, false);
            document.Range.Replace("{number1}", currentNumber.ToString(), false, false);
            document.Range.Replace("{number2}", totalNumber.ToString(), false, false);
            document.Range.Replace("{ReportType1}", reportType1, false, false);
            document.Range.Replace("{TypeString}", CommonUtility.ReplaceReportType(reportItem.Text), false, false);
            document.Range.Replace("{aTypeString}", CommonUtility.ReplaceReportType(reportItem.Text).Replace("本", ""), false, false);
            int?   totalNewsQuanity = 0;
            int?   sensitiveNumber  = 0;
            int?   totalHudongCount = 0;
            int?   totalMinganCount = 0;
            string strText          = "均为正面或中性报道";

            using (var context = new ChartContext())
            {
                var entity = context.Gathers.FirstOrDefault(a => a.PngFilePath == this.txtPath0.Text);
                if (entity != null)
                {
                    var entities = entity.GatherQuantities;
                    totalNewsQuanity = entities.FirstOrDefault(a => a.ChannelName == "新闻").TotalNumber;
                    document.Range.Replace("{news_number}", totalNewsQuanity.ToString(), false, false);
                    sensitiveNumber = entities.FirstOrDefault(a => a.ChannelName == "新闻").SensitiveNumber;

                    if (sensitiveNumber > 0)
                    {
                        strText = String.Format("其中有{0}篇敏感报道。", sensitiveNumber);
                    }
                    document.Range.Replace("{strText}", strText, false, false);
                    totalHudongCount = entities.Where(a => a.ChannelName != "新闻").Select(a => a.TotalNumber).Sum();
                    document.Range.Replace("{hudong_number}", totalHudongCount.ToString(), false, false);
                    totalMinganCount = entities.Where(a => a.ChannelName != "新闻").Select(a => a.SensitiveNumber).Sum();
                    document.Range.Replace("{mingan_number}", totalMinganCount.ToString(), false, false);
                }
            }

            //-------------------
            document.Range.Replace(new Regex("{info_total_pic}"), new ReplaceAndInsertImage(Server.MapPath(this.txtPath0.Text)), false);
            //本周重点敏感舆情、风险分析研判与处置建议
            using (var context = new ReportContext())
            {
                if (!string.IsNullOrEmpty(news_ids))
                {
                    var articleIds = news_ids.Split(',').Select(a => int.Parse(a));
                    var entities   = context.Articles.Where(a => a.CustomerID == customerId && articleIds.Contains(a.ID)).OrderByDescending(a => a.Rating).Select(a => a);
                    int i          = 0;
                    docBuilder.MoveToMergeField("Content");
                    foreach (var entity in entities)
                    {
                        i++;
                        if (i == 1)
                        {
                            //插入标题
                            docBuilder.Writeln();
                            docBuilder.Font.Name = "楷体_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Bold = true;
                            docBuilder.Writeln(String.Format("{0}.{1}", i, entity.Title));
                            docBuilder.Font.ClearFormatting();

                            //插入内容
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Writeln(entity.Content);
                            docBuilder.Font.ClearFormatting();


                            //插入链接
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Write("    网址链接:");
                            docBuilder.Font.ClearFormatting();

                            docBuilder.Font.Color     = Color.Blue;
                            docBuilder.Font.Size      = 10;
                            docBuilder.Font.Name      = "仿宋";
                            docBuilder.Font.Underline = Underline.Single;
                            ParagraphFormat paragraphFormat = docBuilder.ParagraphFormat;
                            paragraphFormat.Alignment = ParagraphAlignment.Center;

                            docBuilder.InsertHyperlink(entity.Url, entity.Url, false);
                            paragraphFormat.ClearFormatting();
                            docBuilder.Font.ClearFormatting();

                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Writeln();
                            docBuilder.Writeln(String.Format("    风险分析研判:{0}", entity.JudgeContent));
                            docBuilder.Write("    舆情星级:");
                            docBuilder.Font.ClearFormatting();

                            //插入舆情星级
                            docBuilder.Font.Name  = "仿宋_GB2312";
                            docBuilder.Font.Size  = 16;
                            docBuilder.Font.Color = Color.Red;
                            docBuilder.Writeln("★".Repeat(entity.Rating.Value));
                            docBuilder.Font.ClearFormatting();

                            //插入处置建议
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Write(String.Format("    处置建议:{0}", entity.SuggestContent));;
                            docBuilder.Font.ClearFormatting();
                        }
                        else
                        {
                            //插入标题
                            docBuilder.Writeln();
                            docBuilder.Font.Name = "楷体_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Bold = true;
                            docBuilder.Writeln("    " + String.Format("{0}.{1}", i, entity.Title));
                            docBuilder.Font.ClearFormatting();

                            //插入内容
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Writeln("    " + entity.Content);
                            docBuilder.Font.ClearFormatting();

                            //插入图片
                            if (!string.IsNullOrEmpty(entity.ScreenshotsPath))
                            {
                                FileInfo fileInfo = new FileInfo(Server.MapPath(entity.ScreenshotsPath));
                                if (fileInfo.Exists)
                                {
                                    docBuilder.InsertImage(Server.MapPath(entity.ScreenshotsPath), RelativeHorizontalPosition.Margin, 1, RelativeVerticalPosition.Default, 10, 430, 220, WrapType.Square);
                                }
                            }

                            //插入链接
                            docBuilder.Font.Size = 16;
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Write("    网址链接:");
                            docBuilder.Font.ClearFormatting();

                            docBuilder.Font.Color     = Color.Blue;
                            docBuilder.Font.Size      = 10;
                            docBuilder.Font.Name      = "仿宋";
                            docBuilder.Font.Underline = Underline.Single;
                            ParagraphFormat paragraphFormat = docBuilder.ParagraphFormat;
                            paragraphFormat.Alignment = ParagraphAlignment.Center;

                            docBuilder.InsertHyperlink(entity.Url, entity.Url, false);
                            paragraphFormat.ClearFormatting();
                            docBuilder.Font.ClearFormatting();

                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Writeln();
                            docBuilder.Writeln(String.Format("    风险分析研判:{0}", entity.JudgeContent));
                            docBuilder.Write("    舆情星级:");
                            docBuilder.Font.ClearFormatting();

                            //插入舆情星级
                            docBuilder.Font.Name  = "仿宋_GB2312";
                            docBuilder.Font.Size  = 16;
                            docBuilder.Font.Color = Color.Red;
                            docBuilder.Writeln("★".Repeat(entity.Rating.Value));
                            docBuilder.Font.ClearFormatting();

                            //插入处置建议
                            docBuilder.Font.Name = "仿宋_GB2312";
                            docBuilder.Font.Size = 16;
                            docBuilder.Write(String.Format("    处置建议:{0}", entity.SuggestContent));;
                            docBuilder.Font.ClearFormatting();
                        }
                    }
                }
            }

            docBuilder.MoveToMergeField("DistributeContent");
            docBuilder.Write(this.txtDistributeSummary.Text.Trim().Replace("#", ""));
            if (!string.IsNullOrEmpty(this.txtPath10.Text.Trim()))
            {
                docBuilder.InsertImage(Server.MapPath(txtPath10.Text.Trim()), RelativeHorizontalPosition.Default, 1, RelativeVerticalPosition.Default, 10, 430, 220, WrapType.Square);
            }

            document.Range.Replace(new Regex("{NextWeekWarning_Pic}"), new ReplaceAndInsertImage(Server.MapPath(this.txtPath11.Text)), false);
            document.Range.Replace("{NextWeekMinganValue}", this.ddlNextWeekMinganValue.SelectedValue, false, false);
            document.Range.Replace("{NextWeekSustainNumber}", this.txtNextWeekSustainNumber.Text, false, false);
            docBuilder.MoveToMergeField("Questions");
            int b = 0;

            docBuilder.Font.Size = 16;
            docBuilder.Font.Name = "仿宋_GB2312";
            docBuilder.Writeln();
            foreach (ListItem item in this.lstWarningList.Items)
            {
                b++;
                if (item.Value != item.Text)
                {
                    string str = String.Format("{0}.{1}", b, item.Value);
                    docBuilder.Font.Size = 16;
                    docBuilder.Font.Name = "仿宋_GB2312";
                    docBuilder.Font.Bold = true;
                    docBuilder.Writeln(str);
                    docBuilder.Font.ClearFormatting();
                    if (b == this.lstWarningList.Items.Count)
                    {
                        docBuilder.Font.Size = 16;
                        docBuilder.Font.Name = "仿宋_GB2312";
                        docBuilder.Write(item.Text.Trim());
                        docBuilder.Font.ClearFormatting();
                    }
                    else
                    {
                        docBuilder.Font.Size = 16;
                        docBuilder.Font.Name = "仿宋_GB2312";
                        docBuilder.Writeln(item.Text.Trim());
                        docBuilder.Font.ClearFormatting();
                    }
                }
                else
                {
                    if (b == this.lstWarningList.Items.Count)
                    {
                        docBuilder.Font.Size = 16;
                        docBuilder.Font.Name = "仿宋_GB2312";
                        docBuilder.Write(String.Format("{0}.{1}", b, item.Value));
                        docBuilder.Font.ClearFormatting();
                    }
                    else
                    {
                        docBuilder.Font.Size = 16;
                        docBuilder.Font.Name = "仿宋_GB2312";
                        docBuilder.Writeln(String.Format("{0}.{1}", b, item.Value));
                        docBuilder.Font.ClearFormatting();
                    }
                }
            }

            document.Range.Replace(new Regex("{week_pic}"), new ReplaceAndInsertImage(Server.MapPath(this.txtPath1.Text)), false);
            document.Range.Replace("{lowExponent}", this.txtLowExponent.Value, false, false);
            document.Range.Replace("{heightExponent}", this.txtHeightExponent.Value, false, false);
            document.Range.Replace("{avgExponent}", this.txtAvgExponent.Value, false, false);
            document.Range.Replace("{startMonth}", this.txtStartMonth.Value, false, false);
            document.Range.Replace("{startDay}", this.txtStartdDay.Value, false, false);
            document.Range.Replace("{lowNumber}", this.txtLowNumber.Value, false, false);
            document.Range.Replace("{endMonth}", this.txtEndMonth.Value, false, false);
            document.Range.Replace("{endDay}", this.txtEndDay.Value, false, false);
            document.Range.Replace("{heightNumber}", this.txtHeightNumber.Value, false, false);
            document.Range.Replace("{trend}", this.ddlTrend.Value, false, false);

            document.Range.Replace(new Regex("{attention_pic}"), new ReplaceAndInsertImage(Server.MapPath(this.txtPath2.Text), 410, 307), false);
            document.Range.Replace("{total_AttentionNumber}", this.txtTotal_AttentionNumber.Value, false, false);
            document.Range.Replace("{mobile_AttentNumber}", this.txtMobile_AttentionNumber.Value, false, false);
            document.Range.Replace("{total_FloatingType}", this.ddlTotal_FloatingType.Value, false, false);
            document.Range.Replace("{total_AttentionPercent}", this.txtTotal_AttentionPercent.Value, false, false);
            document.Range.Replace("{mobile_FloatingType}", this.ddlMobile_FloatingType.Value, false, false);
            document.Range.Replace("{mobile_AttentionPercent}", this.txtMobile_AttentionPercent.Value, false, false);
            StringBuilder cityBuilder = new StringBuilder();

            foreach (ListItem item in this.lstAttentionCities.Items)
            {
                cityBuilder.AppendFormat("{0}、", item.Value);
            }
            string cities = cityBuilder.ToString().TrimEnd('、');

            document.Range.Replace("{cities}", cities, false, false);


            string fileName = String.Format("{0}网络舆情{1}第{2}期.doc", customerItem.Text, reportItem.Text, currentNumber.ToString());

            StringBuilder questionsBuilder = new StringBuilder();

            foreach (ListItem item in this.lstWarningList.Items)
            {
                questionsBuilder.AppendFormat("{0},{1}|", item.Value, item.Text);
            }
            string questions = questionsBuilder.ToString().TrimEnd('|');

            using (var context = new ReportContext())
            {
                var report = new Report
                {
                    ReportName              = fileName,
                    CustomerID              = int.Parse(customerItem.Value),
                    Company                 = customerItem.Text,
                    ReportType              = reportType,
                    Year                    = DateTime.Now.ToString("yyyy"),
                    Month                   = DateTime.Now.ToString("MM"),
                    Day                     = DateTime.Now.ToString("dd"),
                    CurrentNumber           = currentNumber.ToString(),
                    TotalNumber             = totalNumber.ToString(),
                    StrText                 = strText,
                    News_number             = totalNewsQuanity,
                    Hudong_number           = totalHudongCount,
                    Mingan_number           = totalMinganCount,
                    Info_total_pic          = this.txtPath0.Text,
                    PriorityArticles        = this.hideSelectedIDs.Value,
                    DistributeSummary       = this.txtDistributeSummary.Text.Replace("#", ""),
                    Distribute_Pic          = this.txtPath10.Text,
                    NextWeekWarning_Pic     = this.txtPath11.Text,
                    NextWeekMinganValue     = this.ddlNextWeekMinganValue.SelectedValue,
                    NextWeekSustainNumber   = int.Parse(this.txtNextWeekSustainNumber.Text),
                    AttentionQuestions      = questions,
                    Week_Pic                = this.txtPath1.Text,
                    LowExponent             = int.Parse(this.txtLowExponent.Value),
                    HeightExponent          = int.Parse(this.txtHeightExponent.Value),
                    AvgExponent             = int.Parse(this.txtAvgExponent.Value),
                    StartMonth              = int.Parse(this.txtStartMonth.Value),
                    StartDay                = int.Parse(this.txtStartdDay.Value),
                    LowNumber               = int.Parse(this.txtLowNumber.Value),
                    EndMonth                = int.Parse(this.txtEndMonth.Value),
                    EndDay                  = int.Parse(this.txtEndDay.Value),
                    HeightNumber            = int.Parse(this.txtHeightNumber.Value),
                    Tend                    = this.ddlTrend.Value,
                    Attention_Picture       = this.txtPath2.Text,
                    Total_AttentionNumber   = int.Parse(this.txtTotal_AttentionNumber.Value),
                    Mobile_AttentNumber     = int.Parse(this.txtMobile_AttentionNumber.Value),
                    Total_FloatingType      = this.ddlTotal_FloatingType.Value,
                    Mobile_FloatingType     = this.ddlMobile_FloatingType.Value,
                    Total_AttentionPercent  = this.txtTotal_AttentionPercent.Value,
                    Mobile_AttentionPercent = this.txtMobile_AttentionPercent.Value,
                    AttentionCities         = cities,
                    AddDate                 = DateTime.Now,
                    Area                    = area,
                    Subsidiary              = Subsidiary
                };
                context.Reports.Add(report);
                int reportTypeId = int.Parse(reportType);
                var entity       = context.ReportNumbers.FirstOrDefault(a => a.CustomerID == customerId && a.ReportTypeId == reportTypeId);
                if (entity != null)
                {
                    entity.CurrentNumber++;
                    entity.TotalNumber++;
                    context.SaveChanges();
                }
                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            using (MemoryStream ms = new MemoryStream())
            {
                document.Save(ms, SaveOptions.CreateSaveOptions(SaveFormat.Doc));
                Response.ContentType = "application/msword";
                Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                Response.BinaryWrite(ms.ToArray());
                Response.End();
            }
        }
Пример #26
0
 public SplineService(ChartContext context) : base(context)
 {
 }
Пример #27
0
 public BaseService(ChartContext context)
 {
     Context = context;
 }
Пример #28
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DataTable table = (DataTable)ViewState["CloneTable"];

            if (table == null)
            {
                MessageBox.Show(this, "数据表不存在!");
                return;
            }
            if (table.Rows.Count < 3)
            {
                MessageBox.Show(this, "不能低于3条数据!");
                return;
            }
            string customerId = this.ddlCustomer.SelectedValue;
            string chartTitle = this.txtChartTitle.Text.Trim().Replace("#", "");

            try
            {
                var               missing     = Type.Missing;
                string            fileName    = Server.MapPath("~/template_files/template_workbook.xlsx");
                Excel.Application application = new Excel.Application();
                application.Visible       = false;
                application.DisplayAlerts = false;
                Excel.Workbook workbook = application.Workbooks.Open(fileName);

                string           SheetName = "sheet1";
                Excel._Worksheet worksheet = workbook.Sheets[SheetName];
                worksheet.Activate();

                //写入Excel列头
                int i            = 0;
                int columnsCount = table.Columns.Count;
                for (int j = 0; j < columnsCount; j++)
                {
                    if (j > 1)
                    {
                        i++;
                        var         letter = CommonUtility.GetLetters()[i];
                        Excel.Range range  = worksheet.get_Range(letter + "1");
                        range.Value2 = table.Columns[j].ColumnName;
                    }
                }
                //写入Excel数据
                int a = 1;
                foreach (DataRow row in table.Rows)
                {
                    a++;
                    for (int b = 1; b < columnsCount; b++)
                    {
                        Excel.Range range = worksheet.get_Range(CommonUtility.GetLetters()[b - 1] + a);
                        range.Value2 = row[b].ToString();
                    }
                }


                Excel.Shape shape1 = worksheet.Shapes.AddChart(Excel.XlChartType.xlLine, missing, missing, missing, missing);

                Excel.Range sourceRange = worksheet.get_Range("A1", CommonUtility.GetLetters()[columnsCount - 2] + a);

                //设置数据源
                shape1.Chart.SetSourceData(sourceRange, missing);

                //设置标题
                shape1.Chart.HasTitle        = true;
                shape1.Chart.ChartTitle.Text = chartTitle;
                shape1.Chart.ChartTitle.Format.TextFrame2.TextRange.Font.Size = 16;

                Excel.Series se = shape1.Chart.SeriesCollection(1);
                se.Format.Line.Visible      = MsoTriState.msoTrue;
                se.Format.Line.Transparency = 0.0f;
                se.Format.Line.Weight       = 2.25f;

                se = shape1.Chart.SeriesCollection(2);
                se.Format.Line.ForeColor.RGB = Color.FromArgb(0, 0, 192).ToArgb();
                se.Format.Line.Visible       = MsoTriState.msoTrue;
                se.Format.Line.Transparency  = 0.0f;
                se.Format.Line.Weight        = 2.25f;

                shape1.Left               = (float)worksheet.get_Range("G1").Left;
                shape1.Top                = (float)worksheet.get_Range("G8").Top;
                shape1.Fill.Visible       = MsoTriState.msoTrue;
                shape1.Fill.ForeColor.RGB = Color.FromArgb(225, 236, 238).ToArgb();
                shape1.Fill.Transparency  = 0;
                shape1.Fill.Solid();
                shape1.Chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom;
                shape1.Chart.PlotArea.Format.Fill.Visible       = MsoTriState.msoTrue;
                shape1.Chart.PlotArea.Format.Fill.ForeColor.RGB = Color.FromArgb(218, 234, 253).ToArgb();
                shape1.Chart.PlotArea.Format.Fill.Transparency  = 0;
                shape1.Chart.PlotArea.Format.Fill.Solid();

                DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("~/Download/" + this.ddlCustomer.SelectedItem.Text));
                if (!directoryInfo.Exists)
                {
                    directoryInfo.Create();
                }
                String ymd = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                string saveExcelFileName = String.Format("{0}_{1}.xlsx", chartTitle, ymd);
                string saveExcelFilePath = Path.Combine(directoryInfo.FullName, saveExcelFileName);
                string savePngFileName   = String.Format("{0}_{1}.png", chartTitle, ymd);
                string savePngFilePath   = Path.Combine(directoryInfo.FullName, savePngFileName);
                string excelFileName     = "/Download/" + this.ddlCustomer.SelectedItem.Text + "/" + saveExcelFileName;
                string pngFileName       = "/Download/" + this.ddlCustomer.SelectedItem.Text + "/" + savePngFileName;
                worksheet.SaveAs(saveExcelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                shape1.Chart.Export(savePngFilePath, missing, missing);

                application.Quit();
                worksheet   = null;
                workbook    = null;
                application = null;
                GC.GetTotalMemory(false);
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.GetTotalMemory(true);
                using (var context = new ChartContext())
                {
                    var entity = new Gather
                    {
                        CustomerID    = int.Parse(customerId),
                        TimeRange     = "",
                        ChartTitle    = chartTitle,
                        ExcelFilePath = excelFileName,
                        PngFilePath   = pngFileName,
                        AddDate       = DateTime.Now,
                        Flag          = "trendCompare"
                    };
                    StringBuilder sBuilder = new StringBuilder();
                    foreach (ListItem item in this.lstCategories.Items)
                    {
                        sBuilder.AppendFormat("{0},", item.Value);
                    }
                    string legendString = sBuilder.ToString().TrimEnd(',');
                    Legend legend       = new Legend()
                    {
                        LegendName = legendString
                    };
                    entity.Legends.Add(legend);

                    StringBuilder legendDataBuilder = new StringBuilder();
                    foreach (DataRow row in table.Rows)
                    {
                        for (int c = 0; c < table.Columns.Count; c++)
                        {
                            if (c > 0)
                            {
                                if (c == 1)
                                {
                                    legendDataBuilder.AppendFormat("{0}+", row[c].ToString());
                                }
                                else
                                {
                                    legendDataBuilder.AppendFormat("{0},", row[c].ToString());
                                }
                            }
                        }
                        legendDataBuilder.Append("|");
                    }
                    string strValue = legendDataBuilder.ToString().TrimEnd('|');
                    foreach (string str in strValue.Split('|'))
                    {
                        LegendData legendData = new LegendData()
                        {
                            DateString  = str.TrimEnd(',').Split('+')[0],
                            LegendValue = str.TrimEnd(',').Split('+')[1]
                        };
                        legend.LegendDatas.Add(legendData);
                    }
                    context.Gathers.Add(entity);
                    context.SaveChanges();
                }

                using (FileStream fileStream = new FileStream(saveExcelFilePath, FileMode.Open))
                {
                    byte[] bytes = fileStream.ToByteArray();
                    Response.Clear();
                    Response.AddHeader("Content-Length", fileStream.Length.ToString());
                    Response.ContentType = "application/ms-excel";
                    Response.AddHeader("Content-Disposition", "inline;FileName=" + saveExcelFileName);
                    fileStream.Close();
                    fileStream.Dispose();
                    Response.BinaryWrite(bytes);
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is AreaSeriesViewBase view)
            {
                view.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

                var borderColor = Utils.ColorFromString(BorderColor);
                if (borderColor != System.Drawing.Color.Empty)
                {
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                    view.Border.Color      = borderColor;
                }
                if (BorderThickness.HasValue)
                {
                    view.Border.Thickness  = BorderThickness.Value;
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                }

                if (FillMode.HasValue)
                {
                    view.FillStyle.FillMode = FillMode.Value;
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                        {
                            var color2 = Utils.ColorFromString(Color2);
                            if (color2 != System.Drawing.Color.Empty)
                            {
                                gradientOptions.Color2 = color2;
                            }
                            if (FillGradientMode.HasValue)
                            {
                                gradientOptions.GradientMode = FillGradientMode.Value;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.FillStyle.Options is HatchFillOptions hatchOptions)
                        {
                            var color2 = Utils.ColorFromString(Color2);
                            if (color2 != System.Drawing.Color.Empty)
                            {
                                hatchOptions.Color2 = color2;
                            }
                            if (FillHatchStyle.HasValue)
                            {
                                hatchOptions.HatchStyle = FillHatchStyle.Value;
                            }
                        }
                        break;
                    }
                }

                if (Transparency.HasValue)
                {
                    view.Transparency = Transparency.Value;
                }


                if (MarkerKind.HasValue)
                {
                    view.MarkerOptions.Kind = MarkerKind.Value;
                }
                var markerColor = Utils.ColorFromString(MarkerColor);
                if (markerColor != System.Drawing.Color.Empty)
                {
                    view.MarkerOptions.Color = markerColor;
                }
                if (MarkerSize.HasValue)
                {
                    view.MarkerOptions.Size = MarkerSize.Value;
                }
                if (MarkerStarPointCount.HasValue)
                {
                    view.MarkerOptions.StarPointCount = MarkerStarPointCount.Value;
                }
                var markerBorderColor = Utils.ColorFromString(MarkerBorderColor);
                if (markerBorderColor != System.Drawing.Color.Empty)
                {
                    view.MarkerOptions.BorderColor = markerBorderColor;
                }
                if (HideMarkerBorder)
                {
                    view.MarkerOptions.BorderVisible = false;
                }

                if (MarkerFillMode.HasValue)
                {
                    switch (MarkerFillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.MarkerOptions.FillStyle.Options is PolygonGradientFillOptions gradientFillOptions)
                        {
                            if (MarkerGradientMode.HasValue)
                            {
                                gradientFillOptions.GradientMode = MarkerGradientMode.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                gradientFillOptions.Color2 = backColor2;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.MarkerOptions.FillStyle.Options is HatchFillOptions hatchFillOptions)
                        {
                            if (MarkerHatchStyle.HasValue)
                            {
                                hatchFillOptions.HatchStyle = MarkerHatchStyle.Value;
                            }
                            var backColor2 = Utils.ColorFromString(MarkerBackColor2);
                            if (backColor2 != System.Drawing.Color.Empty)
                            {
                                hatchFillOptions.Color2 = backColor2;
                            }
                        }
                        break;
                    }
                }

                if (MarkerVisibility.HasValue)
                {
                    view.MarkerVisibility = MarkerVisibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                }
            }
        }
Пример #30
0
 public UserLoginRepository(ChartContext context) :
     base(context)
 {
 }
Пример #31
0
        public override void SetupXtraChartSeries(ChartContext chartContext, Series series)
        {
            base.SetupXtraChartSeries(chartContext, series);

            if (series.View is BarSeriesView view)
            {
                var borderColor = Utils.ColorFromString(BorderColor);
                if (borderColor != System.Drawing.Color.Empty)
                {
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                    view.Border.Color      = borderColor;
                }
                if (BorderThickness > 0)
                {
                    view.Border.Thickness  = BorderThickness;
                    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
                }

                if (FillMode.HasValue)
                {
                    view.FillStyle.FillMode = FillMode.Value;
                    switch (FillMode.Value)
                    {
                    case DevExpress.XtraCharts.FillMode.Empty:
                        break;

                    case DevExpress.XtraCharts.FillMode.Solid:
                        break;

                    case DevExpress.XtraCharts.FillMode.Gradient:
                        if (view.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                        {
                            var color2 = Utils.ColorFromString(Color2);
                            if (color2 != System.Drawing.Color.Empty)
                            {
                                gradientOptions.Color2 = color2;
                            }
                            if (FillGradientMode.HasValue)
                            {
                                gradientOptions.GradientMode = FillGradientMode.Value;
                            }
                        }
                        break;

                    case DevExpress.XtraCharts.FillMode.Hatch:
                        if (view.FillStyle.Options is HatchFillOptions hatchOptions)
                        {
                            var color2 = Utils.ColorFromString(Color2);
                            if (color2 != System.Drawing.Color.Empty)
                            {
                                hatchOptions.Color2 = color2;
                            }
                            if (FillHatchStyle.HasValue)
                            {
                                hatchOptions.HatchStyle = FillHatchStyle.Value;
                            }
                        }
                        break;
                    }
                }

                if (Transparency.HasValue)
                {
                    view.Transparency = Transparency.Value;
                }
            }
        }