/// <summary> /// Builds the Paxiom model used for selection /// </summary> /// <returns></returns> public override bool BuildForSelection() { #if DEBUG System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); logTime.DebugFormat("Start " + System.Reflection.MethodBase.GetCurrentMethod().Name + ". Maintable={0}", maintableId); #endif log.Debug("Start BuildForSelection"); if (!_hasCalledSetPath) { throw new ApplicationException("BUG: SetPath must be called before BuildForSelection()"); } try { setDbConfig(); //log.Debug("Database: id = " + dbConf.Database.id + " Description = " + dbConf.Database.Description); log.Debug("Database: id = " + dbConf.Database.id + " Description preferred language = " + dbConf.GetDescription(m_preferredLanguage)); log.Debug("_preferredLanguage:" + m_preferredLanguage + " _readAllLanguages:" + m_readAllLanguages.ToString()); if (String.IsNullOrEmpty(maintableId)) { mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(pxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.selection, false); } else { mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(maintableId, m_preferredLanguage, m_readAllLanguages, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.selection, false); } m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta); // this.m_model.Meta.CreateTitle(); base.BuildForSelection(); if (!DoNotApplyCurrentValueSet) { ((PXSqlParser)m_parser).SetCurrentValueSets(this.Model.Meta); } _haveDoneBuildForSelection = true; Model.Meta.SetPreferredLanguage(m_preferredLanguage); } catch (Exception e) { errorHandler(e, "Error in BuildForSelection"); throw; } log.Debug("Done BuildForSelection"); #if DEBUG stopWatch.Stop(); logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " Done in ms = {0}", stopWatch.ElapsedMilliseconds); #endif return(true); }
/// <summary> /// Builds the Paxiom model used for presentation /// </summary> /// <param name="selections">Selections of parameters used to specify what data that should be presented</param> /// <returns></returns> public override bool BuildForPresentation(PCAxis.Paxiom.Selection[] selections) { #if DEBUG System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); logTime.DebugFormat("Start " + System.Reflection.MethodBase.GetCurrentMethod().Name + ". Maintable={0}", maintableId); #endif log.Debug("Start BuildForPresentation"); if (!_hasCalledSetPath) { throw new ApplicationException("BUG: SetPath must be called before BuildForPresentation."); } if (_haveDoneBuildForPresentation) { throw new ApplicationException("Hmm BuildForPresentation has allready been called, what is the policy on this?"); } try { setDbConfig(); //m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta); if (!_haveDoneBuildForSelection) { // a WS or batch. selection is irrelevat and should be null. if (String.IsNullOrEmpty(maintableId)) { mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(pxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true); } else { mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(maintableId, m_preferredLanguage, m_readAllLanguages, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true); } } else { //Not in use //PxSQLEliniationProvider.ApplyEliminationIfSupported(selections, dbConf, GetInfoForDbConnection(), this.Model.Meta); // a GUI: need to create a new pxs with the selections made in GUI // and ajust the _parser and reread meta PxsQuery tmpPxs = new PxsQuery(base.m_model.Meta, getLanguagesPxsQueryCreation(), selections, mPXSqlMeta.GetInfoFromPxSqlMeta2PxsQuery()); //for debugging: TODO Kun for test. //tmpPxs.WriteToFile("aaapxs.xml"); mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(tmpPxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true); base.m_model.Meta = new PCAxis.Paxiom.PXMeta(); } m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta); // this.m_model.Meta.CreateTitle(); base.BuildForSelection(); this.SetMatrixSize(); if (!mPXSqlMeta.MainTableContainsOnlyMetaData()) { using (PXSqlData mPXSqlData = PXSqlData.GetPXSqlData(mPXSqlMeta, dbConf)) { #if DEBUG logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " before CreateMatrix in ms = {0}", stopWatch.ElapsedMilliseconds); #endif m_model.Data.Write(mPXSqlData.CreateMatrix(), 0, mPXSqlData.MatrixSize - 1); if (mPXSqlData.DataNoteCellEntries.Count > 0) { m_model.Data.WriteDataNoteCells(mPXSqlData.DataCellNotes, 0, mPXSqlData.MatrixSize - 1); m_model.Data.UseDataCellMatrix = true; } m_parser = PXSqlParseMetaPostData.GetPXSqlParseMetaPostData(mPXSqlMeta, mPXSqlData); base.BuildForSelection(); } } else { //lager juksedata m_model.Data.Write(new double[m_model.Data.MatrixSize], 0, m_model.Data.MatrixSize - 1); m_parser = new PXSqlParserForDataCellNote(new Dictionary <string, string>()); base.BuildForSelection(); } m_model.Meta.Prune(); _haveDoneBuildForSelection = true; _haveDoneBuildForPresentation = true; m_model.Meta.SetPreferredLanguage(m_preferredLanguage); this.m_model.IsComplete = true; } catch (Exception e) { errorHandler(e, "Error in BuildForPresentation"); throw; } log.Debug("Done BuildForPresentation"); #if DEBUG stopWatch.Stop(); logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " Done in ms = {0}", stopWatch.ElapsedMilliseconds); #endif return(true); }