Exemple #1
0
        public ChartExportDTO ExportChartToJpg(ChartTableDTO zippedData, object syncLock)
        {
            Utils.CheckNotNull(zippedData, "zippedData");
            if (m_ChartDetail == null)
            {
                throw new AvrException("Chart already disposed.");
            }

            BaseTableDTO unzippedData = BinaryCompressor.Unzip(zippedData);
            DataTable    data         = BinarySerializer.DeserializeToTable(unzippedData);

            if (zippedData.TextPatterns != null)
            {
                foreach (string col in zippedData.TextPatterns.Keys)
                {
                    data.Columns[col].ExtendedProperties.Add("TextPattern", zippedData.TextPatterns[col]);
                }
            }

            ChartExportDTO result;

            lock (syncLock)
            {
                m_ChartDetail.DataSource = data;
                object id = zippedData.ViewId;

                m_ChartDetail.LoadData(ref id);

                m_ChartDetail.ChartControlSize = new Size(zippedData.Width, zippedData.Height);
                result = m_ChartDetail.ExportToJpgBytes(zippedData.ChartSettings, zippedData.ChartType);
            }
            return(result);
        }
Exemple #2
0
        public ChartExportDTO ExportChartToJpg(ChartTableDTO zippedData)
        {
            using (var bitmap = new Bitmap(zippedData.Width, zippedData.Height))
            {
                using (var stream = new MemoryStream())
                {
                    bitmap.Save(stream, ImageFormat.Jpeg);
                    stream.Flush();
                    stream.Seek(0, SeekOrigin.Begin);

                    var buffer = new byte[stream.Length];
                    int readed = stream.Read(buffer, 0, (int)stream.Length);
                    Debug.Assert(stream.Length == readed, "not all bytes readed");

                    return(new ChartExportDTO(buffer, new byte[0]));
                }
            }
        }
Exemple #3
0
        public ChartExportDTO ExportChartToJpg(ChartTableDTO zippedData)
        {
            try
            {
                string    layoutName = AvrDbHelper.GetLayoutNameForLog(zippedData.ViewId);
                Stopwatch watch      = TraceMethodCall(layoutName, zippedData);
                EidssAvrServiceInitializer.CheckAndInitEidssCore();

                ChartExportDTO result;
                using (new CultureInfoTransaction(new CultureInfo(CustomCultureHelper.SupportedLanguages[zippedData.Lang])))
                {
                    VirtualChart virtualChart = null;
                    try
                    {
                        lock (m_ChartSyncLock)
                        {
                            virtualChart = new VirtualChart(m_Container);
                        }
                        result = virtualChart.ExportChartToJpg(zippedData, m_ChartSyncLock);
                    }
                    finally
                    {
                        if (virtualChart != null)
                        {
                            lock (m_ChartSyncLock)
                            {
                                virtualChart.Dispose();
                            }
                        }
                    }
                }
                TraceMethodCallFinished(watch, layoutName, zippedData);
                return(result);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, zippedData);
                string format = EidssMessages.Get("msgCouldNotExportChart",
                                                  "Could not get Export chart from View. ViewID={0}, Lang={1}");
                string msg = String.Format(format, zippedData.ViewId, zippedData.Lang);
                throw new AvrDataException(msg, ex);
            }
        }