Example #1
0
        private void RestorePivotSettings(LayoutDetailDataSet layoutDataSet)
        {
            try
            {
                LayoutDetailDataSet.LayoutRow layoutRow = GetLayoutRow(layoutDataSet);
                List <IAvrPivotGridField>     avrFields = m_AvrPivot.AvrFields.ToList();

                AvrPivotGridHelper.LoadSearchFieldsVersionSixFromDB(avrFields, layoutDataSet.LayoutSearchField,
                                                                    layoutRow.idfsDefaultGroupDate);

                using (m_AvrPivot.BeginTransaction())
                {
                    AvrPivotGridHelper.LoadExstraSearchFieldsProperties(avrFields, layoutDataSet.LayoutSearchField);

                    AvrPivotGridHelper.SwapOriginalAndCopiedFieldsIfReversed(avrFields);

                    m_AvrPivot.PivotGridPresenter.UpdatePivotCaptions();

                    RestoreTotals(layoutRow);
                }
            }
            catch (XmlException ex)
            {
                Trace.WriteLine(ex);
                ErrorForm.ShowError("errCantParseLayout", "Cannot parse Layout retrived from Database", ex);
            }
        }
Example #2
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);
        }
Example #3
0
        private static DataSet GetPivotDataSet()
        {
            var dataSet = new LayoutDetailDataSet {
                EnforceConstraints = false
            };

            LayoutDetailDataSet.LayoutRow row = dataSet.Layout.NewLayoutRow();

            row.idflLayout = 1;
            row.idflQuery  = 1;
            row.idfPerson  = 1;

            row.strPivotGridSettings = "xxx";
            row.blbPivotGridSettings = BinaryCompressor.ZipString(row.strPivotGridSettings);
            row.strLayoutName        = Guid.NewGuid().ToString();
            row.strDefaultLayoutName = Guid.NewGuid().ToString();
            dataSet.Layout.AddLayoutRow(row);
            dataSet.AcceptChanges();
            return(dataSet);
        }
Example #4
0
        private void RestoreTotals(LayoutDetailDataSet.LayoutRow layoutRow)
        {
            PivotGridOptionsView options = m_AvrPivot.OptionsView;

            if (layoutRow.blnCompactPivotGrid)
            {
                options.ShowRowTotals             = true;
                options.ShowTotalsForSingleValues = true;
                options.RowTotalsLocation         = PivotRowTotalsLocation.Tree;
            }
            else
            {
                options.RowTotalsLocation = PivotRowTotalsLocation.Far;

                options.ShowColumnTotals               = (!layoutRow.IsblnShowColsTotalsNull()) && layoutRow.blnShowColsTotals;
                options.ShowRowTotals                  = (!layoutRow.IsblnShowRowsTotalsNull()) && layoutRow.blnShowRowsTotals;
                options.ShowColumnGrandTotals          = (!layoutRow.IsblnShowColGrandTotalsNull()) && layoutRow.blnShowColGrandTotals;
                options.ShowRowGrandTotals             = (!layoutRow.IsblnShowRowGrandTotalsNull()) && layoutRow.blnShowRowGrandTotals;
                options.ShowTotalsForSingleValues      = (!layoutRow.IsblnShowForSingleTotalsNull()) && layoutRow.blnShowForSingleTotals;
                options.ShowGrandTotalsForSingleValues = (!layoutRow.IsblnShowForSingleTotalsNull()) && layoutRow.blnShowForSingleTotals;
            }
        }
Example #5
0
        private LayoutDetailDataSet GetLayoutDataSet(long layoutId)
        {
            if (m_AvrPivot == null)
            {
                throw new AvrException("Pivot grid already disposed.");
            }

            LayoutDetailDataSet layoutDataSet;

            lock (ConnectionManager.DefaultInstance.Connection)
            {
                layoutDataSet = (LayoutDetailDataSet)m_DBService.GetDetail(layoutId);
            }

            LayoutDetailDataSet.LayoutRow layoutRow = GetLayoutRow(layoutDataSet);
            if (string.IsNullOrEmpty(layoutRow.strLayoutName))
            {
                throw new ArgumentException(string.Format("Couldn't find Layout '{0}'", layoutId));
            }

            return(layoutDataSet);
        }