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 ActionResult ShowMissedValues(bool value)
        {
            AvrPivotGridModel model = GetModelFromSession();

            if (model == null)
            {
                return(View("AvrServiceError", (object)m_ErrorMessage));
            }
            model.PivotSettings.HasChanges            = true;
            model.PivotSettings.ShowMissedValues      = value;
            model.PivotSettings.ShowMissedValuesSaved = model.PivotSettings.ShowMissedValues;
            model.PivotSettings.ShowDataInPivot       = true;
            LayoutPivotGridHelper.AddMissedValues(model, true);
            //return RedirectToAction("Layout", new { queryId = model.PivotSettings.QueryId, model.PivotSettings.LayoutId });
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = "ok"
            });
            //return Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri);
        }
Esempio n. 3
0
        public ActionResult OnSaveFieldChanges
            (string caption, string captionEn, string aggregateFunctionId, string precision, string basicCountFunctionId, string adminUnitField, string dateField,
            string groupInterval, string addMissedValue, string startDate, string endDate)
        {
            AvrPivotGridModel model = GetModelFromSession();

            if (model == null)
            {
                return(new JsonResult
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = new { result = "error", error = m_ErrorMessage }
                });
            }
            if (model.PivotSettings.SelectedField != null)
            {
                WebPivotGridFieldClone clonedField =
                    model.PivotSettings.SelectedField.GetClonedField(model.PivotSettings.LayoutDataset, false);
                if (ModelUserContext.CurrentLanguage != Localizer.lngEn)
                {
                    clonedField.Caption = caption;
                }
                clonedField.CaptionEn               = captionEn;
                clonedField.AggregateFunctionId     = bv.common.Core.Utils.ToLong(aggregateFunctionId);
                clonedField.BasicCountFunctionId    = bv.common.Core.Utils.ToLong(basicCountFunctionId);
                clonedField.Precision               = bv.common.Core.Utils.ToNullableInt(precision);
                clonedField.UnitLayoutSearchFieldId = bv.common.Core.Utils.ToNullableLong(adminUnitField);
                clonedField.DateLayoutSearchFieldId = bv.common.Core.Utils.ToNullableLong(dateField);
                bool updateMissedValues = (!clonedField.AddMissedValues.Equals(bool.Parse(addMissedValue)) ||
                                           !clonedField.DiapasonStartDate.Equals(bv.common.Core.Utils.ToDateNullable(startDate)) ||
                                           !clonedField.DiapasonEndDate.Equals(bv.common.Core.Utils.ToDateNullable(endDate)) ||
                                           !clonedField.PrivateGroupInterval.Equals(bv.common.Core.Utils.ToNullableLong(groupInterval)));
                clonedField.PrivateGroupInterval = bv.common.Core.Utils.ToNullableLong(groupInterval);
                bool fillEmptyValues =
                    LayoutPivotGridHelper.IsFieldGroupIntervalChanged(model.PivotSettings.SelectedField,
                                                                      clonedField.PrivateGroupInterval.HasValue ? (PivotGroupInterval)clonedField.PrivateGroupInterval : model.PivotSettings.SelectedField.GroupInterval);
                clonedField.AddMissedValues   = bool.Parse(addMissedValue);
                clonedField.DiapasonStartDate = bv.common.Core.Utils.ToDateNullable(startDate);
                clonedField.DiapasonEndDate   = bv.common.Core.Utils.ToDateNullable(endDate);
                string error = ValidateFieldClone(clonedField, model.PivotSettings.SelectedField.IsDateTimeField);
                if (!string.IsNullOrEmpty(error))
                {
                    return(new JsonResult
                    {
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                        Data = new { result = "error", error = error }
                    });
                }
                bool aggregateChanged =
                    !model.PivotSettings.SelectedField.AggregateFunctionId.Equals(clonedField.AggregateFunctionId);
                model.PivotSettings.SelectedField.FlashChanges(model.PivotSettings.LayoutDataset);
                if (aggregateChanged)
                {
                    WebPivotGridField field           = model.PivotSettings.SelectedField;
                    CustomSummaryType summaryTypeType =
                        AvrPivotGridHelper.ParseSummaryType(model.PivotSettings.SelectedField.AggregateFunctionId);
                    field.SummaryDisplayType = PivotSummaryDisplayType.Default;

                    PivotSummaryType summaryType = summaryTypeType == CustomSummaryType.Count
                        ? PivotSummaryType.Count
                        : PivotSummaryType.Custom;
                    field.CustomSummaryType = summaryTypeType;
                    field.SummaryType       = summaryType;
                }
                if (model.PivotSettings.SelectedField.Action != WebFieldAction.Add)
                {
                    model.PivotSettings.SelectedField.Action = WebFieldAction.Edit;
                }
                model.PivotSettings.UpdatedField = model.PivotSettings.SelectedField;
                if (model.PivotSettings.SelectedField.HasChanges)
                {
                    model.PivotSettings.HasChanges = true;
                }
                if (updateMissedValues)
                {
                    LayoutPivotGridHelper.CopyMissedValuesFromField(model.PivotSettings.SelectedField, model.PivotSettings.Fields);
                    LayoutPivotGridHelper.AddMissedValues(model, true);
                }
                else if (fillEmptyValues)
                {
                    LayoutPivotGridHelper.FillEmptyValuesInDataArea(model);
                }
                if (model.PivotSettings.SelectedField.Action != WebFieldAction.Add)
                {
                    return(new JsonResult {
                        Data = String.Empty, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { result = "refresh", function = "RefeshData2" }
            });
        }