Esempio n. 1
0
        private ActionResult RefreshPivotDataWith(Action <AvrPivotGridModel> action)
        {
            AvrPivotGridModel model = GetModelFromSession();

            if (model == null)
            {
                return(View("AvrServiceError", (object)m_ErrorMessage));
            }
            if (action != null)
            {
                action(model);
            }

            bool   isNewObject;
            string errorMessage;

            model.PivotData = LayoutPivotGridHelper.GetPivotData(model.PivotSettings, out isNewObject, out errorMessage);
            if (!string.IsNullOrEmpty(errorMessage))
            {
                m_ErrorMessage = errorMessage;
                return(View("AvrServiceError", (object)m_ErrorMessage));
            }

            LayoutPivotGridHelper.AddMissedValues(model, false);
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = "ok"
            });
        }
Esempio n. 2
0
        public static AvrPivotGridModel FillData(ref long queryId, long layoutId)
        {
            var service        = new WebLayoutDB();
            var sessionDataSet = (LayoutDetailDataSet)service.GetDetail(layoutId);

            if (queryId <= 0)
            {
                queryId = ((LayoutDetailDataSet.LayoutRow)sessionDataSet.Layout.Rows[0]).idflQuery;
            }
            var helper = new LayoutHelper(sessionDataSet);

            var settings = new AvrPivotSettings(queryId, layoutId);

            helper.InitAvrPivotSettings(settings);
            bool isNewObject;

            string       errorMessage;
            AvrDataTable data = LayoutPivotGridHelper.GetPivotData(
                helper.LayoutDataSet,
                queryId,
                layoutId,
                settings.UseArchiveData,
                settings.ApplyFilter ? settings.FilterCriteriaString :string.Empty,
                out isNewObject, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                throw new AvrException(errorMessage);
            }

            settings.Fields = AvrPivotGridHelper.CreateFields <WebPivotGridField>(data);
            helper.PrepareWebFields(settings);
            List <IAvrPivotGridField> fields = settings.Fields.Cast <IAvrPivotGridField>().ToList();
            LayoutValidateResult      result = helper.LoadPivotFromDB(new AvrPivotGridData(data), fields, isNewObject);
            var model = new AvrPivotGridModel(settings, data);

            if (result.IsCancelOrUserDialogCancel())
            {
                model.HideDataForComplexLayout();
            }
            return(model);
        }