Esempio n. 1
0
        public static void AddMissedValues(AvrPivotGridModel model, bool forceRefill)
        {
            if (forceRefill)
            {
                bool   isNewObject;
                string errorMessage;
                model.PivotData = GetPivotData(model.PivotSettings, out isNewObject, out errorMessage);
                if (!string.IsNullOrEmpty(errorMessage))
                {
                    //todo:[mike]     return ErrorMessage to user
                }
            }

            List <IAvrPivotGridField> fields = model.PivotSettings.Fields.Cast <IAvrPivotGridField>().ToList();
            var result = new LayoutValidateResult();

            if (model.PivotSettings.ShowMissedValues)
            {
                LayoutBaseValidator validator = CreateLayoutComplexityValidator();
                result = AvrPivotGridHelper.AddMissedValuesAndValidateComplexity(model, fields, validator);
            }

            if (result.IsCancelOrUserDialogCancel())
            {
                model.HideDataForComplexLayout();
            }
            else
            {
                FillEmptyValuesInDataArea(model, fields);
            }
        }
Esempio n. 2
0
        public static LayoutValidateResult FillEmptyValuesInDataArea(AvrPivotGridModel model, List <IAvrPivotGridField> fields = null)
        {
            if (fields == null)
            {
                fields = model.PivotSettings.Fields.ToList <IAvrPivotGridField>();
            }
            var avrDataSource = new AvrPivotGridData(model.PivotData);


            var result = new LayoutValidateResult();
            LayoutBaseValidator validator = CreateLayoutComplexityValidator();

            if (model.PivotSettings.ShowMissedValues)
            {
                result = AvrPivotGridHelper.AddMissedValuesAndValidateComplexity(avrDataSource, fields, validator);
            }
            if (!result.IsCancelOrUserDialogCancel())
            {
                result = AvrPivotGridHelper.FillEmptyValuesAndValidateComplexity(avrDataSource, fields, validator);
            }
            //LayoutValidateResult result = AvrPivotGridHelper.FillEmptyValuesAndValidateComplexity(avrDataSource, fields, validator);
            if (result.IsCancelOrUserDialogCancel())
            {
                model.HideDataForComplexLayout();
            }
            return(result);
        }
Esempio n. 3
0
        public LayoutValidateResult LoadPivotFromDB(AvrPivotGridData model, IList <IAvrPivotGridField> avrFields, bool isNewObject)
        {
            if ((PivotGridXmlVersion)LayoutRow.intPivotGridXmlVersion == PivotGridXmlVersion.Version5)
            {
                throw new AvrDbException("Layout has version 5 format. It's not supported.");
            }

            if (!isNewObject)
            {
                AvrPivotGridHelper.LoadSearchFieldsVersionSixFromDB(avrFields, LayoutSearchFieldTable, LayoutRow.idfsDefaultGroupDate);

                LoadPivotFilterVersionSixFromDB();
            }

            AvrPivotGridHelper.LoadExstraSearchFieldsProperties(avrFields, LayoutSearchFieldTable);

            AvrPivotGridHelper.SwapOriginalAndCopiedFieldsIfReversed(avrFields);



            var result = new LayoutValidateResult();
            LayoutBaseValidator validator = LayoutPivotGridHelper.CreateLayoutComplexityValidator();

            if (LayoutRow.blnShowMissedValuesInPivotGrid)
            {
                result = AvrPivotGridHelper.AddMissedValuesAndValidateComplexity(model, avrFields, validator);
            }
            if (!result.IsCancelOrUserDialogCancel())
            {
                result = AvrPivotGridHelper.FillEmptyValuesAndValidateComplexity(model, avrFields, validator);
            }
            return(result);
        }
Esempio n. 4
0
        private AvrPivotViewModel CreateAvrPivotViewModelInternal(long layoutId, string lang)
        {
            LayoutDetailDataSet layoutDataSet = GetLayoutDataSet(layoutId);

            LayoutDetailDataSet.LayoutRow layoutRow = GetLayoutRow(layoutDataSet);

            m_SharedPresenter.SharedModel.SelectedQueryId  = layoutRow.idflQuery;
            m_SharedPresenter.SharedModel.SelectedLayoutId = layoutId;

            m_Trace.Trace(TraceTitle, string.Format("Layout {0} structure read from DB", layoutId));

            var validatorWaiter = new LayoutSilentValidatorWaiter();
            var filter          = layoutRow.blnApplyPivotGridFilter ? layoutRow.strPivotGridSettings : string.Empty;
            var queryResult     = AvrMainFormPresenter.ExecQueryInternal(layoutRow.idflQuery, lang,
                                                                         layoutRow.blnUseArchivedData, filter, validatorWaiter, false, QueryExecutor);

            //var queryResult = AvrMainFormPresenter.ExecQueryInternal(layoutRow.idflQuery, lang,
            //    layoutRow.blnUseArchivedData, layoutRow.strPivotGridSettings, validatorWaiter, false, QueryExecutor);

            m_Trace.Trace(TraceTitle, string.Format("Data for layout {0} received from AVR Cashe ", layoutId));

            AvrDataTable preparedQueryTable = AvrPivotGridHelper.GetPreparedDataSource(layoutDataSet.LayoutSearchField,
                                                                                       layoutRow.idflQuery, layoutId, queryResult.QueryTable, false);

            m_AvrPivot.SetDataSourceAndCreateFields(preparedQueryTable);

            RestorePivotSettings(layoutDataSet);

            using (m_AvrPivot.BeginTransaction())
            {
                List <IAvrPivotGridField> fields = m_AvrPivot.AvrFields.ToList();

                var result = new LayoutValidateResult();
                if (layoutRow.blnShowMissedValuesInPivotGrid)
                {
                    result = AvrPivotGridHelper.AddMissedValuesAndValidateComplexity(m_AvrPivot.DataSource, fields,
                                                                                     validatorWaiter.Validator);
                }
                if (!result.IsCancelOrUserDialogCancel())
                {
                    result = AvrPivotGridHelper.FillEmptyValuesAndValidateComplexity(m_AvrPivot.DataSource, fields,
                                                                                     validatorWaiter.Validator);
                }
                if (result.IsCancelOrUserDialogCancel())
                {
                    m_AvrPivot.HideData = true;
                }

                m_AvrPivot.RefreshData();
            }
            m_Trace.Trace(TraceTitle, string.Format("Layout {0} builded", layoutId));

            PivotGridDataLoadedCommand command = m_AvrPivot.CreatePivotDataLoadedCommand(layoutRow.strLayoutName);

            m_Trace.Trace(TraceTitle, string.Format("View model for layout {0}, language {1} created", layoutId, lang));
            return(command.Model);
        }