示例#1
0
        /// <summary>
        /// Get values from valuetabel in database an add them to the the variables valuecollection
        /// </summary>
        /// <param name="valuePoolId"></param>
        /// <param name="valueList"></param>
        /// <param name="valuePoolValueTextExists"></param>
        private void AddValues(string valuePoolId, StringCollection valueList, string valuePoolValueTextExists)
        {
            PXSqlValue tempValue;

            foreach (ValueRow row in this.meta.MetaQuery.GetValueRowsByValuePool(valuePoolId, valueList, valuePoolValueTextExists))
            {
                tempValue = new PXSqlValue(row, meta.LanguageCodes, meta.MainLanguageCode);
                if (this.variable.Values.ContainsKey(tempValue.ValueCode))
                {
                    log.Debug("Already contains code =" + tempValue.ValueCode);
                }
                else
                {
                    this.variable.Values.Add(tempValue.ValueCode, tempValue);
                }
            }
        }
示例#2
0
        private List <PXSqlValue> GetValuesForParsingWhenSelection()
        {
            PXSqlVariable     var            = variable;
            List <PXSqlValue> tempValuesList = new List <PXSqlValue>();

            if (this.mIncludeType == GroupingIncludesType.AggregatedValues)
            {
                foreach (PXSqlGroup group in this.mGroups)
                {
                    tempValuesList.Add(var.Values[group.ParentCode]);   //todo; sortert etter gruppe sorteringskode
                }
            }
            else if (this.mIncludeType == GroupingIncludesType.SingleValues)
            {
                foreach (PXSqlGroup group in this.mGroups)
                {
                    foreach (string childCode in group.ChildCodes)
                    {
                        tempValuesList.Add(var.Values[childCode]);   //todo; sortert etter gruppe sorteringskode
                    }
                }
            }
            else if (this.IncludeType == GroupingIncludesType.All)
            {
                foreach (PXSqlGroup group in this.mGroups)
                {
                    tempValuesList.Add(var.Values[group.ParentCode]);   //todo; sortert etter gruppe sorteringskode
                    foreach (string childCode in group.ChildCodes)
                    {
                        tempValuesList.Add(var.Values[childCode]);   //todo; sortert etter gruppe sorteringskode
                    }
                }
            }
            //tempValuesList.Sort(PXSqlValue.SortByVsValue());

            //     if ( this.meta.MetaQuery.metaVersionLE("2.0")) {
            if (this.meta.MetaQuery.metaVersionLE("2.1"))
            {
                tempValuesList.Sort(PXSqlValue.SortByValue());
            }

            return(tempValuesList);
        }
示例#3
0
文件: PXSqlValue.cs 项目: trygu/PxWeb
 public int CompareTo(object obj)
 {
     if (this.GetType() != obj.GetType())
     {
         throw new PCAxis.Sql.Exceptions.BugException(10000);
     }
     else
     {
         PXSqlValue SqlValueCompare   = (PXSqlValue)obj;
         int        primaryComparison = this.SortCodePxs.CompareTo(SqlValueCompare.SortCodePxs);
         if (primaryComparison == 0)
         {
             return(this.SortCodeDb.CompareTo(SqlValueCompare.SortCodeDb));
         }
         else
         {
             return(primaryComparison);
         }
     }
 }
示例#4
0
        // when no pxs
        internal void SetValues(StringCollection selSubTables)
        {
            List <PXSqlValue> mSortedValues = new List <PXSqlValue>();

            ValueRowDictionary             mValueRowDictionary = meta.MetaQuery.GetValueRowDictionary(meta.MainTable.MainTable, selSubTables, this.Name, this.ValuePool.ValueTextExists);
            Dictionary <string, ValueRow2> mValueRows          = mValueRowDictionary.ValueRows;

            foreach (ValueRow2 myValueRow in mValueRows.Values)
            {
                PXSqlValue mValue = new PXSqlValue(myValueRow, meta.LanguageCodes, meta.MainLanguageCode);
                mSortedValues.Add(mValue);
            }

            PxSqlValues mValues = new PxSqlValues();

            foreach (PXSqlValue sortedValue in mSortedValues)
            {
                mValues.Add(sortedValue.ValueCode, sortedValue);
            }
            this.Values = mValues;
        }
示例#5
0
        private void SetContents()
        {
            BasicValueType[] contentsInPxs = new BasicValueType[0];
            if (this.ConstructedFromPxs)
            {
                contentsInPxs = mPxsFile.Query.Contents.Content;
            }
            List <PXSqlContent> mTempContentsList = GetSortedContentsList(mMainTableId, this.ConstructedFromPxs, contentsInPxs);

            mFirstContents = mTempContentsList[0].Contents;



            this.mContents = new Dictionary <string, PXSqlContent>();
            foreach (PXSqlContent sortedCont in mTempContentsList)
            {
                sortedCont.AdjustPresDecimalsToCommonDecimals(this.mDecimalHandler.ShowDecimals);
                mContents.Add(sortedCont.Contents, sortedCont);
            }



            PxSqlValues mValues = new PxSqlValues();
            int         counter = 0;

            foreach (PXSqlContent content in mContents.Values)
            {
                mValue = new PXSqlValue(content, counter);
                mValues.Add(mValue.ValueCode, mValue);
                counter++;
            }


            mSqlVariable        = new PXSqlVariableContents(mContVariableCode, this);
            mSqlVariable.Values = mValues;

            mVariables.Add(mSqlVariable.Name, mSqlVariable);
            mContentsVariable = mSqlVariable;
        }
示例#6
0
        protected override void SetElimForPresentation()
        {
            string     tmpElim;
            PXSqlValue mValue;

            this.IsEliminatedByValue = false;

            List <decimal> NumberOfValuesInValuesets = new List <decimal>();


            if (pxsQueryVariable != null)
            {
                if (!string.IsNullOrEmpty(this.pxsQueryVariable.StructureId))
                {
                    tmpElim = meta.Config.Codes.EliminationN;
                }
                else
                {
                    PXSqlValueSet vs = this.ValueSets[selectedValueset];
                    NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                    tmpElim = vs.Elimination;
                }
            }
            else
            {
                PXSqlValueSet vs = this.ValueSets[selectedValueset];
                NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                tmpElim = vs.Elimination;
            }



            if (tmpElim == meta.Config.Codes.EliminationN || tmpElim.Length == 0)
            {
                if (!this.isSelected)
                {
                    throw new PCAxis.Sql.Exceptions.PxsException(11, this.Name);
                }
                else
                {
                    this.PaxiomElimination = PXConstant.NO;
                }
            }
            else if (tmpElim == meta.Config.Codes.EliminationA)
            {
                if (this.isSelected)
                {
                    // We have to compare values in the valuepool(s) with the values selected in the PxsFile

                    if (this.Values.Count == NumberOfValuesInValuesets[0])
                    {
                        this.PaxiomElimination = PXConstant.YES;
                    }
                    else
                    {
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
            }
            else
            { // An elimination value exist for the variable.
                if (this.isSelected)
                {
                    if (this.Values.TryGetValue(tmpElim, out mValue))
                    { // the elimination value is selected
                        this.PaxiomElimination = mValue.ValueCode;
                    }



                    else
                    { // The Elimination value is not selected.  Elimination in Paxiom should be NO.
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
                // If an elimiantion value exists and no values are selected for the variable, the elimination
                // value should be used when selecting data, and metadata should be marked as eliminated by value.
                else
                {
                    mValue           = new PXSqlValue();
                    mValue.ValueCode = tmpElim;

                    this.Values.Add(mValue.ValueCode, mValue);
                    this.IsEliminatedByValue = true;
                }
            }
        }
示例#7
0
        //when pxs
        internal void SetValues(StringCollection selSubTables, PQVariable var)
        {
            log.Debug("PQVariable code = " + var.code);
            StringCollection mSelectedValues = new StringCollection();
            // Defines a dictionary to hold all the sortorders. Necessary because of the wildcards
            Dictionary <string, int> mDefinedSortorder = new Dictionary <string, int>();
            bool usesGrouping = false;


            string mPxsSubTableId = meta.PxsFile.Query.SubTable;


            #region foreach var.Values.Items
            if (var.Values.Items.Length > 0)
            {
                int documentOrder = 0;

                foreach (PCAxis.Sql.Pxs.ValueTypeWithGroup val in var.Values.Items)
                {
                    if (val.Group != null)
                    {
                        usesGrouping = true;
                        //TODO;
                        throw new ApplicationException("PXSqlVariableClassification, SetValues: group not implemented yet");
                    }
                    if (val.code.Contains("*") || val.code.Contains("?"))
                    {
                        DataSet           mValueInfoTbl = meta.MetaQuery.GetValueWildCardBySubTable(meta.MainTable.MainTable, var.code, mPxsSubTableId, val.code);
                        DataRowCollection mValueInfo    = mValueInfoTbl.Tables[0].Rows;

                        foreach (DataRow row in mValueInfo)
                        {
                            string mTempCode = row[meta.MetaQuery.DB.Value.ValueCode].ToString();
                            mSelectedValues.Add(mTempCode);
                            if (!mDefinedSortorder.ContainsKey(mTempCode))
                            {
                                mDefinedSortorder.Add(mTempCode, documentOrder);
                            }
                            documentOrder++;
                        }
                    }
                    else
                    {
                        mSelectedValues.Add(val.code);
                        if (!mDefinedSortorder.ContainsKey(val.code))
                        {
                            mDefinedSortorder.Add(val.code, documentOrder);
                        }
                    }

                    documentOrder++;
                }
                #endregion foreach var.Values.Items


                // mSelectedValues now contains all the selected values, including those defined by wildcards

                Dictionary <string, PXSqlValue> mTempPXSqlValues = new Dictionary <string, PXSqlValue>();
                List <PXSqlValue> mSortedValues = new List <PXSqlValue>();

                ValueRowDictionary mValueRowDictionary = meta.MetaQuery.GetValueRowDictionary(meta.MainTable.MainTable, selSubTables, var.code, mSelectedValues, this.ValuePool.ValueTextExists);


                // todo; fortsette her
                Dictionary <string, ValueRow2> mValueRows = mValueRowDictionary.ValueRows;

                #region foreach mValueRows
                foreach (ValueRow2 myValueRow in mValueRows.Values)
                {
                    PXSqlValue mValue = new PXSqlValue(myValueRow, meta.LanguageCodes, meta.MainLanguageCode);

                    // jfi: kommentaren sto i en kodeblock som forsvant inn i PXSqlValue
                    // todo; legge til sjekk om koden finnes blandt valgte i basen.
                    mValue.SortCodePxs = mDefinedSortorder[myValueRow.ValueCode];
                    mSortedValues.Add(mValue);
                }
                #endregion foreach mValueRows

                mValues = new PxSqlValues();

                foreach (PXSqlValue sortedValue in mSortedValues)
                {
                    mValues.Add(sortedValue.ValueCode, sortedValue);
                }

                this.Values       = mValues;
                this.UsesGrouping = usesGrouping;
            }
        }
示例#8
0
        private void SetTimeValues() {
            // time variable values
            //lage flere overloads databasespørringer avhengig av timeopt
            //mValues = new Dictionary<string, PXSqlValue>();



            PxSqlValues tmpValues = null;

            if (meta.MainTable.ContainsOnlyMetaData)
            {
                PXSqlValue fictiveValue = new PXSqlValue("Time01", meta.LanguageCodes);
                this.mValues.Add("Time01", fictiveValue);
            }

            else
            {

                if (meta.ConstructedFromPxs && ((int)meta.PxsFile.Query.Time.TimeOption != 4))
                {


                    switch ((int)meta.PxsFile.Query.Time.TimeOption)
                    {
                        case 0:
                            Dictionary<string, int> mySelectedValues = new Dictionary<string, int>();
                            int docOrder = 1;
                            TimeTypeTimeValues timevalues = (TimeTypeTimeValues)meta.PxsFile.Query.Time.Item;
                            foreach (BasicValueType time in timevalues.TimeValue)
                            {
                                mySelectedValues.Add(time.code, docOrder++);
                            }

                            tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, mySelectedValues);
                            break;

                        case 1:
                            tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable);
                            break;

                        case 2:
                            int NoOfTimeValues = (int)meta.PxsFile.Query.Time.Item;
                            tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, NoOfTimeValues);
                            break;

                        case 3:
                            string StartTimeValue = (string)meta.PxsFile.Query.Time.Item;
                            tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, StartTimeValue);
                            break;
                    }





                    this.mValues = tmpValues;
                }
                else
                {
                    this.mValues = meta.MetaQuery.GetAllTimeValuesList(meta.MainTable.MainTable, "desc");

                }
            }
        }