Example #1
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 #2
0
 public void FailExecQueryTest()
 {
     try
     {
         AvrMainFormPresenter.ExecQueryForPresenter(new SharedPresenter(StructureMapContainerInit(), new BaseForm()), null, 111, string.Empty);
     }
     catch (AvrDbException ex)
     {
         Assert.AreEqual("Error while executing query with id '111'", ex.Message);
     }
 }