Ejemplo n.º 1
0
        public void AvrServiceViewChartTest()
        {
            using (var wrapper = new AvrServiceClientWrapper(m_HostKeeper.CurrentServiceHostURL))
            {
                var receiver = new AvrCacheReceiver(wrapper);
                AvrPivotViewModel view;
                long layoutId = LayoutFormSave();
                using (new StopwathTransaction("++++ GetView ++++"))
                {
                    view = receiver.GetCachedView("xxx", layoutId, "ru");
                }
                Assert.IsNotNull(view);
                Assert.IsNotNull(view.ViewData);
                Assert.IsNotNull(view.ViewHeader);

                ChartExportDTO chartBytes;
                using (new StopwathTransaction("++++ GetChart ++++"))
                {
                    var tableModel = new ChartTableModel(layoutId, "ru", ExportChartToJpgTests.CreateChartData(), null, DBChartType.chrBar,
                                                         null,
                                                         1000, 750);

                    chartBytes = receiver.ExportChartToJpg(tableModel);
                }
                Assert.IsNotNull(chartBytes);
                Assert.IsNotNull(chartBytes.JpgBytes);
                Assert.IsTrue(chartBytes.JpgBytes.Length > 0);
                ExportTests.AssertJpeg(chartBytes.JpgBytes);
                //File.WriteAllBytes("filexx.jpg", chartBytes);
            }
        }
Ejemplo n.º 2
0
        public void AvrServiceHelperGetAvrServiceChartResultTest()
        {
            var tableModel = new ChartTableModel(-1, ModelUserContext.CurrentLanguage,
                                                 ExportChartToJpgTests.CreateChartData(), null, null, null, 1000, 750);
            AvrServiceChartResult result = ServiceClientHelper.GetAvrServiceChartResult(tableModel);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsOk, result.ErrorMessage);
            Assert.IsNotNull(result.Model);
            Assert.IsNotNull(result.Model.JpgBytes);

            Assert.IsTrue(result.Model.JpgBytes.Length > 0);
            ExportTests.AssertJpeg(result.Model.JpgBytes);
            //File.WriteAllBytes("filexxx.jpg", result.Model);
        }
Ejemplo n.º 3
0
        private byte[] GetChartBytesFromService(long layoutId, AvrPivotViewModel viewModel, int width, int height)
        {
            m_ErrorMessage = "";

            DBChartType?chtp = null;

            if (viewModel.ViewHeader.ChartType != null && viewModel.ViewHeader.ChartType != "")
            {
                chtp = (DBChartType)Enum.Parse(typeof(DBChartType), viewModel.ViewHeader.ChartType);
            }

            var toTable      = GetChartDataFromSession(layoutId, viewModel);
            var textPatterns = new Dictionary <string, object>();

            foreach (DataColumn col in toTable.Columns)
            {
                if (col.ExtendedProperties.ContainsKey("TextPattern"))
                {
                    textPatterns.Add(col.ColumnName, col.ExtendedProperties["TextPattern"]);
                }
            }

            var tbl = new ChartTableModel(viewModel.ViewHeader.ViewID,
                                          EidssUserContext.CurrentLanguage,
                                          toTable,
                                          viewModel.ViewHeader.ChartLocalSettingsZip,
                                          chtp,
                                          textPatterns,
                                          width, height);


            AvrServiceChartResult result = ServiceClientHelper.GetAvrServiceChartResult(tbl);

            if (!result.IsOk)
            {
                m_ErrorMessage = result.ErrorMessage;
                return(null);
            }

            ObjectStorage.Put(Session.SessionID, 0, layoutId, storagePrefix, result.Model.JpgBytes);
            return(result.Model.JpgBytes);
        }