Exemple #1
0
        private List <PXSqlContent> GetSortedContentsList(string mMainTableId, bool contructedFromPxs, BasicValueType[] contentsInPxs)
        {
            List <PXSqlContent> myOut = new List <PXSqlContent>();
            Dictionary <string, ContentsRow> altIBasen = mMetaQuery.GetContentsRows(mMainTableId);


            //side effect:
            ContentsRow someContentsRow = null;

            foreach (ContentsRow tmpRow in altIBasen.Values)
            { //just want any one of the rows
                someContentsRow = tmpRow;
                break;
            }

            couldHaveBeenByMainTableOnly = new PXSqlThingsThatWouldBeTheSameInAllPXSqlContent(someContentsRow, this, mConfig);

            PXSqlContact contact = new PXSqlContact(this, this.MainTable.MainTable);


            PXSqlContent mContent = null;

            if (this.ConstructedFromPxs)
            {
                int documentOrder = 0;
                foreach (BasicValueType contents in contentsInPxs)
                {
                    if (altIBasen.ContainsKey(contents.code))
                    {
                        mContent           = new PXSqlContent(altIBasen[contents.code], this, mConfig, contact);
                        mContent.SortOrder = documentOrder;
                        myOut.Add(mContent);
                        documentOrder++;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <string, ContentsRow> cont in altIBasen)
                {
                    mContent           = new PXSqlContent(cont.Value, this, mConfig, contact);
                    mContent.SortOrder = int.Parse(cont.Value.StoreColumnNo);
                    myOut.Add(mContent);
                }
            }

            if (myOut.Count < 1)
            {
                throw new ApplicationException("No contents to process");
            }
            myOut.Sort();
            return(myOut);
        }
Exemple #2
0
 public PXSqlValue(PXSqlContent content, int sortCode)
 {
     this.mContentsCode = content.Contents;
     //this.ValueCode = content.Contents;
     this.ValueCode  = content.PresCode; // ValueCode should be PresCode. Contents is no sent to Paxiom as Reference_ID an used as code in PXS.
     this.ValueTextL = content.PresText;
     this.ValueTextS = content.PresTextS;
     // SortCodePxs and SortCode are now set to the same value. Maybe no a good thing if sortorder should be reset to db
     // default after read from pxs. //TODO send two sortcodes from PXSQlMeta.
     this.SortCodePxs    = sortCode;
     this.mSortCodeValue = sortCode.ToString();
 }
Exemple #3
0
        public PXSqlData_21(PXSqlMeta_21 mPXSqlMeta)
        {
            log.Debug("Start PXSqlData mPXSqlMeta.Name: " + mPXSqlMeta.Name);

            this.mMeta = mPXSqlMeta;


            symbols = mMeta.mPxsqlNpm;

            this.npm         = mMeta.SpecCharExists;
            this.hasGrouping = mMeta.HasGrouping;

            this.eliminationBySum = mMeta.EliminatedVariablesExist;

            //System.Console.WriteLine("DEBUG tukler med nmp og summ");
            //npm = true;
            //alwaysUseSum = true;

            this.useSum = hasGrouping || eliminationBySum;

            foreach (PXSqlVariable var in mMeta.Stubs)
            {
                keysInReverseOutputOrder.Add(var.Name);
            }

            foreach (PXSqlVariable var in mMeta.Headings)
            {
                keysInReverseOutputOrder.Add(var.Name);
            }
            keysInReverseOutputOrder.Reverse();

            numberOfOutputVariables = keysInReverseOutputOrder.Count;

            mValueCount  = new Dictionary <string, int>(numberOfOutputVariables);
            mIndexFactor = new Dictionary <string, int>(numberOfOutputVariables);

            foreach (PXSqlVariable var in mMeta.Variables.Values)
            {
                if (var.IsEliminatedByValue)
                {
                    log.Debug(var.Name + " Is Eliminated By Value");
                    keysOfEliminatedByValue.Add(var.Name);
                }
                else if (var.IsContentVariable)
                {
                    log.Debug(var.Name + " Is Content Variable");
                    theKeyOfTheContentsVariableVariable = var.Name;
                }
                else if (!var.isSelected)
                {
                    log.Debug(var.Name + " Is Eliminated By SUM");
                    keysOfEliminatedBySum.Add(var.Name);
                    eliminationFactor *= var.TotalNumberOfValuesInDB;
                }
            }

            #region init contKeys
            if (String.IsNullOrEmpty(theKeyOfTheContentsVariableVariable))   //just one contVar
            {
                throw new ApplicationException("Bug");
                // the size of ContentsVariableVariable should not influence how it is stored
                //                contKeys.Add( mMeta.FirstContents );
            }
            else
            {
                PXSqlVariable theContentsVariable = mMeta.Variables[theKeyOfTheContentsVariableVariable];
                foreach (PXSqlValue contCode in theContentsVariable.GetValuesForParsing())
                {
                    //contKeys.Add(contCode.ValueCode);
                    contKeys.Add(contCode.ContentsCode); // 2010.05.07  replaces line above because valuecode is now Prescode from contents. New contentscode added to PXSqlValue
                }
                foreach (string contCode in theContentsVariable.Values.Keys)
                {
                    //    contKeys.Add(contCode);
                }
            }

            #endregion init contKeys

            #region init defaults for missing rows
            //value to be used if row is missing
            ValueOfCellsInMissingRows    = new double[contKeys.Count];
            CategoryOfCellsInMissingRows = new string[contKeys.Count];

            int contCount2 = 0;

            anyDefaultMRNotZero = false;  // MR = missing record
            anyDefaultMROfCat3  = false;  // MR = missing record
            foreach (string contCode in contKeys)
            {
                PXSqlContent tmpCont = mMeta.Contents[contCode];
                log.Debug("PXSqlContents for " + contCode + " PresCellsZero:" + tmpCont.PresCellsZero + " PresMissingLine:" + tmpCont.PresMissingLine);

                CategoryOfCellsInMissingRows[contCount2] = tmpCont.CategoryOfCellsInMissingRows;
                ValueOfCellsInMissingRows[contCount2]    = tmpCont.ValueOfCellsInMissingRows;

                if (!CategoryOfCellsInMissingRows[contCount2].Equals("0"))
                {
                    anyDefaultMRNotZero = true;
                    if (CategoryOfCellsInMissingRows[contCount2].Equals("3"))
                    {
                        anyDefaultMROfCat3 = true;
                    }
                }
                contCount2++;
            }
            #endregion init defaults for missing rows

            log.Debug("eliminationFactor: " + eliminationFactor);



            log.Debug("useSum:" + useSum + " , npm: " + npm);
            log.Debug("Constructor done.");
        }