Exemplo n.º 1
0
        public static string TryToPrepareMapData(AvrPivotViewModel viewModel, out DataSet data)
        {
            string columnName = viewModel.ViewHeader.MapAdminUnitViewColumn;

            if (viewModel.ViewData.Columns.Contains(columnName + "hasc"))
            {
                columnName = columnName + "hasc";
            }

            // remember columns for future DataTable
            List <AvrViewColumn> mapColumns = FillSeriesColumns(viewModel.ViewHeader, viewModel.ViewHeader.GetColumnsBooleans("IsMapDiagramSeries"), viewModel.ViewHeader.GradientColumn);

            // remember rows for future DataTable
            Dictionary <int, DataRow> xAxisRows = FillXAxisData(viewModel.ViewData, columnName, viewModel.ViewHeader);

            //remove * strings
            xAxisRows.ToList().FindAll(d => ((string)d.Value[columnName]).Equals("*")).ForEach(d => xAxisRows.Remove(d.Key));

            // have we duplicates? - remove everything
            var l = new List <DataRow>(xAxisRows.Values);

            if (AvrViewHelper.hasDuplicates(l.ConvertAll(v => v[columnName])))
            {
                data = new DataSet();
                return(EidssMessages.Get("msgDuplicatesInAdmUnit"));
            }

            // fill DataSet with 2 DataTable !!!
            data = CreateDataForMap(columnName, mapColumns, xAxisRows, viewModel.ViewHeader);
            return(String.Empty);
        }
Exemplo n.º 2
0
        public PivotGridDataLoadedCommand(object sender, AvrPivotViewModel model)
            : base(sender)
        {
            Utils.CheckNotNull(model, "model");

            m_Model = model;
        }
Exemplo n.º 3
0
        private long GetModelFromSession(out AvrPivotViewModel model, out string error)
        {
            long LayoutId = GetLayoutId();

            model = GetModelFromSession(LayoutId, out error);

            return(LayoutId);
        }
Exemplo n.º 4
0
        public void PivotGridDataLoadedCommandTest()
        {
            Console.WriteLine(@"PivotGridDataLoadedCommandTest");

            var avrView = new AvrView(-1, "", -1);
            var cmd     = new AvrPivotViewModel(avrView, new DataTable());

            Assert.AreEqual(avrView, cmd.ViewHeader);
        }
Exemplo n.º 5
0
 public static AvrPivotViewModel CreateAvrPivotViewModel(long layoutId, string lang, IContainer container)
 {
     using (new CultureInfoTransaction(new CultureInfo(CustomCultureHelper.SupportedLanguages[lang])))
     {
         using (var virtualPivot = new VirtualPivot(container))
         {
             AvrPivotViewModel model = virtualPivot.CreateAvrPivotViewModelInternal(layoutId, lang);
             return(model);
         }
     }
 }
Exemplo n.º 6
0
        private AvrPivotViewModel AdjustToNew(long layoutId, AvrView view, AvrPivotViewModel model)
        {
            view.SetOrders();
            view.AdjustToNew(model.ViewHeader);
            view.SetColumnsTypes(model.ViewData);

            view.GetAggregateColumnsList().ForEach(c => AggregateCasheWeb.FillAggregateColumn(model.ViewData, c, view.GetSortExpression()));

            var modelView = new AvrPivotViewModel(view, model.ViewData);

            ObjectStorage.Put(Session.SessionID, layoutId, layoutId, StoragePrefix, modelView);
            return(modelView);
        }
Exemplo n.º 7
0
        private DataTable GetChartDataFromSession(long layoutId, AvrPivotViewModel viewModel)
        {
            //var data = ModelStorage.Get(Session.SessionID, layoutId, storagePrefixData, false) as DataTable;
            return(ObjectStorage.Using <DataTable, DataTable>(data =>
            {
                if (data == null)
                {
                    data = ChartMapHelper.TryToPrepareChartData(viewModel);
                    ObjectStorage.Put(Session.SessionID, 0, layoutId, storagePrefixData, data);
                }

                return data;
            }, Session.SessionID, layoutId, storagePrefixData, false));
        }
Exemplo n.º 8
0
        public ActionResult GetShowImage(long layoutId, AvrPivotViewModel viewModel, int width, int height)
        {
            // have we anything selected in combo Xaxis?
            if (!string.IsNullOrEmpty(viewModel.ViewHeader.ChartXAxisViewColumn))
            {
                string img = GetChartStringFromService(layoutId, viewModel, width, height);
                if (img == "")
                {
                    return(View("AvrServiceError", (object)m_ErrorMessage));
                }

                return(View("Index", new ChartMapHelper.ChartModel(viewModel.ViewHeader.LayoutID, viewModel.ViewHeader.ChartType, img)));
            }
            return(View("Index", ChartMapHelper.GetEmptyChartData(viewModel)));
        }
Exemplo n.º 9
0
/*        public static ChartModel TryToPrepareChartData(AvrPivotViewModel viewModel)
 *      {
 *          string columnName = viewModel.ViewHeader.ChartXAxisViewColumn;
 *          string chb = viewModel.ViewHeader.GetColumnsBooleans("IsChartSeries");
 *          // remember columns for future DataTable
 *          List<AvrViewColumn> chartColumns = FillSeriesColumns(viewModel.ViewHeader, chb, null);
 *
 *          // remember rows for future DataTable
 *          Dictionary<int, DataRow> xAxisRows = FillXAxisData(viewModel.ViewData, columnName, viewModel.ViewHeader.GrandTotalSuffix, viewModel.ViewHeader.TotalSuffix);
 *
 *          // fill DataSet with 2 DataTable !!!
 *          DataTable data = CreateDataForChart(columnName, chartColumns, xAxisRows, viewModel.ViewHeader);
 *
 *          return new ChartModel(viewModel.ViewHeader.LayoutID, viewModel.ViewHeader.ChartType, viewModel.ViewHeader.LayoutName, data.Columns[0].Caption, data);
 *      }*/

        public static DataTable TryToPrepareChartData(AvrPivotViewModel viewModel)
        {
            string columnName = viewModel.ViewHeader.ChartXAxisViewColumn;
            string chb        = viewModel.ViewHeader.GetColumnsBooleans("IsChartSeries");
            // remember columns for future DataTable
            List <AvrViewColumn> chartColumns = FillSeriesColumns(viewModel.ViewHeader, chb, null);

            // remember rows for future DataTable
            //viewModel.ViewHeader.GetAllColumns();
            //DataTable dt = viewModel.ViewData.Select();
            Dictionary <int, DataRow> xAxisRows = FillXAxisData(viewModel.ViewData, columnName, viewModel.ViewHeader);

            // fill DataSet with 2 DataTable !!!
            return(CreateDataForChart(columnName, chartColumns, xAxisRows, viewModel.ViewHeader));
        }
Exemplo n.º 10
0
        public void VirtualPivotGetModelTest()
        {
            DataView layoutLookup = LookupCache.Get(LookupTables.Layout);

            if (layoutLookup.Count > 0)
            {
                var layoutId = (long)layoutLookup.Table.Rows[0]["idflLayout"];

                for (int i = 0; i < 3; i++)
                {
                    using (new StopwathTransaction("++ VirtualPivot with View++ " + i))
                    {
                        AvrPivotViewModel model = VirtualPivot.CreateAvrPivotViewModel(layoutId, "en", StructureMapContainerInit());

                        Assert.IsNotNull(model);
                    }
                }
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        private string GetChartStringFromService(long layoutId, AvrPivotViewModel viewModel, int width, int height)
        {
            var ret = GetChartBytesFromService(layoutId, viewModel, width, height);

            if (ret == null)
            {
                return("");
            }

            string base64String;

            try
            {
                base64String = System.Convert.ToBase64String(ret, 0, ret.Length);
                return(base64String);
            }
            catch (System.ArgumentNullException)
            {
                m_ErrorMessage = "Binary data array is null.";
                return("");
            }
        }
Exemplo n.º 13
0
        public ViewDTO GetCachedView(string sessionId, long layoutId, string lang)
        {
            try
            {
                m_ViewSemaphore.Wait();

                var       layout = AvrDbHelper.GetLayoutDTO(layoutId);
                Stopwatch watch  = TraceMethodCall(sessionId, layoutId, layout.DefaultLayoutName, lang);
                EidssAvrServiceInitializer.CheckAndInitEidssCore();

                ViewDTO view         = null;
                var     cacheKey     = new QueryCacheKey(layout.QueryId, lang, layout.UseArchivedData);
                long?   queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
                if (queryCacheId.HasValue)
                {
                    var viewCacheId = AvrDbHelper.GetViewCacheId(queryCacheId.Value, layoutId, RefreshedCacheOnUserCallAfterDays);
                    if (viewCacheId.HasValue)
                    {
                        view = AvrDbHelper.GetViewCache(viewCacheId.Value, false);
                    }
                }

                if (view == null)
                {
                    AvrPivotViewModel model = VirtualPivot.CreateAvrPivotViewModel(layoutId, lang, m_Container);

                    string xmlViewHeader    = AvrViewSerializer.Serialize(model.ViewHeader);
                    byte[] zippedViewHeader = BinaryCompressor.ZipString(xmlViewHeader);

                    BaseTableDTO serializedDTO = BinarySerializer.SerializeFromTable(model.ViewData);
                    BaseTableDTO zippedDTO     = BinaryCompressor.Zip(serializedDTO);

                    view = new ViewDTO(zippedDTO, zippedViewHeader);

                    queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
                    if (queryCacheId.HasValue)
                    {
                        AvrDbHelper.SaveViewCache(queryCacheId.Value, layoutId, view);
                    }
                }
                TraceMethodCallFinished(watch, sessionId, layoutId, layout.DefaultLayoutName, lang);
                return(view);
            }
            catch (OutOfMemoryException ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang);
                throw new AvrDataException(EidssMessages.Get("ErrAVROutOfMemory"), ex);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang);
                string format = EidssMessages.Get("msgCouldNotGetViewData",
                                                  "Could not get View Data from Layout. LayoutID={0}, Lang={1}, SessionId={2}");
                string msg = String.Format(format, layoutId, lang, sessionId);
                throw new AvrDataException(msg, ex);
            }
            finally
            {
                m_ViewSemaphore.Release();
            }
        }
Exemplo n.º 14
0
 public static ChartModel GetEmptyChartData(AvrPivotViewModel viewModel)
 {
     return(new ChartModel(viewModel.ViewHeader.LayoutID, viewModel.ViewHeader.ChartType, ""));
 }